summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2019-08-09 08:30:13 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-08-09 08:30:42 -0700
commitb9ff2dd87edef4a750f2caccbd4923500f3d8405 (patch)
tree074b1a6fc2f2e29185c37f2728ec22aa8c516aa8 /mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
parent59b473c231f6295bd4aa7199da5816caae5a5e3a (diff)
downloadbcm5719-llvm-b9ff2dd87edef4a750f2caccbd4923500f3d8405.tar.gz
bcm5719-llvm-b9ff2dd87edef4a750f2caccbd4923500f3d8405.zip
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
Diffstat (limited to 'mlir/lib/Target/LLVMIR/ModuleTranslation.cpp')
-rw-r--r--mlir/lib/Target/LLVMIR/ModuleTranslation.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 08255b47f9f..bf43848c9ef 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -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,
OpenPOWER on IntegriCloud