@@ -36,9 +36,10 @@ mod emit_tests;
3636// Instructions (top level): definition
3737
3838pub use crate :: isa:: aarch64:: lower:: isle:: generated_code:: {
39- ALUOp , ALUOp3 , AtomicRMWLoopOp , AtomicRMWOp , BitOp , FPUOp1 , FPUOp2 , FPUOp3 , FpuRoundMode ,
40- FpuToIntOp , IntToFpuOp , MInst as Inst , MoveWideOp , VecALUOp , VecExtendOp , VecLanesOp , VecMisc2 ,
41- VecPairOp , VecRRLongOp , VecRRNarrowOp , VecRRPairLongOp , VecRRRLongOp , VecShiftImmOp ,
39+ ALUOp , ALUOp3 , AtomicRMWLoopOp , AtomicRMWOp , BitOp , BranchTargetType , FPUOp1 , FPUOp2 , FPUOp3 ,
40+ FpuRoundMode , FpuToIntOp , IntToFpuOp , MInst as Inst , MoveWideOp , VecALUOp , VecExtendOp ,
41+ VecLanesOp , VecMisc2 , VecPairOp , VecRRLongOp , VecRRNarrowOp , VecRRPairLongOp , VecRRRLongOp ,
42+ VecShiftImmOp ,
4243} ;
4344
4445/// A floating-point unit (FPU) operation with two args, a register and an immediate.
@@ -1025,6 +1026,7 @@ fn aarch64_get_operands<F: Fn(VReg) -> VReg>(inst: &Inst, collector: &mut Operan
10251026 collector. reg_def ( rd) ;
10261027 memarg_operands ( mem, collector) ;
10271028 }
1029+ & Inst :: Bti { .. } => { }
10281030 & Inst :: VirtualSPOffsetAdj { .. } => { }
10291031
10301032 & Inst :: ElfTlsGetAddr { .. } => {
@@ -1224,6 +1226,19 @@ impl MachInst for Inst {
12241226 fn ref_type_regclass ( _: & settings:: Flags ) -> RegClass {
12251227 RegClass :: Int
12261228 }
1229+
1230+ fn gen_block_start (
1231+ is_indirect_branch_target : bool ,
1232+ isa_flags : & Vec < settings:: Value > ,
1233+ ) -> Option < Self > {
1234+ if is_indirect_branch_target && has_bool_setting ( "use_bti" , isa_flags) {
1235+ Some ( Inst :: Bti {
1236+ targets : BranchTargetType :: J ,
1237+ } )
1238+ } else {
1239+ None
1240+ }
1241+ }
12271242}
12281243
12291244//=============================================================================
@@ -2703,6 +2718,16 @@ impl Inst {
27032718 }
27042719 ret
27052720 }
2721+ & Inst :: Bti { targets } => {
2722+ let targets = match targets {
2723+ BranchTargetType :: None => "" ,
2724+ BranchTargetType :: C => " c" ,
2725+ BranchTargetType :: J => " j" ,
2726+ BranchTargetType :: JC => " jc" ,
2727+ } ;
2728+
2729+ "bti" . to_string ( ) + targets
2730+ }
27062731 & Inst :: VirtualSPOffsetAdj { offset } => {
27072732 state. virtual_sp_offset += offset;
27082733 format ! ( "virtual_sp_offset_adjust {}" , offset)
@@ -2896,3 +2921,10 @@ impl MachInstLabelUse for LabelUse {
28962921 }
28972922 }
28982923}
2924+
2925+ pub fn has_bool_setting ( name : & str , isa_flags : & Vec < settings:: Value > ) -> bool {
2926+ isa_flags
2927+ . iter ( )
2928+ . find ( |& f| f. name == name)
2929+ . map_or ( false , |f| f. as_bool ( ) . unwrap_or ( false ) )
2930+ }
0 commit comments