summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Support
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2019-10-10 01:33:33 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-10-10 01:34:06 -0700
commit5e7959a3531c8019052bae3a84a42a67c5857bc9 (patch)
tree1eb248dba17a3c4bfd2f9c815865254681ca78c8 /mlir/lib/Support
parent309b4556d00f531988f34930eedb546512ee619f (diff)
downloadbcm5719-llvm-5e7959a3531c8019052bae3a84a42a67c5857bc9.tar.gz
bcm5719-llvm-5e7959a3531c8019052bae3a84a42a67c5857bc9.zip
Use llvm.func to define functions with wrapped LLVM IR function type
This function-like operation allows one to define functions that have wrapped LLVM IR function type, in particular variadic functions. The operation was added in parallel to the existing lowering flow, this commit only switches the flow to use it. Using a custom function type makes the LLVM IR dialect type system more consistent and avoids complex conversion rules for functions that previously had to use the built-in function type instead of a wrapped LLVM IR dialect type and perform conversions during the analysis. PiperOrigin-RevId: 273910855
Diffstat (limited to 'mlir/lib/Support')
-rw-r--r--mlir/lib/Support/JitRunner.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/mlir/lib/Support/JitRunner.cpp b/mlir/lib/Support/JitRunner.cpp
index 372e69f8855..c877daed2c5 100644
--- a/mlir/lib/Support/JitRunner.cpp
+++ b/mlir/lib/Support/JitRunner.cpp
@@ -177,7 +177,7 @@ compileAndExecute(ModuleOp module, StringRef entryPoint,
static Error compileAndExecuteVoidFunction(
ModuleOp module, StringRef entryPoint,
std::function<llvm::Error(llvm::Module *)> transformer) {
- FuncOp mainFunction = module.lookupSymbol<FuncOp>(entryPoint);
+ auto mainFunction = module.lookupSymbol<LLVM::LLVMFuncOp>(entryPoint);
if (!mainFunction || mainFunction.getBlocks().empty())
return make_string_error("entry point not found");
void *empty = nullptr;
@@ -187,22 +187,14 @@ static Error compileAndExecuteVoidFunction(
static Error compileAndExecuteSingleFloatReturnFunction(
ModuleOp module, StringRef entryPoint,
std::function<llvm::Error(llvm::Module *)> transformer) {
- FuncOp mainFunction = module.lookupSymbol<FuncOp>(entryPoint);
- if (!mainFunction || mainFunction.isExternal()) {
+ auto mainFunction = module.lookupSymbol<LLVM::LLVMFuncOp>(entryPoint);
+ if (!mainFunction || mainFunction.isExternal())
return make_string_error("entry point not found");
- }
- if (!mainFunction.getType().getInputs().empty())
+ if (mainFunction.getType().getFunctionNumParams() != 0)
return make_string_error("function inputs not supported");
- if (mainFunction.getType().getResults().size() != 1)
- return make_string_error("only single f32 function result supported");
-
- auto t = mainFunction.getType().getResults()[0].dyn_cast<LLVM::LLVMType>();
- if (!t)
- return make_string_error("only single llvm.f32 function result supported");
- auto *llvmTy = t.getUnderlyingType();
- if (llvmTy != llvmTy->getFloatTy(llvmTy->getContext()))
+ if (!mainFunction.getType().getFunctionResultType().isFloatTy())
return make_string_error("only single llvm.f32 function result supported");
float res;
OpenPOWER on IntegriCloud