LLVM  14.0.0git
MCParsedAsmOperand.h
Go to the documentation of this file.
1 //===- llvm/MC/MCParsedAsmOperand.h - Asm Parser Operand --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
10 #define LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
11 
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/MC/MCInstrDesc.h"
14 #include "llvm/Support/SMLoc.h"
15 #include <string>
16 
17 namespace llvm {
18 
19 class raw_ostream;
20 
21 /// MCParsedAsmOperand - This abstract class represents a source-level assembly
22 /// instruction operand. It should be subclassed by target-specific code. This
23 /// base class is used by target-independent clients and is the interface
24 /// between parsing an asm instruction and recognizing it.
26  /// MCOperandNum - The corresponding MCInst operand number. Only valid when
27  /// parsing MS-style inline assembly.
28  unsigned MCOperandNum;
29 
30  /// Constraint - The constraint on this operand. Only valid when parsing
31  /// MS-style inline assembly.
32  std::string Constraint;
33 
34 protected:
35  // This only seems to need to be movable (by ARMOperand) but ARMOperand has
36  // lots of members and MSVC doesn't support defaulted move ops, so to avoid
37  // that verbosity, just rely on defaulted copy ops. It's only the Constraint
38  // string member that would benefit from movement anyway.
39  MCParsedAsmOperand() = default;
40  MCParsedAsmOperand(const MCParsedAsmOperand &RHS) = default;
42 
43 public:
44  virtual ~MCParsedAsmOperand() = default;
45 
46  void setConstraint(StringRef C) { Constraint = C.str(); }
47  StringRef getConstraint() { return Constraint; }
48 
49  void setMCOperandNum (unsigned OpNum) { MCOperandNum = OpNum; }
50  unsigned getMCOperandNum() { return MCOperandNum; }
51 
52  virtual StringRef getSymName() { return StringRef(); }
53  virtual void *getOpDecl() { return nullptr; }
54 
55  /// isToken - Is this a token operand?
56  virtual bool isToken() const = 0;
57  /// isImm - Is this an immediate operand?
58  virtual bool isImm() const = 0;
59  /// isReg - Is this a register operand?
60  virtual bool isReg() const = 0;
61  virtual unsigned getReg() const = 0;
62 
63  /// isMem - Is this a memory operand?
64  virtual bool isMem() const = 0;
65 
66  /// getStartLoc - Get the location of the first token of this operand.
67  virtual SMLoc getStartLoc() const = 0;
68  /// getEndLoc - Get the location of the last token of this operand.
69  virtual SMLoc getEndLoc() const = 0;
70 
71  /// needAddressOf - Do we need to emit code to get the address of the
72  /// variable/label? Only valid when parsing MS-style inline assembly.
73  virtual bool needAddressOf() const { return false; }
74 
75  /// isOffsetOfLocal - Do we need to emit code to get the offset of the local
76  /// variable, rather than its value? Only valid when parsing MS-style inline
77  /// assembly.
78  virtual bool isOffsetOfLocal() const { return false; }
79 
80  /// isMemPlaceholder - Do we need to ignore the constraint, rather than emit
81  /// code? Only valid when parsing MS-style inline assembly.
82  virtual bool isMemPlaceholder(const MCInstrDesc &Desc) const { return false; }
83 
84  /// getOffsetOfLoc - Get the location of the offset operator.
85  virtual SMLoc getOffsetOfLoc() const { return SMLoc(); }
86 
87  /// print - Print a debug representation of the operand to the given stream.
88  virtual void print(raw_ostream &OS) const = 0;
89 
90  /// dump - Print to the debug stream.
91  virtual void dump() const;
92 };
93 
94 //===----------------------------------------------------------------------===//
95 // Debugging Support
96 
98  MO.print(OS);
99  return OS;
100 }
101 
102 } // end namespace llvm
103 
104 #endif // LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::MCParsedAsmOperand::~MCParsedAsmOperand
virtual ~MCParsedAsmOperand()=default
llvm::MCParsedAsmOperand::operator=
MCParsedAsmOperand & operator=(const MCParsedAsmOperand &)=default
llvm::MCParsedAsmOperand
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
Definition: MCParsedAsmOperand.h:25
llvm::MCParsedAsmOperand::getOpDecl
virtual void * getOpDecl()
Definition: MCParsedAsmOperand.h:53
llvm::MCParsedAsmOperand::setConstraint
void setConstraint(StringRef C)
Definition: MCParsedAsmOperand.h:46
MCInstrDesc.h
StringRef.h
llvm::MCParsedAsmOperand::getOffsetOfLoc
virtual SMLoc getOffsetOfLoc() const
getOffsetOfLoc - Get the location of the offset operator.
Definition: MCParsedAsmOperand.h:85
llvm::MCParsedAsmOperand::isReg
virtual bool isReg() const =0
isReg - Is this a register operand?
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::MCParsedAsmOperand::dump
virtual void dump() const
dump - Print to the debug stream.
Definition: MCAsmParser.cpp:162
llvm::MCParsedAsmOperand::MCParsedAsmOperand
MCParsedAsmOperand()=default
llvm::MCParsedAsmOperand::getStartLoc
virtual SMLoc getStartLoc() const =0
getStartLoc - Get the location of the first token of this operand.
llvm::MCParsedAsmOperand::setMCOperandNum
void setMCOperandNum(unsigned OpNum)
Definition: MCParsedAsmOperand.h:49
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::MCParsedAsmOperand::isMemPlaceholder
virtual bool isMemPlaceholder(const MCInstrDesc &Desc) const
isMemPlaceholder - Do we need to ignore the constraint, rather than emit code? Only valid when parsin...
Definition: MCParsedAsmOperand.h:82
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::MCParsedAsmOperand::getSymName
virtual StringRef getSymName()
Definition: MCParsedAsmOperand.h:52
llvm::MCInstrDesc
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:195
SMLoc.h
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::MCParsedAsmOperand::isToken
virtual bool isToken() const =0
isToken - Is this a token operand?
llvm::MCParsedAsmOperand::isMem
virtual bool isMem() const =0
isMem - Is this a memory operand?
llvm::MCParsedAsmOperand::getEndLoc
virtual SMLoc getEndLoc() const =0
getEndLoc - Get the location of the last token of this operand.
llvm::MCParsedAsmOperand::print
virtual void print(raw_ostream &OS) const =0
print - Print a debug representation of the operand to the given stream.
llvm::MCParsedAsmOperand::isImm
virtual bool isImm() const =0
isImm - Is this an immediate operand?
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::MCParsedAsmOperand::getReg
virtual unsigned getReg() const =0
llvm::MCParsedAsmOperand::getConstraint
StringRef getConstraint()
Definition: MCParsedAsmOperand.h:47
llvm::MCParsedAsmOperand::getMCOperandNum
unsigned getMCOperandNum()
Definition: MCParsedAsmOperand.h:50
llvm::MCParsedAsmOperand::isOffsetOfLocal
virtual bool isOffsetOfLocal() const
isOffsetOfLocal - Do we need to emit code to get the offset of the local variable,...
Definition: MCParsedAsmOperand.h:78
llvm::MCParsedAsmOperand::needAddressOf
virtual bool needAddressOf() const
needAddressOf - Do we need to emit code to get the address of the variable/label? Only valid when par...
Definition: MCParsedAsmOperand.h:73