[777bfcf] | 1 | // |
---|
[0da3e2c] | 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
[777bfcf] | 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // gccExtensions.c -- |
---|
| 8 | // |
---|
| 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Sun Aug 14 17:28:17 2016 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[926af74] | 12 | // Last Modified On : Wed Aug 17 09:26:50 2016 |
---|
| 13 | // Update Count : 10 |
---|
[777bfcf] | 14 | // |
---|
| 15 | |
---|
| 16 | extern int x asm( "xx" ); |
---|
| 17 | |
---|
[10dc7491] | 18 | int main(int argc, char const *argv[]) { |
---|
[926af74] | 19 | // asm extensions |
---|
| 20 | |
---|
[10dc7491] | 21 | asm( "nop" ); |
---|
| 22 | __asm( "nop" ); |
---|
| 23 | __asm__( "nop" ); |
---|
| 24 | |
---|
[777bfcf] | 25 | static int y asm( "yy" ); |
---|
[5ead9f9] | 26 | #ifdef __CFA__ |
---|
| 27 | static * int z asm( "zz" ); // CFA declaration |
---|
| 28 | #endif // __CFA__ |
---|
[777bfcf] | 29 | |
---|
| 30 | int src; |
---|
| 31 | int dst; |
---|
| 32 | |
---|
| 33 | asm volatile ( "mov %1, %0\n\t" |
---|
| 34 | "add $1, %0" : : : ); |
---|
| 35 | |
---|
| 36 | asm volatile ( "mov %1, %0\n\t" |
---|
| 37 | "add $1, %0" |
---|
| 38 | : "=" "r" (dst)); |
---|
| 39 | |
---|
| 40 | asm volatile ( "mov %1, %0\n\t" |
---|
| 41 | "add $1, %0" |
---|
| 42 | : "=r" (dst) |
---|
| 43 | : "r" (src)); |
---|
| 44 | |
---|
| 45 | asm ( "mov %1, %0\n\t" |
---|
| 46 | "add $1, %0" |
---|
| 47 | : "=r" (dst), "=r" (src) |
---|
| 48 | : [src] "r" (dst) |
---|
| 49 | : "r0"); |
---|
[e82aa9df] | 50 | |
---|
[777bfcf] | 51 | L1: L2: |
---|
| 52 | asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" |
---|
| 53 | : /* No outputs. */ |
---|
| 54 | : "r"(src), "r"(&dst) |
---|
| 55 | : "r5", "memory" |
---|
| 56 | : L1, L2 ); |
---|
[e82aa9df] | 57 | |
---|
[926af74] | 58 | // alternative type/qualifer names |
---|
| 59 | |
---|
[10dc7491] | 60 | __complex__ c1; |
---|
| 61 | _Complex c2; |
---|
| 62 | |
---|
| 63 | const int i1; |
---|
| 64 | __const int i2; |
---|
| 65 | __const__ int i3; |
---|
| 66 | |
---|
[926af74] | 67 | __inline int f1() {} |
---|
| 68 | __inline__ int f2() {} |
---|
| 69 | |
---|
| 70 | __signed s1; |
---|
| 71 | __signed s2; |
---|
| 72 | |
---|
| 73 | __volatile int v1; |
---|
| 74 | __volatile__ int v2; |
---|
| 75 | |
---|
| 76 | // symbol table attributes |
---|
| 77 | |
---|
| 78 | __typeof(s1) t1; |
---|
| 79 | __typeof__(s1) t2; |
---|
| 80 | |
---|
| 81 | // strange extension qualifier |
---|
| 82 | |
---|
[10dc7491] | 83 | __extension__ const int ex; |
---|
| 84 | struct S { |
---|
| 85 | __extension__ int a, b, c; |
---|
| 86 | }; |
---|
| 87 | int i = __extension__ 3; |
---|
| 88 | __extension__ int a, b, c; |
---|
| 89 | __extension__ a, __extension__ b, __extension__ c; |
---|
| 90 | __extension__ a = __extension__ b + __extension__ c; |
---|
| 91 | __extension__ a = __extension__ ( __extension__ b + __extension__ c ); |
---|
| 92 | |
---|
[926af74] | 93 | // attributes |
---|
[10dc7491] | 94 | |
---|
| 95 | __attribute__(()) int a1; |
---|
| 96 | const __attribute(()) int a2; |
---|
| 97 | const static __attribute(()) int a3; |
---|
| 98 | const static int __attribute(()) a4; |
---|
| 99 | const static int a5 __attribute(()); |
---|
| 100 | const static int a6, __attribute(()) a7; |
---|
| 101 | |
---|
| 102 | int * __attribute(()) p1; |
---|
| 103 | int (* __attribute(()) p2); |
---|
| 104 | // int (__attribute(()) (p3)); |
---|
| 105 | // int ( __attribute(()) (* __attribute(()) p4)); |
---|
| 106 | |
---|
| 107 | struct __attribute(()) s1; |
---|
| 108 | struct __attribute(()) s2 { int i; }; |
---|
| 109 | struct __attribute(()) s3 { int i; } x1, __attribute(()) y1; |
---|
| 110 | struct __attribute(()) s4 { int i; } x2, y2 __attribute(()); |
---|
| 111 | |
---|
| 112 | int m1 [10] __attribute(()); |
---|
| 113 | int m2 [10][10] __attribute(()); |
---|
| 114 | int __attribute(()) m3 [10][10]; |
---|
| 115 | // int ( __attribute(()) m4 [10] )[10]; |
---|
[62edde5] | 116 | |
---|
| 117 | return 0; |
---|
| 118 | } |
---|
[777bfcf] | 119 | |
---|
| 120 | // Local Variables: // |
---|
| 121 | // tab-width: 4 // |
---|
| 122 | // compile-command: "cfa gccExtensions.c" // |
---|
| 123 | // End: // |
---|