Commit Graph

81 Commits

Author SHA1 Message Date
Hal Finkel
c72cf87285 Add an OutPatFrag TableGen class
Unfortunately, it is currently impossible to use a PatFrag as part of an output
pattern (the part of the pattern that has instructions in it) in TableGen.
Looking at the current implementation, this was clearly intended to work (there
is already code in place to expand patterns in the output DAG), but is
currently broken by the baked-in type-checking assumption and the order in which
the pattern fragments are processed (output pattern fragments need to be
processed after the instruction definitions are processed).

Fixing this is fairly simple, but requires some way of differentiating output
patterns from the existing input patterns. The simplest way to handle this
seems to be to create a subclass of PatFrag, and so that's what I've done here.

As a simple example, this allows us to write:

def crnot : OutPatFrag<(ops node:$in),
                       (CRNOR $in, $in)>;

def       : Pat<(not i1:$in),
                (crnot $in)>;

which captures the core use case: handling of repeated subexpressions inside
of complicated output patterns.

This will be used by an upcoming commit to the PowerPC backend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202450 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 00:26:56 +00:00
Craig Topper
90790c3217 Improve handling of EnforceSmallerThan. Remove all types that are smaller from the larger set not just the smallest type from the smaller set. Ensure 'smaller' vectors have the same or fewer total bits. Similar for 'larger' vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200287 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-28 04:49:01 +00:00
Ahmed Bougacha
2b43ffff32 TableGen: Refactor DAG patterns to enable parsing one pattern at a time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193526 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-28 18:07:21 +00:00
Jakob Stoklund Olesen
7a42fb3b6e Make all unnamed RegisterClass TreePatternNodes typed MVT::i32.
A register class can appear as a leaf TreePatternNode with and without a
name:

  (COPY_TO_REGCLASS GPR:$src, F8RC)

In a named leaf node like GPR:$src, the register class provides type
information for the named variable represented by the node. The TypeSet
for such a node is the set of value types that the register class can
represent.

In an unnamed leaf node like F8RC above, the register class represents
itself as a kind of immediate. Such a node has the type MVT::i32,
we'll never create a virtual register representing it.

This change makes it possible to remove the special handling of
COPY_TO_REGCLASS in CodeGenDAGPatterns.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177825 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-23 18:08:44 +00:00
Jakob Stoklund Olesen
4c16916883 Extract a method.
This computes the type of an instruction operand or result based on the
records in the instruction's ins and outs lists.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177244 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-18 04:08:07 +00:00
Jakob Stoklund Olesen
26369a930c Use ArrayRef<MVT::SimpleValueType> when possible.
Not passing vector references around makes it possible to use
SmallVector in most places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177235 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-17 17:26:09 +00:00
Chandler Carruth
4ffd89fa4d Sort the #include lines for utils/...
I've tried to find main moudle headers where possible, but the TableGen
stuff may warrant someone else looking at it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169251 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 10:37:14 +00:00
Joerg Sonnenberger
61131ab15f Remove exception handling usage from tblgen.
Most places can use PrintFatalError as the unwinding mechanism was not
used for anything other than printing the error. The single exception
was CodeGenDAGPatterns.cpp, where intermediate errors during type
resolution were ignored to simplify incremental platform development.
This use is replaced by an error flag in TreePattern and bailout earlier
in various places if it is set. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166712 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-25 20:33:17 +00:00
Sean Silva
90fee07298 Refactor Record* by-ID comparator to Record.h
This is a generally useful utility; there's no reason to have it hidden
in CodeGenDAGPatterns.cpp.

Also, rename it to fit the other comparators in Record.h

