mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
ARM: consolidate MachO checks for ARM asm parser
This consolidates the duplicated MachO checks in the directive parsing for various directives that are unsupported for Mach-O. The error message change is unimportant as this restores the behaviour to that prior to the addition of the new directive handling. Furthermore, use a more direct check for MachO targeting rather than an indirect feature check of the assembler. Also simplify the test execution command to avoid temporary files. Further more, perform the check in both object and assembly emission. Whether all non-applicable directives are handled is another question. .fnstart is marked as being unsupported, however, the complementary .fnend is not. The additional unwinding directives are also still honoured. This change does not change that, though, it would be good to validate and mark them as being unsupported if they are unsupported for the MachO emission. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205678 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b4074c010b
commit
2a65dd3101
@ -7975,6 +7975,10 @@ MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
|
|||||||
|
|
||||||
/// parseDirective parses the arm specific directives
|
/// parseDirective parses the arm specific directives
|
||||||
bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) {
|
bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) {
|
||||||
|
const MCObjectFileInfo::Environment Format =
|
||||||
|
getContext().getObjectFileInfo()->getObjectFileType();
|
||||||
|
bool IsMachO = Format == MCObjectFileInfo::IsMachO;
|
||||||
|
|
||||||
StringRef IDVal = DirectiveID.getIdentifier();
|
StringRef IDVal = DirectiveID.getIdentifier();
|
||||||
if (IDVal == ".word")
|
if (IDVal == ".word")
|
||||||
return parseLiteralValues(4, DirectiveID.getLoc());
|
return parseLiteralValues(4, DirectiveID.getLoc());
|
||||||
@ -7992,16 +7996,6 @@ bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) {
|
|||||||
return parseDirectiveSyntax(DirectiveID.getLoc());
|
return parseDirectiveSyntax(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".unreq")
|
else if (IDVal == ".unreq")
|
||||||
return parseDirectiveUnreq(DirectiveID.getLoc());
|
return parseDirectiveUnreq(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".arch")
|
|
||||||
return parseDirectiveArch(DirectiveID.getLoc());
|
|
||||||
else if (IDVal == ".eabi_attribute")
|
|
||||||
return parseDirectiveEabiAttr(DirectiveID.getLoc());
|
|
||||||
else if (IDVal == ".cpu")
|
|
||||||
return parseDirectiveCPU(DirectiveID.getLoc());
|
|
||||||
else if (IDVal == ".fpu")
|
|
||||||
return parseDirectiveFPU(DirectiveID.getLoc());
|
|
||||||
else if (IDVal == ".fnstart")
|
|
||||||
return parseDirectiveFnStart(DirectiveID.getLoc());
|
|
||||||
else if (IDVal == ".fnend")
|
else if (IDVal == ".fnend")
|
||||||
return parseDirectiveFnEnd(DirectiveID.getLoc());
|
return parseDirectiveFnEnd(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".cantunwind")
|
else if (IDVal == ".cantunwind")
|
||||||
@ -8018,12 +8012,6 @@ bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) {
|
|||||||
return parseDirectiveRegSave(DirectiveID.getLoc(), false);
|
return parseDirectiveRegSave(DirectiveID.getLoc(), false);
|
||||||
else if (IDVal == ".vsave")
|
else if (IDVal == ".vsave")
|
||||||
return parseDirectiveRegSave(DirectiveID.getLoc(), true);
|
return parseDirectiveRegSave(DirectiveID.getLoc(), true);
|
||||||
else if (IDVal == ".inst")
|
|
||||||
return parseDirectiveInst(DirectiveID.getLoc());
|
|
||||||
else if (IDVal == ".inst.n")
|
|
||||||
return parseDirectiveInst(DirectiveID.getLoc(), 'n');
|
|
||||||
else if (IDVal == ".inst.w")
|
|
||||||
return parseDirectiveInst(DirectiveID.getLoc(), 'w');
|
|
||||||
else if (IDVal == ".ltorg" || IDVal == ".pool")
|
else if (IDVal == ".ltorg" || IDVal == ".pool")
|
||||||
return parseDirectiveLtorg(DirectiveID.getLoc());
|
return parseDirectiveLtorg(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".even")
|
else if (IDVal == ".even")
|
||||||
@ -8032,18 +8020,38 @@ bool ARMAsmParser::ParseDirective(AsmToken DirectiveID) {
|
|||||||
return parseDirectivePersonalityIndex(DirectiveID.getLoc());
|
return parseDirectivePersonalityIndex(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".unwind_raw")
|
else if (IDVal == ".unwind_raw")
|
||||||
return parseDirectiveUnwindRaw(DirectiveID.getLoc());
|
return parseDirectiveUnwindRaw(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".tlsdescseq")
|
|
||||||
return parseDirectiveTLSDescSeq(DirectiveID.getLoc());
|
|
||||||
else if (IDVal == ".movsp")
|
else if (IDVal == ".movsp")
|
||||||
return parseDirectiveMovSP(DirectiveID.getLoc());
|
return parseDirectiveMovSP(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".object_arch")
|
|
||||||
return parseDirectiveObjectArch(DirectiveID.getLoc());
|
|
||||||
else if (IDVal == ".arch_extension")
|
else if (IDVal == ".arch_extension")
|
||||||
return parseDirectiveArchExtension(DirectiveID.getLoc());
|
return parseDirectiveArchExtension(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".align")
|
else if (IDVal == ".align")
|
||||||
return parseDirectiveAlign(DirectiveID.getLoc());
|
return parseDirectiveAlign(DirectiveID.getLoc());
|
||||||
else if (IDVal == ".thumb_set")
|
else if (IDVal == ".thumb_set")
|
||||||
return parseDirectiveThumbSet(DirectiveID.getLoc());
|
return parseDirectiveThumbSet(DirectiveID.getLoc());
|
||||||
|
|
||||||
|
if (!IsMachO) {
|
||||||
|
if (IDVal == ".arch")
|
||||||
|
return parseDirectiveArch(DirectiveID.getLoc());
|
||||||
|
else if (IDVal == ".cpu")
|
||||||
|
return parseDirectiveCPU(DirectiveID.getLoc());
|
||||||
|
else if (IDVal == ".eabi_attribute")
|
||||||
|
return parseDirectiveEabiAttr(DirectiveID.getLoc());
|
||||||
|
else if (IDVal == ".fpu")
|
||||||
|
return parseDirectiveFPU(DirectiveID.getLoc());
|
||||||
|
else if (IDVal == ".fnstart")
|
||||||
|
return parseDirectiveFnStart(DirectiveID.getLoc());
|
||||||
|
else if (IDVal == ".inst")
|
||||||
|
return parseDirectiveInst(DirectiveID.getLoc());
|
||||||
|
else if (IDVal == ".inst.n")
|
||||||
|
return parseDirectiveInst(DirectiveID.getLoc(), 'n');
|
||||||
|
else if (IDVal == ".inst.w")
|
||||||
|
return parseDirectiveInst(DirectiveID.getLoc(), 'w');
|
||||||
|
else if (IDVal == ".object_arch")
|
||||||
|
return parseDirectiveObjectArch(DirectiveID.getLoc());
|
||||||
|
else if (IDVal == ".tlsdescseq")
|
||||||
|
return parseDirectiveTLSDescSeq(DirectiveID.getLoc());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8306,14 +8314,6 @@ bool ARMAsmParser::parseDirectiveUnreq(SMLoc L) {
|
|||||||
/// parseDirectiveArch
|
/// parseDirectiveArch
|
||||||
/// ::= .arch token
|
/// ::= .arch token
|
||||||
bool ARMAsmParser::parseDirectiveArch(SMLoc L) {
|
bool ARMAsmParser::parseDirectiveArch(SMLoc L) {
|
||||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
|
||||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
|
||||||
if (isMachO) {
|
|
||||||
Error(L, ".arch directive not valid for Mach-O");
|
|
||||||
Parser.eatToEndOfStatement();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringRef Arch = getParser().parseStringToEndOfStatement().trim();
|
StringRef Arch = getParser().parseStringToEndOfStatement().trim();
|
||||||
|
|
||||||
unsigned ID = StringSwitch<unsigned>(Arch)
|
unsigned ID = StringSwitch<unsigned>(Arch)
|
||||||
@ -8337,14 +8337,6 @@ bool ARMAsmParser::parseDirectiveArch(SMLoc L) {
|
|||||||
/// ::= .eabi_attribute int, int [, "str"]
|
/// ::= .eabi_attribute int, int [, "str"]
|
||||||
/// ::= .eabi_attribute Tag_name, int [, "str"]
|
/// ::= .eabi_attribute Tag_name, int [, "str"]
|
||||||
bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
|
bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
|
||||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
|
||||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
|
||||||
if (isMachO) {
|
|
||||||
Error(L, ".eabi_attribute directive not valid for Mach-O");
|
|
||||||
Parser.eatToEndOfStatement();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t Tag;
|
int64_t Tag;
|
||||||
SMLoc TagLoc;
|
SMLoc TagLoc;
|
||||||
TagLoc = Parser.getTok().getLoc();
|
TagLoc = Parser.getTok().getLoc();
|
||||||
@ -8450,14 +8442,6 @@ bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
|
|||||||
/// parseDirectiveCPU
|
/// parseDirectiveCPU
|
||||||
/// ::= .cpu str
|
/// ::= .cpu str
|
||||||
bool ARMAsmParser::parseDirectiveCPU(SMLoc L) {
|
bool ARMAsmParser::parseDirectiveCPU(SMLoc L) {
|
||||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
|
||||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
|
||||||
if (isMachO) {
|
|
||||||
Error(L, ".cpu directive not valid for Mach-O");
|
|
||||||
Parser.eatToEndOfStatement();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringRef CPU = getParser().parseStringToEndOfStatement().trim();
|
StringRef CPU = getParser().parseStringToEndOfStatement().trim();
|
||||||
getTargetStreamer().emitTextAttribute(ARMBuildAttrs::CPU_name, CPU);
|
getTargetStreamer().emitTextAttribute(ARMBuildAttrs::CPU_name, CPU);
|
||||||
return false;
|
return false;
|
||||||
@ -8466,14 +8450,6 @@ bool ARMAsmParser::parseDirectiveCPU(SMLoc L) {
|
|||||||
/// parseDirectiveFPU
|
/// parseDirectiveFPU
|
||||||
/// ::= .fpu str
|
/// ::= .fpu str
|
||||||
bool ARMAsmParser::parseDirectiveFPU(SMLoc L) {
|
bool ARMAsmParser::parseDirectiveFPU(SMLoc L) {
|
||||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
|
||||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
|
||||||
if (isMachO) {
|
|
||||||
Error(L, ".fpu directive not valid for Mach-O");
|
|
||||||
Parser.eatToEndOfStatement();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringRef FPU = getParser().parseStringToEndOfStatement().trim();
|
StringRef FPU = getParser().parseStringToEndOfStatement().trim();
|
||||||
|
|
||||||
unsigned ID = StringSwitch<unsigned>(FPU)
|
unsigned ID = StringSwitch<unsigned>(FPU)
|
||||||
@ -8493,14 +8469,6 @@ bool ARMAsmParser::parseDirectiveFPU(SMLoc L) {
|
|||||||
/// parseDirectiveFnStart
|
/// parseDirectiveFnStart
|
||||||
/// ::= .fnstart
|
/// ::= .fnstart
|
||||||
bool ARMAsmParser::parseDirectiveFnStart(SMLoc L) {
|
bool ARMAsmParser::parseDirectiveFnStart(SMLoc L) {
|
||||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
|
||||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
|
||||||
if (isMachO) {
|
|
||||||
Error(L, ".fnstart directive not valid for Mach-O");
|
|
||||||
Parser.eatToEndOfStatement();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UC.hasFnStart()) {
|
if (UC.hasFnStart()) {
|
||||||
Error(L, ".fnstart starts before the end of previous one");
|
Error(L, ".fnstart starts before the end of previous one");
|
||||||
UC.emitFnStartLocNotes();
|
UC.emitFnStartLocNotes();
|
||||||
@ -8780,14 +8748,6 @@ bool ARMAsmParser::parseDirectiveRegSave(SMLoc L, bool IsVector) {
|
|||||||
/// ::= .inst.n opcode [, ...]
|
/// ::= .inst.n opcode [, ...]
|
||||||
/// ::= .inst.w opcode [, ...]
|
/// ::= .inst.w opcode [, ...]
|
||||||
bool ARMAsmParser::parseDirectiveInst(SMLoc Loc, char Suffix) {
|
bool ARMAsmParser::parseDirectiveInst(SMLoc Loc, char Suffix) {
|
||||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
|
||||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
|
||||||
if (isMachO) {
|
|
||||||
Error(Loc, ".inst directive not valid for Mach-O");
|
|
||||||
Parser.eatToEndOfStatement();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Width;
|
int Width;
|
||||||
|
|
||||||
if (isThumb()) {
|
if (isThumb()) {
|
||||||
@ -9036,14 +8996,6 @@ bool ARMAsmParser::parseDirectiveUnwindRaw(SMLoc L) {
|
|||||||
/// parseDirectiveTLSDescSeq
|
/// parseDirectiveTLSDescSeq
|
||||||
/// ::= .tlsdescseq tls-variable
|
/// ::= .tlsdescseq tls-variable
|
||||||
bool ARMAsmParser::parseDirectiveTLSDescSeq(SMLoc L) {
|
bool ARMAsmParser::parseDirectiveTLSDescSeq(SMLoc L) {
|
||||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
|
||||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
|
||||||
if (isMachO) {
|
|
||||||
Error(L, ".tlsdescseq directive not valid for Mach-O");
|
|
||||||
Parser.eatToEndOfStatement();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::Identifier)) {
|
if (getLexer().isNot(AsmToken::Identifier)) {
|
||||||
TokError("expected variable after '.tlsdescseq' directive");
|
TokError("expected variable after '.tlsdescseq' directive");
|
||||||
Parser.eatToEndOfStatement();
|
Parser.eatToEndOfStatement();
|
||||||
@ -9131,14 +9083,6 @@ bool ARMAsmParser::parseDirectiveMovSP(SMLoc L) {
|
|||||||
/// parseDirectiveObjectArch
|
/// parseDirectiveObjectArch
|
||||||
/// ::= .object_arch name
|
/// ::= .object_arch name
|
||||||
bool ARMAsmParser::parseDirectiveObjectArch(SMLoc L) {
|
bool ARMAsmParser::parseDirectiveObjectArch(SMLoc L) {
|
||||||
const MCAsmInfo *MAI = getParser().getStreamer().getContext().getAsmInfo();
|
|
||||||
bool isMachO = MAI->hasSubsectionsViaSymbols();
|
|
||||||
if (isMachO) {
|
|
||||||
Error(L, ".object_arch directive not valid for Mach-O");
|
|
||||||
Parser.eatToEndOfStatement();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getLexer().isNot(AsmToken::Identifier)) {
|
if (getLexer().isNot(AsmToken::Identifier)) {
|
||||||
Error(getLexer().getLoc(), "unexpected token");
|
Error(getLexer().getLoc(), "unexpected token");
|
||||||
Parser.eatToEndOfStatement();
|
Parser.eatToEndOfStatement();
|
||||||
|
@ -1,24 +1,29 @@
|
|||||||
@ RUN: not llvm-mc -n -triple armv7-apple-darwin10 %s -filetype=obj -o - 2> %t.err > %t
|
@ RUN: not llvm-mc -n -triple armv7-apple-darwin10 %s -filetype asm -o /dev/null 2>&1 \
|
||||||
@ RUN: FileCheck --check-prefix=CHECK-ERROR < %t.err %s
|
@ RUN: | FileCheck --check-prefix CHECK-ERROR %s
|
||||||
|
|
||||||
|
@ RUN: not llvm-mc -n -triple armv7-apple-darwin10 %s -filetype obj -o /dev/null 2>&1 \
|
||||||
|
@ RUN: | FileCheck --check-prefix CHECK-ERROR %s
|
||||||
|
|
||||||
@ rdar://16335232
|
@ rdar://16335232
|
||||||
|
|
||||||
.eabi_attribute 8, 1
|
.eabi_attribute 8, 1
|
||||||
@ CHECK-ERROR: error: .eabi_attribute directive not valid for Mach-O
|
@ CHECK-ERROR: error: unknown directive
|
||||||
|
|
||||||
.cpu
|
.cpu
|
||||||
@ CHECK-ERROR: error: .cpu directive not valid for Mach-O
|
@ CHECK-ERROR: error: unknown directive
|
||||||
|
|
||||||
.fpu neon
|
.fpu neon
|
||||||
@ CHECK-ERROR: error: .fpu directive not valid for Mach-O
|
@ CHECK-ERROR: error: unknown directive
|
||||||
|
|
||||||
.arch armv7
|
.arch armv7
|
||||||
@ CHECK-ERROR: error: .arch directive not valid for Mach-O
|
@ CHECK-ERROR: error: unknown directive
|
||||||
|
|
||||||
.fnstart
|
.fnstart
|
||||||
@ CHECK-ERROR: error: .fnstart directive not valid for Mach-O
|
@ CHECK-ERROR: error: unknown directive
|
||||||
|
|
||||||
.tlsdescseq
|
.tlsdescseq
|
||||||
@ CHECK-ERROR: error: .tlsdescseq directive not valid for Mach-O
|
@ CHECK-ERROR: error: unknown directive
|
||||||
|
|
||||||
.object_arch armv7
|
.object_arch armv7
|
||||||
@ CHECK-ERROR: error: .object_arch directive not valid for Mach-O
|
@ CHECK-ERROR: error: unknown directive
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user