diff options
| author | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-08-09 15:32:48 +0000 |
|---|---|---|
| committer | Andrea Di Biagio <Andrea_DiBiagio@sn.scee.net> | 2018-08-09 15:32:48 +0000 |
| commit | f3bde0485c2451487c0debc8719d290d56eb7009 (patch) | |
| tree | e52c0416302bc835bbd0477b54b260a2b5cf5017 /llvm/lib | |
| parent | 879c1421301af0880d711320bcc0df0d911b16a8 (diff) | |
| download | bcm5719-llvm-f3bde0485c2451487c0debc8719d290d56eb7009.tar.gz bcm5719-llvm-f3bde0485c2451487c0debc8719d290d56eb7009.zip | |
[MC][PredicateExpander] Extend the grammar to support simple switch and return statements.
This patch introduces tablegen class MCStatement.
Currently, an MCStatement can be either a return statement, or a switch
statement.
```
MCStatement:
MCReturnStatement
MCOpcodeSwitchStatement
```
A MCReturnStatement expands to a return statement, and the boolean expression
associated with the return statement is described by a MCInstPredicate.
An MCOpcodeSwitchStatement is a switch statement where the condition is a check
on the machine opcode. It allows the definition of multiple checks, as well as a
default case. More details on the grammar implemented by these two new
constructs can be found in the diff for TargetInstrPredicates.td.
This patch makes it easier to read the body of auto-generated TargetInstrInfo
predicates.
In future, I plan to reuse/extend the MCStatement grammar to describe more
complex target hooks. For now, this is just a first step (mostly a minor
cosmetic change to polish the new predicates framework).
Differential Revision: https://reviews.llvm.org/D50457
llvm-svn: 339352
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/X86/X86SchedPredicates.td | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Target/X86/X86SchedPredicates.td b/llvm/lib/Target/X86/X86SchedPredicates.td index 27aaeb19358..abb86119d45 100644 --- a/llvm/lib/Target/X86/X86SchedPredicates.td +++ b/llvm/lib/Target/X86/X86SchedPredicates.td @@ -19,11 +19,9 @@ // different zero-idioms. def ZeroIdiomPredicate : CheckSameRegOperand<1, 2>; -// A predicate used to check if an instruction is a LEA, and if it uses all -// three source operands: base, index, and offset. +// A predicate used to check if a LEA instruction uses all three source +// operands: base, index, and offset. def IsThreeOperandsLEAPredicate: CheckAll<[ - CheckOpcode<[LEA32r, LEA64r, LEA64_32r, LEA16r]>, - // isRegOperand(Base) CheckIsRegOperand<1>, CheckNot<CheckInvalidRegOperand<1>>, @@ -42,8 +40,17 @@ def IsThreeOperandsLEAPredicate: CheckAll<[ ]> ]>; +def LEACases : MCOpcodeSwitchCase< + [LEA32r, LEA64r, LEA64_32r, LEA16r], + MCReturnStatement<IsThreeOperandsLEAPredicate> +>; + +// Used to generate the body of a TII member function. +def IsThreeOperandsLEABody : + MCOpcodeSwitchStatement<[LEACases], MCReturnStatement<FalsePred>>; + // This predicate evaluates to true only if the input machine instruction is a // 3-operands LEA. Tablegen automatically generates a new method for it in // X86GenInstrInfo. def IsThreeOperandsLEAFn : - TIIPredicate<"X86", "isThreeOperandsLEA", IsThreeOperandsLEAPredicate>; + TIIPredicate<"X86", "isThreeOperandsLEA", IsThreeOperandsLEABody>; |

