From: Alex Zinenko Date: Thu, 19 Dec 2019 20:16:19 +0000 (-0800) Subject: LLVMFuncOp: implement addEntryBlock X-Git-Tag: llvmorg-11-init~1466^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1bcd8ef32f8104cc4bbe9e7003cf8a23c51ae24f;p=platform%2Fupstream%2Fllvm.git LLVMFuncOp: implement addEntryBlock This function has been declared as a part of the LLVMFuncOp interface but never implemented. Closes tensorflow/mlir#325. PiperOrigin-RevId: 286439619 --- diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index abbc4e0..1813b30 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -1115,9 +1115,23 @@ static ParseResult parseShuffleVectorOp(OpAsmParser &parser, } //===----------------------------------------------------------------------===// -// Builder, printer and verifier for LLVM::LLVMFuncOp. +// Implementations for LLVM::LLVMFuncOp. //===----------------------------------------------------------------------===// +// Add the entry block to the function. +Block *LLVMFuncOp::addEntryBlock() { + assert(empty() && "function already has an entry block"); + assert(!isVarArg() && "unimplemented: non-external variadic functions"); + + auto *entry = new Block; + push_back(entry); + + LLVMType type = getType(); + for (unsigned i = 0, e = type.getFunctionNumParams(); i < e; ++i) + entry->addArgument(type.getFunctionParamType(i)); + return entry; +} + void LLVMFuncOp::build(Builder *builder, OperationState &result, StringRef name, LLVMType type, LLVM::Linkage linkage, ArrayRef attrs,