@@ -115,7 +115,7 @@ impl ModuleOp {
115
115
#[ allow( missing_docs) ]
116
116
pub enum ConstValue {
117
117
/// An arbitrary length integer constant.
118
- Int ( i64 ) ,
118
+ Int { value : i64 , width : usize } ,
119
119
/// A constant specifying a variant of a Sum type.
120
120
Sum {
121
121
tag : usize ,
@@ -131,7 +131,16 @@ pub enum ConstValue {
131
131
impl PartialEq for ConstValue {
132
132
fn eq ( & self , other : & Self ) -> bool {
133
133
match ( self , other) {
134
- ( Self :: Int ( l0) , Self :: Int ( r0) ) => l0 == r0,
134
+ (
135
+ Self :: Int {
136
+ value : l0,
137
+ width : l_width,
138
+ } ,
139
+ Self :: Int {
140
+ value : r0,
141
+ width : r_width,
142
+ } ,
143
+ ) => l0 == r0 && l_width == r_width,
135
144
( Self :: Opaque ( l0, l1) , Self :: Opaque ( r0, r1) ) => l0 == r0 && l1. eq ( & * * r1) ,
136
145
(
137
146
Self :: Sum { tag, variants, val } ,
@@ -152,15 +161,18 @@ impl Eq for ConstValue {}
152
161
153
162
impl Default for ConstValue {
154
163
fn default ( ) -> Self {
155
- Self :: Int ( 0 )
164
+ Self :: Int {
165
+ value : 0 ,
166
+ width : 64 ,
167
+ }
156
168
}
157
169
}
158
170
159
171
impl ConstValue {
160
172
/// Returns the datatype of the constant.
161
173
pub fn const_type ( & self ) -> ClassicType {
162
174
match self {
163
- Self :: Int ( _ ) => ClassicType :: i64 ( ) ,
175
+ Self :: Int { value : _ , width } => ClassicType :: Int ( * width ) ,
164
176
Self :: Opaque ( _, b) => ( * b) . const_type ( ) ,
165
177
Self :: Sum { variants, .. } => {
166
178
ClassicType :: Container ( Container :: Sum ( Box :: new ( variants. clone ( ) ) ) )
@@ -178,7 +190,7 @@ impl ConstValue {
178
190
/// Unique name of the constant.
179
191
pub fn name ( & self ) -> SmolStr {
180
192
match self {
181
- Self :: Int ( v ) => format ! ( "const:int:{v }" ) ,
193
+ Self :: Int { value , width } => format ! ( "const:int<{width}>:{value }" ) ,
182
194
Self :: Opaque ( _, v) => format ! ( "const:{}" , v. name( ) ) ,
183
195
Self :: Sum { tag, val, .. } => {
184
196
format ! ( "const:sum:{{tag:{tag}, val:{}}}" , val. name( ) )
@@ -235,6 +247,11 @@ impl ConstValue {
235
247
pub fn simple_unary_predicate ( ) -> Self {
236
248
Self :: simple_predicate ( 0 , 1 )
237
249
}
250
+
251
+ /// New 64 bit integer constant
252
+ pub fn i64 ( value : i64 ) -> Self {
253
+ Self :: Int { value, width : 64 }
254
+ }
238
255
}
239
256
240
257
impl < T : CustomConst > From < T > for ConstValue {
0 commit comments