LLVM 22.0.0git
SDNodeInfo.h
Go to the documentation of this file.
1//==------------------------------------------------------------------------==//
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_CODEGEN_SDNODEINFO_H
10#define LLVM_CODEGEN_SDNODEINFO_H
11
12#include "llvm/ADT/ArrayRef.h"
16
17namespace llvm {
18
19class SDNode;
20class SelectionDAG;
21
30
46
50
55
60 /// For Kind == SDTCisVT or SDTCVecEltisVT:
61 /// - if not using HwMode, NumHwModes == 0 and VT is MVT::SimpleValueType;
62 /// - otherwise, VT is offset into VTByHwModeTable and NumHwModes specifies
63 /// the number of entries.
66};
67
69
70struct SDNodeDesc {
72 int16_t NumOperands;
76 unsigned NameOffset;
79
80 bool hasProperty(SDNP Property) const { return Properties & (1 << Property); }
81
82 bool hasFlag(SDNF Flag) const { return Flags & (1 << Flag); }
83};
84
85class SDNodeInfo final {
86 unsigned NumOpcodes;
87 const SDNodeDesc *Descs;
88 StringTable Names;
89 const VTByHwModePair *VTByHwModeTable;
90 const SDTypeConstraint *Constraints;
91
92public:
93 constexpr SDNodeInfo(unsigned NumOpcodes, const SDNodeDesc *Descs,
94 StringTable Names, const VTByHwModePair *VTByHwModeTable,
95 const SDTypeConstraint *Constraints)
96 : NumOpcodes(NumOpcodes), Descs(Descs), Names(Names),
97 VTByHwModeTable(VTByHwModeTable), Constraints(Constraints) {}
98
99 /// Returns true if there is a generated description for a node with the given
100 /// target-specific opcode.
101 bool hasDesc(unsigned Opcode) const {
102 assert(Opcode >= ISD::BUILTIN_OP_END && "Expected target-specific opcode");
103 return Opcode < ISD::BUILTIN_OP_END + NumOpcodes;
104 }
105
106 /// Returns the description of a node with the given opcode.
107 const SDNodeDesc &getDesc(unsigned Opcode) const {
108 assert(hasDesc(Opcode));
109 return Descs[Opcode - ISD::BUILTIN_OP_END];
110 }
111
112 /// Returns operand constraints for a node with the given opcode.
114 const SDNodeDesc &Desc = getDesc(Opcode);
115 return ArrayRef(&Constraints[Desc.ConstraintOffset], Desc.ConstraintCount);
116 }
117
118 /// Returns the name of the given target-specific opcode, suitable for
119 /// debug printing.
120 StringRef getName(unsigned Opcode) const {
121 return Names[getDesc(Opcode).NameOffset];
122 }
123
124 void verifyNode(const SelectionDAG &DAG, const SDNode *N) const;
125};
126
127} // namespace llvm
128
129#endif // LLVM_CODEGEN_SDNODEINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
const SDNodeDesc & getDesc(unsigned Opcode) const
Returns the description of a node with the given opcode.
Definition SDNodeInfo.h:107
void verifyNode(const SelectionDAG &DAG, const SDNode *N) const
constexpr SDNodeInfo(unsigned NumOpcodes, const SDNodeDesc *Descs, StringTable Names, const VTByHwModePair *VTByHwModeTable, const SDTypeConstraint *Constraints)
Definition SDNodeInfo.h:93
StringRef getName(unsigned Opcode) const
Returns the name of the given target-specific opcode, suitable for debug printing.
Definition SDNodeInfo.h:120
ArrayRef< SDTypeConstraint > getConstraints(unsigned Opcode) const
Returns operand constraints for a node with the given opcode.
Definition SDNodeInfo.h:113
bool hasDesc(unsigned Opcode) const
Returns true if there is a generated description for a node with the given target-specific opcode.
Definition SDNodeInfo.h:101
Represents one node in the SelectionDAG.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
A table of densely packed, null-terminated strings indexed by offset.
Definition StringTable.h:34
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
This is an optimization pass for GlobalISel generic memory operations.
uint32_t SDNodeTSFlags
Definition SDNodeInfo.h:68
Op::Description Desc
@ SDNPOptInGlue
Definition SDNodeInfo.h:26
@ SDNPVariadic
Definition SDNodeInfo.h:28
@ SDNPInGlue
Definition SDNodeInfo.h:25
@ SDNPOutGlue
Definition SDNodeInfo.h:24
@ SDNPMemOperand
Definition SDNodeInfo.h:27
@ SDNPHasChain
Definition SDNodeInfo.h:23
ArrayRef(const T &OneElt) -> ArrayRef< T >
@ SDNFIsStrictFP
Definition SDNodeInfo.h:48
@ SDTCisSameAs
Definition SDNodeInfo.h:37
@ SDTCisPtrTy
Definition SDNodeInfo.h:33
@ SDTCisOpSmallerThanOp
Definition SDNodeInfo.h:39
@ SDTCisSameSizeAs
Definition SDNodeInfo.h:44
@ SDTCisSameNumEltsAs
Definition SDNodeInfo.h:43
@ SDTCisEltOfVec
Definition SDNodeInfo.h:40
@ SDTCisVTSmallerThanOp
Definition SDNodeInfo.h:38
@ SDTCisInt
Definition SDNodeInfo.h:34
@ SDTCisVec
Definition SDNodeInfo.h:36
@ SDTCisVT
Definition SDNodeInfo.h:32
@ SDTCVecEltisVT
Definition SDNodeInfo.h:42
@ SDTCisSubVecOfVec
Definition SDNodeInfo.h:41
@ SDTCisFP
Definition SDNodeInfo.h:35
#define N
SDNodeTSFlags TSFlags
Definition SDNodeInfo.h:75
unsigned ConstraintOffset
Definition SDNodeInfo.h:77
unsigned NameOffset
Definition SDNodeInfo.h:76
int16_t NumOperands
Definition SDNodeInfo.h:72
uint16_t NumResults
Definition SDNodeInfo.h:71
bool hasProperty(SDNP Property) const
Definition SDNodeInfo.h:80
bool hasFlag(SDNF Flag) const
Definition SDNodeInfo.h:82
uint32_t Properties
Definition SDNodeInfo.h:73
unsigned ConstraintCount
Definition SDNodeInfo.h:78
uint8_t NumHwModes
For Kind == SDTCisVT or SDTCVecEltisVT:
Definition SDNodeInfo.h:64
MVT::SimpleValueType VT
Definition SDNodeInfo.h:53