mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 18:34:09 +00:00
ARM: prepare prefix parsing for improved AAELF support
AAELF specifies a number of ELF specific relocation types which have custom prefixes for the symbol reference. Switch the parser to be more table driven with an idea of file formats for which they apply. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225758 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6b1894aeae
commit
3423a7b24f
@ -5254,15 +5254,52 @@ bool ARMAsmParser::parsePrefix(ARMMCExpr::VariantKind &RefKind) {
|
||||
return true;
|
||||
}
|
||||
|
||||
enum {
|
||||
COFF = (1 << MCObjectFileInfo::IsCOFF),
|
||||
ELF = (1 << MCObjectFileInfo::IsELF),
|
||||
MACHO = (1 << MCObjectFileInfo::IsMachO)
|
||||
};
|
||||
static const struct PrefixEntry {
|
||||
const char *Spelling;
|
||||
ARMMCExpr::VariantKind VariantKind;
|
||||
uint8_t SupportedFormats;
|
||||
} PrefixEntries[] = {
|
||||
{ "lower16", ARMMCExpr::VK_ARM_LO16, COFF | ELF | MACHO },
|
||||
{ "upper16", ARMMCExpr::VK_ARM_HI16, COFF | ELF | MACHO },
|
||||
};
|
||||
|
||||
StringRef IDVal = Parser.getTok().getIdentifier();
|
||||
if (IDVal == "lower16") {
|
||||
RefKind = ARMMCExpr::VK_ARM_LO16;
|
||||
} else if (IDVal == "upper16") {
|
||||
RefKind = ARMMCExpr::VK_ARM_HI16;
|
||||
} else {
|
||||
|
||||
const auto &Prefix =
|
||||
std::find_if(std::begin(PrefixEntries), std::end(PrefixEntries),
|
||||
[&IDVal](const PrefixEntry &PE) {
|
||||
return PE.Spelling == IDVal;
|
||||
});
|
||||
if (Prefix == std::end(PrefixEntries)) {
|
||||
Error(Parser.getTok().getLoc(), "unexpected prefix in operand");
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t CurrentFormat;
|
||||
switch (getContext().getObjectFileInfo()->getObjectFileType()) {
|
||||
case MCObjectFileInfo::IsMachO:
|
||||
CurrentFormat = MACHO;
|
||||
break;
|
||||
case MCObjectFileInfo::IsELF:
|
||||
CurrentFormat = ELF;
|
||||
break;
|
||||
case MCObjectFileInfo::IsCOFF:
|
||||
CurrentFormat = COFF;
|
||||
break;
|
||||
}
|
||||
|
||||
if (~Prefix->SupportedFormats & CurrentFormat) {
|
||||
Error(Parser.getTok().getLoc(),
|
||||
"cannot represent relocation in the current file format");
|
||||
return true;
|
||||
}
|
||||
|
||||
RefKind = Prefix->VariantKind;
|
||||
Parser.Lex();
|
||||
|
||||
if (getLexer().isNot(AsmToken::Colon)) {
|
||||
@ -5270,6 +5307,7 @@ bool ARMAsmParser::parsePrefix(ARMMCExpr::VariantKind &RefKind) {
|
||||
return true;
|
||||
}
|
||||
Parser.Lex(); // Eat the last ':'
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user