added support for assert
This commit is contained in:
@@ -1404,3 +1404,63 @@ define <1 x i8*> @__insert_void(<1 x i8*>, i32,
|
|||||||
ret <1 x i8*> %insert
|
ret <1 x i8*> %insert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; assert
|
||||||
|
|
||||||
|
declare void @__assertfail(i64,i64,i32,i64,i64) noreturn;
|
||||||
|
declare i32 @vprintf(i64,i64)
|
||||||
|
define i32 @__puts_nvptx(i8*) alwaysinline
|
||||||
|
{
|
||||||
|
%str = ptrtoint i8* %0 to i64
|
||||||
|
%parm = or i64 0, 0
|
||||||
|
%call = call i32 @vprintf(i64 %str, i64 %parm)
|
||||||
|
%cr = alloca <2 x i8>
|
||||||
|
store <2 x i8> <i8 10, i8 0>, <2 x i8>* %cr
|
||||||
|
%cr1 = ptrtoint <2 x i8>* %cr to i64
|
||||||
|
%call1 = call i32 @vprintf(i64 %cr1, i64 %parm)
|
||||||
|
ret i32 %call1;
|
||||||
|
}
|
||||||
|
define void @__abort_nvptx(i8* %str) noreturn
|
||||||
|
{
|
||||||
|
%tmp1 = alloca <3 x i8>
|
||||||
|
store <3 x i8> <i8 58, i8 58, i8 0>, <3 x i8>* %tmp1
|
||||||
|
%tmp2 = alloca <2 x i8>
|
||||||
|
store <2 x i8> <i8 0, i8 0>, <2 x i8>* %tmp2
|
||||||
|
|
||||||
|
%param1 = ptrtoint <2 x i8>* %tmp2 to i64
|
||||||
|
%param3 = or i32 0, 0
|
||||||
|
%string = ptrtoint i8* %str to i64
|
||||||
|
%param4 = ptrtoint <3 x i8>* %tmp1 to i64
|
||||||
|
%param5 = or i64 1, 1
|
||||||
|
call void @__assertfail(i64 %param1, i64 %string, i32 %param3, i64 %param4, i64 %param5);
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @__do_assert_uniform(i8 *%str, i1 %test, <WIDTH x MASK> %mask) {
|
||||||
|
br i1 %test, label %ok, label %fail
|
||||||
|
|
||||||
|
fail:
|
||||||
|
call void @__abort_nvptx(i8* %str) noreturn
|
||||||
|
unreachable
|
||||||
|
|
||||||
|
ok:
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
define void @__do_assert_varying(i8 *%str, <WIDTH x MASK> %test,
|
||||||
|
<WIDTH x MASK> %mask) {
|
||||||
|
%nottest = xor <WIDTH x MASK> %test,
|
||||||
|
< forloop(i, 1, eval(WIDTH-1), `MASK -1, ') MASK -1 >
|
||||||
|
%nottest_and_mask = and <WIDTH x MASK> %nottest, %mask
|
||||||
|
%mm = call i64 @__movmsk(<WIDTH x MASK> %nottest_and_mask)
|
||||||
|
%all_ok = icmp eq i64 %mm, 0
|
||||||
|
br i1 %all_ok, label %ok, label %fail
|
||||||
|
|
||||||
|
fail:
|
||||||
|
call void @__abort_nvptx(i8* %str) noreturn
|
||||||
|
unreachable
|
||||||
|
|
||||||
|
ok:
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|||||||
@@ -2064,42 +2064,6 @@ define void @__memset64(i8 * %dst, i8 %val, i64 %len) alwaysinline {
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; assert
|
|
||||||
|
|
||||||
declare i32 @puts(i8*)
|
|
||||||
declare void @abort() noreturn
|
|
||||||
|
|
||||||
define void @__do_assert_uniform(i8 *%str, i1 %test, <WIDTH x MASK> %mask) {
|
|
||||||
br i1 %test, label %ok, label %fail
|
|
||||||
|
|
||||||
fail:
|
|
||||||
%call = call i32 @puts(i8* %str)
|
|
||||||
call void @abort() noreturn
|
|
||||||
unreachable
|
|
||||||
|
|
||||||
ok:
|
|
||||||
ret void
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
define void @__do_assert_varying(i8 *%str, <WIDTH x MASK> %test,
|
|
||||||
<WIDTH x MASK> %mask) {
|
|
||||||
%nottest = xor <WIDTH x MASK> %test,
|
|
||||||
< forloop(i, 1, eval(WIDTH-1), `MASK -1, ') MASK -1 >
|
|
||||||
%nottest_and_mask = and <WIDTH x MASK> %nottest, %mask
|
|
||||||
%mm = call i64 @__movmsk(<WIDTH x MASK> %nottest_and_mask)
|
|
||||||
%all_ok = icmp eq i64 %mm, 0
|
|
||||||
br i1 %all_ok, label %ok, label %fail
|
|
||||||
|
|
||||||
fail:
|
|
||||||
%call = call i32 @puts(i8* %str)
|
|
||||||
call void @abort() noreturn
|
|
||||||
unreachable
|
|
||||||
|
|
||||||
ok:
|
|
||||||
ret void
|
|
||||||
}
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; new/delete
|
;; new/delete
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
|||||||
float a = aFOO[programIndex];
|
float a = aFOO[programIndex];
|
||||||
#ifndef __NVPTX__
|
#ifndef __NVPTX__
|
||||||
uniform Foo f[5];
|
uniform Foo f[5];
|
||||||
#else __NVPTX__ /* too much shared memory allocated, nvcc fails to link */
|
#else /* too much shared memory allocated, nvcc fails to link */
|
||||||
uniform Foo * uniform f = uniform new uniform Foo[5];
|
uniform Foo * uniform f = uniform new uniform Foo[5];
|
||||||
#define _UNMALLOC
|
#define _UNMALLOC
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
|||||||
float a = aFOO[programIndex];
|
float a = aFOO[programIndex];
|
||||||
a *= -1;
|
a *= -1;
|
||||||
Point vp = { a, { 2*a, 3*a, 4*a }, {5*a} };
|
Point vp = { a, { 2*a, 3*a, 4*a }, {5*a} };
|
||||||
#ifndef __NVPTX__
|
|
||||||
assert(2+programIndex < 160);
|
assert(2+programIndex < 160);
|
||||||
#endif
|
|
||||||
pts[2+programIndex] = vp;
|
pts[2+programIndex] = vp;
|
||||||
|
|
||||||
RET[programIndex] = pts[programIndex].y[2];
|
RET[programIndex] = pts[programIndex].y[2];
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __NVPTX__
|
|
||||||
assert(programIndex < 80);
|
assert(programIndex < 80);
|
||||||
#endif
|
|
||||||
RET[programIndex] = pts[programIndex].pts[programIndex % 3][programIndex % 4].z;
|
RET[programIndex] = pts[programIndex].pts[programIndex % 3][programIndex % 4].z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user