@@ -16,8 +16,6 @@ use std::fmt::{Debug, Display};
1616
1717pub use lower:: test_interpreter;
1818
19- use crate :: ir:: lower:: ValueContext ;
20-
2119#[ derive( Clone , Copy , Debug ) ]
2220#[ repr( transparent) ]
2321pub struct NonLocal ( pub u16 ) ;
@@ -83,7 +81,6 @@ const _: () = const { assert!(size_of::<Instruction>() <= 8) };
8381#[ repr( C , align( 8 ) ) ]
8482pub struct Instruction {
8583 pub opcode : OpCode ,
86- pub hint : Hint ,
8784 pub args : Arguments ,
8885}
8986
@@ -110,61 +107,41 @@ pub type CallArgs = (Reg, NonLocal, ArgCount);
110107pub type IndCallArgs = ( Reg , Reg , ArgCount ) ;
111108
112109impl Instruction {
113- fn unary ( opcode : impl Into < OpCode > , dest : Reg , src : & impl HintedReg ) -> Self {
110+ fn unary ( opcode : impl Into < OpCode > , dest : Reg , src : Reg ) -> Self {
114111 let opcode = opcode. into ( ) ;
115112 debug_assert ! ( opcode. is_unary( ) ) ;
116113 Self {
117114 opcode,
118- args : Arguments { unary_local : ( dest, src. reg ( ) ) } ,
119- hint : src. hint ( ) ,
115+ args : Arguments { unary_local : ( dest, src) } ,
120116 }
121117 }
122118
123- fn binary (
124- opcode : impl Into < OpCode > ,
125- dest : Reg ,
126- lhs : & impl HintedReg ,
127- rhs : & impl HintedReg ,
128- ) -> Self {
119+ fn binary ( opcode : impl Into < OpCode > , dest : Reg , lhs : Reg , rhs : Reg ) -> Self {
129120 let opcode = opcode. into ( ) ;
130121 debug_assert ! ( opcode. is_binary( ) ) ;
131- let hint = match ( lhs. hint ( ) , rhs. hint ( ) ) {
132- // TODO: Remove once we get const folding.
133- ( Hint :: UnboxedFloat64 , Hint :: UnboxedFloat64 ) => Hint :: UnboxedFloat64 ,
134- ( _, Hint :: UnboxedFloat64 ) => Hint :: UnboxedRhsFloat64 ,
135- ( Hint :: UnboxedFloat64 , _) => Hint :: UnboxedLhsFloat64 ,
136- _ => Hint :: None ,
137- } ;
138122 Self {
139123 opcode,
140- args : Arguments { binary_local : ( dest, lhs. reg ( ) , rhs. reg ( ) ) } ,
141- hint,
124+ args : Arguments { binary_local : ( dest, lhs, rhs) } ,
142125 }
143126 }
144127
145- fn load_store ( opcode : impl Into < OpCode > , dest : Reg , src : NonLocal , ctx : ValueContext ) -> Self {
128+ fn load_store ( opcode : impl Into < OpCode > , dest : Reg , src : NonLocal ) -> Self {
146129 let opcode = opcode. into ( ) ;
147130 debug_assert ! ( opcode. is_load_store( ) ) ;
148131 Self {
149132 opcode,
150133 args : Arguments { load_store : ( dest, src) } ,
151- hint : ctx. into ( ) ,
152134 }
153135 }
154136
155137 fn jump ( to : Label ) -> Self {
156- Self {
157- opcode : OpCode :: Jump ,
158- args : Arguments { jump : to } ,
159- hint : Hint :: None ,
160- }
138+ Self { opcode : OpCode :: Jump , args : Arguments { jump : to } }
161139 }
162140
163141 fn branch ( cond : Reg , true_to : Label , false_to : Label ) -> Self {
164142 Self {
165143 opcode : OpCode :: Branch ,
166144 args : Arguments { branch : ( cond, true_to, false_to) } ,
167- hint : Hint :: None ,
168145 }
169146 }
170147
@@ -248,42 +225,6 @@ impl OpCode {
248225 }
249226}
250227
251- #[ repr( u8 , align( 1 ) ) ]
252- #[ derive( Clone , Copy , Debug ) ]
253- pub enum Hint {
254- None = 0 ,
255- UnboxedFloat64 ,
256- UnboxedLhsFloat64 ,
257- UnboxedRhsFloat64 ,
258- ScalarCtx ,
259- ArrayCtx ,
260- }
261-
262- trait HintedReg {
263- fn reg ( & self ) -> Reg ;
264- fn hint ( & self ) -> Hint ;
265- }
266-
267- impl From < ValueContext > for Hint {
268- fn from ( value : ValueContext ) -> Self {
269- match value {
270- ValueContext :: Scalar => Self :: ScalarCtx ,
271- ValueContext :: Array => Self :: ArrayCtx ,
272- ValueContext :: Untyped => Self :: None ,
273- }
274- }
275- }
276-
277- impl From < Hint > for ValueContext {
278- fn from ( value : Hint ) -> Self {
279- match value {
280- Hint :: ScalarCtx => Self :: Scalar ,
281- Hint :: ArrayCtx => Self :: Array ,
282- _ => Self :: Untyped ,
283- }
284- }
285- }
286-
287228impl Debug for Instruction {
288229 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
289230 write ! ( f, "Instruction::{:?}" , self . opcode) ?;
@@ -365,15 +306,6 @@ impl Display for Instruction {
365306 write ! ( f, "{op} {label}" )
366307 }
367308 _ => todo ! ( ) ,
368- } ?;
369- match self . hint {
370- Hint :: UnboxedFloat64 if self . opcode . is_binary ( ) => write ! ( f, " @ all_unboxedf64" ) ,
371- Hint :: UnboxedFloat64 => write ! ( f, " @ all_unboxedf64" ) ,
372- Hint :: UnboxedLhsFloat64 => write ! ( f, " @ lhs_unboxedf64" ) ,
373- Hint :: UnboxedRhsFloat64 => write ! ( f, " @ rhs_unboxedf64" ) ,
374- Hint :: ScalarCtx => write ! ( f, "@ scalar_ctx" ) ,
375- Hint :: ArrayCtx => write ! ( f, "@ array_ctx" ) ,
376- Hint :: None => Ok ( ( ) ) ,
377309 }
378310 }
379311}
0 commit comments