1616
1717include "clang/CIR/Dialect/IR/CIRDialect.td"
1818include "clang/CIR/Dialect/IR/CIRTypes.td"
19+ include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
1920include "clang/CIR/Dialect/IR/CIRAttrs.td"
2021
2122include "clang/CIR/Interfaces/ASTAttrInterfaces.td"
@@ -297,7 +298,7 @@ def ObjSizeOp : CIR_Op<"objsize", [Pure]> {
297298
298299 let arguments = (ins CIR_PointerType:$ptr, SizeInfoType:$kind,
299300 UnitAttr:$dynamic);
300- let results = (outs PrimitiveInt :$result);
301+ let results = (outs CIR_IntType :$result);
301302
302303 let assemblyFormat = [{
303304 `(`
@@ -333,7 +334,7 @@ def PtrDiffOp : CIR_Op<"ptr_diff", [Pure, SameTypeOperands]> {
333334 ```
334335 }];
335336
336- let results = (outs PrimitiveInt :$result);
337+ let results = (outs CIR_IntType :$result);
337338 let arguments = (ins CIR_PointerType:$lhs, CIR_PointerType:$rhs);
338339
339340 let assemblyFormat = [{
@@ -361,7 +362,7 @@ def PtrStrideOp : CIR_Op<"ptr_stride",
361362 ```
362363 }];
363364
364- let arguments = (ins CIR_PointerType:$base, PrimitiveInt :$stride);
365+ let arguments = (ins CIR_PointerType:$base, CIR_IntType :$stride);
365366 let results = (outs CIR_PointerType:$result);
366367
367368 let assemblyFormat = [{
@@ -492,7 +493,7 @@ def AllocaOp : CIR_Op<"alloca", [
492493 }];
493494
494495 let arguments = (ins
495- Optional<PrimitiveInt >:$dynAllocSize,
496+ Optional<CIR_IntType >:$dynAllocSize,
496497 TypeAttr:$allocaType,
497498 StrAttr:$name,
498499 UnitAttr:$init,
@@ -1033,7 +1034,7 @@ def ResumeOp : CIR_Op<"resume", [ReturnLike, Terminator,
10331034 }];
10341035
10351036 let arguments = (ins Optional<VoidPtr>:$exception_ptr,
1036- Optional<UInt32 >:$type_id,
1037+ Optional<CIR_UInt32 >:$type_id,
10371038 UnitAttr:$rethrow);
10381039 let assemblyFormat = [{
10391040 ($rethrow^)?
@@ -1585,7 +1586,7 @@ class CIR_CountZerosBitOp<string mnemonic, TypeConstraint inputTy>
15851586 }];
15861587}
15871588
1588- def BitClrsbOp : CIR_BitOp<"bit.clrsb", AnyTypeOf<[SInt32, SInt64 ]>> {
1589+ def BitClrsbOp : CIR_BitOp<"bit.clrsb", CIR_SIntOfWidths<[32, 64 ]>> {
15891590 let summary = "Get the number of leading redundant sign bits in the input";
15901591 let description = [{
15911592 Compute the number of leading redundant sign bits in the input integer.
@@ -1616,7 +1617,7 @@ def BitClrsbOp : CIR_BitOp<"bit.clrsb", AnyTypeOf<[SInt32, SInt64]>> {
16161617 }];
16171618}
16181619
1619- def BitClzOp : CIR_CountZerosBitOp<"bit.clz", AnyTypeOf<[UInt16, UInt32, UInt64 ]>> {
1620+ def BitClzOp : CIR_CountZerosBitOp<"bit.clz", CIR_UIntOfWidths<[16, 32, 64 ]>> {
16201621 let summary = "Get the number of leading 0-bits in the input";
16211622 let description = [{
16221623 Compute the number of leading 0-bits in the input.
@@ -1641,7 +1642,7 @@ def BitClzOp : CIR_CountZerosBitOp<"bit.clz", AnyTypeOf<[UInt16, UInt32, UInt64]
16411642 }];
16421643}
16431644
1644- def BitCtzOp : CIR_CountZerosBitOp<"bit.ctz", AnyTypeOf<[UInt16, UInt32, UInt64 ]>> {
1645+ def BitCtzOp : CIR_CountZerosBitOp<"bit.ctz", CIR_UIntOfWidths<[16, 32, 64 ]>> {
16451646 let summary = "Get the number of trailing 0-bits in the input";
16461647 let description = [{
16471648 Compute the number of trailing 0-bits in the input.
@@ -1667,7 +1668,7 @@ def BitCtzOp : CIR_CountZerosBitOp<"bit.ctz", AnyTypeOf<[UInt16, UInt32, UInt64]
16671668 }];
16681669}
16691670
1670- def BitFfsOp : CIR_BitOp<"bit.ffs", AnyTypeOf<[SInt32, SInt64 ]>> {
1671+ def BitFfsOp : CIR_BitOp<"bit.ffs", CIR_SIntOfWidths<[32, 64 ]>> {
16711672 let summary = "Get the position of the least significant 1-bit of input";
16721673 let description = [{
16731674 Compute the position of the least significant 1-bit of the input.
@@ -1690,7 +1691,7 @@ def BitFfsOp : CIR_BitOp<"bit.ffs", AnyTypeOf<[SInt32, SInt64]>> {
16901691 }];
16911692}
16921693
1693- def BitParityOp : CIR_BitOp<"bit.parity", AnyTypeOf<[UInt32, UInt64 ]>> {
1694+ def BitParityOp : CIR_BitOp<"bit.parity", CIR_UIntOfWidths<[32, 64 ]>> {
16941695 let summary = "Get the parity of input";
16951696 let description = [{
16961697 Compute the parity of the input. The parity of an integer is the number of
@@ -1713,7 +1714,7 @@ def BitParityOp : CIR_BitOp<"bit.parity", AnyTypeOf<[UInt32, UInt64]>> {
17131714}
17141715
17151716def BitPopcountOp
1716- : CIR_BitOp<"bit.popcount", AnyTypeOf<[UInt16, UInt32, UInt64 ]>> {
1717+ : CIR_BitOp<"bit.popcount", CIR_UIntOfWidths<[16, 32, 64 ]>> {
17171718 let summary = "Get the number of 1-bits in input";
17181719 let description = [{
17191720 Compute the number of 1-bits in the input.
@@ -1760,7 +1761,7 @@ def ByteswapOp : CIR_Op<"bswap", [Pure, SameOperandsAndResultType]> {
17601761 }];
17611762
17621763 let results = (outs CIR_IntType:$result);
1763- let arguments = (ins AnyTypeOf<[UInt16, UInt32, UInt64 ]>:$input);
1764+ let arguments = (ins CIR_UIntOfWidths<[16, 32, 64 ]>:$input);
17641765
17651766 let assemblyFormat = [{
17661767 `(` $input `:` type($input) `)` `:` type($result) attr-dict
@@ -1792,7 +1793,7 @@ def RotateOp : CIR_Op<"rotate", [Pure, SameOperandsAndResultType]> {
17921793 }];
17931794
17941795 let results = (outs CIR_IntType:$result);
1795- let arguments = (ins PrimitiveInt :$src, PrimitiveInt :$amt,
1796+ let arguments = (ins CIR_IntType :$src, CIR_IntType :$amt,
17961797 UnitAttr:$left);
17971798
17981799 let assemblyFormat = [{
@@ -1821,8 +1822,8 @@ def BitReverseOp : CIR_Op<"bit_reverse", [Pure, SameOperandsAndResultType]> {
18211822 ```
18221823 }];
18231824
1824- let arguments = (ins AnyTypeOf<[UInt8, UInt16, UInt32, UInt64 ]>:$src);
1825- let results = (outs AnyTypeOf<[UInt8, UInt16, UInt32, UInt64 ]>:$result);
1825+ let arguments = (ins CIR_UIntOfWidths<[8, 16, 32, 64 ]>:$src);
1826+ let results = (outs CIR_UIntOfWidths<[8, 16, 32, 64 ]>:$result);
18261827
18271828 let assemblyFormat = [{
18281829 $src `:` type($result) attr-dict
@@ -1868,7 +1869,7 @@ def CmpThreeWayOp : CIR_Op<"cmp3way", [Pure, SameTypeOperands]> {
18681869 ```
18691870 }];
18701871
1871- let results = (outs PrimitiveSInt :$result);
1872+ let results = (outs CIR_SIntType :$result);
18721873 let arguments = (ins CIR_AnyType:$lhs, CIR_AnyType:$rhs,
18731874 CmpThreeWayInfoAttr:$info);
18741875
@@ -3134,7 +3135,7 @@ def VecInsertOp : CIR_Op<"vec.insert", [Pure,
31343135 element is returned.
31353136 }];
31363137
3137- let arguments = (ins CIR_VectorType:$vec, AnyType:$value, PrimitiveInt :$index);
3138+ let arguments = (ins CIR_VectorType:$vec, AnyType:$value, CIR_IntType :$index);
31383139 let results = (outs CIR_VectorType:$result);
31393140
31403141 let assemblyFormat = [{
@@ -3161,7 +3162,7 @@ def VecExtractOp : CIR_Op<"vec.extract", [Pure,
31613162 from a vector object.
31623163 }];
31633164
3164- let arguments = (ins CIR_VectorType:$vec, PrimitiveInt :$index);
3165+ let arguments = (ins CIR_VectorType:$vec, CIR_IntType :$index);
31653166 let results = (outs CIR_AnyType:$result);
31663167
31673168 let assemblyFormat = [{
@@ -4367,7 +4368,7 @@ def EhInflightOp : CIR_Op<"eh.inflight_exception"> {
43674368
43684369 let arguments = (ins UnitAttr:$cleanup,
43694370 OptionalAttr<FlatSymbolRefArrayAttr>:$sym_type_list);
4370- let results = (outs VoidPtr:$exception_ptr, UInt32 :$type_id);
4371+ let results = (outs VoidPtr:$exception_ptr, CIR_UInt32 :$type_id);
43714372 let assemblyFormat = [{
43724373 (`cleanup` $cleanup^)?
43734374 ($sym_type_list^)?
@@ -4386,7 +4387,7 @@ def EhTypeIdOp : CIR_Op<"eh.typeid",
43864387 }];
43874388
43884389 let arguments = (ins FlatSymbolRefAttr:$type_sym);
4389- let results = (outs UInt32 :$type_id);
4390+ let results = (outs CIR_UInt32 :$type_id);
43904391 let assemblyFormat = [{
43914392 $type_sym attr-dict
43924393 }];
@@ -4469,7 +4470,7 @@ def MemCpyOp : CIR_MemOp<"libc.memcpy"> {
44694470 ```
44704471 }];
44714472
4472- let arguments = !con(commonArgs, (ins PrimitiveUInt :$len));
4473+ let arguments = !con(commonArgs, (ins CIR_UIntType :$len));
44734474
44744475 let assemblyFormat = [{
44754476 $len `bytes` `from` $src `to` $dst attr-dict
@@ -4499,7 +4500,7 @@ def MemMoveOp : CIR_MemOp<"libc.memmove"> {
44994500 ```
45004501 }];
45014502
4502- let arguments = !con(commonArgs, (ins PrimitiveUInt :$len));
4503+ let arguments = !con(commonArgs, (ins CIR_UIntType :$len));
45034504
45044505 let assemblyFormat = [{
45054506 $len `bytes` `from` $src `to` $dst attr-dict
@@ -4548,8 +4549,8 @@ def MemCpyInlineOp : CIR_MemOp<"memcpy_inline"> {
45484549
45494550def MemSetOp : CIR_Op<"libc.memset"> {
45504551 let arguments = (ins Arg<VoidPtr, "", [MemWrite]>:$dst,
4551- SInt32 :$val,
4552- PrimitiveUInt :$len);
4552+ CIR_SInt32 :$val,
4553+ CIR_UIntType :$len);
45534554 let summary = "Equivalent to libc's `memset`";
45544555 let description = [{
45554556 Given the CIR pointer, `dst`, `cir.libc.memset` will set the first `len`
@@ -4579,7 +4580,7 @@ def MemSetOp : CIR_Op<"libc.memset"> {
45794580
45804581def MemSetInlineOp : CIR_Op<"memset_inline"> {
45814582 let arguments = (ins Arg<VoidPtr, "", [MemWrite]>:$dst,
4582- SInt32 :$val,
4583+ CIR_SInt32 :$val,
45834584 I64Attr:$len);
45844585 let summary = "Fill a block of memory with constant length without calling"
45854586 "any external function";
@@ -4612,8 +4613,8 @@ def MemChrOp : CIR_Op<"libc.memchr"> {
46124613 // TODO: instead of using UInt64 for len, we could make it constrained on
46134614 // size_t (64 or 32) and have a builder that does the right job.
46144615 let arguments = (ins Arg<VoidPtr, "", [MemRead]>:$src,
4615- SInt32 :$pattern,
4616- UInt64 :$len);
4616+ CIR_SInt32 :$pattern,
4617+ CIR_UInt64 :$len);
46174618 let summary = "libc's `memchr`";
46184619 let results = (outs Res<VoidPtr, "">:$result);
46194620
@@ -4641,7 +4642,7 @@ def MemChrOp : CIR_Op<"libc.memchr"> {
46414642//===----------------------------------------------------------------------===//
46424643
46434644class FuncAddrBuiltinOp<string mnemonic> : CIR_Op<mnemonic, []> {
4644- let arguments = (ins UInt32 :$level);
4645+ let arguments = (ins CIR_UInt32 :$level);
46454646 let results = (outs Res<VoidPtr, "">:$result);
46464647 let assemblyFormat = [{
46474648 `(` $level `)` attr-dict
@@ -4951,10 +4952,10 @@ def ExpectOp : CIR_Op<"expect",
49514952 where probability = $prob.
49524953 }];
49534954
4954- let arguments = (ins PrimitiveInt :$val,
4955- PrimitiveInt :$expected,
4955+ let arguments = (ins CIR_IntType :$val,
4956+ CIR_IntType :$expected,
49564957 OptionalAttr<F64Attr>:$prob);
4957- let results = (outs PrimitiveInt :$result);
4958+ let results = (outs CIR_IntType :$result);
49584959 let assemblyFormat = [{
49594960 `(` $val`,` $expected (`,` $prob^)? `)` `:` type($val) attr-dict
49604961 }];
0 commit comments