diff options
| author | Leonard Chan <leonardchan@google.com> | 2018-06-04 16:07:52 +0000 |
|---|---|---|
| committer | Leonard Chan <leonardchan@google.com> | 2018-06-04 16:07:52 +0000 |
| commit | f921d854228a023a4e8247f4dab7de1869db442b (patch) | |
| tree | cd937b115ccde401bb2b91791bccc73ca474b209 /clang/test/Frontend/fixed_point.c | |
| parent | 39e5a5695fd3e560565b40d1b60b4a1e78665875 (diff) | |
| download | bcm5719-llvm-f921d854228a023a4e8247f4dab7de1869db442b.tar.gz bcm5719-llvm-f921d854228a023a4e8247f4dab7de1869db442b.zip | |
This diff includes changes for supporting the following types.
// Primary fixed point types
signed short _Accum s_short_accum;
signed _Accum s_accum;
signed long _Accum s_long_accum;
unsigned short _Accum u_short_accum;
unsigned _Accum u_accum;
unsigned long _Accum u_long_accum;
// Aliased fixed point types
short _Accum short_accum;
_Accum accum;
long _Accum long_accum;
This diff only allows for declaration of the fixed point types. Assignment and other operations done on fixed point types according to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in future patches. The saturated versions of these types and the equivalent _Fract types will also be added in future patches.
The tests included are for asserting that we can declare these types.
Fixed the test that was failing by not checking for dso_local on some
targets.
Differential Revision: https://reviews.llvm.org/D46084
llvm-svn: 333923
Diffstat (limited to 'clang/test/Frontend/fixed_point.c')
| -rw-r--r-- | clang/test/Frontend/fixed_point.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/clang/test/Frontend/fixed_point.c b/clang/test/Frontend/fixed_point.c new file mode 100644 index 00000000000..d64bd55aa0b --- /dev/null +++ b/clang/test/Frontend/fixed_point.c @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -x c -ffixed-point -ast-dump %s | FileCheck %s --strict-whitespace + +/* Various contexts where type _Accum can appear. */ + +// Primary fixed point types +signed short _Accum s_short_accum; +signed _Accum s_accum; +signed long _Accum s_long_accum; +unsigned short _Accum u_short_accum; +unsigned _Accum u_accum; +unsigned long _Accum u_long_accum; + +// Aliased fixed point types +short _Accum short_accum; +_Accum accum; +long _Accum long_accum; + +// CHECK: |-VarDecl {{.*}} s_short_accum 'short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum' +// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum' +// CHECK-NEXT: |-VarDecl {{.*}} long_accum 'long _Accum' + +#define MIX_TYPE_SPEC(SPEC, SIGN, SIZE, ID) \ + SPEC SIGN SIZE _Accum ID; \ + SIGN SPEC SIZE _Accum ID ## 2; \ + SIGN SIZE SPEC _Accum ID ## 3; \ + SIGN SIZE _Accum SPEC ID ## 4; + +/* Mixing fixed point types with other type specifiers */ + +#define MIX_VOLATILE(SIGN, SIZE, ID) MIX_TYPE_SPEC(volatile, SIGN, SIZE, ID) +#define MIX_ATOMIC(SIGN, SIZE, ID) MIX_TYPE_SPEC(_Atomic, SIGN, SIZE, ID) +#define MIX_CONST(SIGN, SIZE, ID) MIX_TYPE_SPEC(const, SIGN, SIZE, ID) + +MIX_VOLATILE(signed, short, vol_s_short_accum) +MIX_ATOMIC(signed, short, atm_s_short_accum) +MIX_CONST(signed, short, const_s_short_accum) + +// CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum 'volatile short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum2 'volatile short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum3 'volatile short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} vol_s_short_accum4 'volatile short _Accum' + +// CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum '_Atomic(short _Accum)' +// CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum2 '_Atomic(short _Accum)' +// CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum3 '_Atomic(short _Accum)' +// CHECK-NEXT: |-VarDecl {{.*}} atm_s_short_accum4 '_Atomic(short _Accum)' + +// CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum 'const short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum2 'const short _Accum' +// CHECK-NEXT: |-VarDecl {{.*}} const_s_short_accum3 'const short _Accum' +// CHECK-NEXT: `-VarDecl {{.*}} const_s_short_accum4 'const short _Accum' |

