[llvm-commits] [llvm] r76460 - in /llvm/trunk: include/llvm/MC/MCAsmLexer.h include/llvm/MC/MCAsmParser.h lib/MC/CMakeLists.txt lib/MC/MCAsmLexer.cpp lib/Target/X86/AsmParser/X86AsmParser.cpp tools/llvm-mc/AsmLexer.h tools/llvm-mc/AsmParser.h
Daniel Dunbar
daniel at zuster.org
Mon Jul 20 13:01:54 PDT 2009
Author: ddunbar
Date: Mon Jul 20 15:01:54 2009
New Revision: 76460
URL: http://llvm.org/viewvc/llvm-project?rev=76460&view=rev
Log:
Add MCAsmLexer interface.
- This provides the AsmLexer interface to the target specific assembly parsers.
Added:
llvm/trunk/include/llvm/MC/MCAsmLexer.h
llvm/trunk/lib/MC/MCAsmLexer.cpp
Modified:
llvm/trunk/include/llvm/MC/MCAsmParser.h
llvm/trunk/lib/MC/CMakeLists.txt
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/trunk/tools/llvm-mc/AsmLexer.h
llvm/trunk/tools/llvm-mc/AsmParser.h
Added: llvm/trunk/include/llvm/MC/MCAsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLexer.h?rev=76460&view=auto
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmLexer.h (added)
+++ llvm/trunk/include/llvm/MC/MCAsmLexer.h Mon Jul 20 15:01:54 2009
@@ -0,0 +1,32 @@
+//===-- llvm/MC/MCAsmLexer.h - Abstract Asm Lexer Interface -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_MC_MCASMLEXER_H
+#define LLVM_MC_MCASMLEXER_H
+
+namespace llvm {
+class MCAsmLexer;
+class MCInst;
+class Target;
+
+/// MCAsmLexer - Generic assembler lexer interface, for use by target specific
+/// assembly lexers.
+class MCAsmLexer {
+ MCAsmLexer(const MCAsmLexer &); // DO NOT IMPLEMENT
+ void operator=(const MCAsmLexer &); // DO NOT IMPLEMENT
+protected: // Can only create subclasses.
+ MCAsmLexer();
+
+public:
+ virtual ~MCAsmLexer();
+};
+
+} // End llvm namespace
+
+#endif
Modified: llvm/trunk/include/llvm/MC/MCAsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmParser.h?rev=76460&r1=76459&r2=76460&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmParser.h Mon Jul 20 15:01:54 2009
@@ -11,10 +11,7 @@
#define LLVM_MC_MCASMPARSER_H
namespace llvm {
-class MCAsmParser;
-class MCInst;
-class Target;
-class TargetAsmParser;
+class MCAsmLexer;
/// MCAsmParser - Generic assembler parser interface, for use by target specific
/// assembly parsers.
@@ -26,6 +23,8 @@
public:
virtual ~MCAsmParser();
+
+ virtual MCAsmLexer &getLexer() = 0;
};
} // End llvm namespace
Modified: llvm/trunk/lib/MC/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/CMakeLists.txt?rev=76460&r1=76459&r2=76460&view=diff
==============================================================================
--- llvm/trunk/lib/MC/CMakeLists.txt (original)
+++ llvm/trunk/lib/MC/CMakeLists.txt Mon Jul 20 15:01:54 2009
@@ -1,4 +1,5 @@
add_llvm_library(LLVMMC
+ MCAsmLexer.cpp
MCAsmParser.cpp
MCAsmStreamer.cpp
MCContext.cpp
Added: llvm/trunk/lib/MC/MCAsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmLexer.cpp?rev=76460&view=auto
==============================================================================
--- llvm/trunk/lib/MC/MCAsmLexer.cpp (added)
+++ llvm/trunk/lib/MC/MCAsmLexer.cpp Mon Jul 20 15:01:54 2009
@@ -0,0 +1,18 @@
+//===-- MCAsmLexer.cpp - Abstract Asm Lexer Interface ---------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/MCAsmLexer.h"
+
+using namespace llvm;
+
+MCAsmLexer::MCAsmLexer() {
+}
+
+MCAsmLexer::~MCAsmLexer() {
+}
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=76460&r1=76459&r2=76460&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Mon Jul 20 15:01:54 2009
@@ -8,21 +8,29 @@
//===----------------------------------------------------------------------===//
#include "X86.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCAsmParser.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetAsmParser.h"
using namespace llvm;
namespace {
+ struct X86Operand {
+ };
-class X86ATTAsmParser : public TargetAsmParser {
- public:
- explicit X86ATTAsmParser(const Target &);
-
- virtual bool ParseInstruction(MCAsmParser &AP, const char *Name,
- MCInst &Inst);
-};
-
+ class X86ATTAsmParser : public TargetAsmParser {
+ bool ParseOperand(X86Operand &Op);
+
+ bool MatchInstruction(const char *Name,
+ llvm::SmallVector<X86Operand, 3> &Operands,
+ MCInst &Inst);
+
+ public:
+ explicit X86ATTAsmParser(const Target &);
+
+ virtual bool ParseInstruction(MCAsmParser &AP, const char *Name,
+ MCInst &Inst);
+ };
}
X86ATTAsmParser::X86ATTAsmParser(const Target &T)
@@ -30,9 +38,25 @@
{
}
+bool X86ATTAsmParser::ParseOperand(X86Operand &Op) {
+ return true;
+}
+
+bool
+X86ATTAsmParser::MatchInstruction(const char *Name,
+ llvm::SmallVector<X86Operand, 3> &Operands,
+ MCInst &Inst) {
+ return false;
+}
+
bool X86ATTAsmParser::ParseInstruction(MCAsmParser &AP, const char *Name,
MCInst &Inst) {
- return true;
+ MCAsmLexer &Lexer = AP.getLexer();
+ llvm::SmallVector<X86Operand, 3> Operands;
+ (void) Lexer;
+ (void) Operands;
+
+ return MatchInstruction(Name, Operands, Inst);
}
namespace {
Modified: llvm/trunk/tools/llvm-mc/AsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.h?rev=76460&r1=76459&r2=76460&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmLexer.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmLexer.h Mon Jul 20 15:01:54 2009
@@ -14,6 +14,7 @@
#ifndef ASMLEXER_H
#define ASMLEXER_H
+#include "llvm/MC/MCAsmLexer.h"
#include "llvm/Support/DataTypes.h"
#include <string>
#include <cassert>
@@ -52,7 +53,7 @@
}
/// AsmLexer - Lexer class for assembly files.
-class AsmLexer {
+class AsmLexer : public MCAsmLexer {
SourceMgr &SrcMgr;
const char *CurPtr;
Modified: llvm/trunk/tools/llvm-mc/AsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmParser.h?rev=76460&r1=76459&r2=76460&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmParser.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmParser.h Mon Jul 20 15:01:54 2009
@@ -24,6 +24,7 @@
class MCInst;
class MCStreamer;
class MCValue;
+class TargetAsmParser;
class AsmParser : MCAsmParser {
public:
@@ -46,6 +47,8 @@
public:
TargetAsmParser &getTargetParser() const { return TargetParser; }
+ virtual MCAsmLexer &getLexer() { return Lexer; }
+
private:
bool ParseStatement();
More information about the llvm-commits
mailing list