spirv: dont use OpIAddCarry

This instruction is not really working well in the LLVM SPIRV translator,
as it is not implemented.

This commit also intruces the constructStruct helper function to initialize
structs at runtime. This is ALSO buggy in the translator, and we must work
around OpCompositeConstruct not working when some of the constituents are
runtime-known only.

Some other improvements are made:
- improved variable() so that it is more useful and no longer requires the
  address space. It always puts values in the Function address space,
  and returns a pointer to the Generic address space
- adds a boolToInt utility function
This commit is contained in:
Robin Voetter
2023-05-18 17:39:43 +02:00
parent 7d519b3383
commit 0ba0d8fecb
3 changed files with 153 additions and 145 deletions

View File

@@ -82,8 +82,6 @@ test "type equality" {
}
test "pointer dereferencing" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var x = @as(i32, 3);
const y = &x;
@@ -293,8 +291,6 @@ test "function closes over local const" {
}
test "volatile load and store" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var number: i32 = 1234;
const ptr = @as(*volatile i32, &number);
ptr.* += 1;
@@ -466,7 +462,6 @@ fn nine() u8 {
test "struct inside function" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
try testStructInFn();
comptime try testStructInFn();
@@ -691,7 +686,6 @@ test "string concatenation" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const a = "OK" ++ " IT " ++ "WORKED";
const b = "OK IT WORKED";
@@ -1130,7 +1124,6 @@ test "returning an opaque type from a function" {
test "orelse coercion as function argument" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const Loc = struct { start: i32 = -1 };
const Container = struct {