@@ -125,7 +125,7 @@ impl PReg {
125
125
/// The register class.
126
126
#[ inline( always) ]
127
127
pub const fn class ( self ) -> RegClass {
128
- match self . bits & ( 0b11 << Self :: MAX_BITS ) {
128
+ match ( self . bits >> Self :: MAX_BITS ) & 0b11 {
129
129
0 => RegClass :: Int ,
130
130
1 => RegClass :: Float ,
131
131
2 => RegClass :: Vector ,
@@ -188,49 +188,54 @@ impl core::fmt::Display for PReg {
188
188
#[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Default ) ]
189
189
#[ cfg_attr( feature = "enable-serde" , derive( Serialize , Deserialize ) ) ]
190
190
pub struct PRegSet {
191
- bits : u128 ,
191
+ bits : [ u128 ; 2 ] ,
192
192
}
193
193
194
194
impl PRegSet {
195
195
/// Create an empty set.
196
196
pub const fn empty ( ) -> Self {
197
- Self { bits : 0 }
197
+ Self { bits : [ 0 ; 2 ] }
198
198
}
199
199
200
200
/// Returns whether the given register is part of the set.
201
201
pub fn contains ( & self , reg : PReg ) -> bool {
202
- let bit = reg. index ( ) ;
203
- debug_assert ! ( bit < 128 ) ;
204
- self . bits & 1u128 << bit != 0
202
+ debug_assert ! ( reg. index( ) < 256 ) ;
203
+ let bit = reg. index ( ) & 127 ;
204
+ let index = reg. index ( ) >> 7 ;
205
+ self . bits [ index] & ( 1u128 << bit) != 0
205
206
}
206
207
207
208
/// Add a physical register (PReg) to the set, returning the new value.
208
209
pub const fn with ( self , reg : PReg ) -> Self {
209
- let bit = reg. index ( ) ;
210
- debug_assert ! ( bit < 128 ) ;
211
- Self {
212
- bits : self . bits | ( 1u128 << bit) ,
213
- }
210
+ debug_assert ! ( reg. index( ) < 256 ) ;
211
+ let bit = reg. index ( ) & 127 ;
212
+ let index = reg. index ( ) >> 7 ;
213
+ let mut out = self ;
214
+ out. bits [ index] |= 1u128 << bit;
215
+ out
214
216
}
215
217
216
218
/// Add a physical register (PReg) to the set.
217
219
pub fn add ( & mut self , reg : PReg ) {
218
- let bit = reg. index ( ) ;
219
- debug_assert ! ( bit < 128 ) ;
220
- self . bits |= 1u128 << bit;
220
+ debug_assert ! ( reg. index( ) < 256 ) ;
221
+ let bit = reg. index ( ) & 127 ;
222
+ let index = reg. index ( ) >> 7 ;
223
+ self . bits [ index] |= 1u128 << bit;
221
224
}
222
225
223
226
/// Remove a physical register (PReg) from the set.
224
227
pub fn remove ( & mut self , reg : PReg ) {
225
- let bit = reg. index ( ) ;
226
- debug_assert ! ( bit < 128 ) ;
227
- self . bits &= !( 1u128 << bit) ;
228
+ debug_assert ! ( reg. index( ) < 256 ) ;
229
+ let bit = reg. index ( ) & 127 ;
230
+ let index = reg. index ( ) >> 7 ;
231
+ self . bits [ index] &= !( 1u128 << bit) ;
228
232
}
229
233
230
234
/// Add all of the registers in one set to this one, mutating in
231
235
/// place.
232
236
pub fn union_from ( & mut self , other : PRegSet ) {
233
- self . bits |= other. bits ;
237
+ self . bits [ 0 ] |= other. bits [ 0 ] ;
238
+ self . bits [ 1 ] |= other. bits [ 1 ] ;
234
239
}
235
240
}
236
241
@@ -243,18 +248,22 @@ impl IntoIterator for PRegSet {
243
248
}
244
249
245
250
pub struct PRegSetIter {
246
- bits : u128 ,
251
+ bits : [ u128 ; 2 ] ,
247
252
}
248
253
249
254
impl Iterator for PRegSetIter {
250
255
type Item = PReg ;
251
256
fn next ( & mut self ) -> Option < PReg > {
252
- if self . bits == 0 {
253
- None
254
- } else {
255
- let index = self . bits . trailing_zeros ( ) ;
256
- self . bits &= !( 1u128 << index) ;
257
+ if self . bits [ 0 ] != 0 {
258
+ let index = self . bits [ 0 ] . trailing_zeros ( ) ;
259
+ self . bits [ 0 ] &= !( 1u128 << index) ;
257
260
Some ( PReg :: from_index ( index as usize ) )
261
+ } else if self . bits [ 1 ] != 0 {
262
+ let index = self . bits [ 1 ] . trailing_zeros ( ) ;
263
+ self . bits [ 1 ] &= !( 1u128 << index) ;
264
+ Some ( PReg :: from_index ( index as usize + 128 ) )
265
+ } else {
266
+ None
258
267
}
259
268
}
260
269
}
@@ -822,6 +831,9 @@ impl core::fmt::Debug for Operand {
822
831
823
832
impl core:: fmt:: Display for Operand {
824
833
fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
834
+ if let Some ( preg) = self . as_fixed_nonallocatable ( ) {
835
+ return write ! ( f, "Fixed: {preg}" ) ;
836
+ }
825
837
match ( self . kind ( ) , self . pos ( ) ) {
826
838
( OperandKind :: Def , OperandPos :: Late ) | ( OperandKind :: Use , OperandPos :: Early ) => {
827
839
write ! ( f, "{:?}" , self . kind( ) ) ?;
0 commit comments