LLVM  3.7.0
MCParsedAsmOperand.h
Go to the documentation of this file.
1 //===-- llvm/MC/MCParsedAsmOperand.h - Asm Parser Operand -------*- 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_MCPARSER_MCPARSEDASMOPERAND_H
11 #define LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
12 
13 #include <string>
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/SMLoc.h"
16 
17 namespace llvm {
18 class raw_ostream;
19 
20 /// MCParsedAsmOperand - This abstract class represents a source-level assembly
21 /// instruction operand. It should be subclassed by target-specific code. This
22 /// base class is used by target-independent clients and is the interface
23 /// between parsing an asm instruction and recognizing it.
25  /// MCOperandNum - The corresponding MCInst operand number. Only valid when
26  /// parsing MS-style inline assembly.
27  unsigned MCOperandNum;
28 
29  /// Constraint - The constraint on this operand. Only valid when parsing
30  /// MS-style inline assembly.
31  std::string Constraint;
32 
33 public:
35  virtual ~MCParsedAsmOperand() {}
36 
37  void setConstraint(StringRef C) { Constraint = C.str(); }
38  StringRef getConstraint() { return Constraint; }
39 
40  void setMCOperandNum (unsigned OpNum) { MCOperandNum = OpNum; }
41  unsigned getMCOperandNum() { return MCOperandNum; }
42 
43  virtual StringRef getSymName() { return StringRef(); }
44  virtual void *getOpDecl() { return nullptr; }
45 
46  /// isToken - Is this a token operand?
47  virtual bool isToken() const = 0;
48  /// isImm - Is this an immediate operand?
49  virtual bool isImm() const = 0;
50  /// isReg - Is this a register operand?
51  virtual bool isReg() const = 0;
52  virtual unsigned getReg() const = 0;
53 
54  /// isMem - Is this a memory operand?
55  virtual bool isMem() const = 0;
56 
57  /// getStartLoc - Get the location of the first token of this operand.
58  virtual SMLoc getStartLoc() const = 0;
59  /// getEndLoc - Get the location of the last token of this operand.
60  virtual SMLoc getEndLoc() const = 0;
61 
62  /// needAddressOf - Do we need to emit code to get the address of the
63  /// variable/label? Only valid when parsing MS-style inline assembly.
64  virtual bool needAddressOf() const { return false; }
65 
66  /// isOffsetOf - Do we need to emit code to get the offset of the variable,
67  /// rather then the value of the variable? Only valid when parsing MS-style
68  /// inline assembly.
69  virtual bool isOffsetOf() const { return false; }
70 
71  /// getOffsetOfLoc - Get the location of the offset operator.
72  virtual SMLoc getOffsetOfLoc() const { return SMLoc(); }
73 
74  /// print - Print a debug representation of the operand to the given stream.
75  virtual void print(raw_ostream &OS) const = 0;
76  /// dump - Print to the debug stream.
77  virtual void dump() const;
78 };
79 
80 //===----------------------------------------------------------------------===//
81 // Debugging Support
82 
84  MO.print(OS);
85  return OS;
86 }
87 
88 } // end namespace llvm.
89 
90 #endif
virtual bool isToken() const =0
isToken - Is this a token operand?
void setConstraint(StringRef C)
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:188
virtual bool isMem() const =0
isMem - Is this a memory operand?
virtual SMLoc getOffsetOfLoc() const
getOffsetOfLoc - Get the location of the offset operator.
virtual StringRef getSymName()
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand...
void setMCOperandNum(unsigned OpNum)
virtual bool isOffsetOf() const
isOffsetOf - Do we need to emit code to get the offset of the variable, rather then the value of the ...
virtual unsigned getReg() const =0
virtual SMLoc getEndLoc() const =0
getEndLoc - Get the location of the last token of this operand.
virtual SMLoc getStartLoc() const =0
getStartLoc - Get the location of the first token of this operand.
virtual void dump() const
dump - Print to the debug stream.
Definition: MCAsmParser.cpp:46
virtual void print(raw_ostream &OS) const =0
print - Print a debug representation of the operand to the given stream.
virtual bool isImm() const =0
isImm - Is this an immediate operand?
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:1738
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
virtual bool needAddressOf() const
needAddressOf - Do we need to emit code to get the address of the variable/label? Only valid when par...
Represents a location in source code.
Definition: SMLoc.h:23
virtual bool isReg() const =0
isReg - Is this a register operand?