[Mlir-commits] [mlir] 9cb421c - [mlir][llvm] Define annotation intrinsics
Victor Perez
llvmlistbot at llvm.org
Tue Jul 11 06:37:22 PDT 2023
Author: Victor Perez
Date: 2023-07-11T14:37:11+01:00
New Revision: 9cb421cdea022c60d66216520094a87596a8aec7
URL: https://github.com/llvm/llvm-project/commit/9cb421cdea022c60d66216520094a87596a8aec7
DIFF: https://github.com/llvm/llvm-project/commit/9cb421cdea022c60d66216520094a87596a8aec7.diff
LOG: [mlir][llvm] Define annotation intrinsics
Define `llvm.intr.var.annotation`, `llvm.intr.ptr.annotation` and
`llvm.intr.annotation` in the llvm dialect as `llvm.var.annotation`,
`llvm.ptr.annotation` and `llvm.annotation` counterparts.
Signed-off-by: Victor Perez <victor.perez at codeplay.com>
Differential Revision: https://reviews.llvm.org/D154842
Added:
Modified:
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/test/Target/LLVMIR/Import/intrinsic.ll
mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
index 66edaab2ad5d47..010ffb9eccb1bc 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -934,6 +934,43 @@ def LLVM_masked_compressstore
let arguments = (ins LLVM_AnyVector, LLVM_AnyPointer, LLVM_VectorOf<I1>);
}
+//
+// Annotate intrinsics.
+//
+
+def LLVM_VarAnnotation
+ : LLVM_ZeroResultIntrOp<"var.annotation", [0, 1],
+ [AllTypesMatch<["annotation", "fileName", "attr"]>]> {
+ let arguments = (ins LLVM_AnyPointer:$val,
+ LLVM_AnyPointer:$annotation,
+ LLVM_AnyPointer:$fileName,
+ I32:$line,
+ LLVM_AnyPointer:$attr);
+}
+
+def LLVM_PtrAnnotation
+ : LLVM_OneResultIntrOp<"ptr.annotation", [0], [2],
+ [AllTypesMatch<["res", "ptr"]>,
+ AllTypesMatch<["annotation", "fileName", "attr"]>]> {
+ let arguments = (ins LLVM_PointerTo<AnySignlessInteger>:$ptr,
+ LLVM_AnyPointer:$annotation,
+ LLVM_AnyPointer:$fileName,
+ I32:$line,
+ LLVM_AnyPointer:$attr);
+ let results = (outs LLVM_PointerTo<AnySignlessInteger>:$res);
+}
+
+def LLVM_Annotation
+ : LLVM_OneResultIntrOp<"annotation", [0], [2],
+ [AllTypesMatch<["res", "integer"]>,
+ AllTypesMatch<["annotation", "fileName"]>]> {
+ let arguments = (ins AnySignlessInteger:$integer,
+ LLVM_AnyPointer:$annotation,
+ LLVM_AnyPointer:$fileName,
+ I32:$line);
+ let results = (outs AnySignlessInteger:$res);
+}
+
//
// Trap intrinsics.
//
diff --git a/mlir/test/Target/LLVMIR/Import/intrinsic.ll b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
index 5c8777e0c77df7..34f0b5a96ed658 100644
--- a/mlir/test/Target/LLVMIR/Import/intrinsic.ll
+++ b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
@@ -436,6 +436,17 @@ define void @masked_expand_compress_intrinsics(ptr %0, <7 x i1> %1, <7 x float>
ret void
}
+; CHECK-LABEL: llvm.func @annotate_intrinsics
+define void @annotate_intrinsics(ptr %var, ptr %ptr, i16 %int, ptr %annotation, ptr %fileName, i32 %line, ptr %args) {
+ ; CHECK: "llvm.intr.var.annotation"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32, !llvm.ptr) -> ()
+ call void @llvm.var.annotation.p0.p0(ptr %var, ptr %annotation, ptr %fileName, i32 %line, ptr %args)
+ ; CHECK: %{{.*}} = "llvm.intr.ptr.annotation"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32, !llvm.ptr) -> !llvm.ptr
+ %1 = call ptr @llvm.ptr.annotation.p0.p0(ptr %ptr, ptr %annotation, ptr %fileName, i32 %line, ptr %args)
+ ; CHECK: %{{.*}} = "llvm.intr.annotation"(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) : (i16, !llvm.ptr, !llvm.ptr, i32) -> i16
+ %2 = call i16 @llvm.annotation.i16.p0(i16 %int, ptr %annotation, ptr %fileName, i32 %line)
+ ret void
+}
+
; CHECK-LABEL: llvm.func @trap_intrinsics
define void @trap_intrinsics() {
; CHECK: "llvm.intr.trap"() : () -> ()
@@ -946,6 +957,9 @@ declare <7 x float> @llvm.masked.gather.v7f32.v7p0(<7 x ptr>, i32 immarg, <7 x i
declare void @llvm.masked.scatter.v7f32.v7p0(<7 x float>, <7 x ptr>, i32 immarg, <7 x i1>)
declare <7 x float> @llvm.masked.expandload.v7f32(ptr, <7 x i1>, <7 x float>)
declare void @llvm.masked.compressstore.v7f32(<7 x float>, ptr, <7 x i1>)
+declare void @llvm.var.annotation.p0.p0(ptr, ptr, ptr, i32, ptr)
+declare ptr @llvm.ptr.annotation.p0.p0(ptr, ptr, ptr, i32, ptr)
+declare i16 @llvm.annotation.i16.p0(i16, ptr, ptr, i32)
declare void @llvm.trap()
declare void @llvm.debugtrap()
declare void @llvm.ubsantrap(i8 immarg)
diff --git a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
index 6d8d078d8d4ee8..674e8637134832 100644
--- a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
@@ -447,6 +447,17 @@ llvm.func @masked_expand_compress_intrinsics(%ptr: !llvm.ptr<f32>, %mask: vector
llvm.return
}
+// CHECK-LABEL: @annotate_intrinsics
+llvm.func @annotate_intrinsics(%var: !llvm.ptr, %int: i16, %ptr: !llvm.ptr, %annotation: !llvm.ptr, %fileName: !llvm.ptr, %line: i32, %attr: !llvm.ptr) {
+ // CHECK: call void @llvm.var.annotation.p0.p0(ptr %{{.*}}, ptr %{{.*}}, ptr %{{.*}}, i32 %{{.*}}, ptr %{{.*}})
+ "llvm.intr.var.annotation"(%var, %annotation, %fileName, %line, %attr) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32, !llvm.ptr) -> ()
+ // CHECK: call ptr @llvm.ptr.annotation.p0.p0(ptr %{{.*}}, ptr %{{.*}}, ptr %{{.*}}, i32 %{{.*}}, ptr %{{.*}})
+ %res0 = "llvm.intr.ptr.annotation"(%ptr, %annotation, %fileName, %line, %attr) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32, !llvm.ptr) -> (!llvm.ptr)
+ // CHECK: call i16 @llvm.annotation.i16.p0(i16 %{{.*}}, ptr %{{.*}}, ptr %{{.*}}, i32 %{{.*}})
+ %res1 = "llvm.intr.annotation"(%int, %annotation, %fileName, %line) : (i16, !llvm.ptr, !llvm.ptr, i32) -> (i16)
+ llvm.return
+}
+
// CHECK-LABEL: @trap_intrinsics
llvm.func @trap_intrinsics() {
// CHECK: call void @llvm.trap()
@@ -976,6 +987,9 @@ llvm.func @lifetime(%p: !llvm.ptr) {
// CHECK-DAG: declare void @llvm.masked.scatter.v7f32.v7p0(<7 x float>, <7 x ptr>, i32 immarg, <7 x i1>)
// CHECK-DAG: declare <7 x float> @llvm.masked.expandload.v7f32(ptr nocapture, <7 x i1>, <7 x float>)
// CHECK-DAG: declare void @llvm.masked.compressstore.v7f32(<7 x float>, ptr nocapture, <7 x i1>)
+// CHECK-DAG: declare void @llvm.var.annotation.p0.p0(ptr, ptr, ptr, i32, ptr)
+// CHECK-DAG: declare ptr @llvm.ptr.annotation.p0.p0(ptr, ptr, ptr, i32, ptr)
+// CHECK-DAG: declare i16 @llvm.annotation.i16.p0(i16, ptr, ptr, i32)
// CHECK-DAG: declare void @llvm.trap()
// CHECK-DAG: declare void @llvm.debugtrap()
// CHECK-DAG: declare void @llvm.ubsantrap(i8 immarg)
More information about the Mlir-commits
mailing list