aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fixed-point/binary.c
diff options
context:
space:
mode:
authorChao-ying Fu <fu@mips.com>2007-09-22 00:27:56 +0000
committerChao-ying Fu <chaoyingfu@gcc.gnu.org>2007-09-22 00:27:56 +0000
commitfca8ed94a2c35b23fb2e98f99a41f294086d9501 (patch)
treef5dc51d3916f31749f7fac613ed79e055257b81f /gcc/testsuite/gcc.dg/fixed-point/binary.c
parentfca1a50fd93729fc338af57b7615898c3823986d (diff)
downloadgcc-fca8ed94a2c35b23fb2e98f99a41f294086d9501.zip
gcc-fca8ed94a2c35b23fb2e98f99a41f294086d9501.tar.gz
gcc-fca8ed94a2c35b23fb2e98f99a41f294086d9501.tar.bz2
target-supports.exp (check_effective_target_fixed_point): New to check if targets have fixed-point supports.
* lib/target-supports.exp (check_effective_target_fixed_point): New to check if targets have fixed-point supports. * gcc.dg/fixed-point/fixed-point.exp: New file. * gcc.dg/fixed-point/addsub.c, gcc.dg/fixed-point/allconv.c, * gcc.dg/fixed-point/allop.c, gcc.dg/fixed-point/call-by-value.c, * gcc.dg/fixed-point/cast-bad.c, gcc.dg/fixed-point/composite-type.c, * gcc.dg/fixed-point/const-1.c, gcc.dg/fixed-point/constant.c, * gcc.dg/fixed-point/constants-pedantic.c, * gcc.dg/fixed-point/convert.c, gcc.dg/fixed-point/define.c, * gcc.dg/fixed-point/keywords-c89.c, gcc.dg/fixed-point/keywords-c99.c, * gcc.dg/fixed-point/keywords-ignored-c99.c, * gcc.dg/fixed-point/keywords-pedantic.c, * gcc.dg/fixed-point/keywords-reserved.c, gcc.dg/fixed-point/binary.c, * gcc.dg/fixed-point/modes.c, gcc.dg/fixed-point/noassoc.c, * gcc.dg/fixed-point/types.c, gcc.dg/fixed-point/typespec.c, * gcc.dg/fixed-point/unary.c, gcc.dg/fixed-point/func-array.c, * gcc.dg/fixed-point/func-scalar.c, gcc.dg/fixed-point/func-struct.c, * gcc.dg/fixed-point/func-vararg-mixed.c, * gcc.dg/fixed-point/operator-logical.c, * gcc.dg/fixed-point/struct-union.c, * gcc.dg/fixed-point/bit-complement.c, * gcc.dg/fixed-point/operator-bitwise.c, * gcc.dg/fixed-point/operator-comma.c, * gcc.dg/fixed-point/struct-layout-1.c, * gcc.dg/fixed-point/union-init.c, * gcc.dg/fixed-point/Wbad-function-cast-1.c, * gcc.dg/fixed-point/func-mixed.c, * gcc.dg/fixed-point/func-vararg-size0.c, * gcc.dg/fixed-point/func-vararg.c, gcc.dg/fixed-point/int-warning.c, * gcc.dg/fixed-point/loop-index.c, gcc.dg/fixed-point/operator-cond.c, * gcc.dg/fixed-point/operator-unary.c, * gcc.dg/fixed-point/allop-const.c, * gcc.dg/fixed-point/muldiv-warning.c, * gcc.dg/nofixed-point-1.c, * gcc.target/mips/dpaq_sa_l_w.c, gcc.target/mips/dpsq_sa_l_w.c, * gcc.target/mips/fixed-vector-type.c, * gcc.target/mips/fixed-scalar-type.c: New tests. From-SVN: r128661
Diffstat (limited to 'gcc/testsuite/gcc.dg/fixed-point/binary.c')
-rw-r--r--gcc/testsuite/gcc.dg/fixed-point/binary.c158
1 files changed, 158 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/fixed-point/binary.c b/gcc/testsuite/gcc.dg/fixed-point/binary.c
new file mode 100644
index 0000000..e2cb6ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fixed-point/binary.c
@@ -0,0 +1,158 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+/* N1169 6.5.7 - Bitwise shift operands.
+ C99 6.5.5 Multiplicative operators.
+ C99 6.5.6 Additive operators.
+ C99 6.5.7 Bitwise shift operators.
+ C99 6.5.8 Relational operators.
+ C99 6.5.9 Equality operators.
+ C99 6.5.16 Assignment operators.
+
+ Check binary operators + - * / << >> < <= >= > == != += -= *= /= <<= >>=. */
+
+extern void abort (void);
+
+#define BINARY(TYPE,POSTFIX) \
+ { TYPE a = 0.5 ## POSTFIX; \
+ TYPE b = 0.25 ## POSTFIX; \
+ if (a + b != 0.75 ## POSTFIX) \
+ abort(); \
+ if (a - b != 0.25 ## POSTFIX) \
+ abort(); \
+ if (a * b != 0.125 ## POSTFIX) \
+ abort(); \
+ if (b / a != 0.5 ## POSTFIX) \
+ abort(); \
+ if (b << 1 != a) \
+ abort(); \
+ if (a >> 1 != b) \
+ abort(); \
+ if (a < b != 0) \
+ abort(); \
+ if (a <= b != 0) \
+ abort(); \
+ if (a > b != 1) \
+ abort(); \
+ if (a >= b != 1) \
+ abort(); \
+ if (a == b != 0) \
+ abort(); \
+ if (a != b != 1) \
+ abort(); \
+ a += b; \
+ if (a != 0.75 ## POSTFIX) \
+ abort(); \
+ a -= b; \
+ if (a != 0.5 ## POSTFIX) \
+ abort(); \
+ a *= b; \
+ if (a != 0.125 ## POSTFIX) \
+ abort(); \
+ a /= b; \
+ if (a != 0.5 ## POSTFIX) \
+ abort(); \
+ a >>= 2; \
+ if (a != 0.125 ## POSTFIX) \
+ abort(); \
+ a <<= 1; \
+ if (a != 0.25 ## POSTFIX) \
+ abort(); \
+ }
+
+#define FRACT_SAT_BINARY(TYPE,POSTFIX) \
+ { TYPE a = 0.7 ## POSTFIX; \
+ TYPE b = 0.9 ## POSTFIX; \
+ if (a + b != 1.0 ## POSTFIX) \
+ abort(); \
+ a = -0.7 ## POSTFIX; \
+ b = -0.9 ## POSTFIX; \
+ if (a + b != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
+ abort(); \
+ a = 0.7 ## POSTFIX; \
+ b = -0.9 ## POSTFIX; \
+ if (a - b != 1.0 ## POSTFIX) \
+ abort(); \
+ a = -0.7 ## POSTFIX; \
+ b = 0.9 ## POSTFIX; \
+ if (a - b != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
+ abort(); \
+ a = -0.5 ## POSTFIX - 0.5 ## POSTFIX; \
+ if (a * a != 1.0 ## POSTFIX) \
+ abort(); \
+ a = 0.8 ## POSTFIX; \
+ b = 0.5 ## POSTFIX; \
+ if (a / b != 1.0 ## POSTFIX) \
+ abort(); \
+ a = -0.8 ## POSTFIX; \
+ b = 0.5 ## POSTFIX; \
+ if (a / b != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
+ abort(); \
+ a = 0.1 ## POSTFIX; \
+ if (a << 4 != 1.0 ## POSTFIX) \
+ abort(); \
+ a = -0.8 ## POSTFIX; \
+ if (a << 4 != -0.5 ## POSTFIX - 0.5 ## POSTFIX) \
+ abort(); \
+ }
+
+#define FRACT_SAT_UNS_BINARY(TYPE,POSTFIX) \
+ { TYPE a = 0.7 ## POSTFIX; \
+ TYPE b = 0.9 ## POSTFIX; \
+ if (a + b != 1.0 ## POSTFIX) \
+ abort(); \
+ if (a - b != 0.0 ## POSTFIX) \
+ abort(); \
+ if (b / a != 1.0 ## POSTFIX) \
+ abort(); \
+ if (a << 1 != 1.0 ## POSTFIX) \
+ abort(); \
+ }
+
+int main ()
+{
+ BINARY(short _Fract, hr);
+ BINARY(_Fract, r);
+ BINARY(long _Fract, lr);
+ BINARY(long long _Fract, llr);
+ BINARY(unsigned short _Fract, uhr);
+ BINARY(unsigned _Fract, ur);
+ BINARY(unsigned long _Fract, ulr);
+ BINARY(unsigned long long _Fract, ullr);
+ BINARY(_Sat short _Fract, hr);
+ BINARY(_Sat _Fract, r);
+ BINARY(_Sat long _Fract, lr);
+ BINARY(_Sat long long _Fract, llr);
+ BINARY(_Sat unsigned short _Fract, uhr);
+ BINARY(_Sat unsigned _Fract, ur);
+ BINARY(_Sat unsigned long _Fract, ulr);
+ BINARY(_Sat unsigned long long _Fract, ullr);
+ BINARY(short _Accum, hk);
+ BINARY(_Accum, k);
+ BINARY(long _Accum, lk);
+ BINARY(long long _Accum, llk);
+ BINARY(unsigned short _Accum, uhk);
+ BINARY(unsigned _Accum, uk);
+ BINARY(unsigned long _Accum, ulk);
+ BINARY(unsigned long long _Accum, ullk);
+ BINARY(_Sat short _Accum, hk);
+ BINARY(_Sat _Accum, k);
+ BINARY(_Sat long _Accum, lk);
+ BINARY(_Sat long long _Accum, llk);
+ BINARY(_Sat unsigned short _Accum, uhk);
+ BINARY(_Sat unsigned _Accum, uk);
+ BINARY(_Sat unsigned long _Accum, ulk);
+ BINARY(_Sat unsigned long long _Accum, ullk);
+
+ FRACT_SAT_BINARY(_Sat short _Fract, hr);
+ FRACT_SAT_BINARY(_Sat _Fract, r);
+ FRACT_SAT_BINARY(_Sat long _Fract, lr);
+ FRACT_SAT_BINARY(_Sat long long _Fract, llr);
+
+ FRACT_SAT_UNS_BINARY(_Sat unsigned short _Fract, uhr);
+ FRACT_SAT_UNS_BINARY(_Sat unsigned _Fract, ur);
+ FRACT_SAT_UNS_BINARY(_Sat unsigned long _Fract, ulr);
+ FRACT_SAT_UNS_BINARY(_Sat unsigned long long _Fract, ullr);
+
+ return 0;
+}