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
22enum SDNP {
29};
30
31enum SDTC : uint8_t {
45};
46
47enum SDNF {
49};
50
56};
57
59
60struct SDNodeDesc {
62 int16_t NumOperands;
66 unsigned NameOffset;
69
70 bool hasProperty(SDNP Property) const { return Properties & (1 << Property); }
71
72 bool hasFlag(SDNF Flag) const { return Flags & (1 << Flag); }
73};
74
75class SDNodeInfo final {
76 unsigned NumOpcodes;
77 const SDNodeDesc *Descs;
78 StringTable Names;
79 const SDTypeConstraint *Constraints;
80
81public:
82 constexpr SDNodeInfo(unsigned NumOpcodes, const SDNodeDesc *Descs,
83 StringTable Names, const SDTypeConstraint *Constraints)
84 : NumOpcodes(NumOpcodes), Descs(Descs), Names(Names),
85 Constraints(Constraints) {}
86
87 /// Returns true if there is a generated description for a node with the given
88 /// target-specific opcode.
89 bool hasDesc(unsigned Opcode) const {
90 assert(Opcode >= ISD::BUILTIN_OP_END && "Expected target-specific opcode");
91 return Opcode < ISD::BUILTIN_OP_END + NumOpcodes;
92 }
93
94 /// Returns the description of a node with the given opcode.
95 const SDNodeDesc &getDesc(unsigned Opcode) const {
96 assert(hasDesc(Opcode));
97 return Descs[Opcode - ISD::BUILTIN_OP_END];
98 }
99
100 /// Returns operand constraints for a node with the given opcode.
102 const SDNodeDesc &Desc = getDesc(Opcode);
103 return ArrayRef(&Constraints[Desc.ConstraintOffset], Desc.ConstraintCount);
104 }
105
106 /// Returns the name of the given target-specific opcode, suitable for
107 /// debug printing.
108 StringRef getName(unsigned Opcode) const {
109 return Names[getDesc(Opcode).NameOffset];
110 }
111
112 void verifyNode(const SelectionDAG &DAG, const SDNode *N) const;
113};
114
115} // namespace llvm
116
117#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:41
const SDNodeDesc & getDesc(unsigned Opcode) const
Returns the description of a node with the given opcode.
Definition: SDNodeInfo.h:95
constexpr SDNodeInfo(unsigned NumOpcodes, const SDNodeDesc *Descs, StringTable Names, const SDTypeConstraint *Constraints)
Definition: SDNodeInfo.h:82
void verifyNode(const SelectionDAG &DAG, const SDNode *N) const
Definition: SDNodeInfo.cpp:43
StringRef getName(unsigned Opcode) const
Returns the name of the given target-specific opcode, suitable for debug printing.
Definition: SDNodeInfo.h:108
ArrayRef< SDTypeConstraint > getConstraints(unsigned Opcode) const
Returns operand constraints for a node with the given opcode.
Definition: SDNodeInfo.h:101
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:89
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...
Definition: SelectionDAG.h:229
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:33
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:1568
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ 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
@ 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
Description of the encoding of one expression Op.
SDNodeTSFlags TSFlags
Definition: SDNodeInfo.h:65
uint32_t Flags
Definition: SDNodeInfo.h:64
unsigned ConstraintOffset
Definition: SDNodeInfo.h:67
unsigned NameOffset
Definition: SDNodeInfo.h:66
int16_t NumOperands
Definition: SDNodeInfo.h:62
uint16_t NumResults
Definition: SDNodeInfo.h:61
bool hasProperty(SDNP Property) const
Definition: SDNodeInfo.h:70
bool hasFlag(SDNF Flag) const
Definition: SDNodeInfo.h:72
uint32_t Properties
Definition: SDNodeInfo.h:63
unsigned ConstraintCount
Definition: SDNodeInfo.h:68
MVT::SimpleValueType VT
Definition: SDNodeInfo.h:55