stage2: implement shl

This is implemented in the llvm and cbe backends.
x86_64 will take a bit more time.
This commit is contained in:
Jacob G-W
2021-08-19 13:04:52 -04:00
parent 2e6ce11eb2
commit 2e22f7e5a5
4 changed files with 50 additions and 8 deletions

View File

@@ -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 {