diff options
| author | Gary Guo <gary@garyguo.net> | 2021-09-06 18:33:23 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2021-09-25 01:08:41 +0100 |
| commit | c38da2e0a322908ba4b1d4b7e59c5da0531af4e1 (patch) | |
| tree | cd26f185c4302d0389f8703ea0d2b76cfa1ac4ba /compiler/rustc_codegen_ssa/src | |
| parent | 308dffd25cb55bbb4a1fbee9822cf82c6a5d012d (diff) | |
| download | rust-c38da2e0a322908ba4b1d4b7e59c5da0531af4e1.tar.gz rust-c38da2e0a322908ba4b1d4b7e59c5da0531af4e1.zip | |
Introduce `Rvalue::ShallowInitBox`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 7403c21a906..f087b9f7815 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -550,6 +550,18 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { OperandRef::new_zst(&mut bx, self.cx.layout_of(self.monomorphize(ty))); (bx, operand) } + mir::Rvalue::ShallowInitBox(ref operand, content_ty) => { + let operand = self.codegen_operand(&mut bx, operand); + let lloperand = operand.immediate(); + + let content_ty = self.monomorphize(content_ty); + let box_layout = bx.cx().layout_of(bx.tcx().mk_box(content_ty)); + let llty_ptr = bx.cx().backend_type(box_layout); + + let val = bx.pointercast(lloperand, llty_ptr); + let operand = OperandRef { val: OperandValue::Immediate(val), layout: box_layout }; + (bx, operand) + } } } @@ -763,6 +775,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { mir::Rvalue::AddressOf(..) | mir::Rvalue::Len(..) | mir::Rvalue::Cast(..) | // (*) + mir::Rvalue::ShallowInitBox(..) | // (*) mir::Rvalue::BinaryOp(..) | mir::Rvalue::CheckedBinaryOp(..) | mir::Rvalue::UnaryOp(..) | |
