| author | |
| committer | |
| log | 4c71942f84261e9872cd27139c45b6d5fb1ab6c7 |
| tree | 29edf638919b456298339933be1ac9ec68893054 |
| parent | bcc371618fd71185e71a889c09eb68733ca66842 |
| signature |
4 files changed, 18 insertions(+), 0 deletions(-)
src/Sema.zig+1| ... | ... | @@ -3540,6 +3540,7 @@ fn analyzeArithmetic( |
| 3540 | 3540 | .subwrap => .subwrap, |
| 3541 | 3541 | .mul => .mul, |
| 3542 | 3542 | .mulwrap => .mulwrap, |
| 3543 | .div => .div, | |
| 3543 | 3544 | else => return sema.mod.fail(&block.base, src, "TODO implement arithmetic for operand '{s}''", .{@tagName(zir_tag)}), |
| 3544 | 3545 | }; |
| 3545 | 3546 |
src/codegen.zig+10| ... | ... | @@ -855,6 +855,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 855 | 855 | .not => return self.genNot(inst.castTag(.not).?), |
| 856 | 856 | .mul => return self.genMul(inst.castTag(.mul).?), |
| 857 | 857 | .mulwrap => return self.genMulWrap(inst.castTag(.mulwrap).?), |
| 858 | .div => return self.genDiv(inst.castTag(.div).?), | |
| 858 | 859 | .ptrtoint => return self.genPtrToInt(inst.castTag(.ptrtoint).?), |
| 859 | 860 | .ref => return self.genRef(inst.castTag(.ref).?), |
| 860 | 861 | .ret => return self.genRet(inst.castTag(.ret).?), |
| ... | ... | @@ -1092,6 +1093,15 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 1092 | 1093 | } |
| 1093 | 1094 | } |
| 1094 | 1095 | |
| 1096 | fn genDiv(self: *Self, inst: *ir.Inst.BinOp) !MCValue { | |
| 1097 | // No side effects, so if it's unreferenced, do nothing. | |
| 1098 | if (inst.base.isUnused()) | |
| 1099 | return MCValue.dead; | |
| 1100 | switch (arch) { | |
| 1101 | else => return self.fail(inst.base.src, "TODO implement div for {}", .{self.target.cpu.arch}), | |
| 1102 | } | |
| 1103 | } | |
| 1104 | ||
| 1095 | 1105 | fn genBitAnd(self: *Self, inst: *ir.Inst.BinOp) !MCValue { |
| 1096 | 1106 | // No side effects, so if it's unreferenced, do nothing. |
| 1097 | 1107 | if (inst.base.isUnused()) |
src/codegen/c.zig+3| ... | ... | @@ -582,6 +582,9 @@ pub fn genBody(o: *Object, body: ir.Body) error{ AnalysisFail, OutOfMemory }!voi |
| 582 | 582 | .mul => try genBinOp(o, inst.castTag(.sub).?, " * "), |
| 583 | 583 | // TODO make this do wrapping multiplication for signed ints |
| 584 | 584 | .mulwrap => try genBinOp(o, inst.castTag(.sub).?, " * "), |
| 585 | // TODO use a different strategy for div that communicates to the optimizer | |
| 586 | // that wrapping is UB. | |
| 587 | .div => try genBinOp(o, inst.castTag(.div).?, " / "), | |
| 585 | 588 | |
| 586 | 589 | .constant => unreachable, // excluded from function bodies |
| 587 | 590 | .alloc => try genAlloc(o, inst.castTag(.alloc).?), |
src/ir.zig+4| ... | ... | @@ -115,6 +115,7 @@ pub const Inst = struct { |
| 115 | 115 | unreach, |
| 116 | 116 | mul, |
| 117 | 117 | mulwrap, |
| 118 | div, | |
| 118 | 119 | not, |
| 119 | 120 | floatcast, |
| 120 | 121 | intcast, |
| ... | ... | @@ -181,6 +182,7 @@ pub const Inst = struct { |
| 181 | 182 | .subwrap, |
| 182 | 183 | .mul, |
| 183 | 184 | .mulwrap, |
| 185 | .div, | |
| 184 | 186 | .cmp_lt, |
| 185 | 187 | .cmp_lte, |
| 186 | 188 | .cmp_eq, |
| ... | ... | @@ -752,6 +754,7 @@ const DumpTzir = struct { |
| 752 | 754 | .subwrap, |
| 753 | 755 | .mul, |
| 754 | 756 | .mulwrap, |
| 757 | .div, | |
| 755 | 758 | .cmp_lt, |
| 756 | 759 | .cmp_lte, |
| 757 | 760 | .cmp_eq, |
| ... | ... | @@ -891,6 +894,7 @@ const DumpTzir = struct { |
| 891 | 894 | .subwrap, |
| 892 | 895 | .mul, |
| 893 | 896 | .mulwrap, |
| 897 | .div, | |
| 894 | 898 | .cmp_lt, |
| 895 | 899 | .cmp_lte, |
| 896 | 900 | .cmp_eq, |