[PATCH] D76159: [mlir][LLVMIR] Add a support for boolean type arguments conversion
Ahmed S. Taei via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 13 14:01:32 PDT 2020
asaadaldien created this revision.
asaadaldien added reviewers: nicolasvasilache, rriddle.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, burmako, jpienaar, mehdi_amini.
Herald added a project: LLVM.
Otherwise this will fail translating ops with boolean arguments and
added test will fail.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76159
Files:
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Target/llvmir.mlir
Index: mlir/test/Target/llvmir.mlir
===================================================================
--- mlir/test/Target/llvmir.mlir
+++ mlir/test/Target/llvmir.mlir
@@ -1177,7 +1177,16 @@
// CHECK: freeze i32 %{{[0-9]+}}
%0 = llvm.freeze %x : !llvm.i32
%1 = llvm.mlir.undef : !llvm.i32
- // CHECK: freeze i32 undef
+ // CHECK: freeze i32 undef
%2 = llvm.freeze %1 : !llvm.i32
llvm.return
-}
\ No newline at end of file
+}
+
+// CHECK-LABEL: @boolConstArg
+llvm.func @boolConstArg() -> !llvm.i1 {
+ // CHECK: ret i1 false
+ %0 = llvm.mlir.constant(true) : !llvm.i1
+ %1 = llvm.mlir.constant(false) : !llvm.i1
+ %2 = llvm.and %0, %1 : !llvm.i1
+ llvm.return %2 : !llvm.i1
+}
Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===================================================================
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -94,6 +94,8 @@
}
if (auto intAttr = attr.dyn_cast<IntegerAttr>())
return llvm::ConstantInt::get(llvmType, intAttr.getValue());
+ if (auto boolAttr = attr.dyn_cast<BoolAttr>())
+ return llvm::ConstantInt::get(llvmType, boolAttr.getValue());
if (auto floatAttr = attr.dyn_cast<FloatAttr>())
return llvm::ConstantFP::get(llvmType, floatAttr.getValue());
if (auto funcAttr = attr.dyn_cast<FlatSymbolRefAttr>())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76159.250294.patch
Type: text/x-patch
Size: 1355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200313/57d37832/attachment-0001.bin>
More information about the llvm-commits
mailing list