Add address space attribute to LLVMIR's GlobalOp.
PiperOrigin-RevId: 270012505
This commit is contained in:
parent
866724d7cf
commit
9d1bb322c8
@ -487,7 +487,8 @@ def LLVM_AddressOfOp
|
|||||||
def LLVM_GlobalOp
|
def LLVM_GlobalOp
|
||||||
: LLVM_ZeroResultOp<"mlir.global">,
|
: LLVM_ZeroResultOp<"mlir.global">,
|
||||||
Arguments<(ins TypeAttr:$type, UnitAttr:$constant, StrAttr:$sym_name,
|
Arguments<(ins TypeAttr:$type, UnitAttr:$constant, StrAttr:$sym_name,
|
||||||
AnyAttr:$value)> {
|
AnyAttr:$value,
|
||||||
|
DefaultValuedAttr<NonNegativeI32Attr, "0">:$addr_space)> {
|
||||||
|
|
||||||
let builders = [
|
let builders = [
|
||||||
OpBuilder<"Builder *builder, OperationState *result, LLVMType type, "
|
OpBuilder<"Builder *builder, OperationState *result, LLVMType type, "
|
||||||
|
@ -326,9 +326,12 @@ void ModuleTranslation::convertGlobals() {
|
|||||||
cst = getLLVMConstant(type, op.value(), op.getLoc());
|
cst = getLLVMConstant(type, op.value(), op.getLoc());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *var = new llvm::GlobalVariable(*llvmModule, type, op.constant(),
|
auto addrSpace = op.addr_space().getLimitedValue();
|
||||||
llvm::GlobalValue::InternalLinkage,
|
auto *var = new llvm::GlobalVariable(
|
||||||
cst, op.sym_name());
|
*llvmModule, type, op.constant(), llvm::GlobalValue::InternalLinkage,
|
||||||
|
cst, op.sym_name(), /*InsertBefore=*/nullptr,
|
||||||
|
llvm::GlobalValue::NotThreadLocal, addrSpace);
|
||||||
|
|
||||||
globalsMapping.try_emplace(op, var);
|
globalsMapping.try_emplace(op, var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user