1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
// RUN: %{ispc} %s --ast-dump --wno-perf --target=host
// This test doesn't check anything specific about format of --ast-dump, but
// it covers most of --ast-dump functionality with respect to Expr and verifies
// that the options doesn't crash the compiler.
void unary(int i) {
i++;
i--;
++i;
--i;
!i;
~i;
-i;
}
int binary(int a, int b) {
int i = (((a + b) - (b * a)) / b) % a;
a, b;
int j = ((a << b) >> b) & (a ^ b) | b;
bool k = (a < b) || (a <= b) && (a == b) || (a >= b) && (a == b) || (a != b);
return i + j + (int)k;
}
void assign(int a, int b) {
a = b;
b *= a;
b /= a;
a %= b;
a += b;
a -= b;
a <<= b;
a >>= b;
a &= b;
a ^= b;
a |= b;
}
int select(int a, int b, int c, int d) { return (a > b) ? a + b : a - b; }
int call_expr_list(int a, int b) { return select(a, b, a + b, a - b); }
int index(int a[], int b) { return a[b]; }
struct S {
int fieldA;
int fieldB;
} s;
int struct_member(struct S *p) { return p->fieldA + s.fieldB; }
int vector_member(int<4> v, int<4> *p) { return v.x + p->x; }
void const_expr() {
bool b1 = true;
bool b2 = programIndex % 2 == 0 ? true : false;
int8 i1 = 1;
uint8 i2 = 1;
int16 i3 = 1;
uint16 i4 = 1;
int32 i5 = 1;
uint32 i6 = 1;
int64 i7 = 1;
uint64 i8 = 1;
float16 f1 = 1.f16;
float f2 = 1.;
double f3 = 1.d;
#if TARGET_WIDTH == 4
int i = {1, 8, 1, 9};
#elif TARGET_WIDTH == 8
int i = {1, 8, 1, 9, 1, 1, 1, 1};
#elif TARGET_WIDTH == 16
int i = {1, 8, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
#elif TARGET_WIDTH == 32
int i = {1, 8, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
#elif TARGET_WIDTH == 64
int i = {1, 8, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
#endif
int folding = programIndex % 3 == 0 ? ((1 + 2) * 3 - 1) : 9 / 2;
;
}
void type_cast(int8 b, int i, float f, double d) {
int ii = (int)b;
int8 bb = (int8)i;
int iii = ((int)f) + ((int)d);
float ff = ((float)d) + ((float)i);
}
int ref(uniform int i, uniform int *uniform p, uniform int &r) {
// ReferenceExpr
uniform int &x = (uniform int &)i;
// RefDerefExpr
uniform int y = r;
// PtrDerefExpr
uniform int z = *p;
// AddressOfExpr
uniform int *pp = &y;
}
int size(float *p) { return sizeof(int) + sizeof(p); }
int allocaaa(uniform int i) {
void *p = alloca(10);
void *p2 = alloca(i);
}
task void my_task_foo() {}
void others(int vi, uniform int ui) {
sync;
launch[5] my_task_foo();
NULL;
new uniform int;
new uniform float[ui];
new uniform float[vi];
int *ptr = new int[100];
delete[] ptr;
}
|