mirror of
https://github.com/ziglang/zig.git
synced 2024-11-25 05:40:16 +00:00
riscv: finally fix bug + airAggregateInit
i just hadn't realized that I placed the `riscv_start` branch in the non-simplified starts
This commit is contained in:
parent
2fd83d8c0a
commit
ffb63a05a3
@ -22,7 +22,8 @@ pub const simplified_logic =
|
||||
builtin.zig_backend == .stage2_arm or
|
||||
builtin.zig_backend == .stage2_sparc64 or
|
||||
builtin.cpu.arch == .spirv32 or
|
||||
builtin.cpu.arch == .spirv64;
|
||||
builtin.cpu.arch == .spirv64 or
|
||||
builtin.zig_backend == .stage2_riscv64;
|
||||
|
||||
comptime {
|
||||
// No matter what, we import the root file, so that any export, test, comptime
|
||||
@ -42,6 +43,10 @@ comptime {
|
||||
} else if (builtin.os.tag == .opencl) {
|
||||
if (@hasDecl(root, "main"))
|
||||
@export(spirvMain2, .{ .name = "main" });
|
||||
} else if (native_arch.isRISCV()) {
|
||||
if (!@hasDecl(root, "_start")) {
|
||||
@export(riscv_start, .{ .name = "_start" });
|
||||
}
|
||||
} else {
|
||||
if (!@hasDecl(root, "_start")) {
|
||||
@export(_start2, .{ .name = "_start" });
|
||||
@ -60,10 +65,6 @@ comptime {
|
||||
} else if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
|
||||
@export(main, .{ .name = "main" });
|
||||
}
|
||||
} else if (native_arch.isRISCV()) {
|
||||
if (!@hasDecl(root, "_start")) {
|
||||
@export(riscv_start, .{ .name = "_start" });
|
||||
}
|
||||
} else if (native_os == .windows) {
|
||||
if (!@hasDecl(root, "WinMain") and !@hasDecl(root, "WinMainCRTStartup") and
|
||||
!@hasDecl(root, "wWinMain") and !@hasDecl(root, "wWinMainCRTStartup"))
|
||||
@ -208,7 +209,20 @@ fn wasi_start() callconv(.C) void {
|
||||
}
|
||||
|
||||
fn riscv_start() callconv(.C) noreturn {
|
||||
std.process.exit(@call(.always_inline, callMain, .{}));
|
||||
std.process.exit(switch (@typeInfo(@typeInfo(@TypeOf(root.main)).Fn.return_type.?)) {
|
||||
.NoReturn => root.main(),
|
||||
.Void => ret: {
|
||||
root.main();
|
||||
break :ret 0;
|
||||
},
|
||||
.Int => |info| ret: {
|
||||
if (info.bits != 8 or info.signedness == .signed) {
|
||||
@compileError(bad_main_ret);
|
||||
}
|
||||
break :ret root.main();
|
||||
},
|
||||
else => @compileError("expected return type of main to be 'void', 'noreturn', 'u8'"),
|
||||
});
|
||||
}
|
||||
|
||||
fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv(.C) usize {
|
||||
|
@ -22,7 +22,7 @@ pub var base_allocator_instance = std.heap.FixedBufferAllocator.init("");
|
||||
pub var log_level = std.log.Level.warn;
|
||||
|
||||
// Disable printing in tests for simple backends.
|
||||
pub const backend_can_print = builtin.zig_backend != .stage2_spirv64 and builtin.zig_backend != .stage2_riscv64;
|
||||
pub const backend_can_print = !(builtin.zig_backend == .stage2_spirv64 or builtin.zig_backend == .stage2_riscv64);
|
||||
|
||||
fn print(comptime fmt: []const u8, args: anytype) void {
|
||||
if (@inComptime()) {
|
||||
|
@ -43,6 +43,8 @@ const callee_preserved_regs = abi.callee_preserved_regs;
|
||||
const gp = abi.RegisterClass.gp;
|
||||
/// Function Args
|
||||
const fa = abi.RegisterClass.fa;
|
||||
/// Function Returns
|
||||
const fr = abi.RegisterClass.fr;
|
||||
/// Temporary Use
|
||||
const tp = abi.RegisterClass.tp;
|
||||
|
||||
@ -1083,8 +1085,8 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
|
||||
.mod => try self.airMod(inst),
|
||||
.shl, .shl_exact => try self.airShl(inst),
|
||||
.shl_sat => try self.airShlSat(inst),
|
||||
.min => try self.airMin(inst),
|
||||
.max => try self.airMax(inst),
|
||||
.min => try self.airMinMax(inst, .min),
|
||||
.max => try self.airMinMax(inst, .max),
|
||||
.slice => try self.airSlice(inst),
|
||||
|
||||
.sqrt,
|
||||
@ -1672,7 +1674,6 @@ fn airAlloc(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const result: MCValue = switch (self.ret_mcv.long) {
|
||||
else => unreachable,
|
||||
.none => .{ .lea_frame = .{ .index = try self.allocMemPtr(inst) } },
|
||||
.load_frame => .{ .register_offset = .{
|
||||
.reg = (try self.copyToNewRegister(
|
||||
@ -1681,6 +1682,7 @@ fn airRetPtr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
)).register,
|
||||
.off = self.ret_mcv.short.indirect.off,
|
||||
} },
|
||||
else => |t| return self.fail("TODO: airRetPtr {s}", .{@tagName(t)}),
|
||||
};
|
||||
return self.finishAir(inst, result, .{ .none, .none, .none });
|
||||
}
|
||||
@ -1799,7 +1801,14 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {
|
||||
return self.finishAir(inst, result, .{ ty_op.operand, .none, .none });
|
||||
}
|
||||
|
||||
fn airMin(self: *Self, inst: Air.Inst.Index) !void {
|
||||
fn airMinMax(
|
||||
self: *Self,
|
||||
inst: Air.Inst.Index,
|
||||
comptime tag: enum {
|
||||
max,
|
||||
min,
|
||||
},
|
||||
) !void {
|
||||
const zcu = self.bin_file.comp.module.?;
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
|
||||
@ -1882,7 +1891,7 @@ fn airMin(self: *Self, inst: Air.Inst.Index) !void {
|
||||
.ops = .rrr,
|
||||
.data = .{ .r_type = .{
|
||||
.rd = result_reg,
|
||||
.rs1 = rhs_reg,
|
||||
.rs1 = if (tag == .min) rhs_reg else lhs_reg,
|
||||
.rs2 = mask_reg,
|
||||
} },
|
||||
});
|
||||
@ -1892,12 +1901,6 @@ fn airMin(self: *Self, inst: Air.Inst.Index) !void {
|
||||
return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
|
||||
}
|
||||
|
||||
fn airMax(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
|
||||
const result: MCValue = if (self.liveness.isUnused(inst)) .unreach else return self.fail("TODO implement max for {}", .{self.target.cpu.arch});
|
||||
return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
|
||||
}
|
||||
|
||||
fn airSlice(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
|
||||
@ -3577,10 +3580,10 @@ fn genCall(
|
||||
const func_key = zcu.intern_pool.indexToKey(func_value.ip_index);
|
||||
switch (switch (func_key) {
|
||||
else => func_key,
|
||||
.ptr => |ptr| switch (ptr.addr) {
|
||||
.ptr => |ptr| if (ptr.byte_offset == 0) switch (ptr.base_addr) {
|
||||
.decl => |decl| zcu.intern_pool.indexToKey(zcu.declPtr(decl).val.toIntern()),
|
||||
else => func_key,
|
||||
},
|
||||
} else func_key,
|
||||
}) {
|
||||
.func => |func| {
|
||||
if (self.bin_file.cast(link.File.Elf)) |elf_file| {
|
||||
@ -4174,8 +4177,7 @@ fn performReloc(self: *Self, inst: Mir.Inst.Index) void {
|
||||
.bne,
|
||||
.beq,
|
||||
=> self.mir_instructions.items(.data)[inst].b_type.inst = target,
|
||||
.jal,
|
||||
=> self.mir_instructions.items(.data)[inst].j_type.inst = target,
|
||||
.jal => self.mir_instructions.items(.data)[inst].j_type.inst = target,
|
||||
.pseudo => switch (ops) {
|
||||
.pseudo_j => self.mir_instructions.items(.data)[inst].inst = target,
|
||||
else => std.debug.panic("TODO: performReloc {s}", .{@tagName(ops)}),
|
||||
@ -5021,13 +5023,36 @@ fn airReduce(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const zcu = self.bin_file.comp.module.?;
|
||||
const vector_ty = self.typeOfIndex(inst);
|
||||
const len = vector_ty.vectorLen(zcu);
|
||||
const result_ty = self.typeOfIndex(inst);
|
||||
const len: usize = @intCast(result_ty.arrayLen(zcu));
|
||||
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
|
||||
const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]);
|
||||
const result: MCValue = res: {
|
||||
if (self.liveness.isUnused(inst)) break :res .unreach;
|
||||
return self.fail("TODO implement airAggregateInit for riscv64", .{});
|
||||
const result: MCValue = result: {
|
||||
switch (result_ty.zigTypeTag(zcu)) {
|
||||
.Struct => {
|
||||
const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu));
|
||||
|
||||
if (result_ty.containerLayout(zcu) == .@"packed") {} else for (elements, 0..) |elem, elem_i| {
|
||||
if ((try result_ty.structFieldValueComptime(zcu, elem_i)) != null) continue;
|
||||
|
||||
const elem_ty = result_ty.structFieldType(elem_i, zcu);
|
||||
const elem_off: i32 = @intCast(result_ty.structFieldOffset(elem_i, zcu));
|
||||
const elem_mcv = try self.resolveInst(elem);
|
||||
|
||||
const elem_frame: FrameAddr = .{
|
||||
.index = frame_index,
|
||||
.off = elem_off,
|
||||
};
|
||||
try self.genSetStack(
|
||||
elem_ty,
|
||||
elem_frame,
|
||||
elem_mcv,
|
||||
);
|
||||
}
|
||||
},
|
||||
else => return self.fail("TODO: airAggregateInit {}", .{result_ty.fmt(zcu)}),
|
||||
}
|
||||
break :result .{ .register = .zero };
|
||||
};
|
||||
|
||||
if (elements.len <= Liveness.bpi - 1) {
|
||||
@ -5189,12 +5214,24 @@ fn resolveCallingConventionValues(
|
||||
|
||||
for (classes) |class| switch (class) {
|
||||
.integer => {
|
||||
const ret_int_reg = abi.function_arg_regs[ret_int_reg_i];
|
||||
const ret_int_reg = abi.function_ret_regs[ret_int_reg_i];
|
||||
ret_int_reg_i += 1;
|
||||
|
||||
ret_tracking[ret_tracking_i] = InstTracking.init(.{ .register = ret_int_reg });
|
||||
ret_tracking_i += 1;
|
||||
},
|
||||
.memory => {
|
||||
const ret_int_reg = abi.function_ret_regs[ret_int_reg_i];
|
||||
ret_int_reg_i += 1;
|
||||
const ret_indirect_reg = abi.function_arg_regs[param_int_reg_i];
|
||||
param_int_reg_i += 1;
|
||||
|
||||
ret_tracking[ret_tracking_i] = .{
|
||||
.short = .{ .indirect = .{ .reg = ret_int_reg } },
|
||||
.long = .{ .indirect = .{ .reg = ret_indirect_reg } },
|
||||
};
|
||||
ret_tracking_i += 1;
|
||||
},
|
||||
else => return self.fail("TODO: C calling convention return class {}", .{class}),
|
||||
};
|
||||
|
||||
@ -5226,6 +5263,13 @@ fn resolveCallingConventionValues(
|
||||
arg_mcv[arg_mcv_i] = .{ .register = param_int_reg };
|
||||
arg_mcv_i += 1;
|
||||
},
|
||||
.memory => {
|
||||
const param_int_regs = abi.function_arg_regs;
|
||||
const param_int_reg = param_int_regs[param_int_reg_i];
|
||||
|
||||
arg_mcv[arg_mcv_i] = .{ .indirect = .{ .reg = param_int_reg } };
|
||||
arg_mcv_i += 1;
|
||||
},
|
||||
else => return self.fail("TODO: C calling convention arg class {}", .{class}),
|
||||
} else {
|
||||
arg.* = switch (arg_mcv_i) {
|
||||
|
@ -96,7 +96,6 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
|
||||
/// There are a maximum of 8 possible return slots. Returned values are in
|
||||
/// the beginning of the array; unused slots are filled with .none.
|
||||
pub fn classifySystem(ty: Type, zcu: *Module) [8]Class {
|
||||
const ip = zcu.intern_pool;
|
||||
var result = [1]Class{.none} ** 8;
|
||||
const memory_class = [_]Class{
|
||||
.memory, .none, .none, .none,
|
||||
@ -158,22 +157,17 @@ pub fn classifySystem(ty: Type, zcu: *Module) [8]Class {
|
||||
std.debug.panic("TODO: classifySystem ErrorUnion > 64 bit payload", .{});
|
||||
},
|
||||
.Struct => {
|
||||
const loaded_struct = ip.loadStructType(ty.toIntern());
|
||||
const layout = ty.containerLayout(zcu);
|
||||
const ty_size = ty.abiSize(zcu);
|
||||
|
||||
if (loaded_struct.layout == .@"packed") {
|
||||
if (layout == .@"packed") {
|
||||
assert(ty_size <= 16);
|
||||
result[0] = .integer;
|
||||
if (ty_size > 8) result[1] = .integer;
|
||||
return result;
|
||||
}
|
||||
if (ty_size > 64)
|
||||
return memory_class;
|
||||
|
||||
var byte_offset: u64 = 0;
|
||||
classifyStruct(&result, &byte_offset, loaded_struct, zcu);
|
||||
|
||||
return result;
|
||||
return memory_class;
|
||||
},
|
||||
else => |bad_ty| std.debug.panic("classifySystem {s}", .{@tagName(bad_ty)}),
|
||||
}
|
||||
@ -245,6 +239,10 @@ pub const function_arg_regs = [_]Register{
|
||||
.a0, .a1, .a2, .a3, .a4, .a5, .a6, .a7,
|
||||
};
|
||||
|
||||
pub const function_ret_regs = [_]Register{
|
||||
.a0, .a1,
|
||||
};
|
||||
|
||||
pub const temporary_regs = [_]Register{
|
||||
.t0, .t1, .t2, .t3, .t4, .t5, .t6,
|
||||
};
|
||||
@ -273,6 +271,15 @@ pub const RegisterClass = struct {
|
||||
break :blk set;
|
||||
};
|
||||
|
||||
pub const fr: RegisterBitSet = blk: {
|
||||
var set = RegisterBitSet.initEmpty();
|
||||
set.setRangeValue(.{
|
||||
.start = callee_preserved_regs.len,
|
||||
.end = callee_preserved_regs.len + function_ret_regs.len,
|
||||
}, true);
|
||||
break :blk set;
|
||||
};
|
||||
|
||||
pub const tp: RegisterBitSet = blk: {
|
||||
var set = RegisterBitSet.initEmpty();
|
||||
set.setRangeValue(.{
|
||||
|
@ -388,7 +388,6 @@ test "function align expression depends on generic parameter" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
// function alignment is a compile error on wasm32/wasm64
|
||||
if (native_arch == .wasm32 or native_arch == .wasm64) return error.SkipZigTest;
|
||||
|
@ -593,6 +593,7 @@ test "equality compare fn ptrs" {
|
||||
|
||||
test "self reference through fn ptr field" {
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const A = struct {
|
||||
|
@ -541,6 +541,7 @@ test "@bitCast of packed struct containing pointer" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const A = packed struct {
|
||||
@ -570,6 +571,7 @@ test "@bitCast of extern struct containing pointer" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const A = extern struct {
|
||||
|
@ -2713,7 +2713,6 @@ test "bitcast vector" {
|
||||
if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO
|
||||
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_riscv64) return error.SkipZigTest;
|
||||
|
||||
const u8x32 = @Vector(32, u8);
|
||||
const u32x8 = @Vector(8, u32);
|
||||
|
@ -32,6 +32,8 @@ test "type pun signed and unsigned as array pointer" {
|
||||
}
|
||||
|
||||
test "type pun signed and unsigned as offset many pointer" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
var x: [11]u32 = undefined;
|
||||
var y: [*]i32 = @ptrCast(&x[10]);
|
||||
@ -42,6 +44,8 @@ test "type pun signed and unsigned as offset many pointer" {
|
||||
}
|
||||
|
||||
test "type pun signed and unsigned as array pointer with pointer arithemtic" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
var x: [11]u32 = undefined;
|
||||
const y = @as([*]i32, @ptrCast(&x[10])) - 10;
|
||||
@ -289,6 +293,8 @@ test "dance on linker values" {
|
||||
}
|
||||
|
||||
test "offset array ptr by element size" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
const VirtualStruct = struct { x: u32 };
|
||||
var arr: [4]VirtualStruct = .{
|
||||
@ -418,8 +424,6 @@ test "dereference undefined pointer to zero-bit type" {
|
||||
}
|
||||
|
||||
test "type pun extern struct" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = extern struct { f: u8 };
|
||||
comptime var s = S{ .f = 123 };
|
||||
@as(*u8, @ptrCast(&s)).* = 72;
|
||||
|
@ -1246,8 +1246,6 @@ test "auto-numbered enum with signed tag type" {
|
||||
}
|
||||
|
||||
test "lazy initialized field" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
try std.testing.expectEqual(@as(u8, @alignOf(struct {})), getLazyInitialized(.a));
|
||||
}
|
||||
|
||||
|
@ -1102,6 +1102,7 @@ test "result location initialization of error union with OPV payload" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
x: u0,
|
||||
|
@ -1705,8 +1705,6 @@ test "early exit in container level const" {
|
||||
}
|
||||
|
||||
test "@inComptime" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn inComptime() bool {
|
||||
return @inComptime();
|
||||
|
@ -191,6 +191,7 @@ test "function with complex callconv and return type expressions" {
|
||||
|
||||
test "pass by non-copying value" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
try expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3);
|
||||
}
|
||||
@ -218,6 +219,7 @@ fn addPointCoordsVar(pt: anytype) !i32 {
|
||||
|
||||
test "pass by non-copying value as method" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
var pt = Point2{ .x = 1, .y = 2 };
|
||||
try expect(pt.addPointCoords() == 3);
|
||||
@ -234,6 +236,7 @@ const Point2 = struct {
|
||||
|
||||
test "pass by non-copying value as method, which is generic" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
var pt = Point3{ .x = 1, .y = 2 };
|
||||
try expect(pt.addPointCoords(i32) == 3);
|
||||
@ -624,8 +627,6 @@ test "comptime parameters don't have to be marked comptime if only called at com
|
||||
}
|
||||
|
||||
test "inline function with comptime-known comptime-only return type called at runtime" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
inline fn foo(x: *i32, y: *const i32) type {
|
||||
x.* = y.*;
|
||||
|
@ -34,6 +34,7 @@ fn custom(comptime T: type, comptime num: u64) fn (T) u64 {
|
||||
test "fn delegation" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const foo = Foo{};
|
||||
try expect(foo.one() == 11);
|
||||
|
@ -395,6 +395,7 @@ test "extern function used as generic parameter" {
|
||||
|
||||
test "generic struct as parameter type" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest(comptime Int: type, thing: struct { int: Int }) !void {
|
||||
|
@ -179,8 +179,6 @@ fn returnTrue() bool {
|
||||
}
|
||||
|
||||
test "if value shouldn't be load-elided if used later (structs)" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const Foo = struct { x: i32 };
|
||||
|
||||
var a = Foo{ .x = 1 };
|
||||
|
@ -160,8 +160,6 @@ test "@min/@max on lazy values" {
|
||||
}
|
||||
|
||||
test "@min/@max more than two arguments" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const x: u32 = 30;
|
||||
const y: u32 = 10;
|
||||
const z: u32 = 20;
|
||||
@ -187,7 +185,6 @@ test "@min/@max notices bounds" {
|
||||
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_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
var x: u16 = 20;
|
||||
const y = 30;
|
||||
@ -239,7 +236,6 @@ test "@min/@max notices bounds from types" {
|
||||
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_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
var x: u16 = 123;
|
||||
var y: u32 = 456;
|
||||
@ -325,8 +321,6 @@ test "@min/@max notices bounds from vector types when element of comptime-known
|
||||
}
|
||||
|
||||
test "@min/@max of signed and unsigned runtime integers" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
var x: i32 = -1;
|
||||
var y: u31 = 1;
|
||||
_ = .{ &x, &y };
|
||||
|
@ -640,6 +640,7 @@ test "result location initialization of optional with OPV payload" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
x: u0,
|
||||
|
@ -124,7 +124,6 @@ test "correct sizeOf and offsets in packed structs" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const PStruct = packed struct {
|
||||
bool_a: bool,
|
||||
@ -193,7 +192,6 @@ test "nested packed structs" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S1 = packed struct { a: u8, b: u8, c: u8 };
|
||||
|
||||
|
@ -177,6 +177,8 @@ test "assigning to non-active field at comptime" {
|
||||
}
|
||||
|
||||
test "comptime packed union of pointers" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const U = packed union {
|
||||
a: *const u32,
|
||||
b: *const [1]u32,
|
||||
|
@ -10,7 +10,6 @@ test "packed struct explicit backing integer" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S1 = packed struct { a: u8, b: u8, c: u8 };
|
||||
|
||||
|
@ -640,6 +640,8 @@ test "cast pointers with zero sized elements" {
|
||||
}
|
||||
|
||||
test "comptime pointer equality through distinct fields with well-defined layout" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const A = extern struct {
|
||||
x: u32,
|
||||
z: u16,
|
||||
@ -664,6 +666,8 @@ test "comptime pointer equality through distinct fields with well-defined layout
|
||||
}
|
||||
|
||||
test "comptime pointer equality through distinct elements with well-defined layout" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const buf: [2]u32 = .{ 123, 456 };
|
||||
|
||||
const ptr: *const [2]u32 = &buf;
|
||||
|
@ -298,6 +298,8 @@ test "comptime @ptrCast with packed struct leaves value unmodified" {
|
||||
}
|
||||
|
||||
test "@ptrCast restructures comptime-only array" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
{
|
||||
const a3a2: [3][2]comptime_int = .{
|
||||
.{ 1, 2 },
|
||||
@ -340,6 +342,8 @@ test "@ptrCast restructures comptime-only array" {
|
||||
}
|
||||
|
||||
test "@ptrCast restructures sliced comptime-only array" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const a3a2: [4][2]comptime_int = .{
|
||||
.{ 1, 2 },
|
||||
.{ 3, 4 },
|
||||
|
@ -412,6 +412,7 @@ test "Extern function calls, dereferences and field access in @TypeOf" {
|
||||
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;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const Test = struct {
|
||||
fn test_fn_1(a: c_long) @TypeOf(c_fopen("test", "r").*) {
|
||||
|
@ -176,6 +176,7 @@ const MemberFnTestFoo = struct {
|
||||
|
||||
test "call member function directly" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const instance = MemberFnTestFoo{ .x = 1234 };
|
||||
const result = MemberFnTestFoo.member(instance);
|
||||
@ -184,6 +185,7 @@ test "call member function directly" {
|
||||
|
||||
test "store member function in variable" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const instance = MemberFnTestFoo{ .x = 1234 };
|
||||
const memberFn = MemberFnTestFoo.member;
|
||||
@ -1559,6 +1561,7 @@ test "discarded struct initialization works as expected" {
|
||||
test "function pointer in struct returns the struct" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const A = struct {
|
||||
const A = @This();
|
||||
@ -1699,7 +1702,6 @@ test "struct field pointer has correct alignment" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
@ -1781,6 +1783,8 @@ fn countFields(v: anytype) usize {
|
||||
}
|
||||
|
||||
test "struct init with no result pointer sets field result types" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
// A function parameter has a result type, but no result pointer.
|
||||
fn f(s: struct { x: u32 }) u32 {
|
||||
@ -1928,6 +1932,8 @@ test "circular dependency through pointer field of a struct" {
|
||||
}
|
||||
|
||||
test "field calls do not force struct field init resolution" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
x: u32 = blk: {
|
||||
_ = @TypeOf(make().dummyFn()); // runtime field call - S not fully resolved - dummyFn call should not force field init resolution
|
||||
@ -1958,7 +1964,6 @@ test "extern struct fields are aligned to 1" {
|
||||
if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO
|
||||
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_riscv64) return error.SkipZigTest;
|
||||
|
||||
const Foo = extern struct {
|
||||
a: u8 align(1),
|
||||
@ -2090,7 +2095,6 @@ test "struct field default value is a call" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const Z = packed struct {
|
||||
a: u32,
|
||||
|
@ -451,7 +451,6 @@ test "tuple pointer is indexable" {
|
||||
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_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct { u32, bool };
|
||||
|
||||
|
@ -203,6 +203,7 @@ test "Type.Opaque" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const Opaque = @Type(.{
|
||||
.Opaque = .{
|
||||
@ -348,7 +349,6 @@ test "Type.Struct" {
|
||||
test "Type.Enum" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const Foo = @Type(.{
|
||||
.Enum = .{
|
||||
@ -763,6 +763,8 @@ test "matching captures causes opaque equivalence" {
|
||||
}
|
||||
|
||||
test "reify enum where fields refers to part of array" {
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const fields: [3]std.builtin.Type.EnumField = .{
|
||||
.{ .name = "foo", .value = 0 },
|
||||
.{ .name = "bar", .value = 1 },
|
||||
|
@ -1622,7 +1622,6 @@ test "defined-layout union field pointer has correct alignment" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest(comptime U: type) !void {
|
||||
@ -1658,7 +1657,6 @@ test "undefined-layout union field pointer has correct alignment" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest(comptime U: type) !void {
|
||||
@ -1694,7 +1692,6 @@ test "packed union field pointer has correct alignment" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
const U = packed union { x: u20 };
|
||||
const S = packed struct(u24) { a: u2, u: U, b: u2 };
|
||||
|
Loading…
Reference in New Issue
Block a user