From f007e853e26845cd6866b52d646455fc69f4e0af Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 14 Jan 2010 21:32:45 +0000 Subject: [PATCH] prune #includes in TargetAsmParser.h Pass in SMLoc of instr opcode into ParseInstruction. Make AsmToken be a class, not a struct. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93457 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmLexer.h | 3 ++- include/llvm/MC/MCParsedAsmOperand.h | 4 ++-- include/llvm/Target/TargetAsmParser.h | 7 ++++--- lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 6 ++++-- lib/Target/X86/AsmParser/X86AsmParser.cpp | 6 ++++-- tools/llvm-mc/AsmParser.cpp | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/llvm/MC/MCAsmLexer.h b/include/llvm/MC/MCAsmLexer.h index da471d284cc..e9a6e3fda4a 100644 --- a/include/llvm/MC/MCAsmLexer.h +++ b/include/llvm/MC/MCAsmLexer.h @@ -20,7 +20,8 @@ class SMLoc; class Target; /// AsmToken - Target independent representation for an assembler token. -struct AsmToken { +class AsmToken { +public: enum TokenKind { // Markers Eof, Error, diff --git a/include/llvm/MC/MCParsedAsmOperand.h b/include/llvm/MC/MCParsedAsmOperand.h index 7c9e9e65c1e..847ab43f44d 100644 --- a/include/llvm/MC/MCParsedAsmOperand.h +++ b/include/llvm/MC/MCParsedAsmOperand.h @@ -18,8 +18,8 @@ namespace llvm { /// between parsing an asm instruction and recognizing it. class MCParsedAsmOperand { public: - MCParsedAsmOperand(); - virtual ~MCParsedAsmOperand() = 0; + MCParsedAsmOperand() {} + virtual ~MCParsedAsmOperand() {} // TODO: Out of line vfun. }; diff --git a/include/llvm/Target/TargetAsmParser.h b/include/llvm/Target/TargetAsmParser.h index ef1fc49cefe..a265610f2f2 100644 --- a/include/llvm/Target/TargetAsmParser.h +++ b/include/llvm/Target/TargetAsmParser.h @@ -10,13 +10,13 @@ #ifndef LLVM_TARGET_TARGETPARSER_H #define LLVM_TARGET_TARGETPARSER_H -#include "llvm/MC/MCAsmLexer.h" - namespace llvm { class MCAsmParser; class MCInst; class StringRef; class Target; +class SMLoc; +class AsmToken; /// TargetAsmParser - Generic interface to target specific assembly parsers. class TargetAsmParser { @@ -45,7 +45,8 @@ public: /// \param Name - The instruction name. /// \param Inst [out] - On success, the parsed instruction. /// \return True on failure. - virtual bool ParseInstruction(const StringRef &Name, MCInst &Inst) = 0; + virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, + MCInst &Inst) = 0; /// ParseDirective - Parse a target specific assembler directive /// diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index db776850464..9288384508c 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -95,7 +95,8 @@ public: ARMAsmParser(const Target &T, MCAsmParser &_Parser) : TargetAsmParser(T), Parser(_Parser) {} - virtual bool ParseInstruction(const StringRef &Name, MCInst &Inst); + virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, + MCInst &Inst); virtual bool ParseDirective(AsmToken DirectiveID); }; @@ -579,7 +580,8 @@ bool ARMAsmParser::ParseOperand(ARMOperand &Op) { } /// Parse an arm instruction mnemonic followed by its operands. -bool ARMAsmParser::ParseInstruction(const StringRef &Name, MCInst &Inst) { +bool ARMAsmParser::ParseInstruction(const StringRef &Name, SMLoc NameLoc, + MCInst &Inst) { SmallVector Operands; Operands.push_back(ARMOperand::CreateToken(Name)); diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 1237c45c5f9..d431aa67957 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -60,7 +60,8 @@ public: X86ATTAsmParser(const Target &T, MCAsmParser &_Parser) : TargetAsmParser(T), Parser(_Parser) {} - virtual bool ParseInstruction(const StringRef &Name, MCInst &Inst); + virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc, + MCInst &Inst); virtual bool ParseDirective(AsmToken DirectiveID); }; @@ -401,7 +402,8 @@ bool X86ATTAsmParser::ParseMemOperand(X86Operand &Op) { return false; } -bool X86ATTAsmParser::ParseInstruction(const StringRef &Name, MCInst &Inst) { +bool X86ATTAsmParser::ParseInstruction(const StringRef &Name, + SMLoc NameLoc, MCInst &Inst) { SmallVector Operands; Operands.push_back(X86Operand::CreateToken(Name)); diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index 1204a0054af..4ef3a7fc355 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -711,7 +711,7 @@ bool AsmParser::ParseStatement() { } MCInst Inst; - if (getTargetParser().ParseInstruction(IDVal, Inst)) + if (getTargetParser().ParseInstruction(IDVal, IDLoc, Inst)) return true; if (Lexer.isNot(AsmToken::EndOfStatement)) -- 2.34.1