mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Added LLVM Asm/Bitcode Reader/Writer support for new IR keyword externally_initialized.
llvm-svn: 174340
This commit is contained in:
parent
5380cead1a
commit
15a605b34e
@ -463,6 +463,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
|||||||
KEYWORD(hidden);
|
KEYWORD(hidden);
|
||||||
KEYWORD(protected);
|
KEYWORD(protected);
|
||||||
KEYWORD(unnamed_addr);
|
KEYWORD(unnamed_addr);
|
||||||
|
KEYWORD(externally_initialized);
|
||||||
KEYWORD(extern_weak);
|
KEYWORD(extern_weak);
|
||||||
KEYWORD(external);
|
KEYWORD(external);
|
||||||
KEYWORD(thread_local);
|
KEYWORD(thread_local);
|
||||||
|
@ -632,9 +632,11 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
|
|||||||
|
|
||||||
/// ParseGlobal
|
/// ParseGlobal
|
||||||
/// ::= GlobalVar '=' OptionalLinkage OptionalVisibility OptionalThreadLocal
|
/// ::= GlobalVar '=' OptionalLinkage OptionalVisibility OptionalThreadLocal
|
||||||
/// OptionalAddrSpace OptionalUnNammedAddr GlobalType Type Const
|
/// OptionalAddrSpace OptionalUnNammedAddr
|
||||||
|
/// OptionalExternallyInitialized GlobalType Type Const
|
||||||
/// ::= OptionalLinkage OptionalVisibility OptionalThreadLocal
|
/// ::= OptionalLinkage OptionalVisibility OptionalThreadLocal
|
||||||
/// OptionalAddrSpace OptionalUnNammedAddr GlobalType Type Const
|
/// OptionalAddrSpace OptionalUnNammedAddr
|
||||||
|
/// OptionalExternallyInitialized GlobalType Type Const
|
||||||
///
|
///
|
||||||
/// Everything through visibility has been parsed already.
|
/// Everything through visibility has been parsed already.
|
||||||
///
|
///
|
||||||
@ -642,9 +644,10 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
|||||||
unsigned Linkage, bool HasLinkage,
|
unsigned Linkage, bool HasLinkage,
|
||||||
unsigned Visibility) {
|
unsigned Visibility) {
|
||||||
unsigned AddrSpace;
|
unsigned AddrSpace;
|
||||||
bool IsConstant, UnnamedAddr;
|
bool IsConstant, UnnamedAddr, IsExternallyInitialized;
|
||||||
GlobalVariable::ThreadLocalMode TLM;
|
GlobalVariable::ThreadLocalMode TLM;
|
||||||
LocTy UnnamedAddrLoc;
|
LocTy UnnamedAddrLoc;
|
||||||
|
LocTy IsExternallyInitializedLoc;
|
||||||
LocTy TyLoc;
|
LocTy TyLoc;
|
||||||
|
|
||||||
Type *Ty = 0;
|
Type *Ty = 0;
|
||||||
@ -652,6 +655,9 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
|||||||
ParseOptionalAddrSpace(AddrSpace) ||
|
ParseOptionalAddrSpace(AddrSpace) ||
|
||||||
ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
|
ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
|
||||||
&UnnamedAddrLoc) ||
|
&UnnamedAddrLoc) ||
|
||||||
|
ParseOptionalToken(lltok::kw_externally_initialized,
|
||||||
|
IsExternallyInitialized,
|
||||||
|
&IsExternallyInitializedLoc) ||
|
||||||
ParseGlobalType(IsConstant) ||
|
ParseGlobalType(IsConstant) ||
|
||||||
ParseType(Ty, TyLoc))
|
ParseType(Ty, TyLoc))
|
||||||
return true;
|
return true;
|
||||||
@ -709,6 +715,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
|||||||
GV->setConstant(IsConstant);
|
GV->setConstant(IsConstant);
|
||||||
GV->setLinkage((GlobalValue::LinkageTypes)Linkage);
|
GV->setLinkage((GlobalValue::LinkageTypes)Linkage);
|
||||||
GV->setVisibility((GlobalValue::VisibilityTypes)Visibility);
|
GV->setVisibility((GlobalValue::VisibilityTypes)Visibility);
|
||||||
|
GV->setExternallyInitialized(IsExternallyInitialized);
|
||||||
GV->setThreadLocalMode(TLM);
|
GV->setThreadLocalMode(TLM);
|
||||||
GV->setUnnamedAddr(UnnamedAddr);
|
GV->setUnnamedAddr(UnnamedAddr);
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ namespace lltok {
|
|||||||
kw_dllimport, kw_dllexport, kw_common, kw_available_externally,
|
kw_dllimport, kw_dllexport, kw_common, kw_available_externally,
|
||||||
kw_default, kw_hidden, kw_protected,
|
kw_default, kw_hidden, kw_protected,
|
||||||
kw_unnamed_addr,
|
kw_unnamed_addr,
|
||||||
|
kw_externally_initialized,
|
||||||
kw_extern_weak,
|
kw_extern_weak,
|
||||||
kw_external, kw_thread_local,
|
kw_external, kw_thread_local,
|
||||||
kw_localdynamic, kw_initialexec, kw_localexec,
|
kw_localdynamic, kw_initialexec, kw_localexec,
|
||||||
|
@ -1596,9 +1596,13 @@ bool BitcodeReader::ParseModule(bool Resume) {
|
|||||||
if (Record.size() > 8)
|
if (Record.size() > 8)
|
||||||
UnnamedAddr = Record[8];
|
UnnamedAddr = Record[8];
|
||||||
|
|
||||||
|
bool ExternallyInitialized = false;
|
||||||
|
if (Record.size() > 9)
|
||||||
|
ExternallyInitialized = Record[9];
|
||||||
|
|
||||||
GlobalVariable *NewGV =
|
GlobalVariable *NewGV =
|
||||||
new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0,
|
new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0,
|
||||||
TLM, AddressSpace);
|
TLM, AddressSpace, ExternallyInitialized);
|
||||||
NewGV->setAlignment(Alignment);
|
NewGV->setAlignment(Alignment);
|
||||||
if (!Section.empty())
|
if (!Section.empty())
|
||||||
NewGV->setSection(Section);
|
NewGV->setSection(Section);
|
||||||
|
@ -514,10 +514,11 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE,
|
|||||||
Vals.push_back(GV->hasSection() ? SectionMap[GV->getSection()] : 0);
|
Vals.push_back(GV->hasSection() ? SectionMap[GV->getSection()] : 0);
|
||||||
if (GV->isThreadLocal() ||
|
if (GV->isThreadLocal() ||
|
||||||
GV->getVisibility() != GlobalValue::DefaultVisibility ||
|
GV->getVisibility() != GlobalValue::DefaultVisibility ||
|
||||||
GV->hasUnnamedAddr()) {
|
GV->hasUnnamedAddr() || GV->isExternallyInitialized()) {
|
||||||
Vals.push_back(getEncodedVisibility(GV));
|
Vals.push_back(getEncodedVisibility(GV));
|
||||||
Vals.push_back(getEncodedThreadLocalMode(GV));
|
Vals.push_back(getEncodedThreadLocalMode(GV));
|
||||||
Vals.push_back(GV->hasUnnamedAddr());
|
Vals.push_back(GV->hasUnnamedAddr());
|
||||||
|
Vals.push_back(GV->isExternallyInitialized());
|
||||||
} else {
|
} else {
|
||||||
AbbrevToUse = SimpleGVarAbbrev;
|
AbbrevToUse = SimpleGVarAbbrev;
|
||||||
}
|
}
|
||||||
|
@ -1443,6 +1443,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
|
|||||||
if (unsigned AddressSpace = GV->getType()->getAddressSpace())
|
if (unsigned AddressSpace = GV->getType()->getAddressSpace())
|
||||||
Out << "addrspace(" << AddressSpace << ") ";
|
Out << "addrspace(" << AddressSpace << ") ";
|
||||||
if (GV->hasUnnamedAddr()) Out << "unnamed_addr ";
|
if (GV->hasUnnamedAddr()) Out << "unnamed_addr ";
|
||||||
|
if (GV->isExternallyInitialized()) Out << "externally_initialized ";
|
||||||
Out << (GV->isConstant() ? "constant " : "global ");
|
Out << (GV->isConstant() ? "constant " : "global ");
|
||||||
TypePrinter.print(GV->getType()->getElementType(), Out);
|
TypePrinter.print(GV->getType()->getElementType(), Out);
|
||||||
|
|
||||||
|
5
test/Assembler/externally-initialized.ll
Normal file
5
test/Assembler/externally-initialized.ll
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: @G = externally_initialized global i32 0
|
||||||
|
|
||||||
|
@G = externally_initialized global i32 0
|
Loading…
x
Reference in New Issue
Block a user