Add address space attribute to LLVMIR's GlobalOp.

PiperOrigin-RevId: 270012505
This commit is contained in:
Christian Sigg 2019-09-19 04:50:17 -07:00 committed by TensorFlower Gardener
parent 866724d7cf
commit 9d1bb322c8
2 changed files with 8 additions and 4 deletions

View File

@ -487,7 +487,8 @@ def LLVM_AddressOfOp
def LLVM_GlobalOp
: LLVM_ZeroResultOp<"mlir.global">,
Arguments<(ins TypeAttr:$type, UnitAttr:$constant, StrAttr:$sym_name,
AnyAttr:$value)> {
AnyAttr:$value,
DefaultValuedAttr<NonNegativeI32Attr, "0">:$addr_space)> {
let builders = [
OpBuilder<"Builder *builder, OperationState *result, LLVMType type, "

View File

@ -326,9 +326,12 @@ void ModuleTranslation::convertGlobals() {
cst = getLLVMConstant(type, op.value(), op.getLoc());
}
auto *var = new llvm::GlobalVariable(*llvmModule, type, op.constant(),
llvm::GlobalValue::InternalLinkage,
cst, op.sym_name());
auto addrSpace = op.addr_space().getLimitedValue();
auto *var = new llvm::GlobalVariable(
*llvmModule, type, op.constant(), llvm::GlobalValue::InternalLinkage,
cst, op.sym_name(), /*InsertBefore=*/nullptr,
llvm::GlobalValue::NotThreadLocal, addrSpace);
globalsMapping.try_emplace(op, var);
}
}