@@ -13,9 +13,9 @@ use crate::isa::x64::inst::args::*;
1313use crate :: isa:: x64:: inst:: * ;
1414use crate :: isa:: { x64:: settings as x64_settings, x64:: X64Backend , CallConv } ;
1515use crate :: machinst:: lower:: * ;
16+ use crate :: machinst:: * ;
1617use crate :: result:: CodegenResult ;
1718use crate :: settings:: { Flags , TlsModel } ;
18- use crate :: { machinst:: * , trace} ;
1919use alloc:: boxed:: Box ;
2020use smallvec:: SmallVec ;
2121use std:: convert:: TryFrom ;
@@ -33,14 +33,6 @@ fn is_int_or_ref_ty(ty: Type) -> bool {
3333 }
3434}
3535
36- fn is_bool_ty ( ty : Type ) -> bool {
37- match ty {
38- types:: B1 | types:: B8 | types:: B16 | types:: B32 | types:: B64 => true ,
39- types:: R32 => panic ! ( "shouldn't have 32-bits refs on x64" ) ,
40- _ => false ,
41- }
42- }
43-
4436/// Returns whether the given specified `input` is a result produced by an instruction with Opcode
4537/// `op`.
4638// TODO investigate failures with checking against the result index.
@@ -2758,75 +2750,7 @@ impl LowerBackend for X64Backend {
27582750 } ;
27592751
27602752 if branches. len ( ) == 2 {
2761- // Must be a conditional branch followed by an unconditional branch.
2762- let op0 = ctx. data ( branches[ 0 ] ) . opcode ( ) ;
2763- let op1 = ctx. data ( branches[ 1 ] ) . opcode ( ) ;
2764-
2765- trace ! (
2766- "lowering two-branch group: opcodes are {:?} and {:?}" ,
2767- op0,
2768- op1
2769- ) ;
2770- assert ! ( op1 == Opcode :: Jump ) ;
2771-
2772- let taken = targets[ 0 ] ;
2773- // not_taken target is the target of the second branch.
2774- let not_taken = targets[ 1 ] ;
2775-
2776- match op0 {
2777- Opcode :: Brz | Opcode :: Brnz => {
2778- let flag_input = InsnInput {
2779- insn : branches[ 0 ] ,
2780- input : 0 ,
2781- } ;
2782-
2783- let src_ty = ctx. input_ty ( branches[ 0 ] , 0 ) ;
2784-
2785- if let Some ( _icmp) = matches_input ( ctx, flag_input, Opcode :: Icmp ) {
2786- implemented_in_isle ( ctx)
2787- } else if let Some ( _fcmp) = matches_input ( ctx, flag_input, Opcode :: Fcmp ) {
2788- implemented_in_isle ( ctx)
2789- } else if src_ty == types:: I128 {
2790- implemented_in_isle ( ctx) ;
2791- } else if is_int_or_ref_ty ( src_ty) || is_bool_ty ( src_ty) {
2792- let src = put_input_in_reg (
2793- ctx,
2794- InsnInput {
2795- insn : branches[ 0 ] ,
2796- input : 0 ,
2797- } ,
2798- ) ;
2799- let cc = match op0 {
2800- Opcode :: Brz => CC :: Z ,
2801- Opcode :: Brnz => CC :: NZ ,
2802- _ => unreachable ! ( ) ,
2803- } ;
2804- // See case for `Opcode::Select` above re: testing the
2805- // boolean input.
2806- let test_input = if src_ty == types:: B1 {
2807- // test src, 1
2808- RegMemImm :: imm ( 1 )
2809- } else {
2810- assert ! ( !is_bool_ty( src_ty) ) ;
2811- // test src, src
2812- RegMemImm :: reg ( src)
2813- } ;
2814-
2815- ctx. emit ( Inst :: test_rmi_r (
2816- OperandSize :: from_ty ( src_ty) ,
2817- test_input,
2818- src,
2819- ) ) ;
2820- ctx. emit ( Inst :: jmp_cond ( cc, taken, not_taken) ) ;
2821- } else {
2822- unimplemented ! ( "brz/brnz with non-int type {:?}" , src_ty) ;
2823- }
2824- }
2825-
2826- Opcode :: BrIcmp | Opcode :: Brif | Opcode :: Brff => implemented_in_isle ( ctx) ,
2827-
2828- _ => panic ! ( "unexpected branch opcode: {:?}" , op0) ,
2829- }
2753+ implemented_in_isle ( ctx)
28302754 } else {
28312755 assert_eq ! ( branches. len( ) , 1 ) ;
28322756
0 commit comments