1
Fork 0

Add Offset binary op to custom mir

This commit is contained in:
Andy Wang 2023-04-11 16:23:35 +02:00
parent dfe024e104
commit cecb901e68
No known key found for this signature in database
GPG key ID: 181B49F9F38F3374
4 changed files with 28 additions and 0 deletions

View file

@ -148,6 +148,11 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
)),
)
},
@call("mir_offset", args) => {
let ptr = self.parse_operand(args[0])?;
let offset = self.parse_operand(args[1])?;
Ok(Rvalue::BinaryOp(BinOp::Offset, Box::new((ptr, offset))))
},
@call("mir_len", args) => Ok(Rvalue::Len(self.parse_place(args[0])?)),
ExprKind::Borrow { borrow_kind, arg } => Ok(
Rvalue::Ref(self.tcx.lifetimes.re_erased, *borrow_kind, self.parse_place(*arg)?)