TableGen: permit non-leaf ComplexPattern uses

This allows the results of a ComplexPattern check to be distributed to separate
named Operands, instead of the current system where all results must apply (and
match perfectly) with a single Operand.

For example, if "some_addrmode" is a ComplexPattern producing two results, you
can write:

   def : Pat<(load (some_addrmode GPR64:$base, imm:$offset)),
             (INST GPR64:$base, imm:$offset)>;

This should allow neater instruction definitions in TableGen that don't put all
possible aspects of addressing into a single operand, but are still usable with
relatively simple C++ CodeGen idioms.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209206 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tim Northover
2014-05-20 11:52:46 +00:00
parent 57a98baa07
commit ee8d5c393e
4 changed files with 173 additions and 62 deletions
+13
View File
@@ -409,6 +409,12 @@ public:
const ComplexPattern *
getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const;
/// Returns the number of MachineInstr operands that would be produced by this
/// node if it mapped directly to an output Instruction's
/// operand. ComplexPattern specifies this explicitly; MIOperandInfo gives it
/// for Operands; otherwise 1.
unsigned getNumMIResults(const CodeGenDAGPatterns &CGP) const;
/// NodeHasProperty - Return true if this node has the specified property.
bool NodeHasProperty(SDNP Property, const CodeGenDAGPatterns &CGP) const;
@@ -527,6 +533,13 @@ class TreePattern {
/// hasError - True if the currently processed nodes have unresolvable types
/// or other non-fatal errors
bool HasError;
/// It's important that the usage of operands in ComplexPatterns is
/// consistent: each named operand can be defined by at most one
/// ComplexPattern. This records the ComplexPattern instance and the operand
/// number for each operand encountered in a ComplexPattern to aid in that
/// check.
StringMap<std::pair<Record *, unsigned>> ComplexPatternOperands;
public:
/// TreePattern constructor - Parse the specified DagInits into the