@@ -264,7 +264,7 @@ def PtrStrideOp : CIR_Op<"ptr_stride",
264
264
a stride (second operand).
265
265
266
266
```mlir
267
- %3 = cir.const(0 : i32) : i32
267
+ %3 = cir.const 0 : i32
268
268
%4 = cir.ptr_stride(%2 : !cir.ptr<i32>, %3 : i32), !cir.ptr<i32>
269
269
```
270
270
}];
@@ -293,7 +293,7 @@ def PtrStrideOp : CIR_Op<"ptr_stride",
293
293
//===----------------------------------------------------------------------===//
294
294
295
295
def ConstantOp : CIR_Op<"const",
296
- [ConstantLike, Pure]> {
296
+ [ConstantLike, Pure, AllTypesMatch<["value", "res"]> ]> {
297
297
// FIXME: Use SameOperandsAndResultType or similar and prevent eye bleeding
298
298
// type repetition in the assembly form.
299
299
@@ -303,9 +303,9 @@ def ConstantOp : CIR_Op<"const",
303
303
attached to the operation as an attribute.
304
304
305
305
```mlir
306
- %0 = cir.const(42 : i32) : i32
307
- %1 = cir.const( 4.2 : f32) : f32
308
- %2 = cir.const(nullptr : !cir.ptr<i32>) : !cir.ptr<i32>
306
+ %0 = cir.const 42 : i32
307
+ %1 = cir.const 4.2 : f32
308
+ %2 = cir.const nullptr : !cir.ptr<i32>
309
309
```
310
310
}];
311
311
@@ -315,9 +315,7 @@ def ConstantOp : CIR_Op<"const",
315
315
// The constant operation returns a single value of CIR_AnyType.
316
316
let results = (outs CIR_AnyType:$res);
317
317
318
- let assemblyFormat = [{
319
- `(` custom<ConstantValue>($value) `)` attr-dict `:` type($res)
320
- }];
318
+ let assemblyFormat = "attr-dict $value";
321
319
322
320
let hasVerifier = 1;
323
321
@@ -1111,13 +1109,13 @@ def BitClrsbOp : CIR_BitOp<"bit.clrsb", AnyTypeOf<[SInt32, SInt64]>> {
1111
1109
!s32i = !cir.int<s, 32>
1112
1110
1113
1111
// %0 = 0xDEADBEEF, 0b1101_1110_1010_1101_1011_1110_1110_1111
1114
- %0 = cir.const( #cir.int<3735928559> : !s32i) : !s32i
1112
+ %0 = cir.const #cir.int<3735928559> : !s32i
1115
1113
// %1 will be 1 because there is 1 bit following the most significant bit
1116
1114
// that is identical to it.
1117
1115
%1 = cir.bit.clrsb(%0 : !s32i) : !s32i
1118
1116
1119
1117
// %2 = 1, 0b0000_0000_0000_0000_0000_0000_0000_0001
1120
- %2 = cir.const( #cir.int<1> : !s32i) : !s32i
1118
+ %2 = cir.const #cir.int<1> : !s32i
1121
1119
// %3 will be 30
1122
1120
%3 = cir.bit.clrsb(%2 : !s32i) : !s32i
1123
1121
```
@@ -1142,7 +1140,7 @@ def BitClzOp : CIR_BitOp<"bit.clz", AnyTypeOf<[UInt16, UInt32, UInt64]>> {
1142
1140
!u32i = !cir.int<u, 32>
1143
1141
1144
1142
// %0 = 0b0000_0000_0000_0000_0000_0000_0000_1000
1145
- %0 = cir.const( #cir.int<8> : !u32i) : !u32i
1143
+ %0 = cir.const #cir.int<8> : !u32i
1146
1144
// %1 will be 28
1147
1145
%1 = cir.bit.clz(%0 : !u32i) : !s32i
1148
1146
```
@@ -1167,7 +1165,7 @@ def BitCtzOp : CIR_BitOp<"bit.ctz", AnyTypeOf<[UInt16, UInt32, UInt64]>> {
1167
1165
!u32i = !cir.int<u, 32>
1168
1166
1169
1167
// %0 = 0b1000
1170
- %0 = cir.const( #cir.int<8> : !u32i) : !u32i
1168
+ %0 = cir.const #cir.int<8> : !u32i
1171
1169
// %1 will be 3
1172
1170
%1 = cir.bit.ctz(%0 : !u32i) : !s32i
1173
1171
```
@@ -1190,7 +1188,7 @@ def BitFfsOp : CIR_BitOp<"bit.ffs", AnyTypeOf<[SInt32, SInt64]>> {
1190
1188
!s32i = !cir.int<s, 32>
1191
1189
1192
1190
// %0 = 0x0010_1000
1193
- %0 = cir.const( #cir.int<40> : !s32i) : !s32i
1191
+ %0 = cir.const #cir.int<40> : !s32i
1194
1192
// #1 will be 4 since the 4th least significant bit is 1.
1195
1193
%1 = cir.bit.ffs(%0 : !s32i) : !s32i
1196
1194
```
@@ -1212,9 +1210,9 @@ def BitParityOp : CIR_BitOp<"bit.parity", AnyTypeOf<[UInt32, UInt64]>> {
1212
1210
!u32i = !cir.int<u, 32>
1213
1211
1214
1212
// %0 = 0x0110_1000
1215
- %0 = cir.const( #cir.int<104> : !u32i) : !s32i
1213
+ %0 = cir.const #cir.int<104> : !u32i
1216
1214
// %1 will be 1 since there are 3 1-bits in %0
1217
- %1 = cir.bit.parity(%0 : !u32i) : !s32i
1215
+ %1 = cir.bit.parity(%0 : !u32i) : !u32i
1218
1216
```
1219
1217
}];
1220
1218
}
@@ -1230,13 +1228,12 @@ def BitPopcountOp
1230
1228
Example:
1231
1229
1232
1230
```mlir
1233
- !s32i = !cir.int<s, 32>
1234
1231
!u32i = !cir.int<u, 32>
1235
1232
1236
1233
// %0 = 0x0110_1000
1237
- %0 = cir.const( #cir.int<104> : !u32i) : !s32i
1234
+ %0 = cir.const #cir.int<104> : !u32i
1238
1235
// %1 will be 3 since there are 3 1-bits in %0
1239
- %1 = cir.bit.popcount(%0 : !u32i) : !s32i
1236
+ %1 = cir.bit.popcount(%0 : !u32i) : !u32i
1240
1237
```
1241
1238
}];
1242
1239
}
@@ -1260,7 +1257,7 @@ def ByteswapOp : CIR_Op<"bswap", [Pure, SameOperandsAndResultType]> {
1260
1257
!u32i = !cir.int<u, 32>
1261
1258
1262
1259
// %0 = 0x12345678
1263
- %0 = cir.const( #cir.int<305419896> : !u32i) : !u32i
1260
+ %0 = cir.const #cir.int<305419896> : !u32i
1264
1261
1265
1262
// %1 should be 0x78563412
1266
1263
%1 = cir.bswap(%0 : !u32i) : !u32i
@@ -1302,12 +1299,12 @@ def CmpThreeWayOp : CIR_Op<"cmp3way", [Pure, SameTypeOperands]> {
1302
1299
#cmp3way_strong = #cmp3way_info<strong, lt = -1, eq = 0, gt = 1>
1303
1300
#cmp3way_partial = #cmp3way_info<strong, lt = -1, eq = 0, gt = 1, unordered = 2>
1304
1301
1305
- %0 = cir.const( #cir.int<0> : !s32i) : !s32i
1306
- %1 = cir.const( #cir.int<1> : !s32i) : !s32i
1302
+ %0 = cir.const #cir.int<0> : !s32i
1303
+ %1 = cir.const #cir.int<1> : !s32i
1307
1304
%2 = cir.cmp3way(%0 : !s32i, %1, #cmp3way_strong) : !s8i
1308
1305
1309
- %3 = cir.const( #cir.fp<0.0> : !cir.float) : !cir.float
1310
- %4 = cir.const( #cir.fp<1.0> : !cir.float) : !cir.float
1306
+ %3 = cir.const #cir.fp<0.0> : !cir.float
1307
+ %4 = cir.const #cir.fp<1.0> : !cir.float
1311
1308
%5 = cir.cmp3way(%3 : !cir.float, %4, #cmp3way_partial) : !s8i
1312
1309
```
1313
1310
}];
@@ -1961,7 +1958,7 @@ def SetBitfieldOp : CIR_Op<"set_bitfield"> {
1961
1958
!struct_type = !cir.struct<struct "S" {!cir.int<u, 32>, !cir.int<u, 32>, !cir.int<u, 16>} #cir.record.decl.ast>
1962
1959
#bfi_d = #cir.bitfield_info<name = "d", storage_type = !u32i, size = 2, offset = 17, is_signed = true>
1963
1960
1964
- %1 = cir.const( #cir.int<3> : !s32i) : !s32i
1961
+ %1 = cir.const #cir.int<3> : !s32i
1965
1962
%2 = cir.load %0 : !cir.ptr<!cir.ptr<!struct_type>>, !cir.ptr<!struct_type>
1966
1963
%3 = cir.get_member %2[1] {name = "d"} : !cir.ptr<!struct_type> -> !cir.ptr<!u32i>
1967
1964
%4 = cir.set_bitfield(#bfi_d, %3 : !cir.ptr<!u32i>, %1 : !s32i) -> !s32i
@@ -3045,7 +3042,7 @@ def MemCpyOp : CIR_Op<"libc.memcpy"> {
3045
3042
3046
3043
```mlir
3047
3044
// Copying 2 bytes from one array to a struct:
3048
- %2 = cir.const( #cir.int<2> : !u32i) : !u32i
3045
+ %2 = cir.const #cir.int<2> : !u32i
3049
3046
cir.libc.memcpy %2 bytes from %arr to %struct : !cir.ptr<!arr> -> !cir.ptr<!struct>
3050
3047
```
3051
3048
}];
0 commit comments