Review by Jakob.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164189 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-19 01:47:00 +00:00
Tom Stellard
6d3d765653 Tablegen: Add OperandWithDefaultOps Operand type
This Operand type takes a default argument, and is initialized to
this value if it does not appear in a patter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163315 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-06 14:15:52 +00:00
Jakob Stoklund Olesen
325907d086 Check all patterns for missing instruction flags.
Both single-instruction and multi-instruction patterns can be checked
for missing mayLoad / mayStore, and hasSideEffects flags.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162734 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-28 03:26:49 +00:00
Craig Topper
655b8de7b2 Convert assert(0) to llvm_unreachable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149814 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-05 07:21:30 +00:00
David Greene
05bce0beee Unconstify Inits
Remove const qualifiers from Init references, per Chris' request.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136531 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 22:43:06 +00:00
David Greene
f37dd02f77 [AVX] Constify Inits
Make references to Inits const everywhere.  This is the final step
before making them unique.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136485 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 19:07:05 +00:00
David Greene
afd54269ab struct Init -> class Init
Rename struct Init to class Init for consistency and in preparation
for making Init a FoldingSetNode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135097 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-13 22:25:51 +00:00
Eric Christopher
d568b3f552 Revert r134921, 134917, 134908 and 134907. They're causing failures
in multiple buildbots.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134936 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 23:06:52 +00:00
Evan Cheng
9bcc399f1c struct Init -> class Init.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134917 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 20:23:13 +00:00
David Greene
d4a9066c93 [AVX] Make Inits Foldable
Manage Inits in a FoldingSet.  This provides several benefits:

- Memory for Inits is properly managed

- Duplicate Inits are folded into Flyweights, saving memory

- It enforces const-correctness, protecting against certain classes
  of bugs

