remove switch_ty reliance in codegen
This commit is contained in:
parent
38bd83df88
commit
3bfd0c9f07
3 changed files with 7 additions and 2 deletions
|
@ -200,6 +200,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
targets: &Vec<mir::BasicBlock>,
|
||||
) {
|
||||
let discr = self.codegen_operand(&mut bx, &discr);
|
||||
// `switch_ty` is redundant, sanity-check that.
|
||||
assert_eq!(discr.layout.ty, switch_ty);
|
||||
if targets.len() == 2 {
|
||||
// If there are two targets, emit br instead of switch
|
||||
let lltrue = helper.llblock(self, targets[0]);
|
||||
|
|
|
@ -1075,6 +1075,8 @@ pub enum TerminatorKind<'tcx> {
|
|||
discr: Operand<'tcx>,
|
||||
|
||||
/// The type of value being tested.
|
||||
/// This is always the same as the type of `discr`.
|
||||
/// FIXME: remove this redundant information. Currently, it is relied on by pretty-printing.
|
||||
switch_ty: Ty<'tcx>,
|
||||
|
||||
/// Possible values. The locations to branch to in each case
|
||||
|
|
|
@ -24,9 +24,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
|
||||
Goto { target } => self.go_to_block(target),
|
||||
|
||||
SwitchInt { ref discr, ref values, ref targets, .. } => {
|
||||
SwitchInt { ref discr, ref values, ref targets, switch_ty } => {
|
||||
let discr = self.read_immediate(self.eval_operand(discr, None)?)?;
|
||||
trace!("SwitchInt({:?})", *discr);
|
||||
assert_eq!(discr.layout.ty, switch_ty);
|
||||
|
||||
// Branch to the `otherwise` case by default, if no match is found.
|
||||
assert!(!targets.is_empty());
|
||||
|
@ -55,7 +56,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
ref args,
|
||||
destination,
|
||||
ref cleanup,
|
||||
from_hir_call: _from_hir_call,
|
||||
from_hir_call: _,
|
||||
fn_span: _,
|
||||
} => {
|
||||
let old_stack = self.frame_idx();
|
||||
|
|
Loading…
Reference in a new issue