llvm.org GIT mirror llvm / 434f0e3
Revert of r213521. This change introduced a non-hermetic test (depending on a file not in the test/ area). Backing out now so that this test isn't part of the 3.5 branch. Original commit message: "TableGen: Allow AddedComplexity values to be negative [...]" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213596 91177308-0d34-0410-b5e6-96231b3b80d8 Richard Smith 5 years ago
4 changed file(s) with 7 addition(s) and 48 deletion(s). Raw diff Collapse all Expand all
+0
-41
test/TableGen/NegativeAddedComplexity.ll less more
None // RUN: llvm-tblgen -I../../include -gen-dag-isel %s | FileCheck %s
1 // XFAIL: vg_leak
2
3 include "llvm/Target/Target.td"
4
5 // Make sure the higher complexity pattern comes first
6 // CHECK: TARGET_VAL(::ADD0)
7 // CHECK: Complexity = {{[^-]}}
8 // Make sure the ADD1 pattern has a negative complexity
9 // CHECK: TARGET_VAL(::ADD1)
10 // CHECK: Complexity = -{{[0-9]+}}
11
12 def TestRC : RegisterClass<"TEST", [i32], 32, (add)>;
13
14 def TestInstrInfo : InstrInfo;
15
16 def Test : Target {
17 let InstructionSet = TestInstrInfo;
18 }
19
20 def ADD0 : Instruction {
21 let OutOperandList = (outs TestRC:$dst);
22 let InOperandList = (ins TestRC:$src0, TestRC:$src1);
23 }
24
25 def ADD1 : Instruction {
26 let OutOperandList = (outs TestRC:$dst);
27 let InOperandList = (ins TestRC:$src0, TestRC:$src1);
28 }
29
30 def : Pat <
31 (add i32:$src0, i32:$src1),
32 (ADD1 $src0, $src1)
33 > {
34 let AddedComplexity = -1000;
35 }
36
37 def : Pat <
38 (add i32:$src0, i32:$src1),
39 (ADD0 $src0, $src1)
40 >;
770770
771771 /// Compute the complexity metric for the input pattern. This roughly
772772 /// corresponds to the number of nodes that are covered.
773 int PatternToMatch::
773 unsigned PatternToMatch::
774774 getPatternComplexity(const CodeGenDAGPatterns &CGP) const {
775775 return getPatternSize(getSrcPattern(), CGP) + getAddedComplexity();
776776 }
666666 PatternToMatch(Record *srcrecord, ListInit *preds,
667667 TreePatternNode *src, TreePatternNode *dst,
668668 const std::vector &dstregs,
669 int complexity, unsigned uid)
669 unsigned complexity, unsigned uid)
670670 : SrcRecord(srcrecord), Predicates(preds), SrcPattern(src), DstPattern(dst),
671671 Dstregs(dstregs), AddedComplexity(complexity), ID(uid) {}
672672
675675 TreePatternNode *SrcPattern; // Source pattern to match.
676676 TreePatternNode *DstPattern; // Resulting pattern.
677677 std::vector Dstregs; // Physical register defs being matched.
678 int AddedComplexity; // Add to matching pattern complexity.
678 unsigned AddedComplexity; // Add to matching pattern complexity.
679679 unsigned ID; // Unique ID for the record.
680680
681681 Record *getSrcRecord() const { return SrcRecord; }
683683 TreePatternNode *getSrcPattern() const { return SrcPattern; }
684684 TreePatternNode *getDstPattern() const { return DstPattern; }
685685 const std::vector &getDstRegs() const { return Dstregs; }
686 int getAddedComplexity() const { return AddedComplexity; }
686 unsigned getAddedComplexity() const { return AddedComplexity; }
687687
688688 std::string getPredicateCheck() const;
689689
690690 /// Compute the complexity metric for the input pattern. This roughly
691691 /// corresponds to the number of nodes that are covered.
692 int getPatternComplexity(const CodeGenDAGPatterns &CGP) const;
692 unsigned getPatternComplexity(const CodeGenDAGPatterns &CGP) const;
693693 };
694694
695695 class CodeGenDAGPatterns {
9393 // Otherwise, if the patterns might both match, sort based on complexity,
9494 // which means that we prefer to match patterns that cover more nodes in the
9595 // input over nodes that cover fewer.
96 int LHSSize = LHS->getPatternComplexity(CGP);
97 int RHSSize = RHS->getPatternComplexity(CGP);
96 unsigned LHSSize = LHS->getPatternComplexity(CGP);
97 unsigned RHSSize = RHS->getPatternComplexity(CGP);
9898 if (LHSSize > RHSSize) return true; // LHS -> bigger -> less cost
9999 if (LHSSize < RHSSize) return false;
100100