mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-18 13:34:04 +00:00
Support .code32 and .code64 in X86 assembler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136197 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
26a92003cd
commit
bd27f5adbd
@ -117,6 +117,13 @@ namespace llvm {
|
|||||||
const char *InlineAsmStart; // Defaults to "#APP\n"
|
const char *InlineAsmStart; // Defaults to "#APP\n"
|
||||||
const char *InlineAsmEnd; // Defaults to "#NO_APP\n"
|
const char *InlineAsmEnd; // Defaults to "#NO_APP\n"
|
||||||
|
|
||||||
|
/// Code16Directive, Code32Directive, Code64Directive - These are assembly
|
||||||
|
/// directives that tells the assembler to interpret the following
|
||||||
|
/// instructions differently.
|
||||||
|
const char *Code16Directive; // Defaults to ".code16"
|
||||||
|
const char *Code32Directive; // Defaults to ".code32"
|
||||||
|
const char *Code64Directive; // Defaults to ".code64"
|
||||||
|
|
||||||
/// AssemblerDialect - Which dialect of an assembler variant to use.
|
/// AssemblerDialect - Which dialect of an assembler variant to use.
|
||||||
unsigned AssemblerDialect; // Defaults to 0
|
unsigned AssemblerDialect; // Defaults to 0
|
||||||
|
|
||||||
@ -423,6 +430,15 @@ namespace llvm {
|
|||||||
const char *getInlineAsmEnd() const {
|
const char *getInlineAsmEnd() const {
|
||||||
return InlineAsmEnd;
|
return InlineAsmEnd;
|
||||||
}
|
}
|
||||||
|
const char *getCode16Directive() const {
|
||||||
|
return Code16Directive;
|
||||||
|
}
|
||||||
|
const char *getCode32Directive() const {
|
||||||
|
return Code32Directive;
|
||||||
|
}
|
||||||
|
const char *getCode64Directive() const {
|
||||||
|
return Code64Directive;
|
||||||
|
}
|
||||||
unsigned getAssemblerDialect() const {
|
unsigned getAssemblerDialect() const {
|
||||||
return AssemblerDialect;
|
return AssemblerDialect;
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,6 @@
|
|||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class GlobalValue;
|
|
||||||
class GlobalVariable;
|
|
||||||
class Type;
|
|
||||||
class Mangler;
|
|
||||||
|
|
||||||
struct MCAsmInfoDarwin : public MCAsmInfo {
|
struct MCAsmInfoDarwin : public MCAsmInfo {
|
||||||
explicit MCAsmInfoDarwin();
|
explicit MCAsmInfoDarwin();
|
||||||
};
|
};
|
||||||
|
@ -47,8 +47,9 @@ enum MCSymbolAttr {
|
|||||||
enum MCAssemblerFlag {
|
enum MCAssemblerFlag {
|
||||||
MCAF_SyntaxUnified, ///< .syntax (ARM/ELF)
|
MCAF_SyntaxUnified, ///< .syntax (ARM/ELF)
|
||||||
MCAF_SubsectionsViaSymbols, ///< .subsections_via_symbols (MachO)
|
MCAF_SubsectionsViaSymbols, ///< .subsections_via_symbols (MachO)
|
||||||
MCAF_Code16, ///< .code 16
|
MCAF_Code16, ///< .code16 (X86) / .code 16 (ARM)
|
||||||
MCAF_Code32 ///< .code 32
|
MCAF_Code32, ///< .code32 (X86) / .code 32 (ARM)
|
||||||
|
MCAF_Code64 ///< .code64 (X86)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
@ -42,6 +42,9 @@ MCAsmInfo::MCAsmInfo() {
|
|||||||
LinkerPrivateGlobalPrefix = "";
|
LinkerPrivateGlobalPrefix = "";
|
||||||
InlineAsmStart = "APP";
|
InlineAsmStart = "APP";
|
||||||
InlineAsmEnd = "NO_APP";
|
InlineAsmEnd = "NO_APP";
|
||||||
|
Code16Directive = ".code16";
|
||||||
|
Code32Directive = ".code32";
|
||||||
|
Code64Directive = ".code64";
|
||||||
AssemblerDialect = 0;
|
AssemblerDialect = 0;
|
||||||
AllowQuotesInName = false;
|
AllowQuotesInName = false;
|
||||||
AllowNameToStartWithDigit = false;
|
AllowNameToStartWithDigit = false;
|
||||||
|
@ -335,8 +335,9 @@ void MCAsmStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
|
|||||||
default: assert(0 && "Invalid flag!");
|
default: assert(0 && "Invalid flag!");
|
||||||
case MCAF_SyntaxUnified: OS << "\t.syntax unified"; break;
|
case MCAF_SyntaxUnified: OS << "\t.syntax unified"; break;
|
||||||
case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
|
case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
|
||||||
case MCAF_Code16: OS << "\t.code\t16"; break;
|
case MCAF_Code16: OS << '\t'<< MAI.getCode16Directive(); break;
|
||||||
case MCAF_Code32: OS << "\t.code\t32"; break;
|
case MCAF_Code32: OS << '\t'<< MAI.getCode32Directive(); break;
|
||||||
|
case MCAF_Code64: OS << '\t'<< MAI.getCode64Directive(); break;
|
||||||
}
|
}
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,9 @@ void MCELFStreamer::EmitLabel(MCSymbol *Symbol) {
|
|||||||
void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
|
void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
|
||||||
switch (Flag) {
|
switch (Flag) {
|
||||||
case MCAF_SyntaxUnified: return; // no-op here.
|
case MCAF_SyntaxUnified: return; // no-op here.
|
||||||
case MCAF_Code16: return; // no-op here.
|
case MCAF_Code16: return; // Change parsing mode; no-op here.
|
||||||
case MCAF_Code32: return; // no-op here.
|
case MCAF_Code32: return; // Change parsing mode; no-op here.
|
||||||
|
case MCAF_Code64: return; // Change parsing mode; no-op here.
|
||||||
case MCAF_SubsectionsViaSymbols:
|
case MCAF_SubsectionsViaSymbols:
|
||||||
getAssembler().setSubsectionsViaSymbols(true);
|
getAssembler().setSubsectionsViaSymbols(true);
|
||||||
return;
|
return;
|
||||||
|
@ -143,8 +143,9 @@ void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
|
|||||||
// Do any generic stuff we need to do.
|
// Do any generic stuff we need to do.
|
||||||
switch (Flag) {
|
switch (Flag) {
|
||||||
case MCAF_SyntaxUnified: return; // no-op here.
|
case MCAF_SyntaxUnified: return; // no-op here.
|
||||||
case MCAF_Code16: return; // no-op here.
|
case MCAF_Code16: return; // Change parsing mode; no-op here.
|
||||||
case MCAF_Code32: return; // no-op here.
|
case MCAF_Code32: return; // Change parsing mode; no-op here.
|
||||||
|
case MCAF_Code64: return; // Change parsing mode; no-op here.
|
||||||
case MCAF_SubsectionsViaSymbols:
|
case MCAF_SubsectionsViaSymbols:
|
||||||
getAssembler().setSubsectionsViaSymbols(true);
|
getAssembler().setSubsectionsViaSymbols(true);
|
||||||
return;
|
return;
|
||||||
|
@ -1146,7 +1146,7 @@ bool AsmParser::ParseStatement() {
|
|||||||
if (IDVal == ".include")
|
if (IDVal == ".include")
|
||||||
return ParseDirectiveInclude();
|
return ParseDirectiveInclude();
|
||||||
|
|
||||||
if (IDVal == ".code16" || IDVal == ".code32" || IDVal == ".code64")
|
if (IDVal == ".code16")
|
||||||
return TokError(Twine(IDVal) + " not supported yet");
|
return TokError(Twine(IDVal) + " not supported yet");
|
||||||
|
|
||||||
// Look up the handler in the handler table.
|
// Look up the handler in the handler table.
|
||||||
|
@ -2702,13 +2702,15 @@ bool ARMAsmParser::parseDirectiveCode(SMLoc L) {
|
|||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
|
|
||||||
if (Val == 16) {
|
if (Val == 16) {
|
||||||
if (!isThumb())
|
if (!isThumb()) {
|
||||||
SwitchMode();
|
SwitchMode();
|
||||||
getParser().getStreamer().EmitAssemblerFlag(MCAF_Code16);
|
getParser().getStreamer().EmitAssemblerFlag(MCAF_Code16);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isThumb())
|
if (isThumb()) {
|
||||||
SwitchMode();
|
SwitchMode();
|
||||||
getParser().getStreamer().EmitAssemblerFlag(MCAF_Code32);
|
getParser().getStreamer().EmitAssemblerFlag(MCAF_Code32);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -52,6 +52,9 @@ ARMMCAsmInfoDarwin::ARMMCAsmInfoDarwin() {
|
|||||||
AsmTransCBE = arm_asm_table;
|
AsmTransCBE = arm_asm_table;
|
||||||
Data64bitsDirective = 0;
|
Data64bitsDirective = 0;
|
||||||
CommentString = "@";
|
CommentString = "@";
|
||||||
|
Code16Directive = ".code\t16";
|
||||||
|
Code32Directive = ".code\t32";
|
||||||
|
|
||||||
SupportsDebugInformation = true;
|
SupportsDebugInformation = true;
|
||||||
|
|
||||||
// Exceptions handling
|
// Exceptions handling
|
||||||
@ -64,12 +67,14 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
|
|||||||
|
|
||||||
Data64bitsDirective = 0;
|
Data64bitsDirective = 0;
|
||||||
CommentString = "@";
|
CommentString = "@";
|
||||||
|
|
||||||
HasLEB128 = true;
|
|
||||||
PrivateGlobalPrefix = ".L";
|
PrivateGlobalPrefix = ".L";
|
||||||
|
Code16Directive = ".code\t16";
|
||||||
|
Code32Directive = ".code\t32";
|
||||||
|
|
||||||
WeakRefDirective = "\t.weak\t";
|
WeakRefDirective = "\t.weak\t";
|
||||||
HasLCOMMDirective = true;
|
HasLCOMMDirective = true;
|
||||||
|
|
||||||
|
HasLEB128 = true;
|
||||||
SupportsDebugInformation = true;
|
SupportsDebugInformation = true;
|
||||||
|
|
||||||
// Exceptions handling
|
// Exceptions handling
|
||||||
|
@ -46,6 +46,7 @@ private:
|
|||||||
X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
|
X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
|
||||||
|
|
||||||
bool ParseDirectiveWord(unsigned Size, SMLoc L);
|
bool ParseDirectiveWord(unsigned Size, SMLoc L);
|
||||||
|
bool ParseDirectiveCode(StringRef IDVal, SMLoc L);
|
||||||
|
|
||||||
bool MatchAndEmitInstruction(SMLoc IDLoc,
|
bool MatchAndEmitInstruction(SMLoc IDLoc,
|
||||||
SmallVectorImpl<MCParsedAsmOperand*> &Operands,
|
SmallVectorImpl<MCParsedAsmOperand*> &Operands,
|
||||||
@ -63,6 +64,10 @@ private:
|
|||||||
// FIXME: Can tablegen auto-generate this?
|
// FIXME: Can tablegen auto-generate this?
|
||||||
return (STI.getFeatureBits() & X86::Mode64Bit) != 0;
|
return (STI.getFeatureBits() & X86::Mode64Bit) != 0;
|
||||||
}
|
}
|
||||||
|
void SwitchMode() {
|
||||||
|
unsigned FB = ComputeAvailableFeatures(STI.ToggleFeature(X86::Mode64Bit));
|
||||||
|
setAvailableFeatures(FB);
|
||||||
|
}
|
||||||
|
|
||||||
/// @name Auto-generated Matcher Functions
|
/// @name Auto-generated Matcher Functions
|
||||||
/// {
|
/// {
|
||||||
@ -1094,6 +1099,8 @@ bool X86ATTAsmParser::ParseDirective(AsmToken DirectiveID) {
|
|||||||
StringRef IDVal = DirectiveID.getIdentifier();
|
StringRef IDVal = DirectiveID.getIdentifier();
|
||||||
if (IDVal == ".word")
|
if (IDVal == ".word")
|
||||||
return ParseDirectiveWord(2, DirectiveID.getLoc());
|
return ParseDirectiveWord(2, DirectiveID.getLoc());
|
||||||
|
else if (IDVal.startswith(".code"))
|
||||||
|
return ParseDirectiveCode(IDVal, DirectiveID.getLoc());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,7 +1129,27 @@ bool X86ATTAsmParser::ParseDirectiveWord(unsigned Size, SMLoc L) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ParseDirectiveCode
|
||||||
|
/// ::= .code32 | .code64
|
||||||
|
bool X86ATTAsmParser::ParseDirectiveCode(StringRef IDVal, SMLoc L) {
|
||||||
|
if (IDVal == ".code32") {
|
||||||
|
Parser.Lex();
|
||||||
|
if (is64BitMode()) {
|
||||||
|
SwitchMode();
|
||||||
|
getParser().getStreamer().EmitAssemblerFlag(MCAF_Code32);
|
||||||
|
}
|
||||||
|
} else if (IDVal == ".code64") {
|
||||||
|
Parser.Lex();
|
||||||
|
if (!is64BitMode()) {
|
||||||
|
SwitchMode();
|
||||||
|
getParser().getStreamer().EmitAssemblerFlag(MCAF_Code64);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Error(L, "unexpected directive " + IDVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" void LLVMInitializeX86AsmLexer();
|
extern "C" void LLVMInitializeX86AsmLexer();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user