summaryrefslogtreecommitdiff
path: root/include/llvm/Target/TargetSelectionDAG.td
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-04-17 22:05:17 +0000
committerChris Lattner <sabre@nondot.org>2011-04-17 22:05:17 +0000
commit7ed1391ff66012e4963081cfb20b6166e8784f50 (patch)
tree5daca144fdadefe1c48e3479be81a0a96b35659b /include/llvm/Target/TargetSelectionDAG.td
parent543790673c747ab2793fc657e239ce5f78419dc0 (diff)
downloadllvm-7ed1391ff66012e4963081cfb20b6166e8784f50.tar.gz
llvm-7ed1391ff66012e4963081cfb20b6166e8784f50.tar.bz2
llvm-7ed1391ff66012e4963081cfb20b6166e8784f50.tar.xz
now that predicates have a decent abstraction layer on them, introduce a new
kind of predicate: one that is specific to imm nodes. The predicate function specified here just checks an int64_t directly instead of messing around with SDNode's. The virtue of this is that it means that fastisel and other things can reason about these predicates. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129675 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Target/TargetSelectionDAG.td')
-rw-r--r--include/llvm/Target/TargetSelectionDAG.td17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/Target/TargetSelectionDAG.td b/include/llvm/Target/TargetSelectionDAG.td
index ffb9c5ee49..f7fac7afa3 100644
--- a/include/llvm/Target/TargetSelectionDAG.td
+++ b/include/llvm/Target/TargetSelectionDAG.td
@@ -520,6 +520,7 @@ class PatFrag<dag ops, dag frag, code pred = [{}],
dag Operands = ops;
dag Fragment = frag;
code PredicateCode = pred;
+ code ImmediateCode = [{}];
SDNodeXForm OperandTransform = xform;
}
@@ -528,6 +529,22 @@ class PatFrag<dag ops, dag frag, code pred = [{}],
class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
: PatFrag<(ops), frag, pred, xform>;
+
+// ImmLeaf is a pattern fragment with a constraint on the immediate. The
+// constraint is a function that is run on the immediate (always with the value
+// sign extended out to an int64_t) as Imm. The value type being matched is
+// available as VT. For example:
+//
+// def immSExt8 : ImmLeaf<i16, [{ return (char)Imm == Imm; }]>;
+//
+// this is a more convenient form to match 'imm' nodes in than PatLeaf and also
+// is preferred over using PatLeaf because it allows the code generator to
+// reason more about the constraint.
+class ImmLeaf<ValueType vt, code pred> : PatFrag<(ops), (vt imm)> {
+ let ImmediateCode = pred;
+}
+
+
// Leaf fragments.
def vtInt : PatLeaf<(vt), [{ return N->getVT().isInteger(); }]>;