mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
IRBuilder: Allow globals to be constructed in a specific address space
llvm-svn: 240113
This commit is contained in:
parent
0b2dfae3ba
commit
fc7285d7eb
@ -245,7 +245,8 @@ public:
|
|||||||
/// filled in with the null terminated string value specified. The new global
|
/// filled in with the null terminated string value specified. The new global
|
||||||
/// variable will be marked mergable with any others of the same contents. If
|
/// variable will be marked mergable with any others of the same contents. If
|
||||||
/// Name is specified, it is the name of the global variable created.
|
/// Name is specified, it is the name of the global variable created.
|
||||||
GlobalVariable *CreateGlobalString(StringRef Str, const Twine &Name = "");
|
GlobalVariable *CreateGlobalString(StringRef Str, const Twine &Name = "",
|
||||||
|
unsigned AddressSpace = 0);
|
||||||
|
|
||||||
/// \brief Get a constant value representing either true or false.
|
/// \brief Get a constant value representing either true or false.
|
||||||
ConstantInt *getInt1(bool V) {
|
ConstantInt *getInt1(bool V) {
|
||||||
@ -1191,8 +1192,9 @@ public:
|
|||||||
|
|
||||||
/// \brief Same as CreateGlobalString, but return a pointer with "i8*" type
|
/// \brief Same as CreateGlobalString, but return a pointer with "i8*" type
|
||||||
/// instead of a pointer to array of i8.
|
/// instead of a pointer to array of i8.
|
||||||
Value *CreateGlobalStringPtr(StringRef Str, const Twine &Name = "") {
|
Value *CreateGlobalStringPtr(StringRef Str, const Twine &Name = "",
|
||||||
GlobalVariable *gv = CreateGlobalString(Str, Name);
|
unsigned AddressSpace = 0) {
|
||||||
|
GlobalVariable *gv = CreateGlobalString(Str, Name, AddressSpace);
|
||||||
Value *zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
|
Value *zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
|
||||||
Value *Args[] = { zero, zero };
|
Value *Args[] = { zero, zero };
|
||||||
return CreateInBoundsGEP(gv->getValueType(), gv, Args, Name);
|
return CreateInBoundsGEP(gv->getValueType(), gv, Args, Name);
|
||||||
|
@ -25,13 +25,15 @@ using namespace llvm;
|
|||||||
/// specified. If Name is specified, it is the name of the global variable
|
/// specified. If Name is specified, it is the name of the global variable
|
||||||
/// created.
|
/// created.
|
||||||
GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str,
|
GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str,
|
||||||
const Twine &Name) {
|
const Twine &Name,
|
||||||
|
unsigned AddressSpace) {
|
||||||
Constant *StrConstant = ConstantDataArray::getString(Context, Str);
|
Constant *StrConstant = ConstantDataArray::getString(Context, Str);
|
||||||
Module &M = *BB->getParent()->getParent();
|
Module &M = *BB->getParent()->getParent();
|
||||||
GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
|
GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
|
||||||
true, GlobalValue::PrivateLinkage,
|
true, GlobalValue::PrivateLinkage,
|
||||||
StrConstant);
|
StrConstant, Name, nullptr,
|
||||||
GV->setName(Name);
|
GlobalVariable::NotThreadLocal,
|
||||||
|
AddressSpace);
|
||||||
GV->setUnnamedAddr(true);
|
GV->setUnnamedAddr(true);
|
||||||
return GV;
|
return GV;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user