Skip to content

Commit

Permalink
Add comments and rename a local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ogoffart committed Nov 20, 2018
1 parent 86d4135 commit 4c21f66
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/librustc_codegen_ssa/mir/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,25 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
_ => bug!("OperandRef::extract_field({:?}): not applicable", self)
};

let bitcast = |bx: &mut Bx, val, ty| {
// HACK(eddyb) have to bitcast pointers until LLVM removes pointee types.
// Bools in union fields needs to be truncated.
let to_immediate_or_cast = |bx: &mut Bx, val, ty| {
if ty == bx.cx().type_i1() {
bx.trunc(val, ty)
} else {
bx.bitcast(val, ty)
}
};

// HACK(eddyb) have to bitcast pointers until LLVM removes pointee types.
match val {
OperandValue::Immediate(ref mut llval) => {
*llval = bitcast(bx, *llval, bx.cx().immediate_backend_type(field));
*llval = to_immediate_or_cast(bx, *llval, bx.cx().immediate_backend_type(field));
}
OperandValue::Pair(ref mut a, ref mut b) => {
*a = bitcast(bx, *a, bx.cx().scalar_pair_element_backend_type(field, 0, true));
*b = bitcast(bx, *b, bx.cx().scalar_pair_element_backend_type(field, 1, true));
*a = to_immediate_or_cast(bx, *a, bx.cx()
.scalar_pair_element_backend_type(field, 0, true));
*b = to_immediate_or_cast(bx, *b, bx.cx()
.scalar_pair_element_backend_type(field, 1, true));
}
OperandValue::Ref(..) => bug!()
}
Expand Down

0 comments on commit 4c21f66

Please sign in to comment.