aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorLuuk de Gram <Luukdegram@users.noreply.github.com>2021-01-16 18:22:20 +0100
committerLuuk de Gram <Luukdegram@users.noreply.github.com>2021-01-16 18:22:20 +0100
commit6a87ce0b62a3c9d3a795f3a16b1650f4a8c3b2fc (patch)
tree634a0f3f69f0dbe3b1d4130873bf4114d1c43c1e /src/codegen
parent6c19aeddca7f1f2c25c7d34dd9f6011b495670a9 (diff)
downloadzig-6a87ce0b62a3c9d3a795f3a16b1650f4a8c3b2fc.tar.gz
zig-6a87ce0b62a3c9d3a795f3a16b1650f4a8c3b2fc.zip
Generate correct opcode for 'addGen' depending on type
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/wasm.zig10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/codegen/wasm.zig b/src/codegen/wasm.zig
index b5e044b258..70e9de7baf 100644
--- a/src/codegen/wasm.zig
+++ b/src/codegen/wasm.zig
@@ -264,7 +264,15 @@ pub const Context = struct {
try self.emitWValue(lhs);
try self.emitWValue(rhs);
- try self.code.append(0x6A); // i32.add
+ const opcode: u8 = switch (inst.base.ty.tag()) {
+ .u32, .i32 => 0x6A, //i32.add
+ .u64, .i64 => 0x7C, //i64.add
+ .f32 => 0x92, //f32.add
+ .f64 => 0xA0, //f64.add
+ else => return self.fail(inst.base.src, "TODO - Implement wasm genAdd for type '{s}'", .{inst.base.ty.tag()}),
+ };
+
+ try self.code.append(opcode);
return WValue.none;
}