1 //===-- llvm/Target/TargetAsmParser.h - Target Assembly Parser --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_TARGET_TARGETPARSER_H
11 #define LLVM_TARGET_TARGETPARSER_H
19 class MCParsedAsmOperand;
20 template <typename T> class SmallVectorImpl;
22 /// TargetAsmParser - Generic interface to target specific assembly parsers.
23 class TargetAsmParser {
24 TargetAsmParser(const TargetAsmParser &); // DO NOT IMPLEMENT
25 void operator=(const TargetAsmParser &); // DO NOT IMPLEMENT
26 protected: // Can only create subclasses.
27 TargetAsmParser(const Target &);
29 /// TheTarget - The Target that this machine was created for.
30 const Target &TheTarget;
33 virtual ~TargetAsmParser();
35 const Target &getTarget() const { return TheTarget; }
37 /// ParseInstruction - Parse one assembly instruction.
39 /// The parser is positioned following the instruction name. The target
40 /// specific instruction parser should parse the entire instruction and
41 /// construct the appropriate MCInst, or emit an error. On success, the entire
42 /// line should be parsed up to and including the end-of-statement token. On
43 /// failure, the parser is not required to read to the end of the line.
45 /// \param AP - The current parser object.
46 /// \param Name - The instruction name.
47 /// \param Operands [out] - The list of parsed operands, this returns
48 /// ownership of them to the caller.
49 /// \return True on failure.
50 virtual bool ParseInstruction(const StringRef &Name, SMLoc NameLoc,
51 SmallVectorImpl<MCParsedAsmOperand*> &Operands) = 0;
53 /// ParseDirective - Parse a target specific assembler directive
55 /// The parser is positioned following the directive name. The target
56 /// specific directive parser should parse the entire directive doing or
57 /// recording any target specific work, or return true and do nothing if the
58 /// directive is not target specific. If the directive is specific for
59 /// the target, the entire line is parsed up to and including the
60 /// end-of-statement token and false is returned.
62 /// \param ID - the identifier token of the directive.
63 virtual bool ParseDirective(AsmToken DirectiveID) = 0;
65 /// MatchInstruction - Recognize a series of operands of a parsed instruction
66 /// as an actual MCInst. This returns false and fills in Inst on success and
67 /// returns true on failure to match.
69 MatchInstruction(const SmallVectorImpl<MCParsedAsmOperand*> &Operands,
74 } // End llvm namespace