From b9ff2dd87edef4a750f2caccbd4923500f3d8405 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Fri, 9 Aug 2019 08:30:13 -0700 Subject: 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 --- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mlir/lib/Target/LLVMIR/ModuleTranslation.cpp') 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::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, -- cgit v1.2.3