This patch removes redundant template argument `TargetName` from TIIPredicate. Tablegen can always infer the target name from the context. So we don't need to force users of TIIPredicate to always specify it. This allows us to better modularize the tablegen class hierarchy for the so-called "function predicates". class FunctionPredicateBase has been added; it is currently used as a building block for TIIPredicates. However, I plan to reuse that class to model other function predicate classes too (i.e. not just TIIPredicates). For example, this can be a first step towards implementing proper support for dependency breaking instructions in tablegen. This patch also adds a verification step on TIIPredicates in tablegen. We cannot have multiple TIIPredicates with the same name. Otherwise, this will cause build errors later on, when tablegen'd .inc files are included by cpp files and then compiled. Differential Revision: https://reviews.llvm.org/D50708 llvm-svn: 339706
57 lines
1.9 KiB
TableGen
57 lines
1.9 KiB
TableGen
//===-- X86SchedPredicates.td - X86 Scheduling Predicates --*- tablegen -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines scheduling predicate definitions that are common to
|
|
// all X86 subtargets.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// A predicate used to identify dependency-breaking instructions that clear the
|
|
// content of the destination register. Note that this predicate only checks if
|
|
// input registers are the same. This predicate doesn't make any assumptions on
|
|
// the expected instruction opcodes, because different processors may implement
|
|
// different zero-idioms.
|
|
def ZeroIdiomPredicate : CheckSameRegOperand<1, 2>;
|
|
|
|
// A predicate used to check if a LEA instruction uses all three source
|
|
// operands: base, index, and offset.
|
|
def IsThreeOperandsLEAPredicate: CheckAll<[
|
|
// isRegOperand(Base)
|
|
CheckIsRegOperand<1>,
|
|
CheckNot<CheckInvalidRegOperand<1>>,
|
|
|
|
// isRegOperand(Index)
|
|
CheckIsRegOperand<3>,
|
|
CheckNot<CheckInvalidRegOperand<3>>,
|
|
|
|
// hasLEAOffset(Offset)
|
|
CheckAny<[
|
|
CheckAll<[
|
|
CheckIsImmOperand<4>,
|
|
CheckNot<CheckZeroOperand<4>>
|
|
]>,
|
|
CheckNonPortable<"MI.getOperand(4).isGlobal()">
|
|
]>
|
|
]>;
|
|
|
|
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<"isThreeOperandsLEA", IsThreeOperandsLEABody>;
|