diff options
| author | Jacob G-W <jacoblevgw@gmail.com> | 2021-08-19 13:04:52 -0400 |
|---|---|---|
| committer | Jacob G-W <jacoblevgw@gmail.com> | 2021-08-19 16:18:42 -0400 |
| commit | 2e22f7e5a5ff51aa4a1672e011cdc07b08a9a661 (patch) | |
| tree | f040c30d93c76e2e1376c1029e5cfdd7b6dc0492 /src/codegen/llvm.zig | |
| parent | 2e6ce11eb29434231102c00fddd0a1b3e0ba5608 (diff) | |
| download | zig-2e22f7e5a5ff51aa4a1672e011cdc07b08a9a661.tar.gz zig-2e22f7e5a5ff51aa4a1672e011cdc07b08a9a661.zip | |
stage2: implement shl
This is implemented in the llvm and cbe backends.
x86_64 will take a bit more time.
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 4b5ac9efe9..632b275704 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1745,7 +1745,13 @@ pub const FuncGen = struct { const bin_op = self.air.instructions.items(.data)[inst].bin_op; const lhs = try self.resolveInst(bin_op.lhs); const rhs = try self.resolveInst(bin_op.rhs); - return self.builder.buildShl(lhs, rhs, ""); + const lhs_type = self.air.typeOf(bin_op.lhs); + const tg = self.dg.module.getTarget(); + const casted_rhs = if (self.air.typeOf(bin_op.rhs).bitSize(tg) < lhs_type.bitSize(tg)) + self.builder.buildZExt(rhs, try self.dg.llvmType(lhs_type), "") + else + rhs; + return self.builder.buildShl(lhs, casted_rhs, ""); } fn airShr(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { |
