| ... | @@ -221,6 +221,7 @@ pub const Context = struct { | ... | @@ -221,6 +221,7 @@ pub const Context = struct { |
| 221 | .dbg_stmt => WValue.none, | 221 | .dbg_stmt => WValue.none, |
| 222 | .load => self.genLoad(inst.castTag(.load).?), | 222 | .load => self.genLoad(inst.castTag(.load).?), |
| 223 | .loop => self.genLoop(inst.castTag(.loop).?), | 223 | .loop => self.genLoop(inst.castTag(.loop).?), |
| | 224 | .mul => self.genMul(inst.castTag(.mul).?), |
| 224 | .not => self.genNot(inst.castTag(.not).?), | 225 | .not => self.genNot(inst.castTag(.not).?), |
| 225 | .ret => self.genRet(inst.castTag(.ret).?), | 226 | .ret => self.genRet(inst.castTag(.ret).?), |
| 226 | .retvoid => WValue.none, | 227 | .retvoid => WValue.none, |
| ... | @@ -344,6 +345,25 @@ pub const Context = struct { | ... | @@ -344,6 +345,25 @@ pub const Context = struct { |
| 344 | return .none; | 345 | return .none; |
| 345 | } | 346 | } |
| 346 | | 347 | |
| | 348 | fn genMul(self: *Context, inst: *Inst.BinOp) InnerError!WValue { |
| | 349 | const lhs = self.resolveInst(inst.lhs); |
| | 350 | const rhs = self.resolveInst(inst.rhs); |
| | 351 | |
| | 352 | try self.emitWValue(lhs); |
| | 353 | try self.emitWValue(rhs); |
| | 354 | |
| | 355 | const opcode: wasm.Opcode = switch (inst.base.ty.tag()) { |
| | 356 | .u32, .i32 => .i32_mul, |
| | 357 | .u64, .i64 => .i64_mul, |
| | 358 | .f32 => .f32_mul, |
| | 359 | .f64 => .f64_mul, |
| | 360 | else => return self.fail(inst.base.src, "TODO - Implement wasm genMul for type '{s}'", .{inst.base.ty.tag()}), |
| | 361 | }; |
| | 362 | |
| | 363 | try self.code.append(wasm.opcode(opcode)); |
| | 364 | return .none; |
| | 365 | } |
| | 366 | |
| 347 | fn emitConstant(self: *Context, inst: *Inst.Constant) InnerError!void { | 367 | fn emitConstant(self: *Context, inst: *Inst.Constant) InnerError!void { |
| 348 | const writer = self.code.writer(); | 368 | const writer = self.code.writer(); |
| 349 | switch (inst.base.ty.tag()) { | 369 | switch (inst.base.ty.tag()) { |