demonstrate usage of Cases() mapping several strings to the same value; remove traili...
[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 #include "llvm/MC/MCAsmLexer.h"
14
15 namespace llvm {
16 class MCAsmParser;
17 class MCInst;
18 class StringRef;
19 class Target;
20
21 /// TargetAsmParser - Generic interface to target specific assembly parsers.
22 class TargetAsmParser {
23   TargetAsmParser(const TargetAsmParser &);   // DO NOT IMPLEMENT
24   void operator=(const TargetAsmParser &);  // DO NOT IMPLEMENT
25 protected: // Can only create subclasses.
26   TargetAsmParser(const Target &);
27  
28   /// TheTarget - The Target that this machine was created for.
29   const Target &TheTarget;
30
31 public:
32   virtual ~TargetAsmParser();
33
34   const Target &getTarget() const { return TheTarget; }
35
36   /// ParseInstruction - Parse one assembly instruction.
37   ///
38   /// The parser is positioned following the instruction name. The target
39   /// specific instruction parser should parse the entire instruction and
40   /// construct the appropriate MCInst, or emit an error. On success, the entire
41   /// line should be parsed up to and including the end-of-statement token. On
42   /// failure, the parser is not required to read to the end of the line.
43   //
44   /// \param AP - The current parser object.
45   /// \param Name - The instruction name.
46   /// \param Inst [out] - On success, the parsed instruction.
47   /// \return True on failure.
48   virtual bool ParseInstruction(const StringRef &Name, MCInst &Inst) = 0;
49
50   /// ParseDirective - Parse a target specific assembler directive
51   ///
52   /// The parser is positioned following the directive name.  The target
53   /// specific directive parser should parse the entire directive doing or
54   /// recording any target specific work, or return true and do nothing if the
55   /// directive is not target specific. If the directive is specific for
56   /// the target, the entire line is parsed up to and including the
57   /// end-of-statement token and false is returned.
58   ///
59   /// \param ID - the identifier token of the directive.
60   virtual bool ParseDirective(AsmToken DirectiveID) = 0;
61 };
62
63 } // End llvm namespace
64
65 #endif