Skip to content

Commit

Permalink
LLVMFuncOp: implement addEntryBlock
Browse files Browse the repository at this point in the history
This function has been declared as a part of the LLVMFuncOp interface but never
implemented.

Closes tensorflow/mlir#325.

PiperOrigin-RevId: 286439619
  • Loading branch information
ftynse authored and tensorflower-gardener committed Dec 19, 2019
1 parent 15f800f commit 1bcd8ef
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
Expand Up @@ -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<NamedAttribute> attrs,
Expand Down

0 comments on commit 1bcd8ef

Please sign in to comment.