@@ -35,11 +35,6 @@ use std::{fs::File, io::Write, path::Path};
35
35
pub enum SpirvValueKind {
36
36
Def ( Word ) ,
37
37
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
-
43
38
// FIXME(eddyb) this shouldn't be needed, but `rustc_codegen_ssa` still relies
44
39
// on converting `Function`s to `Value`s even for direct calls, the `Builder`
45
40
// should just have direct and indirect `call` variants (or a `Callee` enum).
@@ -96,23 +91,17 @@ impl SpirvValue {
96
91
97
92
pub fn const_fold_load ( self , cx : & CodegenCx < ' _ > ) -> Option < Self > {
98
93
match self . kind {
99
- SpirvValueKind :: Def ( id) | SpirvValueKind :: IllegalConst ( id ) => {
94
+ SpirvValueKind :: Def ( id) => {
100
95
let & entry = cx. builder . id_to_const . borrow ( ) . get ( & id) ?;
101
96
match entry. val {
102
97
SpirvConst :: PtrTo { pointee } => {
103
98
let ty = match cx. lookup_type ( self . ty ) {
104
99
SpirvType :: Pointer { pointee } => pointee,
105
100
ty => bug ! ( "load called on value that wasn't a pointer: {:?}" , ty) ,
106
101
} ;
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
- } ;
113
102
Some ( SpirvValue {
114
103
zombie_waiting_for_span : entry. legal . is_err ( ) ,
115
- kind,
104
+ kind : SpirvValueKind :: Def ( pointee ) ,
116
105
ty,
117
106
} )
118
107
}
@@ -152,7 +141,6 @@ impl SpirvValue {
152
141
}
153
142
154
143
SpirvValueKind :: Def ( id)
155
- | SpirvValueKind :: IllegalConst ( id)
156
144
| SpirvValueKind :: LogicalPtrCast {
157
145
original_ptr : _,
158
146
original_ptr_ty : _,
@@ -573,15 +561,9 @@ impl<'tcx> BuilderSpirv<'tcx> {
573
561
574
562
let val_with_type = WithType { ty, val } ;
575
563
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
- } ;
582
564
return SpirvValue {
583
565
zombie_waiting_for_span : entry. legal . is_err ( ) ,
584
- kind,
566
+ kind : SpirvValueKind :: Def ( entry . val ) ,
585
567
ty,
586
568
} ;
587
569
}
@@ -784,15 +766,9 @@ impl<'tcx> BuilderSpirv<'tcx> {
784
766
. insert( id, WithConstLegality { val, legal } ) ,
785
767
None
786
768
) ;
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
- } ;
793
769
SpirvValue {
794
770
zombie_waiting_for_span : legal. is_err ( ) ,
795
- kind,
771
+ kind : SpirvValueKind :: Def ( id ) ,
796
772
ty,
797
773
}
798
774
}
@@ -803,9 +779,7 @@ impl<'tcx> BuilderSpirv<'tcx> {
803
779
804
780
pub fn lookup_const ( & self , def : SpirvValue ) -> Option < SpirvConst < ' tcx , ' tcx > > {
805
781
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) ,
809
783
_ => None ,
810
784
}
811
785
}
0 commit comments