@@ -38,6 +38,11 @@ macro_rules! debug_assert_valid_regpair {
3838 } ;
3939}
4040
41+ const OPCODE_BRAS : u16 = 0xa75 ;
42+ const OPCODE_BCR : u16 = 0xa74 ;
43+ const OPCODE_LDR : u16 = 0x28 ;
44+ const OPCODE_VLR : u16 = 0xe756 ;
45+
4146/// Type(s) of memory instructions available for mem_finalize.
4247pub struct MemInstType {
4348 /// True if 12-bit unsigned displacement is supported.
@@ -2298,9 +2303,8 @@ impl Inst {
22982303 rd,
22992304 ref symbol_reloc,
23002305 } => {
2301- let opcode = 0xa75 ; // BRAS
23022306 let reg = writable_spilltmp_reg ( ) . to_reg ( ) ;
2303- put ( sink, & enc_ri_b ( opcode , reg, 12 ) ) ;
2307+ put ( sink, & enc_ri_b ( OPCODE_BRAS , reg, 12 ) ) ;
23042308 let ( reloc, name, offset) = match & * * symbol_reloc {
23052309 SymbolReloc :: Absolute { name, offset } => ( Reloc :: Abs8 , name, * offset) ,
23062310 SymbolReloc :: TlsGd { name } => ( Reloc :: S390xTlsGd64 , name, 0 ) ,
@@ -2319,53 +2323,54 @@ impl Inst {
23192323 let opcode = 0x38 ; // LER
23202324 put ( sink, & enc_rr ( opcode, rd. to_reg ( ) , rn) ) ;
23212325 } else {
2322- let opcode = 0xe756 ; // VLR
2323- put ( sink, & enc_vrr_a ( opcode, rd. to_reg ( ) , rn, 0 , 0 , 0 ) ) ;
2326+ put ( sink, & enc_vrr_a ( OPCODE_VLR , rd. to_reg ( ) , rn, 0 , 0 , 0 ) ) ;
23242327 }
23252328 }
23262329 & Inst :: FpuMove64 { rd, rn } => {
23272330 if is_fpr ( rd. to_reg ( ) ) && is_fpr ( rn) {
2328- let opcode = 0x28 ; // LDR
2329- put ( sink, & enc_rr ( opcode, rd. to_reg ( ) , rn) ) ;
2331+ put ( sink, & enc_rr ( OPCODE_LDR , rd. to_reg ( ) , rn) ) ;
23302332 } else {
2331- let opcode = 0xe756 ; // VLR
2332- put ( sink, & enc_vrr_a ( opcode, rd. to_reg ( ) , rn, 0 , 0 , 0 ) ) ;
2333+ put ( sink, & enc_vrr_a ( OPCODE_VLR , rd. to_reg ( ) , rn, 0 , 0 , 0 ) ) ;
23332334 }
23342335 }
23352336 & Inst :: FpuCMov32 { rd, cond, ri, rm } => {
23362337 debug_assert_eq ! ( rd. to_reg( ) , ri) ;
23372338
23382339 if is_fpr ( rd. to_reg ( ) ) && is_fpr ( rm) {
2339- let opcode = 0xa74 ; // BCR
2340- put ( sink, & enc_ri_c ( opcode, cond. invert ( ) . bits ( ) , 4 + 2 ) ) ;
2340+ put ( sink, & enc_ri_c ( OPCODE_BCR , cond. invert ( ) . bits ( ) , 4 + 2 ) ) ;
23412341 let opcode = 0x38 ; // LER
23422342 put ( sink, & enc_rr ( opcode, rd. to_reg ( ) , rm) ) ;
23432343 } else {
2344- let opcode = 0xa74 ; // BCR
2345- put ( sink, & enc_ri_c ( opcode, cond. invert ( ) . bits ( ) , 4 + 6 ) ) ;
2346- let opcode = 0xe756 ; // VLR
2347- put ( sink, & enc_vrr_a ( opcode, rd. to_reg ( ) , rm, 0 , 0 , 0 ) ) ;
2344+ put ( sink, & enc_ri_c ( OPCODE_BCR , cond. invert ( ) . bits ( ) , 4 + 6 ) ) ;
2345+ put ( sink, & enc_vrr_a ( OPCODE_VLR , rd. to_reg ( ) , rm, 0 , 0 , 0 ) ) ;
23482346 }
23492347 }
23502348 & Inst :: FpuCMov64 { rd, cond, ri, rm } => {
23512349 debug_assert_eq ! ( rd. to_reg( ) , ri) ;
23522350
23532351 if is_fpr ( rd. to_reg ( ) ) && is_fpr ( rm) {
2354- let opcode = 0xa74 ; // BCR
2355- put ( sink, & enc_ri_c ( opcode, cond. invert ( ) . bits ( ) , 4 + 2 ) ) ;
2356- let opcode = 0x28 ; // LDR
2357- put ( sink, & enc_rr ( opcode, rd. to_reg ( ) , rm) ) ;
2352+ put ( sink, & enc_ri_c ( OPCODE_BCR , cond. invert ( ) . bits ( ) , 4 + 2 ) ) ;
2353+ put ( sink, & enc_rr ( OPCODE_LDR , rd. to_reg ( ) , rm) ) ;
23582354 } else {
2359- let opcode = 0xa74 ; // BCR
2360- put ( sink, & enc_ri_c ( opcode, cond. invert ( ) . bits ( ) , 4 + 6 ) ) ;
2361- let opcode = 0xe756 ; // VLR
2362- put ( sink, & enc_vrr_a ( opcode, rd. to_reg ( ) , rm, 0 , 0 , 0 ) ) ;
2355+ put ( sink, & enc_ri_c ( OPCODE_BCR , cond. invert ( ) . bits ( ) , 4 + 6 ) ) ;
2356+ put ( sink, & enc_vrr_a ( OPCODE_VLR , rd. to_reg ( ) , rm, 0 , 0 , 0 ) ) ;
23632357 }
23642358 }
2359+ & Inst :: LoadFpuConst16 { rd, const_data } => {
2360+ let reg = writable_spilltmp_reg ( ) . to_reg ( ) ;
2361+ put ( sink, & enc_ri_b ( OPCODE_BRAS , reg, 6 ) ) ;
2362+ sink. put2 ( const_data. swap_bytes ( ) ) ;
2363+ let inst = Inst :: VecLoadLaneUndef {
2364+ size : 16 ,
2365+ rd,
2366+ mem : MemArg :: reg ( reg, MemFlags :: trusted ( ) ) ,
2367+ lane_imm : 0 ,
2368+ } ;
2369+ inst. emit ( sink, emit_info, state) ;
2370+ }
23652371 & Inst :: LoadFpuConst32 { rd, const_data } => {
2366- let opcode = 0xa75 ; // BRAS
23672372 let reg = writable_spilltmp_reg ( ) . to_reg ( ) ;
2368- put ( sink, & enc_ri_b ( opcode , reg, 8 ) ) ;
2373+ put ( sink, & enc_ri_b ( OPCODE_BRAS , reg, 8 ) ) ;
23692374 sink. put4 ( const_data. swap_bytes ( ) ) ;
23702375 let inst = Inst :: VecLoadLaneUndef {
23712376 size : 32 ,
@@ -2376,9 +2381,8 @@ impl Inst {
23762381 inst. emit ( sink, emit_info, state) ;
23772382 }
23782383 & Inst :: LoadFpuConst64 { rd, const_data } => {
2379- let opcode = 0xa75 ; // BRAS
23802384 let reg = writable_spilltmp_reg ( ) . to_reg ( ) ;
2381- put ( sink, & enc_ri_b ( opcode , reg, 12 ) ) ;
2385+ put ( sink, & enc_ri_b ( OPCODE_BRAS , reg, 12 ) ) ;
23822386 sink. put8 ( const_data. swap_bytes ( ) ) ;
23832387 let inst = Inst :: VecLoadLaneUndef {
23842388 size : 64 ,
@@ -2780,8 +2784,7 @@ impl Inst {
27802784 put ( sink, & enc_vrr_a ( opcode, rm, rn, m3, 0 , 0 ) ) ;
27812785
27822786 // If CC != 0, we'd done, so jump over the next instruction.
2783- let opcode = 0xa74 ; // BCR
2784- put ( sink, & enc_ri_c ( opcode, 7 , 4 + 6 ) ) ;
2787+ put ( sink, & enc_ri_c ( OPCODE_BCR , 7 , 4 + 6 ) ) ;
27852788
27862789 // Otherwise, use VECTOR COMPARE HIGH LOGICAL.
27872790 // Since we already know the high parts are equal, the CC
@@ -2864,25 +2867,21 @@ impl Inst {
28642867 }
28652868
28662869 & Inst :: VecMov { rd, rn } => {
2867- let opcode = 0xe756 ; // VLR
2868- put ( sink, & enc_vrr_a ( opcode, rd. to_reg ( ) , rn, 0 , 0 , 0 ) ) ;
2870+ put ( sink, & enc_vrr_a ( OPCODE_VLR , rd. to_reg ( ) , rn, 0 , 0 , 0 ) ) ;
28692871 }
28702872 & Inst :: VecCMov { rd, cond, ri, rm } => {
28712873 debug_assert_eq ! ( rd. to_reg( ) , ri) ;
28722874
2873- let opcode = 0xa74 ; // BCR
2874- put ( sink, & enc_ri_c ( opcode, cond. invert ( ) . bits ( ) , 4 + 6 ) ) ;
2875- let opcode = 0xe756 ; // VLR
2876- put ( sink, & enc_vrr_a ( opcode, rd. to_reg ( ) , rm, 0 , 0 , 0 ) ) ;
2875+ put ( sink, & enc_ri_c ( OPCODE_BCR , cond. invert ( ) . bits ( ) , 4 + 6 ) ) ;
2876+ put ( sink, & enc_vrr_a ( OPCODE_VLR , rd. to_reg ( ) , rm, 0 , 0 , 0 ) ) ;
28772877 }
28782878 & Inst :: MovToVec128 { rd, rn, rm } => {
28792879 let opcode = 0xe762 ; // VLVGP
28802880 put ( sink, & enc_vrr_f ( opcode, rd. to_reg ( ) , rn, rm) ) ;
28812881 }
28822882 & Inst :: VecLoadConst { rd, const_data } => {
2883- let opcode = 0xa75 ; // BRAS
28842883 let reg = writable_spilltmp_reg ( ) . to_reg ( ) ;
2885- put ( sink, & enc_ri_b ( opcode , reg, 20 ) ) ;
2884+ put ( sink, & enc_ri_b ( OPCODE_BRAS , reg, 20 ) ) ;
28862885 for i in const_data. to_be_bytes ( ) . iter ( ) {
28872886 sink. put1 ( * i) ;
28882887 }
@@ -2897,9 +2896,8 @@ impl Inst {
28972896 rd,
28982897 const_data,
28992898 } => {
2900- let opcode = 0xa75 ; // BRAS
29012899 let reg = writable_spilltmp_reg ( ) . to_reg ( ) ;
2902- put ( sink, & enc_ri_b ( opcode , reg, ( 4 + size / 8 ) as i32 ) ) ;
2900+ put ( sink, & enc_ri_b ( OPCODE_BRAS , reg, ( 4 + size / 8 ) as i32 ) ) ;
29032901 for i in 0 ..size / 8 {
29042902 sink. put1 ( ( const_data >> ( size - 8 - 8 * i) ) as u8 ) ;
29052903 }
0 commit comments