diff options
| author | gracefu <81774659+gracefuu@users.noreply.github.com> | 2021-04-09 13:51:00 +0800 |
|---|---|---|
| committer | gracefu <81774659+gracefuu@users.noreply.github.com> | 2021-04-16 15:21:17 +0800 |
| commit | c4b83ea02102611a85f75b189f0803d9b6a335c2 (patch) | |
| tree | 5460625c3766085c5f1210f577e3144296c6a986 /src/Sema.zig | |
| parent | 5bd464e386df35bfe38b062190074ce3c2689001 (diff) | |
| download | zig-c4b83ea02102611a85f75b189f0803d9b6a335c2.tar.gz zig-c4b83ea02102611a85f75b189f0803d9b6a335c2.zip | |
stage2 x86_64: implement integer mul
This was also an experiment to see if it were easier to implement a new
feature when using the instruction encoder.
Verdict: It's not that much easier, but I think it's certainly much more
readable, because the description of the Instruction annotates what each
field means. Right now, precise knowledge of x86_64 instructions is
still required because things like when to set the 64-bit flag, how to
read x86_64 instruction references, etc. are still not automatically
done for you.
In the future, this interface might make it sligtly easier to write an
assembler for x86_64, by abstracting the bit-fiddling aspects of
instruction encoding.
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 98bff5bf23..74af84b078 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -3885,6 +3885,13 @@ fn analyzeArithmetic( try Module.floatSub(sema.arena, scalar_type, src, lhs_val, rhs_val); break :blk val; }, + .mul => blk: { + const val = if (is_int) + try Module.intMul(sema.arena, lhs_val, rhs_val) + else + try Module.floatMul(sema.arena, scalar_type, src, lhs_val, rhs_val); + break :blk val; + }, else => return sema.mod.fail(&block.base, src, "TODO Implement arithmetic operand '{s}'", .{@tagName(zir_tag)}), }; |
