Skip to content

Commit 18fafdc

Browse files
committed
Document tree nodes
1 parent 3ed446e commit 18fafdc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llvm/utils/TableGen/DecoderTree.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class DecoderTreeNode {
6969
KindTy Kind;
7070
};
7171

72+
/// Common base class for nodes with multiple children.
7273
class CheckManyNode : public DecoderTreeNode {
7374
SmallVector<std::unique_ptr<DecoderTreeNode>, 0> Children;
7475

@@ -101,16 +102,22 @@ class CheckManyNode : public DecoderTreeNode {
101102
}
102103
};
103104

105+
/// Executes child nodes one by one until one of them succeeds or all fail.
106+
/// The node fails if all child nodes fail. It never succeeds, because if a
107+
/// child node succeeds, it does not return.
104108
class CheckAnyNode : public CheckManyNode {
105109
public:
106110
CheckAnyNode() : CheckManyNode(CheckAny) {}
107111
};
108112

113+
/// Executes child nodes one by one until one of them fails all all succeed.
114+
/// The node fails if any of the child nodes fails.
109115
class CheckAllNode : public CheckManyNode {
110116
public:
111117
CheckAllNode() : CheckManyNode(CheckAll) {}
112118
};
113119

120+
/// Checks the value of encoding bits in the specified range.
114121
class CheckFieldNode : public DecoderTreeNode {
115122
unsigned StartBit;
116123
unsigned NumBits;
@@ -128,6 +135,10 @@ class CheckFieldNode : public DecoderTreeNode {
128135
uint64_t getValue() const { return Value; }
129136
};
130137

138+
/// Switch based on the value of encoding bits in the specified range.
139+
/// If the value of the bits in the range doesn't match any of the cases,
140+
/// the node fails. This is semantically equivalent to CheckAny node where
141+
/// every child is a CheckField node, but is faster.
131142
class SwitchFieldNode : public DecoderTreeNode {
132143
unsigned StartBit;
133144
unsigned NumBits;
@@ -166,6 +177,7 @@ class SwitchFieldNode : public DecoderTreeNode {
166177
}
167178
};
168179

180+
/// Checks that the instruction to be decoded has its predicates satisfied.
169181
class CheckPredicateNode : public DecoderTreeNode {
170182
unsigned PredicateIndex;
171183

@@ -176,6 +188,8 @@ class CheckPredicateNode : public DecoderTreeNode {
176188
unsigned getPredicateIndex() const { return PredicateIndex; }
177189
};
178190

191+
/// Checks if the encoding bits are correct w.r.t. SoftFail semantics.
192+
/// This is the only node that can never fail.
179193
class SoftFailNode : public DecoderTreeNode {
180194
uint64_t PositiveMask, NegativeMask;
181195

@@ -188,6 +202,7 @@ class SoftFailNode : public DecoderTreeNode {
188202
uint64_t getNegativeMask() const { return NegativeMask; }
189203
};
190204

205+
/// Attempts to decode the specified encoding as the specified instruction.
191206
class DecodeNode : public DecoderTreeNode {
192207
StringRef EncodingName;
193208
unsigned InstOpcode;

0 commit comments

Comments
 (0)