From 078037ab9b410fa13a86eabdfc30918fc83cdcf3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 11 Mar 2022 00:04:42 -0700 Subject: stage2: passing threadlocal tests for x86_64-linux * use the real start code for LLVM backend with x86_64-linux - there is still a check for zig_backend after initializing the TLS area to skip some stuff. * introduce new AIR instructions and implement them for the LLVM backend. They are the same as `call` except with a modifier. - call_always_tail - call_never_tail - call_never_inline * LLVM backend calls hasRuntimeBitsIgnoringComptime in more places to avoid unnecessarily depending on comptimeOnly being resolved for some types. * LLVM backend: remove duplicate code for setting linkage and value name. The canonical place for this is in `updateDeclExports`. * LLVM backend: do some assembly template massaging to make `%%` rendered as `%`. More hacks will be needed to make inline assembly catch up with stage1. --- src/arch/wasm/CodeGen.zig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/arch/wasm/CodeGen.zig') diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index a32e97adf0..3f28b87b55 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -1218,7 +1218,6 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { .breakpoint => self.airBreakpoint(inst), .br => self.airBr(inst), .bool_to_int => self.airBoolToInt(inst), - .call => self.airCall(inst), .cond_br => self.airCondBr(inst), .dbg_stmt => WValue.none, .intcast => self.airIntcast(inst), @@ -1227,6 +1226,11 @@ fn genInst(self: *Self, inst: Air.Inst.Index) !WValue { .float_to_int => self.airFloatToInt(inst), .get_union_tag => self.airGetUnionTag(inst), + .call => self.airCall(inst, .auto), + .call_always_tail => self.airCall(inst, .always_tail), + .call_never_tail => self.airCall(inst, .never_tail), + .call_never_inline => self.airCall(inst, .never_inline), + .is_err => self.airIsErr(inst, .i32_ne), .is_non_err => self.airIsErr(inst, .i32_eq), @@ -1375,7 +1379,7 @@ fn airRet(self: *Self, inst: Air.Inst.Index) InnerError!WValue { fn airRetPtr(self: *Self, inst: Air.Inst.Index) InnerError!WValue { const child_type = self.air.typeOfIndex(inst).childType(); - if (!child_type.isFnOrHasRuntimeBits()) { + if (!child_type.isFnOrHasRuntimeBitsIgnoreComptime()) { return self.allocStack(Type.usize); // create pointer to void } @@ -1401,7 +1405,8 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) InnerError!WValue { return .none; } -fn airCall(self: *Self, inst: Air.Inst.Index) InnerError!WValue { +fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallOptions.Modifier) InnerError!WValue { + if (modifier == .always_tail) return self.fail("TODO implement tail calls for wasm", .{}); const pl_op = self.air.instructions.items(.data)[inst].pl_op; const extra = self.air.extraData(Air.Call, pl_op.payload); const args = self.air.extra[extra.end..][0..extra.data.args_len]; -- cgit v1.2.3