提交 977f213e 编写于 作者: A A. Unique TensorFlower 提交者: TensorFlower Gardener

Translation to LLVM: support llvm.global

Add support for translating recently introduced llvm.global operations to
global variables in the LLVM IR proper.

PiperOrigin-RevId: 262564700
上级 5a174fe8
......@@ -54,6 +54,7 @@ public:
T translator(m);
translator.llvmModule = std::move(llvmModule);
translator.convertGlobals();
if (translator.convertFunctions())
return nullptr;
......@@ -72,6 +73,7 @@ protected:
private:
bool convertFunctions();
void convertGlobals();
bool convertOneFunction(FuncOp func);
void connectPHINodes(FuncOp func);
bool convertBlock(Block &bb, bool ignoreArguments);
......
......@@ -289,6 +289,16 @@ bool ModuleTranslation::convertBlock(Block &bb, bool ignoreArguments) {
return false;
}
// Create named global variables that correspond to llvm.global definitions.
void ModuleTranslation::convertGlobals() {
for (auto op : mlirModule.getOps<LLVM::GlobalOp>()) {
llvm::Type *type = op.getType().getUnderlyingType();
new llvm::GlobalVariable(
*llvmModule, type, op.constant(), llvm::GlobalValue::InternalLinkage,
getLLVMConstant(type, op.value(), op.getLoc()), op.sym_name());
}
}
// Get the SSA value passed to the current block from the terminator operation
// of its predecessor.
static Value *getPHISourceValue(Block *current, Block *pred,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册