aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/MC/MCAsmLexer.h32
-rw-r--r--include/llvm/MC/MCAsmParser.h7
-rw-r--r--lib/MC/CMakeLists.txt1
-rw-r--r--lib/MC/MCAsmLexer.cpp18
-rw-r--r--lib/Target/X86/AsmParser/X86AsmParser.cpp40
-rw-r--r--tools/llvm-mc/AsmLexer.h3
-rw-r--r--tools/llvm-mc/AsmParser.h3
7 files changed, 91 insertions, 13 deletions
diff --git a/include/llvm/MC/MCAsmLexer.h b/include/llvm/MC/MCAsmLexer.h
new file mode 100644
index 0000000000..80628c3a3a
--- /dev/null
+++ b/include/llvm/MC/MCAsmLexer.h
@@ -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
diff --git a/include/llvm/MC/MCAsmParser.h b/include/llvm/MC/MCAsmParser.h
index 2379f21e5a..7cb6433a29 100644
--- a/include/llvm/MC/MCAsmParser.h
+++ b/include/llvm/MC/MCAsmParser.h
@@ -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 @@ protected: // Can only create subclasses.
public:
virtual ~MCAsmParser();
+
+ virtual MCAsmLexer &getLexer() = 0;
};
} // End llvm namespace
diff --git a/lib/MC/CMakeLists.txt b/lib/MC/CMakeLists.txt
index f0af7df959..3dd1e18191 100644
--- a/lib/MC/CMakeLists.txt
+++ b/lib/MC/CMakeLists.txt
@@ -1,4 +1,5 @@
add_llvm_library(LLVMMC
+ MCAsmLexer.cpp
MCAsmParser.cpp
MCAsmStreamer.cpp
MCContext.cpp
diff --git a/lib/MC/MCAsmLexer.cpp b/lib/MC/MCAsmLexer.cpp
new file mode 100644
index 0000000000..5cbcbfd6de
--- /dev/null
+++ b/lib/MC/MCAsmLexer.cpp
@@ -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() {
+}
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp
index b5f6ce608d..357ea6d342 100644
--- a/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -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 @@ X86ATTAsmParser::X86ATTAsmParser(const Target &T)
{
}
+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 {
diff --git a/tools/llvm-mc/AsmLexer.h b/tools/llvm-mc/AsmLexer.h
index 5d59d0ad77..32bbb50e9f 100644
--- a/tools/llvm-mc/AsmLexer.h
+++ b/tools/llvm-mc/AsmLexer.h
@@ -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 @@ namespace asmtok {
}
/// AsmLexer - Lexer class for assembly files.
-class AsmLexer {
+class AsmLexer : public MCAsmLexer {
SourceMgr &SrcMgr;
const char *CurPtr;
diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h
index b996758508..d9f4b4c197 100644
--- a/tools/llvm-mc/AsmParser.h
+++ b/tools/llvm-mc/AsmParser.h
@@ -24,6 +24,7 @@ class MCContext;
class MCInst;
class MCStreamer;
class MCValue;
+class TargetAsmParser;
class AsmParser : MCAsmParser {
public:
@@ -46,6 +47,8 @@ public:
public:
TargetAsmParser &getTargetParser() const { return TargetParser; }
+ virtual MCAsmLexer &getLexer() { return Lexer; }
+
private:
bool ParseStatement();