@@ -29,8 +29,6 @@ pub enum CILNode {
2929
3030 /// A black box that prevents the bulit-in optimization engine from doing any optimizations.
3131 BlackBox ( Box < Self > ) ,
32- /// Loads the value of a static variable described by the descripstor.
33- LDStaticField ( Box < StaticFieldDesc > ) ,
3432 /// Converts the signed inner value to a 32 bit floating-point number.
3533 ConvF32 ( Box < Self > ) ,
3634 /// Converts the signed inner value to a 64 bit floating-point number.
@@ -128,8 +126,6 @@ pub enum CILNode {
128126 ShrUn ( Box < Self > , Box < Self > ) ,
129127 Call ( Box < CallOpArgs > ) ,
130128 CallVirt ( Box < CallOpArgs > ) ,
131- LdcF64 ( HashableF64 ) ,
132- LdcF32 ( HashableF32 ) ,
133129
134130 ConvU8 ( Box < Self > ) ,
135131 ConvU16 ( Box < Self > ) ,
@@ -208,10 +204,12 @@ pub enum CILNode {
208204 /// Marks the inner pointer operation as volatile.
209205 Volatile ( Box < Self > ) ,
210206 UnboxAny ( Box < Self > , Box < Type > ) ,
211- AddressOfStaticField ( Box < StaticFieldDesc > ) ,
212- LdNull ( Interned < ClassRef > ) ,
213207}
214-
208+ impl From < Interned < crate :: v2:: CILNode > > for CILNode {
209+ fn from ( value : Interned < crate :: v2:: CILNode > ) -> Self {
210+ Self :: V2 ( value)
211+ }
212+ }
215213impl CILNode {
216214 pub fn stack_addr ( val : Self , _: Interned < Type > , asm : & mut Assembly ) -> Self {
217215 let val = crate :: v2:: CILNode :: from_v1 ( & val, asm) ;
@@ -336,7 +334,7 @@ impl CILNode {
336334 pub fn uninit_val ( tpe : Type , asm : & mut Assembly ) -> Self {
337335 if tpe == Type :: Void {
338336 let gv = asm. global_void ( ) ;
339- return CILNode :: LDStaticField ( Box :: new ( asm[ gv ] ) ) ;
337+ return CILNode :: V2 ( asm. load_static ( gv ) ) ;
340338 }
341339 let main = asm. main_module ( ) ;
342340 let sig = asm. sig ( [ ] , tpe) ;
@@ -410,100 +408,6 @@ impl CILNode {
410408 new_ptr : Box :: new ( new_ptr) ,
411409 }
412410 }
413- pub ( crate ) fn allocate_tmps ( & mut self , curr_loc : Option < u32 > , locals : & mut Vec < LocalDef > ) {
414- match self {
415- Self :: V2 ( _) =>( ) ,
416- Self :: AddressOfStaticField ( _) =>( ) ,
417- Self :: LdNull ( _tpe) =>( ) ,
418- Self :: UnboxAny ( val, _tpe ) =>val. allocate_tmps ( curr_loc, locals) ,
419- Self :: Volatile ( inner) =>inner. allocate_tmps ( curr_loc, locals) ,
420- Self :: CheckedCast ( inner) =>inner. 0 . allocate_tmps ( curr_loc, locals) ,
421- Self :: IsInst ( inner) =>inner. 0 . allocate_tmps ( curr_loc, locals) ,
422- Self :: GetException =>( ) ,
423- Self :: LocAlloc { ..} =>( ) ,
424- Self :: LocAllocAligned { ..} =>( ) ,
425- Self :: CastPtr { val, new_ptr : _ } =>val. allocate_tmps ( curr_loc, locals) ,
426- Self :: LDLoc ( _) => ( ) ,
427- Self :: BlackBox ( inner) => inner. allocate_tmps ( curr_loc, locals) ,
428- Self :: LDIndI8 { ptr } |
429- Self :: LDIndBool { ptr } |
430- Self :: LDIndI16 { ptr } |
431- Self :: LDIndI32 { ptr } |
432- Self :: LDIndI64 { ptr } |
433- Self :: LDIndU8 { ptr } |
434- Self :: LDIndU16 { ptr } |
435- Self :: LDIndU32 { ptr } |
436- Self :: LDIndU64 { ptr } |
437- Self :: LDIndISize { ptr } |
438- Self :: LDIndPtr { ptr, .. } |
439- Self :: LDIndUSize { ptr } |
440- Self :: LdObj { ptr, .. } |
441- Self :: LDIndF32 { ptr } |
442- Self :: LDIndF64 { ptr } => ptr. allocate_tmps ( curr_loc, locals) ,
443- Self :: LDFieldAdress { addr, field : _ } |
444- Self :: LDField { addr, field : _ } => addr. allocate_tmps ( curr_loc, locals) ,
445- Self :: Add ( a, b)
446- | Self :: And ( a, b)
447- | Self :: Sub ( a, b)
448- | Self :: Mul ( a, b)
449- | Self :: Div ( a, b)
450- | Self :: DivUn ( a, b)
451- | Self :: Rem ( a, b)
452- | Self :: RemUn ( a, b)
453- | Self :: Or ( a, b)
454- | Self :: XOr ( a, b)
455- | Self :: Shr ( a, b)
456- | Self :: Shl ( a, b)
457- | Self :: ShrUn ( a, b)
458- | Self :: Eq ( a, b)
459- | Self :: Lt ( a, b)
460- | Self :: LtUn ( a, b)
461- | Self :: Gt ( a, b)
462- | Self :: GtUn ( a, b) => {
463- a. allocate_tmps ( curr_loc, locals) ;
464- b. allocate_tmps ( curr_loc, locals) ;
465- }
466- Self :: Call ( call_op_args) | Self :: CallVirt ( call_op_args) | Self :: NewObj ( call_op_args) =>call_op_args. args . iter_mut ( ) . for_each ( |arg|arg. allocate_tmps ( curr_loc, locals) ) ,
467- Self :: LdcF64 ( _) |
468- Self :: LdcF32 ( _) =>( ) ,
469- Self :: ConvF64Un ( val) |
470- Self :: ConvF32 ( val) |
471- Self :: ConvF64 ( val) |
472- Self :: ConvU8 ( val) |
473- Self :: ConvU16 ( val) |
474- Self :: ConvU32 ( val) |
475- Self :: ZeroExtendToU64 ( val) |
476- Self :: MRefToRawPtr ( val) |
477- Self :: ZeroExtendToUSize ( val) |
478- Self :: ZeroExtendToISize ( val) |
479- Self :: ConvI8 ( val) |
480- Self :: ConvI16 ( val) |
481- Self :: ConvI32 ( val) |
482- Self :: SignExtendToI64 ( val) |
483- Self :: SignExtendToU64 ( val) |
484- Self :: SignExtendToISize ( val) |
485- Self :: SignExtendToUSize ( val) |
486- //Self::Volatile(_) => todo!(),
487- Self :: Neg ( val) |
488- Self :: Not ( val) =>val. allocate_tmps ( curr_loc, locals) ,
489- Self :: LDFtn ( _) => ( ) ,
490- Self :: LDTypeToken ( _) =>( ) ,
491-
492- Self :: LdStr ( _) => ( ) ,
493- Self :: CallI ( sig_ptr_args) => {
494- sig_ptr_args. 1 . allocate_tmps ( curr_loc, locals) ;
495- sig_ptr_args. 2 . iter_mut ( ) . for_each ( |arg|arg. allocate_tmps ( curr_loc, locals) ) ;
496- }
497- Self :: LDStaticField ( _sfield) =>( ) ,
498- Self :: LDLen { arr } =>{
499- arr. allocate_tmps ( curr_loc, locals) ;
500- }
501- Self :: LDElelemRef { arr, idx } =>{
502- arr. allocate_tmps ( curr_loc, locals) ;
503- idx. allocate_tmps ( curr_loc, locals) ;
504- }
505- } ;
506- }
507411}
508412
509413#[ macro_export]
0 commit comments