Skip to content

Commit a111a51

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b9ce185d4e54' from llvm.org/main into next
2 parents fc4faf3 + b9ce185 commit a111a51

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,8 @@ def LLVM_TBAATagArrayAttr
10951095
//===----------------------------------------------------------------------===//
10961096
def LLVM_ConstantRangeAttr : LLVM_Attr<"ConstantRange", "constant_range"> {
10971097
let parameters = (ins
1098-
"::llvm::APInt":$lower,
1099-
"::llvm::APInt":$upper
1098+
APIntParameter<"">:$lower,
1099+
APIntParameter<"">:$upper
11001100
);
11011101
let summary = "A range of two integers, corresponding to LLVM's ConstantRange";
11021102
let description = [{

mlir/include/mlir/IR/AttrTypeBase.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,14 @@ class StringRefParameter<string desc = "", string value = ""> :
383383
let defaultValue = value;
384384
}
385385

386+
// For APInts, which require comparison supporting different bitwidths. The
387+
// default APInt comparison operator asserts when the bitwidths differ, so
388+
// a custom implementation is necessary.
389+
class APIntParameter<string desc> :
390+
AttrOrTypeParameter<"::llvm::APInt", desc> {
391+
let comparator = "$_lhs.getBitWidth() == $_rhs.getBitWidth() && $_lhs == $_rhs";
392+
}
393+
386394
// For APFloats, which require comparison.
387395
class APFloatParameter<string desc> :
388396
AttrOrTypeParameter<"::llvm::APFloat", desc> {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: mlir-opt %s -o - | FileCheck %s
2+
3+
// CHECK: #llvm.constant_range<i32, 0, 12>
4+
llvm.func external @foo1(!llvm.ptr, i64) -> (i32 {llvm.range = #llvm.constant_range<i32, 0, 12>})
5+
// CHECK: #llvm.constant_range<i8, 1, 10>
6+
llvm.func external @foo2(!llvm.ptr, i64) -> (i8 {llvm.range = #llvm.constant_range<i8, 1, 10>})
7+
// CHECK: #llvm.constant_range<i64, 0, 2147483648>
8+
llvm.func external @foo3(!llvm.ptr, i64) -> (i64 {llvm.range = #llvm.constant_range<i64, 0, 2147483648>})
9+
// CHECK: #llvm.constant_range<i32, 1, -2147483648>
10+
llvm.func external @foo4(!llvm.ptr, i64) -> (i32 {llvm.range = #llvm.constant_range<i32, 1, -2147483648>})

0 commit comments

Comments
 (0)