LLVM 22.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"
14#include "llvm/Support/SMLoc.h"
15#include <string>
16
17namespace llvm {
18
19class MCAsmInfo;
20class MCRegister;
21class raw_ostream;
22
23/// MCParsedAsmOperand - This abstract class represents a source-level assembly
24/// instruction operand. It should be subclassed by target-specific code. This
25/// base class is used by target-independent clients and is the interface
26/// between parsing an asm instruction and recognizing it.
28 /// MCOperandNum - The corresponding MCInst operand number. Only valid when
29 /// parsing MS-style inline assembly.
30 unsigned MCOperandNum = ~0u;
31
32 /// Constraint - The constraint on this operand. Only valid when parsing
33 /// MS-style inline assembly.
34 std::string Constraint;
35
36protected:
37 // This only seems to need to be movable (by ARMOperand) but ARMOperand has
38 // lots of members and MSVC doesn't support defaulted move ops, so to avoid
39 // that verbosity, just rely on defaulted copy ops. It's only the Constraint
40 // string member that would benefit from movement anyway.
41 MCParsedAsmOperand() = default;
44
45public:
46 virtual ~MCParsedAsmOperand() = default;
47
48 void setConstraint(StringRef C) { Constraint = C.str(); }
49 StringRef getConstraint() { return Constraint; }
50
51 void setMCOperandNum (unsigned OpNum) { MCOperandNum = OpNum; }
52 unsigned getMCOperandNum() { return MCOperandNum; }
53
54 virtual StringRef getSymName() { return StringRef(); }
55 virtual void *getOpDecl() { return nullptr; }
56
57 /// isToken - Is this a token operand?
58 virtual bool isToken() const = 0;
59 /// isImm - Is this an immediate operand?
60 virtual bool isImm() const = 0;
61 /// isReg - Is this a register operand?
62 virtual bool isReg() const = 0;
63 virtual MCRegister getReg() const = 0;
64
65 /// isMem - Is this a memory operand?
66 virtual bool isMem() const = 0;
67
68 /// isMemUseUpRegs - Is memory operand use up regs, for example, intel MS
69 /// inline asm may use ARR[baseReg + IndexReg + ...] which may use up regs
70 /// in [...] expr, so ARR[baseReg + IndexReg + ...] can not use extra reg
71 /// for ARR. For example, calculating ARR address to a reg or use another
72 /// base reg in PIC model.
73 virtual bool isMemUseUpRegs() const { return false; }
74
75 /// getStartLoc - Get the location of the first token of this operand.
76 virtual SMLoc getStartLoc() const = 0;
77 /// getEndLoc - Get the location of the last token of this operand.
78 virtual SMLoc getEndLoc() const = 0;
79
80 /// needAddressOf - Do we need to emit code to get the address of the
81 /// variable/label? Only valid when parsing MS-style inline assembly.
82 virtual bool needAddressOf() const { return false; }
83
84 /// isOffsetOfLocal - Do we need to emit code to get the offset of the local
85 /// variable, rather than its value? Only valid when parsing MS-style inline
86 /// assembly.
87 virtual bool isOffsetOfLocal() const { return false; }
88
89 /// getOffsetOfLoc - Get the location of the offset operator.
90 virtual SMLoc getOffsetOfLoc() const { return SMLoc(); }
91
92 /// print - Print a debug representation of the operand to the given stream.
93 virtual void print(raw_ostream &, const MCAsmInfo &) const = 0;
94
95 /// dump - Print to the debug stream.
96 virtual void dump() const;
97};
98} // end namespace llvm
99
100#endif // LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ABI
Definition: Compiler.h:213
Value * RHS
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:64
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
virtual bool isMemUseUpRegs() const
isMemUseUpRegs - Is memory operand use up regs, for example, intel MS inline asm may use ARR[baseReg ...
virtual SMLoc getStartLoc() const =0
getStartLoc - Get the location of the first token of this operand.
void setConstraint(StringRef C)
MCParsedAsmOperand(const MCParsedAsmOperand &RHS)=default
virtual bool isReg() const =0
isReg - Is this a register operand?
virtual bool isMem() const =0
isMem - Is this a memory operand?
virtual ~MCParsedAsmOperand()=default
virtual bool needAddressOf() const
needAddressOf - Do we need to emit code to get the address of the variable/label? Only valid when par...
virtual SMLoc getOffsetOfLoc() const
getOffsetOfLoc - Get the location of the offset operator.
virtual MCRegister getReg() const =0
virtual bool isOffsetOfLocal() const
isOffsetOfLocal - Do we need to emit code to get the offset of the local variable,...
virtual StringRef getSymName()
virtual bool isToken() const =0
isToken - Is this a token operand?
virtual bool isImm() const =0
isImm - Is this an immediate operand?
void setMCOperandNum(unsigned OpNum)
virtual void print(raw_ostream &, const MCAsmInfo &) const =0
print - Print a debug representation of the operand to the given stream.
virtual SMLoc getEndLoc() const =0
getEndLoc - Get the location of the last token of this operand.
MCParsedAsmOperand & operator=(const MCParsedAsmOperand &)=default
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
Represents a location in source code.
Definition: SMLoc.h:23
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)