mir: Load FatPtr constants instead of keeping them indirect.
This commit is contained in:
parent
eb43d95211
commit
92e485874e
2 changed files with 13 additions and 11 deletions
|
|
@ -17,6 +17,7 @@ use trans::abi;
|
|||
use trans::common::{self, BlockAndBuilder, C_bool, C_bytes, C_floating_f64, C_integral,
|
||||
C_str_slice, C_undef};
|
||||
use trans::consts;
|
||||
use trans::datum;
|
||||
use trans::expr;
|
||||
use trans::inline;
|
||||
use trans::type_of;
|
||||
|
|
@ -122,7 +123,18 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
let d = bcx.with_block(|bcx| {
|
||||
expr::trans(bcx, expr)
|
||||
});
|
||||
OperandRef::from_rvalue_datum(d.datum.to_rvalue_datum(d.bcx, "").datum)
|
||||
|
||||
let datum = d.datum.to_rvalue_datum(d.bcx, "").datum;
|
||||
|
||||
match datum.kind.mode {
|
||||
datum::RvalueMode::ByValue => {
|
||||
OperandRef {
|
||||
ty: datum.ty,
|
||||
val: OperandValue::Immediate(datum.val)
|
||||
}
|
||||
}
|
||||
datum::RvalueMode::ByRef => self.trans_load(bcx, datum.val, datum.ty)
|
||||
}
|
||||
}
|
||||
mir::Literal::Value { ref value } => {
|
||||
self.trans_constval(bcx, value, ty)
|
||||
|
|
|
|||
|
|
@ -81,16 +81,6 @@ impl<'tcx> OperandRef<'tcx> {
|
|||
_ => unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_rvalue_datum(datum: datum::Datum<'tcx, datum::Rvalue>) -> OperandRef {
|
||||
OperandRef {
|
||||
ty: datum.ty,
|
||||
val: match datum.kind.mode {
|
||||
datum::RvalueMode::ByRef => OperandValue::Ref(datum.val),
|
||||
datum::RvalueMode::ByValue => OperandValue::Immediate(datum.val),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue