LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 namespace llvm {
14 class SMLoc;
15 class raw_ostream;
16 
17 /// MCParsedAsmOperand - This abstract class represents a source-level assembly
18 /// instruction operand. It should be subclassed by target-specific code. This
19 /// base class is used by target-independent clients and is the interface
20 /// between parsing an asm instruction and recognizing it.
22  /// MCOperandNum - The corresponding MCInst operand number. Only valid when
23  /// parsing MS-style inline assembly.
24  unsigned MCOperandNum;
25 
26  /// Constraint - The constraint on this operand. Only valid when parsing
27  /// MS-style inline assembly.
28  std::string Constraint;
29 
30 public:
32  virtual ~MCParsedAsmOperand() {}
33 
34  void setConstraint(StringRef C) { Constraint = C.str(); }
35  StringRef getConstraint() { return Constraint; }
36 
37  void setMCOperandNum (unsigned OpNum) { MCOperandNum = OpNum; }
38  unsigned getMCOperandNum() { return MCOperandNum; }
39 
40  virtual StringRef getSymName() { return StringRef(); }
41  virtual void *getOpDecl() { return 0; }
42 
43  /// isToken - Is this a token operand?
44  virtual bool isToken() const = 0;
45  /// isImm - Is this an immediate operand?
46  virtual bool isImm() const = 0;
47  /// isReg - Is this a register operand?
48  virtual bool isReg() const = 0;
49  virtual unsigned getReg() const = 0;
50 
51  /// isMem - Is this a memory operand?
52  virtual bool isMem() const = 0;
53 
54  /// getStartLoc - Get the location of the first token of this operand.
55  virtual SMLoc getStartLoc() const = 0;
56  /// getEndLoc - Get the location of the last token of this operand.
57  virtual SMLoc getEndLoc() const = 0;
58 
59  /// needAddressOf - Do we need to emit code to get the address of the
60  /// variable/label? Only valid when parsing MS-style inline assembly.
61  virtual bool needAddressOf() const { return false; }
62 
63  /// isOffsetOf - Do we need to emit code to get the offset of the variable,
64  /// rather then the value of the variable? Only valid when parsing MS-style
65  /// inline assembly.
66  virtual bool isOffsetOf() const { return false; }
67 
68  /// getOffsetOfLoc - Get the location of the offset operator.
69  virtual SMLoc getOffsetOfLoc() const { return SMLoc(); }
70 
71  /// print - Print a debug representation of the operand to the given stream.
72  virtual void print(raw_ostream &OS) const = 0;
73  /// dump - Print to the debug stream.
74  virtual void dump() const;
75 };
76 
77 //===----------------------------------------------------------------------===//
78 // Debugging Support
79 
81  MO.print(OS);
82  return OS;
83 }
84 
85 } // end namespace llvm.
86 
87 #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:181
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()
void setMCOperandNum(unsigned OpNum)
virtual bool isOffsetOf() const
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:1688
virtual bool needAddressOf() const
Represents a location in source code.
Definition: SMLoc.h:23
virtual bool isReg() const =0
isReg - Is this a register operand?