mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
implement mc asmparser support for '.', which gets the
current PC. rdar://7834775 We now produce an identical .o file compared to the cctools assembler for something like this: _f0: L0: jmp L1 .long . - L0 L1: jmp A .long . - L1 .zerofill __DATA,_bss,A,0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101227 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -209,6 +209,7 @@ MCSymbol *AsmParser::CreateSymbol(StringRef Name) {
|
||||
/// primaryexpr ::= (parenexpr
|
||||
/// primaryexpr ::= symbol
|
||||
/// primaryexpr ::= number
|
||||
/// primaryexpr ::= '.'
|
||||
/// primaryexpr ::= ~,+,- primaryexpr
|
||||
bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
||||
switch (Lexer.getKind()) {
|
||||
@ -253,6 +254,17 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
|
||||
EndLoc = Lexer.getLoc();
|
||||
Lex(); // Eat token.
|
||||
return false;
|
||||
case AsmToken::Dot: {
|
||||
// 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 = Lexer.getLoc();
|
||||
Lex(); // Eat identifier.
|
||||
return false;
|
||||
}
|
||||
|
||||
case AsmToken::LParen:
|
||||
Lex(); // Eat the '('.
|
||||
return ParseParenExpr(Res, EndLoc);
|
||||
|
Reference in New Issue
Block a user