mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
MC: Add support for treating $ as a reference to the PC
The binutils assembler supports a mode called DOLLAR_DOT which treats the dollar sign token as a reference to the current program counter if the dollar sign doesn't precede a constant or identifier. This commit adds a new MCAsmInfo flag stating whether or not a given target supports this interpretation of the dollar sign token; by default, this flag is not enabled. Further, enable this flag for PPC. The system assembler for AIX and binutils both support using the dollar sign in this manner. This fixes PR17353. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191368 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
76f8ae87b4
commit
3f22cc1df6
@ -93,6 +93,10 @@ namespace llvm {
|
|||||||
/// this value. Factored out in .debug_frame and .debug_line.
|
/// this value. Factored out in .debug_frame and .debug_line.
|
||||||
unsigned MinInstAlignment; // Defaults to 1.
|
unsigned MinInstAlignment; // Defaults to 1.
|
||||||
|
|
||||||
|
/// DollarIsPC - The '$' token, when not referencing an identifier or
|
||||||
|
/// constant, refers to the current PC.
|
||||||
|
bool DollarIsPC; // Defaults to false.
|
||||||
|
|
||||||
/// SeparatorString - This string, if specified, is used to separate
|
/// SeparatorString - This string, if specified, is used to separate
|
||||||
/// instructions from each other when on the same line.
|
/// instructions from each other when on the same line.
|
||||||
const char *SeparatorString; // Defaults to ';'
|
const char *SeparatorString; // Defaults to ';'
|
||||||
@ -421,6 +425,9 @@ namespace llvm {
|
|||||||
unsigned getMinInstAlignment() const {
|
unsigned getMinInstAlignment() const {
|
||||||
return MinInstAlignment;
|
return MinInstAlignment;
|
||||||
}
|
}
|
||||||
|
bool getDollarIsPC() const {
|
||||||
|
return DollarIsPC;
|
||||||
|
}
|
||||||
const char *getSeparatorString() const {
|
const char *getSeparatorString() const {
|
||||||
return SeparatorString;
|
return SeparatorString;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ MCAsmInfo::MCAsmInfo() {
|
|||||||
LinkerRequiresNonEmptyDwarfLines = false;
|
LinkerRequiresNonEmptyDwarfLines = false;
|
||||||
MaxInstLength = 4;
|
MaxInstLength = 4;
|
||||||
MinInstAlignment = 1;
|
MinInstAlignment = 1;
|
||||||
|
DollarIsPC = false;
|
||||||
SeparatorString = ";";
|
SeparatorString = ";";
|
||||||
CommentColumn = 40;
|
CommentColumn = 40;
|
||||||
CommentString = "#";
|
CommentString = "#";
|
||||||
|
@ -772,9 +772,19 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
|||||||
case AsmToken::Identifier: {
|
case AsmToken::Identifier: {
|
||||||
StringRef Identifier;
|
StringRef Identifier;
|
||||||
if (parseIdentifier(Identifier)) {
|
if (parseIdentifier(Identifier)) {
|
||||||
if (FirstTokenKind == AsmToken::Dollar)
|
if (FirstTokenKind == AsmToken::Dollar) {
|
||||||
return Error(FirstTokenLoc, "invalid token in expression");
|
if (Lexer.getMAI().getDollarIsPC()) {
|
||||||
return true;
|
// This is a '$' reference, which references the current PC. Emit a
|
||||||
|
// temporary label to the streamer and refer to it.
|
||||||
|
MCSymbol *Sym = Ctx.CreateTempSymbol();
|
||||||
|
Out.EmitLabel(Sym);
|
||||||
|
Res = MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None, getContext());
|
||||||
|
EndLoc = FirstTokenLoc;
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return Error(FirstTokenLoc, "invalid token in expression");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EndLoc = SMLoc::getFromPointer(Identifier.end());
|
EndLoc = SMLoc::getFromPointer(Identifier.end());
|
||||||
|
@ -54,6 +54,8 @@ PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {
|
|||||||
// Debug Information
|
// Debug Information
|
||||||
SupportsDebugInformation = true;
|
SupportsDebugInformation = true;
|
||||||
|
|
||||||
|
DollarIsPC = true;
|
||||||
|
|
||||||
// Set up DWARF directives
|
// Set up DWARF directives
|
||||||
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
|
||||||
MinInstAlignment = 4;
|
MinInstAlignment = 4;
|
||||||
|
@ -108,3 +108,8 @@
|
|||||||
# CHECK: beqa 0, 1024 # encoding: [0x41,0x82,0x04,0x02]
|
# CHECK: beqa 0, 1024 # encoding: [0x41,0x82,0x04,0x02]
|
||||||
beqa 1024
|
beqa 1024
|
||||||
|
|
||||||
|
# CHECK: # encoding: [0x42,0x9f,A,0bAAAAAA01]
|
||||||
|
bcl 20, 31, $+4
|
||||||
|
|
||||||
|
# CHECK: # encoding: [0x42,0x00,A,0bAAAAAA00]
|
||||||
|
bdnz $-8
|
||||||
|
Loading…
Reference in New Issue
Block a user