authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-13 18:43:43-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-13 18:43:43-07:00
logb0f80ef0d5517b5ce8ba60dfae6dd986346f8d4c
tree14dbc30206ceed6282ee010685de8da1ede4167d
parentdf7d6d263e4ad6adb302856235641ae9ceb142b6

stage2: remove use of `builtin.stage2_arch` workaround

The LLVM backend no longer needs this hack! However, the other backends still do. So there are still some traces of this workaround in use for now.

5 files changed, 23 insertions(+), 17 deletions(-)

lib/std/special/compiler_rt.zig+1-1
......@@ -2,7 +2,7 @@ const std = @import("std");
22const builtin = @import("builtin");
33const is_test = builtin.is_test;
44const os_tag = builtin.os.tag;
5const arch = builtin.stage2_arch;
5const arch = builtin.cpu.arch;
66const abi = builtin.abi;
77
88const is_gnu = abi.isGnu();
src/Sema.zig+18-11
......@@ -10186,7 +10186,7 @@ fn validateVarType(
1018610186 is_extern: bool,
1018710187) CompileError!void {
1018810188 var ty = var_ty;
10189 const ok: bool = while (true) switch (ty.zigTypeTag()) {
10189 while (true) switch (ty.zigTypeTag()) {
1019010190 .Bool,
1019110191 .Int,
1019210192 .Float,
......@@ -10194,7 +10194,7 @@ fn validateVarType(
1019410194 .Enum,
1019510195 .Frame,
1019610196 .AnyFrame,
10197 => break true,
10197 => return,
1019810198
1019910199 .BoundFn,
1020010200 .ComptimeFloat,
......@@ -10205,14 +10205,14 @@ fn validateVarType(
1020510205 .Void,
1020610206 .Undefined,
1020710207 .Null,
10208 => break false,
10208 => break,
1020910209
1021010210 .Pointer => {
1021110211 const elem_ty = ty.childType();
1021210212 if (elem_ty.zigTypeTag() == .Opaque) return;
1021310213 ty = elem_ty;
1021410214 },
10215 .Opaque => break is_extern,
10215 .Opaque => if (is_extern) return else break,
1021610216
1021710217 .Optional => {
1021810218 var buf: Type.Payload.ElemType = undefined;
......@@ -10223,15 +10223,17 @@ fn validateVarType(
1022310223
1022410224 .ErrorUnion => ty = ty.errorUnionPayload(),
1022510225
10226 .Fn => @panic("TODO fn validateVarType"),
10227 .Struct, .Union => {
10226 .Fn, .Struct, .Union => {
1022810227 const resolved_ty = try sema.resolveTypeFields(block, src, ty);
10229 break !resolved_ty.requiresComptime();
10228 if (resolved_ty.requiresComptime()) {
10229 break;
10230 } else {
10231 return;
10232 }
1023010233 },
1023110234 } else unreachable; // TODO should not need else unreachable
10232 if (!ok) {
10233 return sema.fail(block, src, "variable of type '{}' must be const or comptime", .{var_ty});
10234 }
10235
10236 return sema.fail(block, src, "variable of type '{}' must be const or comptime", .{var_ty});
1023510237}
1023610238
1023710239pub const PanicId = enum {
......@@ -11273,7 +11275,12 @@ fn coerce(
1127311275
1127411276 const in_memory_result = coerceInMemoryAllowed(dest_type, inst_ty, false, target);
1127511277 if (in_memory_result == .ok) {
11276 return sema.bitCast(block, dest_type, inst, inst_src);
11278 if (try sema.resolveMaybeUndefVal(block, inst_src, inst)) |val| {
11279 // Keep the comptime Value representation; take the new type.
11280 return sema.addConstant(dest_type, val);
11281 }
11282 try sema.requireRuntimeBlock(block, inst_src);
11283 return block.addTyOp(.bitcast, dest_type, inst);
1127711284 }
1127811285
1127911286 // undefined to anything
src/type.zig+1-2
......@@ -1458,7 +1458,7 @@ pub const Type = extern union {
14581458 }
14591459 },
14601460 .union_tagged => {
1461 const union_obj = self.castTag(.@"union").?.data;
1461 const union_obj = self.castTag(.union_tagged).?.data;
14621462 if (union_obj.tag_ty.hasCodeGenBits()) {
14631463 return true;
14641464 }
......@@ -1470,7 +1470,6 @@ pub const Type = extern union {
14701470 }
14711471 },
14721472
1473 // TODO lazy types
14741473 .array, .vector => self.elemType().hasCodeGenBits() and self.arrayLen() != 0,
14751474 .array_u8 => self.arrayLen() != 0,
14761475
test/behavior/atomics.zig+1-1
......@@ -89,7 +89,7 @@ test "128-bit cmpxchg" {
8989
9090fn test_u128_cmpxchg() !void {
9191 if (builtin.zig_is_stage2) {
92 if (builtin.stage2_arch != .x86_64) return error.SkipZigTest;
92 if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;
9393 if (!builtin.stage2_x86_cx16) return error.SkipZigTest;
9494 } else {
9595 if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;
test/behavior/widening.zig+2-2
......@@ -30,8 +30,8 @@ test "float widening" {
3030
3131test "float widening f16 to f128" {
3232 // TODO https://github.com/ziglang/zig/issues/3282
33 if (@import("builtin").stage2_arch == .aarch64) return error.SkipZigTest;
34 if (@import("builtin").stage2_arch == .powerpc64le) return error.SkipZigTest;
33 if (@import("builtin").cpu.arch == .aarch64) return error.SkipZigTest;
34 if (@import("builtin").cpu.arch == .powerpc64le) return error.SkipZigTest;
3535
3636 var x: f16 = 12.34;
3737 var y: f128 = x;