aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/AVR/AsmParser
diff options
context:
space:
mode:
authorDylan McKay <me@dylanmckay.io>2017-12-09 07:51:37 +0000
committerDylan McKay <me@dylanmckay.io>2017-12-09 07:51:37 +0000
commitb45d5a85238f8527c6a740249d8894b2700746fa (patch)
tree876e777ff59dbd911f1cd694f80a2be2147522fd /lib/Target/AVR/AsmParser
parentae8f4e85a8e84c149b1da02c7586a5cf02a5c958 (diff)
Revert "[AVR] Override ParseDirective"
This reverts commit 57c16f9267969ebb09d6448607999b4a9f40c418. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320245 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/AVR/AsmParser')
-rw-r--r--lib/Target/AVR/AsmParser/AVRAsmParser.cpp92
1 files changed, 6 insertions, 86 deletions
diff --git a/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
index b527ad3e0b1..2e1adcc6a4f 100644
--- a/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
+++ b/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
@@ -9,7 +9,6 @@
#include "AVR.h"
#include "AVRRegisterInfo.h"
-#include "MCTargetDesc/AVRMCELFStreamer.h"
#include "MCTargetDesc/AVRMCExpr.h"
#include "MCTargetDesc/AVRMCTargetDesc.h"
@@ -41,7 +40,6 @@ class AVRAsmParser : public MCTargetAsmParser {
const MCSubtargetInfo &STI;
MCAsmParser &Parser;
const MCRegisterInfo *MRI;
- const std::string GENERATE_STUBS = "gs";
#define GET_ASSEMBLER_HEADER
#include "AVRGenAsmMatcher.inc"
@@ -56,7 +54,7 @@ class AVRAsmParser : public MCTargetAsmParser {
bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
SMLoc NameLoc, OperandVector &Operands) override;
- bool ParseDirective(AsmToken DirectiveID) override;
+ bool ParseDirective(AsmToken directiveID) override;
OperandMatchResultTy parseMemriOperand(OperandVector &Operands);
@@ -82,8 +80,6 @@ class AVRAsmParser : public MCTargetAsmParser {
uint64_t const &ErrorInfo);
bool missingFeature(SMLoc const &Loc, uint64_t const &ErrorInfo);
- bool parseLiteralValues(unsigned SizeInBytes, SMLoc L);
-
public:
AVRAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser,
const MCInstrInfo &MII, const MCTargetOptions &Options)
@@ -408,14 +404,11 @@ bool AVRAsmParser::tryParseRelocExpression(OperandVector &Operands) {
size_t ReadCount = Parser.getLexer().peekTokens(tokens);
if (ReadCount == 2) {
- if ((tokens[0].getKind() == AsmToken::Identifier &&
- tokens[1].getKind() == AsmToken::LParen) ||
- (tokens[0].getKind() == AsmToken::LParen &&
- tokens[1].getKind() == AsmToken::Minus)) {
+ if (tokens[0].getKind() == AsmToken::Identifier &&
+ tokens[1].getKind() == AsmToken::LParen) {
AsmToken::TokenKind CurTok = Parser.getLexer().getKind();
- if (CurTok == AsmToken::Minus ||
- tokens[1].getKind() == AsmToken::Minus) {
+ if (CurTok == AsmToken::Minus) {
isNegated = true;
} else {
assert(CurTok == AsmToken::Plus);
@@ -423,8 +416,7 @@ bool AVRAsmParser::tryParseRelocExpression(OperandVector &Operands) {
}
// Eat the sign
- if (CurTok == AsmToken::Minus || CurTok == AsmToken::Plus)
- Parser.Lex();
+ Parser.Lex();
}
}
@@ -440,34 +432,14 @@ bool AVRAsmParser::tryParseRelocExpression(OperandVector &Operands) {
if (ModifierKind != AVRMCExpr::VK_AVR_None) {
Parser.Lex();
Parser.Lex(); // Eat modifier name and parenthesis
- if (Parser.getTok().getString() == GENERATE_STUBS &&
- Parser.getTok().getKind() == AsmToken::Identifier) {
- std::string GSModName = ModifierName.str() + "_" + GENERATE_STUBS;
- ModifierKind = AVRMCExpr::getKindByName(GSModName.c_str());
- if (ModifierKind != AVRMCExpr::VK_AVR_None)
- Parser.Lex(); // Eat gs modifier name
- }
} else {
return Error(Parser.getTok().getLoc(), "unknown modifier");
}
- if (tokens[1].getKind() == AsmToken::Minus ||
- tokens[1].getKind() == AsmToken::Plus) {
- Parser.Lex();
- assert(Parser.getTok().getKind() == AsmToken::LParen);
- Parser.Lex(); // Eat the sign and parenthesis
- }
-
MCExpr const *InnerExpression;
if (getParser().parseExpression(InnerExpression))
return true;
- if (tokens[1].getKind() == AsmToken::Minus ||
- tokens[1].getKind() == AsmToken::Plus) {
- assert(Parser.getTok().getKind() == AsmToken::RParen);
- Parser.Lex(); // Eat closing parenthesis
- }
-
// If we have a modifier wrap the inner expression
assert(Parser.getTok().getKind() == AsmToken::RParen);
Parser.Lex(); // Eat closing parenthesis
@@ -608,59 +580,7 @@ bool AVRAsmParser::ParseInstruction(ParseInstructionInfo &Info,
return false;
}
-bool AVRAsmParser::ParseDirective(llvm::AsmToken DirectiveID) {
- StringRef IDVal = DirectiveID.getIdentifier();
- if (IDVal.lower() == ".long") {
- parseLiteralValues(SIZE_LONG, DirectiveID.getLoc());
- } else if (IDVal.lower() == ".word" || IDVal.lower() == ".short") {
- parseLiteralValues(SIZE_WORD, DirectiveID.getLoc());
- } else if (IDVal.lower() == ".byte") {
- parseLiteralValues(1, DirectiveID.getLoc());
- }
- return true;
-}
-
-bool AVRAsmParser::parseLiteralValues(unsigned SizeInBytes, SMLoc L) {
- MCAsmParser &Parser = getParser();
- AVRMCELFStreamer &AVRStreamer =
- static_cast<AVRMCELFStreamer &>(Parser.getStreamer());
- AsmToken Tokens[2];
- size_t ReadCount = Parser.getLexer().peekTokens(Tokens);
- if (ReadCount == 2 && Parser.getTok().getKind() == AsmToken::Identifier &&
- Tokens[0].getKind() == AsmToken::Minus &&
- Tokens[1].getKind() == AsmToken::Identifier) {
- MCSymbol *Symbol = getContext().getOrCreateSymbol(".text");
- AVRStreamer.EmitValueForModiferKind(Symbol, SizeInBytes, L,
- AVRMCExpr::VK_AVR_None);
- return false;
- }
-
- if (Parser.getTok().getKind() == AsmToken::Identifier &&
- Parser.getLexer().peekTok().getKind() == AsmToken::LParen) {
- StringRef ModifierName = Parser.getTok().getString();
- AVRMCExpr::VariantKind ModifierKind =
- AVRMCExpr::getKindByName(ModifierName.str().c_str());
- if (ModifierKind != AVRMCExpr::VK_AVR_None) {
- Parser.Lex();
- Parser.Lex(); // Eat the modifier and parenthesis
- } else {
- return Error(Parser.getTok().getLoc(), "unknown modifier");
- }
- MCSymbol *Symbol =
- getContext().getOrCreateSymbol(Parser.getTok().getString());
- AVRStreamer.EmitValueForModiferKind(Symbol, SizeInBytes, L, ModifierKind);
- return false;
- }
-
- auto parseOne = [&]() -> bool {
- const MCExpr *Value;
- if (Parser.parseExpression(Value))
- return true;
- Parser.getStreamer().EmitValue(Value, SizeInBytes, L);
- return false;
- };
- return (parseMany(parseOne));
-}
+bool AVRAsmParser::ParseDirective(llvm::AsmToken DirectiveID) { return true; }
extern "C" void LLVMInitializeAVRAsmParser() {
RegisterMCAsmParser<AVRAsmParser> X(getTheAVRTarget());