Pointer fixes/improvements.

Allow <, <=, >, >= comparisons of pointers
Allow explicit type-casting of pointers to and from integers
Fix bug in handling expressions of the form "int + ptr" ("ptr + int"
  was fine).
Fix a bug in TypeCastExpr where varying -> uniform typecasts
  would be allowed (leading to a crash later)
This commit is contained in:
Matt Pharr
2011-11-29 13:22:36 -08:00
parent 4ca90272ba
commit e52104ff55
15 changed files with 235 additions and 40 deletions

12
tests/ptr-cmp-1.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * varying b = &aFOO[10];
uniform float * uniform c = aFOO;
RET[programIndex] = (b > c) ? 10 : 0;
}
export void result(uniform float RET[]) {
RET[programIndex] = 10;
}

12
tests/ptr-cmp-2.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * uniform b = aFOO;
uniform float * uniform c = aFOO;
RET[programIndex] = (c <= b) ? 10 : 0;
}
export void result(uniform float RET[]) {
RET[programIndex] = 10;
}

12
tests/ptr-diff-4.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * varying b = aFOO;
b = 5 + b;
RET[programIndex] = b - aFOO;
}
export void result(uniform float RET[]) {
RET[programIndex] = 5;
}

12
tests/ptr-diff-5.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * varying b = aFOO;
uniform float * uniform c = &aFOO[10];
RET[programIndex] = c - b;
}
export void result(uniform float RET[]) {
RET[programIndex] = 10;
}

12
tests/ptr-diff-6.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform float * varying b = &aFOO[10];
uniform float * uniform c = aFOO;
RET[programIndex] = b - c;
}
export void result(uniform float RET[]) {
RET[programIndex] = 10;
}

14
tests/ptr-int-1.ispc Normal file
View File

@@ -0,0 +1,14 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
uniform int a = 1;
uniform int * uniform b = &a;
int64 pi = (int64)b;
RET[programIndex] = *((uniform int * varying)pi);
}
export void result(uniform float RET[]) {
RET[programIndex] = 1;
}