1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[Tablegen][PredicateExpander] Add the ability to define checks for invalid registers.

This was discussed in review D49436.

llvm-svn: 337378
This commit is contained in:
Andrea Di Biagio 2018-07-18 11:03:22 +00:00
parent 01cf565658
commit ef7e76afcf
2 changed files with 10 additions and 0 deletions

View File

@ -44,6 +44,12 @@ void PredicateExpander::expandCheckRegOperand(formatted_raw_ostream &OS,
OS << Reg->getName();
}
void PredicateExpander::expandCheckInvalidRegOperand(formatted_raw_ostream &OS,
int OpIndex) {
OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << OpIndex
<< ").getReg() " << (shouldNegate() ? "!= " : "== ") << "0";
}
void PredicateExpander::expandCheckSameRegOperand(formatted_raw_ostream &OS,
int First, int Second) {
OS << "MI" << (isByRef() ? "." : "->") << "getOperand(" << First
@ -206,6 +212,9 @@ void PredicateExpander::expandPredicate(formatted_raw_ostream &OS,
return expandCheckRegOperand(OS, Rec->getValueAsInt("OpIndex"),
Rec->getValueAsDef("Reg"));
if (Rec->isSubClassOf("CheckInvalidRegOperand"))
return expandCheckInvalidRegOperand(OS, Rec->getValueAsInt("OpIndex"));
if (Rec->isSubClassOf("CheckImmOperand"))
return expandCheckImmOperand(OS, Rec->getValueAsInt("OpIndex"),
Rec->getValueAsInt("ImmVal"));

View File

@ -73,6 +73,7 @@ public:
StringRef MethodName);
void expandCheckIsRegOperand(formatted_raw_ostream &OS, int OpIndex);
void expandCheckIsImmOperand(formatted_raw_ostream &OS, int OpIndex);
void expandCheckInvalidRegOperand(formatted_raw_ostream &OS, int OpIndex);
void expandCheckFunctionPredicate(formatted_raw_ostream &OS,
StringRef MCInstFn,
StringRef MachineInstrFn);