diff --git a/testsuite/c_test/sanity_test/SANITY0022-cc_param3/cc_param3.c b/testsuite/c_test/sanity_test/SANITY0022-cc_param3/cc_param3.c new file mode 100644 index 0000000000000000000000000000000000000000..7a8cafb6d7d558665a7af8200b3cf5bf4af48b7e --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0022-cc_param3/cc_param3.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) [2021] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include + +typedef struct { int i; long long j; } S1; +// IntCC: no intreg, entire s passed on stack +void foo0( int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, S1 s ) +{ if (s.j != 2) abort(); } + +// IntCC: 1 intreg short, half of s passed on stack, half $a7 reg +void foo1( int i1, int i2, int i3, int i4, int i5, int i6, int i7, S1 s ) +{ if (s.j != 2) abort(); } + +// FpCC: 1 intreg short, move to IntCC: 1 stack +typedef struct { float i; int j; } S2; +void foo2( int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, S2 s ) +{ if (s.j != 4) abort(); } + +// FpCC: 1 fpreg short, move to IntCC: 1 intreg + 1 stack +void foo3( float i1, float i2, float i3, float i4, float i5, float i6, float i7, float i8, S2 s ) +{ if (s.j != 4) abort(); } + +// FpCC: 2 fpregs short, move to IntCC: 2 stacks +typedef struct { double i; double j; float k; } S4; +void foo4( float i1, float i2, float i3, float i4, float i5, float i6, float i7, float i8, S4 s ) +{ if (s.j != 6) abort(); } + +// IntCC: 1 float on stack, 8 intregs +typedef struct { float i; int j; } S5; +void foo5( int i1, int i2, int i3, int i4, int i5, int i6, int i7, + float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, + S5 s ) +{ if (s.i != 7.0f || s.j != 8) abort(); } + +// IntCC: 1 int on stack, 8 fpregs +void foo6( int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, + float f1, float f2, float f3, float f4, float f5, float f6, float f7, + S5 s ) +{ if (s.i != 7.0f || s.j != 8) abort(); } + +int main() +{ + S1 s1 = { 1, 2 }; + foo0(1,2,3,4,5,6,7,8, s1); +// foo1(1,2,3,4,5,6,7, s1); + + S2 s2 = { 3, 4 }; + foo2(1,2,3,4,5,6,7,8, s2); +// foo3(0,0,0,0,0,0,0,0, s2); + + S4 s4 = { 5, 6 }; + foo4(0,0,0,0,0,0,0,0, s4); + + S5 s5 = { 7.0f, 8 }; +// foo5( 1,2,3,4,5,6,7, 10,20,30,40,50,60,70,80, s5 ); +// foo6( 1,2,3,4,5,6,7,8, 10,20,30,40,50,60,70, s5 ); + + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0022-cc_param3/test.cfg b/testsuite/c_test/sanity_test/SANITY0022-cc_param3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..54dab4c1323f753876d4abc3bf75a017af66c77a --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0022-cc_param3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(cc_param3) +run(cc_param3) diff --git a/testsuite/c_test/sanity_test/SANITY0023-cc_sret/cc_sret.c b/testsuite/c_test/sanity_test/SANITY0023-cc_sret/cc_sret.c new file mode 100644 index 0000000000000000000000000000000000000000..3b32e2106e5042e0efe29cfe937b43d1a15111db --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0023-cc_sret/cc_sret.c @@ -0,0 +1,186 @@ +/* + * Copyright (C) [2021] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +// +// Test calling convention of struct return type +#include +typedef struct { int x; int y; } s1; +typedef struct { long long x; long long y; } s2; +typedef struct { long long x; long long y; int z; } s3; +typedef struct { float x; float y; } f1; +typedef struct { double x; double y; } f2; +typedef struct { float x; char y; char z; short w; } m1; +typedef struct { int x[4]; } a1; +typedef struct { double x[4]; } a2; +typedef struct { float x[2]; } f3; +typedef struct { float x[3]; } f4; +typedef struct { int x; float y; } m2; +typedef struct { double x; long long y; } m3; + +s1 foo1(int i){ s1 x = {1,2}; return x; } // 1 intreg return +s2 foo2(int i){ s2 x = {3,4}; return x; } // 2 intregs return +s3 foo3(int i){ s3 x = {5,6,7}; return x; } // hidden 1st arg, >16by +f1 foo4(int i){ f1 x = {8,9}; return x; } // 2 fpregs return +f2 foo5(int i){ f2 x = {10,11}; return x; } // 2 fpregs return +m1 foo6(int i){ m1 x = {12,13,14,15}; return x; } // 1 intregs return +a1 foo7(int i){ a1 x = {16,17,18,19}; return x; } // 2 intregs return +a2 foo8(int i){ a2 x = {20,21,22,23}; return x; } // hidden 1st arg, >16by +f3 foo9(int i){ f3 x = {24,25}; return x; } // 2 fpregs return +f4 foo10(int i){ f4 x = {26,27,28}; return x; } // 2 intregs return +m2 foo11(int i){ m2 x = {29,30.0}; return x; } // 1 intreg 1 fpreg +m3 foo12(int i){ m3 x = {31.0,32}; return x; } // 1 fpreg 1 intreg + +typedef struct { int a[2]; } sz8; // 8 byte struct +typedef struct { int a[4]; } sz16; // 16 byte struct +typedef struct { int a[8]; } sz32; // 32 byte struct + +sz8 call8() +{ + s1 x; + s2 y; + s3 e; + f1 z; + f2 w; + f3 v; + f4 u; + m1 m; + m2 n; + m3 o; + a1 a; + a2 b; + + x = foo1( 0 ); + if (x.y != 2) abort(); + y = foo2( 0 ); + if (y.y != 4) abort(); + e = foo3( 0 ); + if (e.z != 7) abort(); + z = foo4( 0 ); + if (z.y != 9) abort(); + w = foo5( 0 ); + if (w.y != 11) abort(); + m = foo6( 0 ); + if (m.w != 15) abort(); + a = foo7( 0 ); + if (a.x[3] != 19) abort(); + b = foo8( 0 ); + if (b.x[3] != 23) abort(); + v = foo9( 0 ); + if (v.x[1] != 25) abort(); + u = foo10( 0 ); + if (u.x[2] != 28) abort(); + n = foo11( 0 ); + if (n.x != 29 || n.y != 30.0) abort(); + o = foo12( 0 ); + if (o.x != 31.0 || o.y != 32) abort(); + + sz8 x8 = { 1, 2}; + return x8; +} + +sz16 call16() +{ + s1 x; + s2 y; + s3 e; + f1 z; + f2 w; + f3 v; + f4 u; + m1 m; + m2 n; + m3 o; + a1 a; + a2 b; + + x = foo1( 0 ); + if (x.y != 2) abort(); + y = foo2( 0 ); + if (y.y != 4) abort(); + e = foo3( 0 ); + if (e.z != 7) abort(); + z = foo4( 0 ); + if (z.y != 9) abort(); + w = foo5( 0 ); + if (w.y != 11) abort(); + m = foo6( 0 ); + if (m.w != 15) abort(); + a = foo7( 0 ); + if (a.x[3] != 19) abort(); + b = foo8( 0 ); + if (b.x[3] != 23) abort(); + v = foo9( 0 ); + if (v.x[1] != 25) abort(); + u = foo10( 0 ); + if (u.x[2] != 28) abort(); + n = foo11( 0 ); + if (n.x != 29 || n.y != 30.0) abort(); + o = foo12( 0 ); + if (o.x != 31.0 || o.y != 32) abort(); + + sz16 x16 = { 1, 2, 3, 4}; + return x16; +} + +sz32 call32() +{ + s1 x; + s2 y; + s3 e; + f1 z; + f2 w; + f3 v; + f4 u; + m1 m; + m2 n; + m3 o; + a1 a; + a2 b; + + x = foo1( 0 ); + if (x.y != 2) abort(); + y = foo2( 0 ); + if (y.y != 4) abort(); + e = foo3( 0 ); + if (e.z != 7) abort(); + z = foo4( 0 ); + if (z.y != 9) abort(); + w = foo5( 0 ); + if (w.y != 11) abort(); + m = foo6( 0 ); + if (m.w != 15) abort(); + a = foo7( 0 ); + if (a.x[3] != 19) abort(); + b = foo8( 0 ); + if (b.x[3] != 23) abort(); + v = foo9( 0 ); + if (v.x[1] != 25) abort(); + u = foo10( 0 ); + if (u.x[2] != 28) abort(); + n = foo11( 0 ); + if (n.x != 29 || n.y != 30.0) abort(); + o = foo12( 0 ); + if (o.x != 31.0 || o.y != 32) abort(); + + sz32 x32 = { 1, 2, 3, 4, 5, 6, 7, 8}; + return x32; +} + +int main() +{ + call8(); + call16(); + call32(); +} diff --git a/testsuite/c_test/sanity_test/SANITY0023-cc_sret/test.cfg b/testsuite/c_test/sanity_test/SANITY0023-cc_sret/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..242d895516ed5d2efc519c010d89e56150f84324 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0023-cc_sret/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(cc_sret) +run(cc_sret) diff --git a/testsuite/c_test/sanity_test/SANITY0024-vararg1/test.cfg b/testsuite/c_test/sanity_test/SANITY0024-vararg1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bdc023f1b3184f30663b6f3164f39ac47b6622e0 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0024-vararg1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(vararg1) +run(vararg1) diff --git a/testsuite/c_test/sanity_test/SANITY0024-vararg1/vararg1.c b/testsuite/c_test/sanity_test/SANITY0024-vararg1/vararg1.c new file mode 100644 index 0000000000000000000000000000000000000000..9560448c53b86e54a44c359b388cdbf1107e9435 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0024-vararg1/vararg1.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) [2021] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include "stdarg.h" +#include "stdlib.h" + +int a,b; +typedef int vfunc_t(int x, int y, ...); +int foo1( int x, int y, ... ) +{ + va_list ap; + + va_start(ap, y); + a = va_arg(ap, int); + b = va_arg(ap, int); + return (int)a + b; +} + +typedef struct { int i; long long j; } S; +int foo2( int a0, int a1, ... ) +{ + va_list ap; + + va_start(ap, a1); + S b = va_arg(ap, S); + if (b.i+b.j != 30) + abort(); +} + +typedef struct { long long x; long long y; int z; } T; +void foo3( int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, T x, ...) +{ + va_list ap; + + va_start(ap, x); + a = va_arg(ap, int); + if (a != 10) // on the stack + abort(); +} + +int main() +{ + vfunc_t *f = &foo1; + int x; + + x = foo1(1,2,3,4); + if (x != 7) + abort(); + x = (*f)(1,2,5,6); + if (x != 11) + abort(); + + S s = {10,20}; + foo2( 1,2, s ); + + T y = { 1, 2, 3 }; + + foo3(1,2,3,4,5,6,7,8, y,10 ); +} + + diff --git a/testsuite/driver/src/mod/CO2.py b/testsuite/driver/src/mod/CO2.py index 3f4af06f3154db83a000342c54dc1376cf46e029..36d129027d50b0339c4526799ff2c7376cc4df3c 100644 --- a/testsuite/driver/src/mod/CO2.py +++ b/testsuite/driver/src/mod/CO2.py @@ -31,7 +31,7 @@ CO2 = { maple="${OUT_ROOT}/aarch64-clang-release/bin/maple", run=["mplcg"], option={ - "mplcg": "-O2 --quiet" + "mplcg": "-O2 --quiet --no-schedule" }, global_option="", infile="${APP}.mpl"