[Mlir-commits] [mlir] ce82037 - [mlir] Support convert token type from LLVM IR.
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jun 1 20:33:19 PDT 2022
Author: jacquesguan
Date: 2022-06-02T03:32:51Z
New Revision: ce820375efc04a4290f568ac0ba7a74486f598ad
URL: https://github.com/llvm/llvm-project/commit/ce820375efc04a4290f568ac0ba7a74486f598ad
DIFF: https://github.com/llvm/llvm-project/commit/ce820375efc04a4290f568ac0ba7a74486f598ad.diff
LOG: [mlir] Support convert token type from LLVM IR.
This patch supports the token type for converting from LLVM IR.
Differential Revision: https://reviews.llvm.org/D126756
Added:
Modified:
mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
mlir/test/Target/LLVMIR/Import/intrinsic.ll
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp b/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
index 07de408da7a31..6beb8eda4c90d 100644
--- a/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
+++ b/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
@@ -71,6 +71,8 @@ class TypeFromLLVMIRTranslatorImpl {
return LLVM::LLVMLabelType::get(&context);
if (type->isMetadataTy())
return LLVM::LLVMMetadataType::get(&context);
+ if (type->isTokenTy())
+ return LLVM::LLVMTokenType::get(&context);
llvm_unreachable("not a primitive type");
}
diff --git a/mlir/test/Target/LLVMIR/Import/intrinsic.ll b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
index 82b3bc6baa8dd..2fa1283ef2ca0 100644
--- a/mlir/test/Target/LLVMIR/Import/intrinsic.ll
+++ b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
@@ -385,18 +385,21 @@ define void @umul_with_overflow_test(i32 %0, i32 %1, <8 x i32> %2, <8 x i32> %3)
ret void
}
-; TODO : support token type.
-; define void @coro_id(i32 %0, i8* %1) {
-; %3 = call token @llvm.coro.id(i32 %0, i8* %1, i8* %1, i8* null)
-; ret void
-; }
-
-; TODO : support token type.
-; define void @coro_begin(i32 %0, i8* %1) {
-; %3 = call token @llvm.coro.id(i32 %0, i8* %1, i8* %1, i8* null)
-; %4 = call i8* @llvm.coro.begin(token %3, i8* %1)
-; ret void
-; }
+; CHECK-LABEL: llvm.func @coro_id
+define void @coro_id(i32 %0, i8* %1) {
+ ; CHECK: llvm.intr.coro.id %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}} : !llvm.token
+ %3 = call token @llvm.coro.id(i32 %0, i8* %1, i8* %1, i8* null)
+ ret void
+}
+
+; CHECK-LABEL: llvm.func @coro_begin
+define void @coro_begin(i32 %0, i8* %1) {
+ ; CHECK: llvm.intr.coro.id %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}} : !llvm.token
+ %3 = call token @llvm.coro.id(i32 %0, i8* %1, i8* %1, i8* null)
+ ; CHECK: llvm.intr.coro.begin %{{.*}}, %{{.*}} : !llvm.ptr<i8>
+ %4 = call i8* @llvm.coro.begin(token %3, i8* %1)
+ ret void
+}
; CHECK-LABEL: llvm.func @coro_size()
define void @coro_size() {
@@ -415,18 +418,21 @@ define void @coro_align() {
ret void
}
-; TODO : support token type.
-; define void @coro_save(i8* %0) {
-; %2 = call token @llvm.coro.save(i8* %0)
-; ret void
-; }
+; CHECK-LABEL: llvm.func @coro_save
+define void @coro_save(i8* %0) {
+ ; CHECK: llvm.intr.coro.save %{{.*}} : !llvm.token
+ %2 = call token @llvm.coro.save(i8* %0)
+ ret void
+}
-; TODO : support token type.
-; define void @coro_suspend(i32 %0, i1 %1, i8* %2) {
-; %4 = call token @llvm.coro.id(i32 %0, i8* %2, i8* %2, i8* null)
-; %5 = call i8 @llvm.coro.suspend(token %4, i1 %1)
-; ret void
-; }
+; CHECK-LABEL: llvm.func @coro_suspend
+define void @coro_suspend(i32 %0, i1 %1, i8* %2) {
+ ; CHECK: llvm.intr.coro.id %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}} : !llvm.token
+ %4 = call token @llvm.coro.id(i32 %0, i8* %2, i8* %2, i8* null)
+ ; CHECK: llvm.intr.coro.suspend %{{.*}}, %{{.*}} : i8
+ %5 = call i8 @llvm.coro.suspend(token %4, i1 %1)
+ ret void
+}
; CHECK-LABEL: llvm.func @coro_end
define void @coro_end(i8* %0, i1 %1) {
@@ -435,12 +441,14 @@ define void @coro_end(i8* %0, i1 %1) {
ret void
}
-; TODO : support token type.
-; define void @coro_free(i32 %0, i8* %1) {
-; %3 = call token @llvm.coro.id(i32 %0, i8* %1, i8* %1, i8* null)
-; %4 = call i8* @llvm.coro.free(token %3, i8* %1)
-; ret void
-; }
+; CHECK-LABEL: llvm.func @coro_free
+define void @coro_free(i32 %0, i8* %1) {
+ ; CHECK: llvm.intr.coro.id %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}} : !llvm.token
+ %3 = call token @llvm.coro.id(i32 %0, i8* %1, i8* %1, i8* null)
+ ; CHECK: llvm.intr.coro.free %{{.*}}, %{{.*}} : !llvm.ptr<i8>
+ %4 = call i8* @llvm.coro.free(token %3, i8* %1)
+ ret void
+}
; CHECK-LABEL: llvm.func @coro_resume
define void @coro_resume(i8* %0) {
@@ -664,16 +672,16 @@ declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32)
declare { <8 x i32>, <8 x i1> } @llvm.smul.with.overflow.v8i32(<8 x i32>, <8 x i32>)
declare { i32, i1 } @llvm.umul.with.overflow.i32(i32, i32)
declare { <8 x i32>, <8 x i1> } @llvm.umul.with.overflow.v8i32(<8 x i32>, <8 x i32>)
-; declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*)
-; declare i8* @llvm.coro.begin(token, i8* writeonly)
+declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*)
+declare i8* @llvm.coro.begin(token, i8* writeonly)
declare i64 @llvm.coro.size.i64()
declare i32 @llvm.coro.size.i32()
declare i64 @llvm.coro.align.i64()
declare i32 @llvm.coro.align.i32()
-; declare token @llvm.coro.save(i8*)
-; declare i8 @llvm.coro.suspend(token, i1)
+declare token @llvm.coro.save(i8*)
+declare i8 @llvm.coro.suspend(token, i1)
declare i1 @llvm.coro.end(i8*, i1)
-; declare i8* @llvm.coro.free(token, i8* nocapture readonly)
+declare i8* @llvm.coro.free(token, i8* nocapture readonly)
declare void @llvm.coro.resume(i8*)
declare i32 @llvm.eh.typeid.for(i8*)
declare i8* @llvm.stacksave()
More information about the Mlir-commits
mailing list