Add MCAsmParser interface.
[oota-llvm.git] / include / llvm / Target / TargetAsmParser.h
1 //===-- llvm/Target/TargetAsmParser.h - Target Assembly Parser --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_TARGET_TARGETPARSER_H
11 #define LLVM_TARGET_TARGETPARSER_H
12
13 namespace llvm {
14 class MCAsmParser;
15 class MCInst;
16 class Target;
17
18 /// TargetAsmParser - Generic interface to target specific assembly parsers.
19 class TargetAsmParser {
20   TargetAsmParser(const TargetAsmParser &);   // DO NOT IMPLEMENT
21   void operator=(const TargetAsmParser &);  // DO NOT IMPLEMENT
22 protected: // Can only create subclasses.
23   TargetAsmParser(const Target &);
24  
25   /// TheTarget - The Target that this machine was created for.
26   const Target &TheTarget;
27
28 public:
29   virtual ~TargetAsmParser();
30
31   const Target &getTarget() const { return TheTarget; }
32
33   /// ParseInstruction - Parse one assembly instruction.
34   ///
35   /// The parser is positioned following the instruction name. The target
36   /// specific instruction parser should parse the entire instruction and
37   /// construct the appropriate MCInst, or emit an error. On success, the entire
38   /// line should be parsed up to and including the end-of-statement token. On
39   /// failure, the parser is not required to read to the end of the line.
40   //
41   /// \param AP - The current parser object.
42   /// \param Name - The instruction name.
43   /// \param Inst [out] - On success, the parsed instruction.
44   /// \return True on failure.
45   virtual bool ParseInstruction(MCAsmParser &AP, const char *Name, 
46                                 MCInst &Inst) = 0;
47 };
48
49 } // End llvm namespace
50
51 #endif