[InstCombine] Signed saturation patterns
[llvm-core.git] / include / llvm / MC / MCParser / MCParsedAsmOperand.h
blob2b6e2aa48b8f1761d73741b8a09133ab5ac55e56
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
10 #define LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
12 #include "llvm/ADT/StringRef.h"
13 #include "llvm/Support/SMLoc.h"
14 #include <string>
16 namespace llvm {
18 class raw_ostream;
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.
24 class MCParsedAsmOperand {
25 /// MCOperandNum - The corresponding MCInst operand number. Only valid when
26 /// parsing MS-style inline assembly.
27 unsigned MCOperandNum;
29 /// Constraint - The constraint on this operand. Only valid when parsing
30 /// MS-style inline assembly.
31 std::string Constraint;
33 protected:
34 // This only seems to need to be movable (by ARMOperand) but ARMOperand has
35 // lots of members and MSVC doesn't support defaulted move ops, so to avoid
36 // that verbosity, just rely on defaulted copy ops. It's only the Constraint
37 // string member that would benefit from movement anyway.
38 MCParsedAsmOperand() = default;
39 MCParsedAsmOperand(const MCParsedAsmOperand &RHS) = default;
40 MCParsedAsmOperand &operator=(const MCParsedAsmOperand &) = default;
42 public:
43 virtual ~MCParsedAsmOperand() = default;
45 void setConstraint(StringRef C) { Constraint = C.str(); }
46 StringRef getConstraint() { return Constraint; }
48 void setMCOperandNum (unsigned OpNum) { MCOperandNum = OpNum; }
49 unsigned getMCOperandNum() { return MCOperandNum; }
51 virtual StringRef getSymName() { return StringRef(); }
52 virtual void *getOpDecl() { return nullptr; }
54 /// isToken - Is this a token operand?
55 virtual bool isToken() const = 0;
56 /// isImm - Is this an immediate operand?
57 virtual bool isImm() const = 0;
58 /// isReg - Is this a register operand?
59 virtual bool isReg() const = 0;
60 virtual unsigned getReg() const = 0;
62 /// isMem - Is this a memory operand?
63 virtual bool isMem() const = 0;
65 /// getStartLoc - Get the location of the first token of this operand.
66 virtual SMLoc getStartLoc() const = 0;
67 /// getEndLoc - Get the location of the last token of this operand.
68 virtual SMLoc getEndLoc() const = 0;
70 /// needAddressOf - Do we need to emit code to get the address of the
71 /// variable/label? Only valid when parsing MS-style inline assembly.
72 virtual bool needAddressOf() const { return false; }
74 /// isOffsetOf - Do we need to emit code to get the offset of the variable,
75 /// rather then the value of the variable? Only valid when parsing MS-style
76 /// inline assembly.
77 virtual bool isOffsetOf() const { return false; }
79 /// getOffsetOfLoc - Get the location of the offset operator.
80 virtual SMLoc getOffsetOfLoc() const { return SMLoc(); }
82 /// print - Print a debug representation of the operand to the given stream.
83 virtual void print(raw_ostream &OS) const = 0;
85 /// dump - Print to the debug stream.
86 virtual void dump() const;
89 //===----------------------------------------------------------------------===//
90 // Debugging Support
92 inline raw_ostream& operator<<(raw_ostream &OS, const MCParsedAsmOperand &MO) {
93 MO.print(OS);
94 return OS;
97 } // end namespace llvm
99 #endif // LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H