| ... | @@ -865,6 +865,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -865,6 +865,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 865 | fn genFuncInst(self: *Self, inst: *ir.Inst) !MCValue { | 865 | fn genFuncInst(self: *Self, inst: *ir.Inst) !MCValue { |
| 866 | switch (inst.tag) { | 866 | switch (inst.tag) { |
| 867 | .add => return self.genAdd(inst.castTag(.add).?), | 867 | .add => return self.genAdd(inst.castTag(.add).?), |
| | 868 | .addwrap => return self.genAddWrap(inst.castTag(.addwrap).?), |
| 868 | .alloc => return self.genAlloc(inst.castTag(.alloc).?), | 869 | .alloc => return self.genAlloc(inst.castTag(.alloc).?), |
| 869 | .arg => return self.genArg(inst.castTag(.arg).?), | 870 | .arg => return self.genArg(inst.castTag(.arg).?), |
| 870 | .assembly => return self.genAsm(inst.castTag(.assembly).?), | 871 | .assembly => return self.genAsm(inst.castTag(.assembly).?), |
| ... | @@ -900,12 +901,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -900,12 +901,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 900 | .loop => return self.genLoop(inst.castTag(.loop).?), | 901 | .loop => return self.genLoop(inst.castTag(.loop).?), |
| 901 | .not => return self.genNot(inst.castTag(.not).?), | 902 | .not => return self.genNot(inst.castTag(.not).?), |
| 902 | .mul => return self.genMul(inst.castTag(.mul).?), | 903 | .mul => return self.genMul(inst.castTag(.mul).?), |
| | 904 | .mulwrap => return self.genMulWrap(inst.castTag(.mulwrap).?), |
| 903 | .ptrtoint => return self.genPtrToInt(inst.castTag(.ptrtoint).?), | 905 | .ptrtoint => return self.genPtrToInt(inst.castTag(.ptrtoint).?), |
| 904 | .ref => return self.genRef(inst.castTag(.ref).?), | 906 | .ref => return self.genRef(inst.castTag(.ref).?), |
| 905 | .ret => return self.genRet(inst.castTag(.ret).?), | 907 | .ret => return self.genRet(inst.castTag(.ret).?), |
| 906 | .retvoid => return self.genRetVoid(inst.castTag(.retvoid).?), | 908 | .retvoid => return self.genRetVoid(inst.castTag(.retvoid).?), |
| 907 | .store => return self.genStore(inst.castTag(.store).?), | 909 | .store => return self.genStore(inst.castTag(.store).?), |
| 908 | .sub => return self.genSub(inst.castTag(.sub).?), | 910 | .sub => return self.genSub(inst.castTag(.sub).?), |
| | 911 | .subwrap => return self.genSubWrap(inst.castTag(.subwrap).?), |
| 909 | .switchbr => return self.genSwitch(inst.castTag(.switchbr).?), | 912 | .switchbr => return self.genSwitch(inst.castTag(.switchbr).?), |
| 910 | .unreach => return MCValue{ .unreach = {} }, | 913 | .unreach => return MCValue{ .unreach = {} }, |
| 911 | .optional_payload => return self.genOptionalPayload(inst.castTag(.optional_payload).?), | 914 | .optional_payload => return self.genOptionalPayload(inst.castTag(.optional_payload).?), |
| ... | @@ -1129,6 +1132,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -1129,6 +1132,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1129 | } | 1132 | } |
| 1130 | } | 1133 | } |
| 1131 | | 1134 | |
| | 1135 | fn genAddWrap(self: *Self, inst: *ir.Inst.BinOp) !MCValue { |
| | 1136 | // No side effects, so if it's unreferenced, do nothing. |
| | 1137 | if (inst.base.isUnused()) |
| | 1138 | return MCValue.dead; |
| | 1139 | switch (arch) { |
| | 1140 | else => return self.fail(inst.base.src, "TODO implement addwrap for {}", .{self.target.cpu.arch}), |
| | 1141 | } |
| | 1142 | } |
| | 1143 | |
| 1132 | fn genMul(self: *Self, inst: *ir.Inst.BinOp) !MCValue { | 1144 | fn genMul(self: *Self, inst: *ir.Inst.BinOp) !MCValue { |
| 1133 | // No side effects, so if it's unreferenced, do nothing. | 1145 | // No side effects, so if it's unreferenced, do nothing. |
| 1134 | if (inst.base.isUnused()) | 1146 | if (inst.base.isUnused()) |
| ... | @@ -1139,6 +1151,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -1139,6 +1151,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1139 | } | 1151 | } |
| 1140 | } | 1152 | } |
| 1141 | | 1153 | |
| | 1154 | fn genMulWrap(self: *Self, inst: *ir.Inst.BinOp) !MCValue { |
| | 1155 | // No side effects, so if it's unreferenced, do nothing. |
| | 1156 | if (inst.base.isUnused()) |
| | 1157 | return MCValue.dead; |
| | 1158 | switch (arch) { |
| | 1159 | else => return self.fail(inst.base.src, "TODO implement mulwrap for {}", .{self.target.cpu.arch}), |
| | 1160 | } |
| | 1161 | } |
| | 1162 | |
| 1142 | fn genBitAnd(self: *Self, inst: *ir.Inst.BinOp) !MCValue { | 1163 | fn genBitAnd(self: *Self, inst: *ir.Inst.BinOp) !MCValue { |
| 1143 | // No side effects, so if it's unreferenced, do nothing. | 1164 | // No side effects, so if it's unreferenced, do nothing. |
| 1144 | if (inst.base.isUnused()) | 1165 | if (inst.base.isUnused()) |
| ... | @@ -1392,6 +1413,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { | ... | @@ -1392,6 +1413,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1392 | } | 1413 | } |
| 1393 | } | 1414 | } |
| 1394 | | 1415 | |
| | 1416 | fn genSubWrap(self: *Self, inst: *ir.Inst.BinOp) !MCValue { |
| | 1417 | // No side effects, so if it's unreferenced, do nothing. |
| | 1418 | if (inst.base.isUnused()) |
| | 1419 | return MCValue.dead; |
| | 1420 | switch (arch) { |
| | 1421 | else => return self.fail(inst.base.src, "TODO implement subwrap for {}", .{self.target.cpu.arch}), |
| | 1422 | } |
| | 1423 | } |
| | 1424 | |
| 1395 | fn genArmBinOp(self: *Self, inst: *ir.Inst, op_lhs: *ir.Inst, op_rhs: *ir.Inst, op: ir.Inst.Tag) !MCValue { | 1425 | fn genArmBinOp(self: *Self, inst: *ir.Inst, op_lhs: *ir.Inst, op_rhs: *ir.Inst, op: ir.Inst.Tag) !MCValue { |
| 1396 | const lhs = try self.resolveInst(op_lhs); | 1426 | const lhs = try self.resolveInst(op_lhs); |
| 1397 | const rhs = try self.resolveInst(op_rhs); | 1427 | const rhs = try self.resolveInst(op_rhs); |