mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Do not forget global definitions from inline asm code block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53693 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0d885d1661
commit
c2aec57c63
@ -238,6 +238,19 @@ void LTOModule::addDefinedSymbol(GlobalValue* def, Mangler &mangler,
|
||||
_defines[info.name] = 1;
|
||||
}
|
||||
|
||||
void LTOModule::addAsmGlobalSymbol(const char *name) {
|
||||
// string is owned by _defines
|
||||
const char *symbolName = ::strdup(name);
|
||||
uint32_t attr = LTO_SYMBOL_DEFINITION_REGULAR;
|
||||
attr |= LTO_SYMBOL_SCOPE_DEFAULT;
|
||||
|
||||
// add to table of symbols
|
||||
NameAndAttributes info;
|
||||
info.name = symbolName;
|
||||
info.attributes = (lto_symbol_attributes)attr;
|
||||
_symbols.push_back(info);
|
||||
_defines[info.name] = 1;
|
||||
}
|
||||
|
||||
void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)
|
||||
{
|
||||
@ -297,6 +310,32 @@ void LTOModule::lazyParseSymbols()
|
||||
addDefinedDataSymbol(v, mangler);
|
||||
}
|
||||
|
||||
// add asm globals
|
||||
const std::string &inlineAsm = _module->getModuleInlineAsm();
|
||||
const std::string glbl = ".globl";
|
||||
std::string asmSymbolName;
|
||||
std::string::size_type pos = inlineAsm.find(glbl, 0);
|
||||
while (pos != std::string::npos) {
|
||||
// eat .globl
|
||||
pos = pos + 6;
|
||||
|
||||
// skip white space between .globl and symbol name
|
||||
std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos);
|
||||
if (pbegin == std::string::npos)
|
||||
break;
|
||||
|
||||
// find end-of-line
|
||||
std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin);
|
||||
if (pend == std::string::npos)
|
||||
break;
|
||||
|
||||
asmSymbolName.assign(inlineAsm, pbegin, pbegin-pend);
|
||||
addAsmGlobalSymbol(asmSymbolName.c_str());
|
||||
|
||||
// search next .globl
|
||||
pos = inlineAsm.find(glbl, pend);
|
||||
}
|
||||
|
||||
// make symbols for all undefines
|
||||
for (StringSet::iterator it=_undefines.begin();
|
||||
it != _undefines.end(); ++it) {
|
||||
|
@ -76,6 +76,7 @@ private:
|
||||
llvm::Mangler &mangler);
|
||||
void addDefinedDataSymbol(llvm::GlobalValue* v,
|
||||
llvm::Mangler &mangler);
|
||||
void addAsmGlobalSymbol(const char *);
|
||||
static bool isTargetMatch(llvm::MemoryBuffer* memBuffer,
|
||||
const char* triplePrefix);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user