aboutsummaryrefslogtreecommitdiff
path: root/src/arch/wasm
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-11 00:04:42 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-11 00:04:42 -0700
commit078037ab9b410fa13a86eabdfc30918fc83cdcf3 (patch)
treeb5e80992e82d015393872fcc57911b03ca7211fd /src/arch/wasm
parentb28b3f6f7b1dd4c3c8a0f3d3a6305a84daed8ead (diff)
downloadzig-078037ab9b410fa13a86eabdfc30918fc83cdcf3.tar.gz
zig-078037ab9b410fa13a86eabdfc30918fc83cdcf3.zip
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.
Diffstat (limited to 'src/arch/wasm')
-rw-r--r--src/arch/wasm/CodeGen.zig11
1 files changed, 8 insertions, 3 deletions
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];