mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +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(protected);
|
||||
KEYWORD(unnamed_addr);
|
||||
KEYWORD(externally_initialized);
|
||||
KEYWORD(extern_weak);
|
||||
KEYWORD(external);
|
||||
KEYWORD(thread_local);
|
||||
|
@ -632,9 +632,11 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
|
||||
|
||||
/// ParseGlobal
|
||||
/// ::= GlobalVar '=' OptionalLinkage OptionalVisibility OptionalThreadLocal
|
||||
/// OptionalAddrSpace OptionalUnNammedAddr GlobalType Type Const
|
||||
/// OptionalAddrSpace OptionalUnNammedAddr
|
||||
/// OptionalExternallyInitialized GlobalType Type Const
|
||||
/// ::= OptionalLinkage OptionalVisibility OptionalThreadLocal
|
||||
/// OptionalAddrSpace OptionalUnNammedAddr GlobalType Type Const
|
||||
/// OptionalAddrSpace OptionalUnNammedAddr
|
||||
/// OptionalExternallyInitialized GlobalType Type Const
|
||||
///
|
||||
/// 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 Visibility) {
|
||||
unsigned AddrSpace;
|
||||
bool IsConstant, UnnamedAddr;
|
||||
bool IsConstant, UnnamedAddr, IsExternallyInitialized;
|
||||
GlobalVariable::ThreadLocalMode TLM;
|
||||
LocTy UnnamedAddrLoc;
|
||||
LocTy IsExternallyInitializedLoc;
|
||||
LocTy TyLoc;
|
||||
|
||||
Type *Ty = 0;
|
||||
@ -652,6 +655,9 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
||||
ParseOptionalAddrSpace(AddrSpace) ||
|
||||
ParseOptionalToken(lltok::kw_unnamed_addr, UnnamedAddr,
|
||||
&UnnamedAddrLoc) ||
|
||||
ParseOptionalToken(lltok::kw_externally_initialized,
|
||||
IsExternallyInitialized,
|
||||
&IsExternallyInitializedLoc) ||
|
||||
ParseGlobalType(IsConstant) ||
|
||||
ParseType(Ty, TyLoc))
|
||||
return true;
|
||||
@ -709,6 +715,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
|
||||
GV->setConstant(IsConstant);
|
||||
GV->setLinkage((GlobalValue::LinkageTypes)Linkage);
|
||||
GV->setVisibility((GlobalValue::VisibilityTypes)Visibility);
|
||||
GV->setExternallyInitialized(IsExternallyInitialized);
|
||||
GV->setThreadLocalMode(TLM);
|
||||
GV->setUnnamedAddr(UnnamedAddr);
|
||||
|
||||
|
@ -44,6 +44,7 @@ namespace lltok {
|
||||
kw_dllimport, kw_dllexport, kw_common, kw_available_externally,
|
||||
kw_default, kw_hidden, kw_protected,
|
||||
kw_unnamed_addr,
|
||||
kw_externally_initialized,
|
||||
kw_extern_weak,
|
||||
kw_external, kw_thread_local,
|
||||
kw_localdynamic, kw_initialexec, kw_localexec,
|
||||
|
@ -1596,9 +1596,13 @@ bool BitcodeReader::ParseModule(bool Resume) {
|
||||
if (Record.size() > 8)
|
||||
UnnamedAddr = Record[8];
|
||||
|
||||
bool ExternallyInitialized = false;
|
||||
if (Record.size() > 9)
|
||||
ExternallyInitialized = Record[9];
|
||||
|
||||
GlobalVariable *NewGV =
|
||||
new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0,
|
||||
TLM, AddressSpace);
|
||||
TLM, AddressSpace, ExternallyInitialized);
|
||||
NewGV->setAlignment(Alignment);
|
||||
if (!Section.empty())
|
||||
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);
|
||||
if (GV->isThreadLocal() ||
|
||||
GV->getVisibility() != GlobalValue::DefaultVisibility ||
|
||||
GV->hasUnnamedAddr()) {
|
||||
GV->hasUnnamedAddr() || GV->isExternallyInitialized()) {
|
||||
Vals.push_back(getEncodedVisibility(GV));
|
||||
Vals.push_back(getEncodedThreadLocalMode(GV));
|
||||
Vals.push_back(GV->hasUnnamedAddr());
|
||||
Vals.push_back(GV->isExternallyInitialized());
|
||||
} else {
|
||||
AbbrevToUse = SimpleGVarAbbrev;
|
||||
}
|
||||
|
@ -1443,6 +1443,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
|
||||
if (unsigned AddressSpace = GV->getType()->getAddressSpace())
|
||||
Out << "addrspace(" << AddressSpace << ") ";
|
||||
if (GV->hasUnnamedAddr()) Out << "unnamed_addr ";
|
||||
if (GV->isExternallyInitialized()) Out << "externally_initialized ";
|
||||
Out << (GV->isConstant() ? "constant " : "global ");
|
||||
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