@@ -35,11 +35,6 @@ use std::{fs::File, io::Write, path::Path};
3535pub  enum  SpirvValueKind  { 
3636    Def ( Word ) , 
3737
38-     /// The ID of a global instruction matching a `SpirvConst`, but which cannot 
39-      /// pass validation. Used to error (or attach zombie spans), at the usesites 
40-      /// of such constants, instead of where they're generated (and cached). 
41-      IllegalConst ( Word ) , 
42- 
4338    // FIXME(eddyb) this shouldn't be needed, but `rustc_codegen_ssa` still relies 
4439    // on converting `Function`s to `Value`s even for direct calls, the `Builder` 
4540    // should just have direct and indirect `call` variants (or a `Callee` enum). 
@@ -96,23 +91,17 @@ impl SpirvValue {
9691
9792    pub  fn  const_fold_load ( self ,  cx :  & CodegenCx < ' _ > )  -> Option < Self >  { 
9893        match  self . kind  { 
99-             SpirvValueKind :: Def ( id)  |  SpirvValueKind :: IllegalConst ( id )   => { 
94+             SpirvValueKind :: Def ( id)  => { 
10095                let  & entry = cx. builder . id_to_const . borrow ( ) . get ( & id) ?; 
10196                match  entry. val  { 
10297                    SpirvConst :: PtrTo  {  pointee }  => { 
10398                        let  ty = match  cx. lookup_type ( self . ty )  { 
10499                            SpirvType :: Pointer  {  pointee }  => pointee, 
105100                            ty => bug ! ( "load called on value that wasn't a pointer: {:?}" ,  ty) , 
106101                        } ; 
107-                         // FIXME(eddyb) deduplicate this `if`-`else` and its other copies. 
108-                         let  kind = if  entry. legal . is_ok ( )  { 
109-                             SpirvValueKind :: Def ( pointee) 
110-                         }  else  { 
111-                             SpirvValueKind :: IllegalConst ( pointee) 
112-                         } ; 
113102                        Some ( SpirvValue  { 
114103                            zombie_waiting_for_span :  entry. legal . is_err ( ) , 
115-                             kind, 
104+                             kind :   SpirvValueKind :: Def ( pointee ) , 
116105                            ty, 
117106                        } ) 
118107                    } 
@@ -152,7 +141,6 @@ impl SpirvValue {
152141            } 
153142
154143            SpirvValueKind :: Def ( id) 
155-             | SpirvValueKind :: IllegalConst ( id) 
156144            | SpirvValueKind :: LogicalPtrCast  { 
157145                original_ptr :  _, 
158146                original_ptr_ty :  _, 
@@ -573,15 +561,9 @@ impl<'tcx> BuilderSpirv<'tcx> {
573561
574562        let  val_with_type = WithType  {  ty,  val } ; 
575563        if  let  Some ( entry)  = self . const_to_id . borrow ( ) . get ( & val_with_type)  { 
576-             // FIXME(eddyb) deduplicate this `if`-`else` and its other copies. 
577-             let  kind = if  entry. legal . is_ok ( )  { 
578-                 SpirvValueKind :: Def ( entry. val ) 
579-             }  else  { 
580-                 SpirvValueKind :: IllegalConst ( entry. val ) 
581-             } ; 
582564            return  SpirvValue  { 
583565                zombie_waiting_for_span :  entry. legal . is_err ( ) , 
584-                 kind, 
566+                 kind :   SpirvValueKind :: Def ( entry . val ) , 
585567                ty, 
586568            } ; 
587569        } 
@@ -784,15 +766,9 @@ impl<'tcx> BuilderSpirv<'tcx> {
784766                . insert( id,  WithConstLegality  {  val,  legal } ) , 
785767            None 
786768        ) ; 
787-         // FIXME(eddyb) deduplicate this `if`-`else` and its other copies. 
788-         let  kind = if  legal. is_ok ( )  { 
789-             SpirvValueKind :: Def ( id) 
790-         }  else  { 
791-             SpirvValueKind :: IllegalConst ( id) 
792-         } ; 
793769        SpirvValue  { 
794770            zombie_waiting_for_span :  legal. is_err ( ) , 
795-             kind, 
771+             kind :   SpirvValueKind :: Def ( id ) , 
796772            ty, 
797773        } 
798774    } 
@@ -803,9 +779,7 @@ impl<'tcx> BuilderSpirv<'tcx> {
803779
804780    pub  fn  lookup_const ( & self ,  def :  SpirvValue )  -> Option < SpirvConst < ' tcx ,  ' tcx > >  { 
805781        match  def. kind  { 
806-             SpirvValueKind :: Def ( id)  | SpirvValueKind :: IllegalConst ( id)  => { 
807-                 self . lookup_const_by_id ( id) 
808-             } 
782+             SpirvValueKind :: Def ( id)  => self . lookup_const_by_id ( id) , 
809783            _ => None , 
810784        } 
811785    } 
0 commit comments