[Mlir-commits] [mlir] [MLIR] Fix LLVM dialect specification to use AnySignlessInteger instead of AnyInteger (PR #82694)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Feb 22 13:56:26 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-llvm
Author: Mehdi Amini (joker-eph)
<details>
<summary>Changes</summary>
LLVM IR does not support signed integer, the LLVM dialect was underspecified (likely unintentionally) and the AnyInteger constraint was overly lax.
The arithmetic dialect is already consistently using AnySignlessInteger.
---
Full diff: https://github.com/llvm/llvm-project/pull/82694.diff
1 Files Affected:
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td (+23-23)
``````````diff
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index d9b130bdf18cb8..3da5deeb4ec7e2 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -49,7 +49,7 @@ class LLVM_ArithmeticOpBase<Type type, string mnemonic,
}
class LLVM_IntArithmeticOp<string mnemonic, string instName,
list<Trait> traits = []> :
- LLVM_ArithmeticOpBase<AnyInteger, mnemonic, instName, traits> {
+ LLVM_ArithmeticOpBase<AnySignlessInteger, mnemonic, instName, traits> {
let arguments = commonArgs;
string mlirBuilder = [{
$res = $_builder.create<$_qualCppClassName>($_location, $lhs, $rhs);
@@ -57,7 +57,7 @@ class LLVM_IntArithmeticOp<string mnemonic, string instName,
}
class LLVM_IntArithmeticOpWithOverflowFlag<string mnemonic, string instName,
list<Trait> traits = []> :
- LLVM_ArithmeticOpBase<AnyInteger, mnemonic, instName,
+ LLVM_ArithmeticOpBase<AnySignlessInteger, mnemonic, instName,
!listconcat([DeclareOpInterfaceMethods<IntegerOverflowFlagsInterface>], traits)> {
dag iofArg = (
ins DefaultValuedAttr<LLVM_IntegerOverflowFlagsAttr, "{}">:$overflowFlags);
@@ -143,9 +143,9 @@ class LLVM_ArithmeticCmpOp<string mnemonic, list<Trait> traits = []> :
// Other integer operations.
def LLVM_ICmpOp : LLVM_ArithmeticCmpOp<"icmp", [Pure]> {
let arguments = (ins ICmpPredicate:$predicate,
- AnyTypeOf<[LLVM_ScalarOrVectorOf<AnyInteger>,
+ AnyTypeOf<[LLVM_ScalarOrVectorOf<AnySignlessInteger>,
LLVM_ScalarOrVectorOf<LLVM_AnyPointer>]>:$lhs,
- AnyTypeOf<[LLVM_ScalarOrVectorOf<AnyInteger>,
+ AnyTypeOf<[LLVM_ScalarOrVectorOf<AnySignlessInteger>,
LLVM_ScalarOrVectorOf<LLVM_AnyPointer>]>:$rhs);
let hasCustomAssemblyFormat = 1;
string llvmInstName = "ICmp";
@@ -204,7 +204,7 @@ def LLVM_AllocaOp : LLVM_Op<"alloca",
DeclareOpInterfaceMethods<DestructurableAllocationOpInterface>,
DeclareOpInterfaceMethods<GetResultPtrElementType>]>,
LLVM_MemOpPatterns {
- let arguments = (ins AnyInteger:$arraySize,
+ let arguments = (ins AnySignlessInteger:$arraySize,
OptionalAttr<I64Attr>:$alignment,
TypeAttr:$elem_type,
UnitAttr:$inalloca);
@@ -250,7 +250,7 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
DeclareOpInterfaceMethods<DestructurableAccessorOpInterface>,
DeclareOpInterfaceMethods<GetResultPtrElementType>]> {
let arguments = (ins LLVM_ScalarOrVectorOf<LLVM_AnyPointer>:$base,
- Variadic<LLVM_ScalarOrVectorOf<AnyInteger>>:$dynamicIndices,
+ Variadic<LLVM_ScalarOrVectorOf<AnySignlessInteger>>:$dynamicIndices,
DenseI32ArrayAttr:$rawConstantIndices,
TypeAttr:$elem_type,
UnitAttr:$inbounds);
@@ -499,37 +499,37 @@ def LLVM_AddrSpaceCastOp : LLVM_CastOp<"addrspacecast", "AddrSpaceCast",
let hasFolder = 1;
}
def LLVM_IntToPtrOp : LLVM_CastOp<"inttoptr", "IntToPtr",
- LLVM_ScalarOrVectorOf<AnyInteger>,
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>,
LLVM_ScalarOrVectorOf<LLVM_AnyPointer>>;
def LLVM_PtrToIntOp : LLVM_CastOp<"ptrtoint", "PtrToInt",
LLVM_ScalarOrVectorOf<LLVM_AnyPointer>,
- LLVM_ScalarOrVectorOf<AnyInteger>>;
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>>;
def LLVM_SExtOp : LLVM_CastOp<"sext", "SExt",
- LLVM_ScalarOrVectorOf<AnyInteger>,
- LLVM_ScalarOrVectorOf<AnyInteger>> {
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>,
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>> {
let hasVerifier = 1;
}
def LLVM_ZExtOp : LLVM_CastOp<"zext", "ZExt",
- LLVM_ScalarOrVectorOf<AnyInteger>,
- LLVM_ScalarOrVectorOf<AnyInteger>> {
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>,
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>> {
let hasFolder = 1;
let hasVerifier = 1;
}
def LLVM_TruncOp : LLVM_CastOp<"trunc", "Trunc",
- LLVM_ScalarOrVectorOf<AnyInteger>,
- LLVM_ScalarOrVectorOf<AnyInteger>>;
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>,
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>>;
def LLVM_SIToFPOp : LLVM_CastOp<"sitofp", "SIToFP",
- LLVM_ScalarOrVectorOf<AnyInteger>,
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>,
LLVM_ScalarOrVectorOf<LLVM_AnyFloat>>;
def LLVM_UIToFPOp : LLVM_CastOp<"uitofp", "UIToFP",
- LLVM_ScalarOrVectorOf<AnyInteger>,
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>,
LLVM_ScalarOrVectorOf<LLVM_AnyFloat>>;
def LLVM_FPToSIOp : LLVM_CastOp<"fptosi", "FPToSI",
LLVM_ScalarOrVectorOf<LLVM_AnyFloat>,
- LLVM_ScalarOrVectorOf<AnyInteger>>;
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>>;
def LLVM_FPToUIOp : LLVM_CastOp<"fptoui", "FPToUI",
LLVM_ScalarOrVectorOf<LLVM_AnyFloat>,
- LLVM_ScalarOrVectorOf<AnyInteger>>;
+ LLVM_ScalarOrVectorOf<AnySignlessInteger>>;
def LLVM_FPExtOp : LLVM_CastOp<"fpext", "FPExt",
LLVM_ScalarOrVectorOf<LLVM_AnyFloat>,
LLVM_ScalarOrVectorOf<LLVM_AnyFloat>>;
@@ -671,7 +671,7 @@ def LLVM_ExtractElementOp : LLVM_Op<"extractelement", [Pure,
"LLVM::getVectorElementType($_self)">]> {
let summary = "Extract an element from an LLVM vector.";
- let arguments = (ins LLVM_AnyVector:$vector, AnyInteger:$position);
+ let arguments = (ins LLVM_AnyVector:$vector, AnySignlessInteger:$position);
let results = (outs LLVM_Type:$res);
let assemblyFormat = [{
@@ -733,7 +733,7 @@ def LLVM_InsertElementOp : LLVM_Op<"insertelement", [Pure,
let summary = "Insert an element into an LLVM vector.";
let arguments = (ins LLVM_AnyVector:$vector, LLVM_PrimitiveType:$value,
- AnyInteger:$position);
+ AnySignlessInteger:$position);
let results = (outs LLVM_AnyVector:$res);
let builders = [LLVM_OneResultOpBuilder];
@@ -971,7 +971,7 @@ def LLVM_SwitchOp : LLVM_TerminatorOp<"switch",
DeclareOpInterfaceMethods<BranchWeightOpInterface>,
Pure]> {
let arguments = (ins
- AnyInteger:$value,
+ AnySignlessInteger:$value,
Variadic<AnyType>:$defaultOperands,
VariadicOfVariadic<AnyType, "case_operand_segments">:$caseOperands,
OptionalAttr<AnyIntElementsAttr>:$case_values,
@@ -1647,7 +1647,7 @@ def LLVM_ConstantOp
// Atomic operations.
//
-def LLVM_AtomicRMWType : AnyTypeOf<[LLVM_AnyFloat, LLVM_AnyPointer, AnyInteger]>;
+def LLVM_AtomicRMWType : AnyTypeOf<[LLVM_AnyFloat, LLVM_AnyPointer, AnySignlessInteger]>;
def LLVM_AtomicRMWOp : LLVM_MemAccessOpBase<"atomicrmw", [
TypesMatchWith<"result #0 and operand #1 have the same type",
@@ -1696,7 +1696,7 @@ def LLVM_AtomicRMWOp : LLVM_MemAccessOpBase<"atomicrmw", [
let hasVerifier = 1;
}
-def LLVM_AtomicCmpXchgType : AnyTypeOf<[AnyInteger, LLVM_AnyPointer]>;
+def LLVM_AtomicCmpXchgType : AnyTypeOf<[AnySignlessInteger, LLVM_AnyPointer]>;
def LLVM_AtomicCmpXchgOp : LLVM_MemAccessOpBase<"cmpxchg", [
TypesMatchWith<"operand #1 and operand #2 have the same type",
``````````
</details>
https://github.com/llvm/llvm-project/pull/82694
More information about the Mlir-commits
mailing list