@@ -69,6 +69,7 @@ class DecoderTreeNode {
6969 KindTy Kind;
7070};
7171
72+ // / Common base class for nodes with multiple children.
7273class 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.
104108class CheckAnyNode : public CheckManyNode {
105109public:
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.
109115class CheckAllNode : public CheckManyNode {
110116public:
111117 CheckAllNode () : CheckManyNode(CheckAll) {}
112118};
113119
120+ // / Checks the value of encoding bits in the specified range.
114121class 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.
131142class 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.
169181class 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.
179193class 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.
191206class DecodeNode : public DecoderTreeNode {
192207 StringRef EncodingName;
193208 unsigned InstOpcode;
0 commit comments