a265610f2f2a61444f5c8f395940a7254054dd84
[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 StringRef;
17 class Target;
18 class SMLoc;
19 class AsmToken;
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, SMLoc NameLoc,
49                                 MCInst &Inst) = 0;
50
51   /// ParseDirective - Parse a target specific assembler directive
52   ///
53   /// The parser is positioned following the directive name.  The target
54   /// specific directive parser should parse the entire directive doing or
55   /// recording any target specific work, or return true and do nothing if the
56   /// directive is not target specific. If the directive is specific for
57   /// the target, the entire line is parsed up to and including the
58   /// end-of-statement token and false is returned.
59   ///
60   /// \param ID - the identifier token of the directive.
61   virtual bool ParseDirective(AsmToken DirectiveID) = 0;
62 };
63
64 } // End llvm namespace
65
66 #endif