Skip to content

Commit 328f1f3

Browse files
committed
Review feedback
1 parent 139f7f2 commit 328f1f3

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

llvm/test/TableGen/AsmPredicateCombining.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ def insn1 : TestInsn<1, [AsmPred1]>;
6666
// DISASS: return FB[arch::AsmCond1]
6767

6868
def insn2 : TestInsn<2, [AsmPred2]>;
69-
// DISASS: return FB[arch::AsmCond2a] && FB[arch::AsmCond2b]
69+
// DISASS: return FB[arch::AsmCond2a] && FB[arch::AsmCond2b];
7070

7171
def insn3 : TestInsn<3, [AsmPred3]>;
72-
// DISASS: return FB[arch::AsmCond3a] || FB[arch::AsmCond3b]
72+
// DISASS: return FB[arch::AsmCond3a] || FB[arch::AsmCond3b];
7373

7474
def insn4 : TestInsn<4, [AsmPred1, AsmPred2]>;
75-
// DISASS: return FB[arch::AsmCond1] && (FB[arch::AsmCond2a] && FB[arch::AsmCond2b])
75+
// DISASS: return FB[arch::AsmCond1] && (FB[arch::AsmCond2a] && FB[arch::AsmCond2b]);
7676

7777
def insn5 : TestInsn<5, [AsmPred1, AsmPred3]>;
78-
// DISASS: return FB[arch::AsmCond1] && (FB[arch::AsmCond3a] || FB[arch::AsmCond3b])
78+
// DISASS: return FB[arch::AsmCond1] && (FB[arch::AsmCond3a] || FB[arch::AsmCond3b]);
7979

8080
def insn6 : TestInsn<6, []>;
8181
def : InstAlias<"alias1", (insn6 R0)> { let Predicates = [AsmPred1]; }

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ class DecoderTableBuilder {
518518
bool emitPredicateMatchAux(const Init &Val, bool ParenIfBinOp,
519519
raw_ostream &OS) const;
520520

521-
void emitPredicateMatch(raw_ostream &OS, unsigned EncodingID) const;
521+
bool emitPredicateMatch(raw_ostream &OS, unsigned EncodingID) const;
522522

523523
void emitPredicateTableEntry(unsigned EncodingID) const;
524524

@@ -1133,14 +1133,19 @@ bool DecoderTableBuilder::emitPredicateMatchAux(const Init &Val,
11331133
return true;
11341134
}
11351135

1136-
void DecoderTableBuilder::emitPredicateMatch(raw_ostream &OS,
1136+
// Returns true if there was any predicate emitted.
1137+
bool DecoderTableBuilder::emitPredicateMatch(raw_ostream &OS,
11371138
unsigned EncodingID) const {
1138-
const ListInit *PredicateList =
1139-
Encodings[EncodingID].getRecord()->getValueAsListInit("Predicates");
1140-
std::vector<const Record *> Predicates;
1141-
for (unsigned i = 0; i < PredicateList->size(); ++i)
1142-
Predicates.push_back(PredicateList->getElementAsRecord(i));
1139+
std::vector<const Record *> Predicates =
1140+
Encodings[EncodingID].getRecord()->getValueAsListOfDefs("Predicates");
1141+
auto It = llvm::find_if(Predicates, [](const Record *R) {
1142+
return R->getValueAsBit("AssemblerMatcherPredicate");
1143+
});
1144+
bool AnyAsmPredicate = It != Predicates.end();
1145+
if (!AnyAsmPredicate)
1146+
return false;
11431147
SubtargetFeatureInfo::emitMCPredicateCheck(OS, Target.getName(), Predicates);
1148+
return true;
11441149
}
11451150

11461151
unsigned DecoderTableBuilder::getPredicateIndex(StringRef Predicate) const {
@@ -1161,11 +1166,7 @@ void DecoderTableBuilder::emitPredicateTableEntry(unsigned EncodingID) const {
11611166
// Build up the predicate string.
11621167
SmallString<256> Predicate;
11631168
raw_svector_ostream PS(Predicate);
1164-
emitPredicateMatch(PS, EncodingID);
1165-
// Predicate being empty indicates that there are no predicates.
1166-
// Predicate being "false" indicate that there are predicates but with no
1167-
// AssemblerMatcherPredicate.
1168-
if (Predicate.empty() || Predicate == "false")
1169+
if (!emitPredicateMatch(PS, EncodingID))
11691170
return;
11701171

11711172
// Figure out the index into the predicate table for the predicate just

0 commit comments

Comments
 (0)