[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 15:08:09 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG18fc42fa3370: [mlir][LLVMIR] Add a support for boolean type arguments conversion (authored by asaadaldien).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76159/new/
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.250313.patch
Type: text/x-patch
Size: 1355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200313/6f55d909/attachment-0001.bin>
More information about the llvm-commits
mailing list