@@ -147,26 +147,15 @@ impl Opnd
147147}
148148}
149149
150- /// Return Some(Opnd) with a given num_bits if self has num_bits.
151- /// None if self doesn't have a num_bits field.
152- pub fn try_num_bits ( & self , num_bits : u8 ) ->Option < Opnd > {
153- assert ! ( num_bits ==8 || num_bits ==16 || num_bits ==32 || num_bits ==64 ) ;
154- match * self {
155- Opnd :: Reg ( reg) =>Some ( Opnd :: Reg ( reg. with_num_bits ( num_bits) ) ) ,
156- Opnd :: Mem ( Mem { base, disp, ..} ) =>Some ( Opnd :: Mem ( Mem { base, disp, num_bits} ) ) ,
157- Opnd :: VReg { idx, ..} =>Some ( Opnd :: VReg { idx, num_bits} ) ,
158- _ =>None ,
159- }
160- }
161-
162- /// Return Opnd with a given num_bits if self has num_bits.
163- /// Panic otherwise. This should be used only when you know which Opnd self is.
150+ /// Return Opnd with a given num_bits if self has num_bits. Panic otherwise.
164151#[ track_caller]
165152pub fn with_num_bits ( & self , num_bits : u8 ) ->Opnd {
166- if let Some ( opnd) =self . try_num_bits ( num_bits) {
167- opnd
168- } else {
169- unreachable ! ( "with_num_bits should not be used on: {self:?}" ) ;
153+ assert ! ( num_bits ==8 || num_bits ==16 || num_bits ==32 || num_bits ==64 ) ;
154+ match * self {
155+ Opnd :: Reg ( reg) =>Opnd :: Reg ( reg. with_num_bits ( num_bits) ) ,
156+ Opnd :: Mem ( Mem { base, disp, ..} ) =>Opnd :: Mem ( Mem { base, disp, num_bits} ) ,
157+ Opnd :: VReg { idx, ..} =>Opnd :: VReg { idx, num_bits} ,
158+ _ =>unreachable ! ( "with_num_bits should not be used for: {self:?}" ) ,
170159}
171160}
172161