Tidy up trailing whitespace.
[oota-llvm.git] / include / llvm / MC / MCTargetAsmParser.h
1 //===-- llvm/MC/MCTargetAsmParser.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_MC_TARGETPARSER_H
11 #define LLVM_MC_TARGETPARSER_H
12
13 #include "llvm/MC/MCParser/MCAsmParserExtension.h"
14
15 namespace llvm {
16 class MCStreamer;
17 class StringRef;
18 class SMLoc;
19 class AsmToken;
20 class MCParsedAsmOperand;
21 template <typename T> class SmallVectorImpl;
22
23 /// MCTargetAsmParser - Generic interface to target specific assembly parsers.
24 class MCTargetAsmParser : public MCAsmParserExtension {
25   MCTargetAsmParser(const MCTargetAsmParser &);   // DO NOT IMPLEMENT
26   void operator=(const MCTargetAsmParser &);  // DO NOT IMPLEMENT
27 protected: // Can only create subclasses.
28   MCTargetAsmParser();
29
30   /// AvailableFeatures - The current set of available features.
31   unsigned AvailableFeatures;
32
33 public:
34   virtual ~MCTargetAsmParser();
35
36   unsigned getAvailableFeatures() const { return AvailableFeatures; }
37   void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }
38
39   virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc,
40                              SMLoc &EndLoc) = 0;
41
42   /// ParseInstruction - Parse one assembly instruction.
43   ///
44   /// The parser is positioned following the instruction name. The target
45   /// specific instruction parser should parse the entire instruction and
46   /// construct the appropriate MCInst, or emit an error. On success, the entire
47   /// line should be parsed up to and including the end-of-statement token. On
48   /// failure, the parser is not required to read to the end of the line.
49   //
50   /// \param Name - The instruction name.
51   /// \param NameLoc - The source location of the name.
52   /// \param Operands [out] - The list of parsed operands, this returns
53   ///        ownership of them to the caller.
54   /// \return True on failure.
55   virtual bool ParseInstruction(StringRef Name, SMLoc NameLoc,
56                             SmallVectorImpl<MCParsedAsmOperand*> &Operands) = 0;
57
58   /// ParseDirective - Parse a target specific assembler directive
59   ///
60   /// The parser is positioned following the directive name.  The target
61   /// specific directive parser should parse the entire directive doing or
62   /// recording any target specific work, or return true and do nothing if the
63   /// directive is not target specific. If the directive is specific for
64   /// the target, the entire line is parsed up to and including the
65   /// end-of-statement token and false is returned.
66   ///
67   /// \param DirectiveID - the identifier token of the directive.
68   virtual bool ParseDirective(AsmToken DirectiveID) = 0;
69
70   /// MatchAndEmitInstruction - Recognize a series of operands of a parsed
71   /// instruction as an actual MCInst and emit it to the specified MCStreamer.
72   /// This returns false on success and returns true on failure to match.
73   ///
74   /// On failure, the target parser is responsible for emitting a diagnostic
75   /// explaining the match failure.
76   virtual bool
77   MatchAndEmitInstruction(SMLoc IDLoc,
78                           SmallVectorImpl<MCParsedAsmOperand*> &Operands,
79                           MCStreamer &Out) = 0;
80
81 };
82
83 } // End llvm namespace
84
85 #endif