The above benefits allow Inits to be used in more contexts, which in
turn provides more dynamism to TableGen.  This enhanced capability
will be used by the AVX code generator to a fold common patterns
together.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134907 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-11 18:25:51 +00:00
Chris Lattner
1518afddea Implement major new fastisel functionality: the matcher can now handle immediates with
value constraints on them (when defined as ImmLeaf's).  This is particularly important
for X86-64, where almost all reg/imm instructions take a i64immSExt32 immediate operand,
which has a value constraint.  Before this patch we ended up iseling the examples into
such amazing code as:

	movabsq	$7, %rax
	imulq	%rax, %rdi
	movq	%rdi, %rax
	ret

now we produce:

	imulq	$7, %rdi, %rax
	ret

This dramatically shrinks the generated code at -O0 on x86-64.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129691 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-18 06:22:33 +00:00
Chris Lattner
7ed1391ff6 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
2011-04-17 22:05:17 +00:00
Chris Lattner
543790673c Rework our internal representation of node predicates to expose more
structure and fix some fixmes.  We now have a TreePredicateFn class
that handles all of the decoding of these things.  This is an internal
cleanup that has no impact on the code generated by tblgen.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129670 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-17 21:38:24 +00:00
David Greene
6032269837 [AVX] Add type checking support for vector/subvector type constraints.
This will be used to check patterns referencing a forthcoming
INSERT_SUBVECTOR SDNode.  INSERT_SUBVECTOR in turn is very useful for
matching to VINSERTF128 instructions and complements the already
existing EXTRACT_SUBVECTOR SDNode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124145 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 20:53:18 +00:00
Jim Grosbach
398abb4a9a Trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:06:32 +00:00
Jim Grosbach
997759ac22 Add source Record* reference to PatternToMatch. Allows better diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121196 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 23:05:49 +00:00
Chris Lattner
acfb70f750 stop computing InstImpInputs, it is dead
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101881 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 06:30:25 +00:00
Chris Lattner
62bcec82b2 DAGInstruction::ImpOperands is dead after my recent tblgen work, zap it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101880 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 06:28:43 +00:00
Chris Lattner
48e86dbe29 print the complexity of the pattern being matched in the
comment in the generated table.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99794 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29 01:40:38 +00:00
Chris Lattner
2a22cdc716 improve type checking of SDNode operand count. This rejects all cases
where an incorrect number of operands is provided to an sdnode instead
of just a few cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99761 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-28 08:48:47 +00:00
Chris Lattner
c217305f76 eliminate a bunch of code duplication in ParseTreePattern
by rotating it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99746 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-28 06:50:34 +00:00
Chris Lattner
084df627c8 add plumbing for handling multiple result nodes
in some more places.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99366 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 00:41:19 +00:00
Chris Lattner
66fb9d26c6 bring sanity to EnforceVectorEltType
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99354 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24 00:01:16 +00:00
Chris Lattner
2e68a02c26 make getOperandNum a static function (since it's just used by
ApplyTypeConstraint) and make it handle multiple result nodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99003 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 21:56:21 +00:00
Chris Lattner
d734919465 major surgery on tblgen: generalize TreePatternNode
to maintain a list of types (one for each result of
the node) instead of a single type.  There are liberal
hacks added to emulate the old behavior in various
situations, but they can start disolving now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98999 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 21:37:09 +00:00
Chris Lattner
774ce29399 make FillWithPossibleTypes take a predicate to filter types so that
we don't blow the smallvector as often.  No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98968 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 17:41:26 +00:00
Chris Lattner
5a9b8fb95c rewrite EnforceSmallerThan to be less bone headed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98933 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 04:54:36 +00:00
Chris Lattner
aac5b5b2e5 eliminate the last use of EEVT::isUnknown
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98918 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 01:14:27 +00:00
Chris Lattner
e14d2e210d Finally change the instruction looking map to be a densemap from
record* -> instrinfo instead of std::string -> instrinfo.

This speeds up tblgen on cellcpu from 7.28 -> 5.98s with a debug
build (20%).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98916 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 01:07:44 +00:00
Chris Lattner
6c6ba36493 infer results of a pattern from implicit defs. This allows you to do something
like this:

 def : Pat<(add ...),
           (FOOINST)>;

When fooinst only has a single implicit def (e.g. to R1).  This will be handled
as if written as (set R1, (FOOINST ...))



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98897 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 23:15:10 +00:00
Chris Lattner
2cacec55f9 Completely rewrite tblgen's type inference mechanism,
changing the primary datastructure from being a 
"std::vector<unsigned char>" to being a new TypeSet class
that actually has (gasp) invariants!

This changes more things than I remember, but one major
innovation here is that it enforces that named input 
values agree in type with their output values.

This also eliminates code that transparently assumes (in 
some cases) that SDNodeXForm input/output types are the
same, because this is wrong in many case.

This also eliminates a bug which caused a lot of ambiguous
patterns to go undetected, where a register class would
sometimes pick the first possible type, causing an
ambiguous pattern to get arbitrary results.

With all the recent target changes, this causes no 
functionality change!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98534 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-15 06:00:16 +00:00
Chris Lattner
117ccb7e51 Fix PR2590 by making PatternSortingPredicate actually be
ordered correctly.  Previously it would get in trouble when
two patterns were too similar and give them nondet ordering.
We force this by using the record ID order as a fallback.

The testsuite diff is due to alpha patterns being ordered
slightly differently, the change is a semantic noop afaict:

< 	lda $0,-100($16)
---
> 	subq $16,100,$0



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97509 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01 22:09:11 +00:00
Chris Lattner
225798143d Generalize my hack to use SDNodeInfo to find out when a
node is always guaranteed to have a particular type 
instead of hacking in ISD::STORE explicitly.  This allows
us to use implied types for a broad range of nodes, even
target specific ones.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97355 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-28 00:22:30 +00:00
Chris Lattner
25b6f91c54 merge some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96896 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23 06:16:51 +00:00
Chris Lattner
b49985a849 start sketching out the structure of code for result emission generation.
Nothing real here yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96575 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 06:47:49 +00:00
Chris Lattner
e39650a805 add support for the new isel matcher to generate
(isprofitable|islegal)tofold checks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96331 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 06:10:58 +00:00
Chris Lattner
751d5aa1ea constize
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96199 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 22:33:49 +00:00
Chris Lattner
4766132036 clean up a bunch of code, move some random predicates
on TreePatternNode to be methods on TreePatternNode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96197 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 22:22:58 +00:00
Chris Lattner
383fed9c7a add an insertion operator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96187 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 21:10:33 +00:00
Daniel Dunbar
e854273892 Remove unneeded ';' and a class/struct mismatch (noticed by clang).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90934 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09 02:58:09 +00:00
Jakob Stoklund Olesen
11ee508d7b Report errors correctly for unselected target intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-15 18:50:03 +00:00
Bob Wilson
cdfa01bf0f PR4795: Remove EEVT::isFP, isInt and isVec types used by TableGen's type
inferencing.  As far as I can tell, these are equivalent to the existing
MVT::fAny, iAny and vAny types, and having both of them makes it harder
to reason about and modify the type inferencing code.

The specific problem in PR4795 occurs when updating a vAny type to be fAny
or iAny, or vice versa.  Both iAny and fAny include vector types -- they
intersect with the set of types represented by vAny.  When merging them,
choose fAny/iAny to represent the intersection.  This is not perfect, since
fAny/iAny also include scalar types, but it is good enough for TableGen's
type inferencing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80423 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-29 05:53:25 +00:00