mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
This patch implements parsing the .word
directive for the Mips assembler. Contributer: Vladimir Medic git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173407 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d2047c6001
commit
801c583883
@ -133,6 +133,8 @@ class MipsAsmParser : public MCTargetAsmParser {
|
|||||||
bool parseSetReorderDirective();
|
bool parseSetReorderDirective();
|
||||||
bool parseSetNoReorderDirective();
|
bool parseSetNoReorderDirective();
|
||||||
|
|
||||||
|
bool parseDirectiveWord(unsigned Size, SMLoc L);
|
||||||
|
|
||||||
MCSymbolRefExpr::VariantKind getVariantKind(StringRef Symbol);
|
MCSymbolRefExpr::VariantKind getVariantKind(StringRef Symbol);
|
||||||
|
|
||||||
bool isMips64() const {
|
bool isMips64() const {
|
||||||
@ -1451,51 +1453,84 @@ bool MipsAsmParser::parseDirectiveSet() {
|
|||||||
Parser.EatToEndOfStatement();
|
Parser.EatToEndOfStatement();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// parseDirectiveWord
|
||||||
|
/// ::= .word [ expression (, expression)* ]
|
||||||
|
bool MipsAsmParser::parseDirectiveWord(unsigned Size, SMLoc L) {
|
||||||
|
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||||
|
for (;;) {
|
||||||
|
const MCExpr *Value;
|
||||||
|
if (getParser().ParseExpression(Value))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
getParser().getStreamer().EmitValue(Value, Size);
|
||||||
|
|
||||||
|
if (getLexer().is(AsmToken::EndOfStatement))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// FIXME: Improve diagnostic.
|
||||||
|
if (getLexer().isNot(AsmToken::Comma))
|
||||||
|
return Error(L, "unexpected token in directive");
|
||||||
|
Parser.Lex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Parser.Lex();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {
|
bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {
|
||||||
|
|
||||||
if (DirectiveID.getString() == ".ent") {
|
StringRef IDVal = DirectiveID.getString();
|
||||||
|
|
||||||
|
if ( IDVal == ".ent") {
|
||||||
// ignore this directive for now
|
// ignore this directive for now
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DirectiveID.getString() == ".end") {
|
if (IDVal == ".end") {
|
||||||
// ignore this directive for now
|
// ignore this directive for now
|
||||||
Parser.Lex();
|
Parser.Lex();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DirectiveID.getString() == ".frame") {
|
if (IDVal == ".frame") {
|
||||||
// ignore this directive for now
|
// ignore this directive for now
|
||||||
Parser.EatToEndOfStatement();
|
Parser.EatToEndOfStatement();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DirectiveID.getString() == ".set") {
|
if (IDVal == ".set") {
|
||||||
return parseDirectiveSet();
|
return parseDirectiveSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DirectiveID.getString() == ".fmask") {
|
if (IDVal == ".fmask") {
|
||||||
// ignore this directive for now
|
// ignore this directive for now
|
||||||
Parser.EatToEndOfStatement();
|
Parser.EatToEndOfStatement();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DirectiveID.getString() == ".mask") {
|
if (IDVal == ".mask") {
|
||||||
// ignore this directive for now
|
// ignore this directive for now
|
||||||
Parser.EatToEndOfStatement();
|
Parser.EatToEndOfStatement();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DirectiveID.getString() == ".gpword") {
|
if (IDVal == ".gpword") {
|
||||||
// ignore this directive for now
|
// ignore this directive for now
|
||||||
Parser.EatToEndOfStatement();
|
Parser.EatToEndOfStatement();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IDVal == ".word") {
|
||||||
|
parseDirectiveWord(4, DirectiveID.getLoc());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# RUN: llvm-mc -triple mips-unknown-unknown %s
|
# RUN: llvm-mc -triple mips-unknown-unknown %s | FileCheck %s
|
||||||
#this test produces no output so there isS no FileCheck call
|
#this test produces no output so there isS no FileCheck call
|
||||||
$BB0_2:
|
$BB0_2:
|
||||||
.ent directives_test
|
.ent directives_test
|
||||||
@ -10,6 +10,9 @@ $BB0_2:
|
|||||||
.set noat
|
.set noat
|
||||||
$JTI0_0:
|
$JTI0_0:
|
||||||
.gpword ($BB0_2)
|
.gpword ($BB0_2)
|
||||||
|
.word 0x77fffffc
|
||||||
|
# CHECK: $JTI0_0:
|
||||||
|
# CHECK-NEXT: .4byte 2013265916
|
||||||
.set at=$12
|
.set at=$12
|
||||||
.set macro
|
.set macro
|
||||||
.set reorder
|
.set reorder
|
||||||
|
Loading…
Reference in New Issue
Block a user