1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 12:02:58 +02:00
Commit Graph

129 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
e4801d77e1 Also compute TopoSigs in synthetic register classes.
CodeGenRegisterClass has two constructors. Both need to compute the
TopoSigs BitVector.

llvm-svn: 157271
2012-05-22 18:20:28 +00:00
Jakob Stoklund Olesen
a912a25126 Use RegUnits to compute overlapping registers.
TableGen already computes register units as the basic unit of
interference. We can use that to compute the set of overlapping
registers.

This means that we can easily compute overlap sets for one register at a
time. There is no benefit to computing all registers at once.

llvm-svn: 156960
2012-05-16 23:03:04 +00:00
Jakob Stoklund Olesen
c52390cafe Create a struct representing register units in TableGen.
Besides the weight, we also want to store up to two root registers per
unit. Most units will have a single root, the leaf register they
represent. Units created for ad hoc aliasing get two roots: The two
aliasing registers.

The root registers can be used to compute the set of overlapping
registers.

llvm-svn: 156792
2012-05-15 00:50:23 +00:00
Jakob Stoklund Olesen
6d4ef2b65f Consider ad hoc aliasing when building RegUnits.
Register units can be used to compute if two registers overlap:

  A overlaps B iff units(A) intersects units(B).

With this change, the above holds true even on targets that use ad hoc
aliasing (currently only ARM). This means that register units can be
used to implement regsOverlap() more efficiently, and the register
allocator can use the concept to model interference.

When there is no ad hoc aliasing, the register units correspond to the
maximal cliques in the register overlap graph. This is optimal, no other
register unit assignment can have fewer units.

With ad hoc aliasing, weird things are possible, and we don't try too
hard to compute the maximal cliques. The current approach is always
correct, and it works very well (probably optimally) as long as the ad
hoc aliasing doesn't have cliques larger than pairs. It seems unlikely
that any target would need more.

llvm-svn: 156763
2012-05-14 15:20:39 +00:00
Jakob Stoklund Olesen
a87c0f6c9d Record the ad hoc aliasing graph in CodeGenRegister.
The ad hoc aliasing specified in the 'Aliases' list in .td files is
currently only used by computeOverlaps(). It will soon be needed to
build accurate register units as well, so build the undirected graph in
CodeGenRegister::buildObjectGraph() instead.

Aliasing is a symmetric relationship with only one direction specified
in the .td files. Make sure both directions are represented in
getExplicitAliases().

llvm-svn: 156762
2012-05-14 15:12:37 +00:00
Jakob Stoklund Olesen
ce6916a00b Compute topological signatures of registers.
TableGen creates new register classes and sub-register indices based on
the sub-register structure present in the register bank. So far, it has
been doing that on a per-register basis, but that is not very efficient.

This patch teaches TableGen to compute topological signatures for
registers, and use that to reduce the amount of redundant computation.
Registers get the same TopoSig if they have identical sub-register
structure.

TopoSigs are not currently exposed outside TableGen.

llvm-svn: 156761
2012-05-14 15:10:07 +00:00
Jakob Stoklund Olesen
afe973fad4 Speed up computeComposites() by using the new SubReg -> SubIdx map.
TableGen doesn't need to search through the SubRegs map to find an
inverse entry.

llvm-svn: 156690
2012-05-12 02:02:26 +00:00
Bill Wendling
55c91b69ec Remove extraneous ; and the resulting warning.
llvm-svn: 156649
2012-05-11 21:56:04 +00:00
Jakob Stoklund Olesen
041239982f Defer computation of SuperRegs.
Don't compute the SuperRegs list until the sub-register graph is
completely finished. This guarantees that the list of super-registers is
properly topologically ordered, and has no duplicates.

llvm-svn: 156629
2012-05-11 19:01:01 +00:00
Jakob Stoklund Olesen
5a51c567a1 Compute secondary sub-registers.
The sub-registers explicitly listed in SubRegs in the .td files form a
tree. In a complicated register bank, it is possible to have
sub-register relationships across sub-trees. For example, the ARM NEON
double vector Q0_Q1 is a tree:

  Q0_Q1 = [Q0, Q1],  Q0 = [D0, D1], Q1 = [D2, D3]

But we also define the DPair register D1_D2 = [D1, D2] which is fully
contained in Q0_Q1.

This patch teaches TableGen to find such sub-register relationships, and
assign sub-register indices to them. In the example, TableGen will
create a dsub_1_dsub_2 sub-register index, and add D1_D2 as a
sub-register of Q0_Q1.

This will eventually enable the coalescer to handle copies of skewed
sub-registers.

llvm-svn: 156587
2012-05-10 23:27:10 +00:00
Jakob Stoklund Olesen
e762a8379f Precompute lists of explicit sub-registers and indices.
The .td files specify a tree of sub-registers. Store that tree as
ExplicitSubRegs lists in CodeGenRegister instead of extracting it from
the Record when needed.

llvm-svn: 156555
2012-05-10 17:46:18 +00:00
Andrew Trick
ac3b83d82b Fix TableGen's RegPressureSet weight normalization to handle subreg DAGS.
I initially assumed that the subreg graph was a tree. That may not be true.

llvm-svn: 156524
2012-05-10 00:32:15 +00:00
Jakob Stoklund Olesen
fbf5e9ff6f Fix warning text.
llvm-svn: 156521
2012-05-09 23:43:30 +00:00
Jakob Stoklund Olesen
b010f9d251 Compute a backwards SubReg -> SubRegIndex map for each register.
This mapping is for internal use by TableGen. It will not be exposed in
the generated files.

Unfortunately, the mapping is not completely well-defined. The X86 xmm
registers appear with multiple sub-register indices in the ymm
registers. This is because of the odd idempotent sub_sd and sub_ss
sub-register indices. I hope to be able to eliminate them entirely, so
we can require the sub-registers to form a tree.

For now, just place the canonical sub_xmm index in the mapping, and
ignore the idempotents.

llvm-svn: 156519
2012-05-09 22:15:00 +00:00
Jakob Stoklund Olesen
da59286b98 Rename getSubRegs() to computeSubRegs().
That's what it does.

llvm-svn: 156518
2012-05-09 22:09:17 +00:00
Jakob Stoklund Olesen
fb40ced513 Order register classes by spill size first, members last.
This is still a topological ordering such that every register class gets
a smaller enum value than its sub-classes.

Placing the smaller spill sizes first makes a difference for the
super-register class bit masks. When looking for a super-register class,
we usually want the smallest possible kind of super-register. That is
now available as the first bit set in the bit mask.

llvm-svn: 156222
2012-05-04 23:12:22 +00:00
Jakob Stoklund Olesen
2c4618568d Remove TargetRegisterClass::SuperRegClasses.
This manually enumerated list of super-register classes has been
superceeded by the automatically computed super-register class masks
available through SuperRegClassIterator.

llvm-svn: 156151
2012-05-04 03:30:28 +00:00
Benjamin Kramer
2991126d0d tblgen: remove duplicated newlines.
llvm-svn: 155038
2012-04-18 19:22:47 +00:00
Jim Grosbach
26c6c85855 Move a few more warnings to use PrintWarning().
llvm-svn: 155027
2012-04-18 18:39:31 +00:00
Andrew Trick
6d7aff8241 TableGen's regpressure: emit per-registerclass weight limits.
llvm-svn: 154518
2012-04-11 18:16:28 +00:00
Andrew Trick
2628429e92 TableGen'd regpressure: register unit set pruning.
The pruning is more complete if it is not done incrementally. The code
is also a tad less convluted.

llvm-svn: 154510
2012-04-11 17:35:26 +00:00
Andrew Trick
ccfe0f1fc6 Table-generated register pressure fixes.
Handle mixing allocatable and unallocatable register gracefully.
Simplify the pruning of register unit sets.

llvm-svn: 154474
2012-04-11 03:19:15 +00:00
Andrew Trick
0c60300f39 TableGen/reginfo potential bug: typo from previous checkin.
llvm-svn: 154452
2012-04-10 23:53:32 +00:00
Andrew Trick
360c19ad86 Fix for register pressure tables.
Recent refactoring introduced a bug. Fix: added buildRegUnitSets.

llvm-svn: 154382
2012-04-10 03:36:49 +00:00
Andrew Trick
218abb3a9c Use std::includes instead of my own implementation.
Jakob's review.

llvm-svn: 154377
2012-04-10 03:12:29 +00:00
Andrew Trick
6b7d15e240 Added register unit sets to the target description.
This is a new algorithm that finds sets of register units that can be
used to model registers pressure. This handles arbitrary, overlapping
register classes. Each register class is associated with a (small)
list of pressure sets. These are the dimensions of pressure affected
by the register class's liveness.

llvm-svn: 154374
2012-04-10 02:25:24 +00:00
Andrew Trick
f73fa6bef2 Added register unit weights to the target description.
This is a new algorithm that associates registers with weighted
register units to accuretely model their effect on register
pressure. This handles registers with multiple overlapping
subregisters. It is possible, but almost inconceivable that the
algorithm fails to find an exact solution for a target description. If
an exact solution cannot be found, an inexact, but reasonable solution
will be chosen.

llvm-svn: 154373
2012-04-10 02:25:21 +00:00
Andrew Trick
a1e25f74dd Cleanup set_union usage. The same thing but a bit cleaner now.
llvm-svn: 153922
2012-04-03 01:35:52 +00:00
Andrew Trick
a92546a4bb Use std::set_union instead of nasty custom code.
I just noticed Jakob's examples of the proper application of
std::set... routines.

llvm-svn: 153918
2012-04-03 00:47:23 +00:00
Andrew Trick
e5028d95da comment typo
llvm-svn: 153796
2012-03-31 02:39:17 +00:00
Andrew Trick
f1fa07f326 Introduce Register Units: Give each leaf register a number.
First small step toward modeling multi-register multi-pressure. In the
future, register units can also be used to model liveness and
aliasing.

llvm-svn: 153794
2012-03-31 01:35:59 +00:00
Jakob Stoklund Olesen
3da52049b4 Add more constness to CodeGenRegisters.
llvm-svn: 153667
2012-03-29 18:03:59 +00:00
Jakob Stoklund Olesen
230a0a4b40 Specify SubRegIndex components on the index itself.
It is simpler to define a composite index directly:

  def ssub_2 : SubRegIndex<[dsub_1, ssub_0]>;
  def ssub_3 : SubRegIndex<[dsub_1, ssub_1]>;

Than specifying the composite indices on each register:

  CompositeIndices = [(ssub_2 dsub_1, ssub_0),
                      (ssub_3 dsub_1, ssub_1)] in ...

This also makes it clear that SubRegIndex composition is supposed to be
unique.

llvm-svn: 149556
2012-02-01 23:16:41 +00:00
Jakob Stoklund Olesen
b1190d3876 Fix a bug in the TopoOrderRC comparison function.
The final tie breaker comparison also needs to return +/-1, or 0.
This is not a less() function.

This could cause otherwise identical super-classes to be ordered
unstably, depending on what the system qsort routine does with a bad
compare function.

llvm-svn: 149549
2012-02-01 22:19:26 +00:00
Jakob Stoklund Olesen
6ce052d3b3 Move the composite map into CodeGenSubRegIndex.
Each SubRegIndex keeps track of how it composes.

llvm-svn: 149423
2012-01-31 21:44:11 +00:00
Jakob Stoklund Olesen
6ec7412170 Add a TableGen CodeGenSubRegIndex class.
This class is used to represent SubRegIndex instances instead of the raw
Record pointers that were used before.

No functional change intended.

llvm-svn: 149418
2012-01-31 20:57:55 +00:00
Jakob Stoklund Olesen
e9c53bc69b Add a CoveredBySubRegs property to Register descriptions.
When set, this bit indicates that a register is completely defined by
the value of its sub-registers.

Use the CoveredBySubRegs property to infer which super-registers are
call-preserved given a list of callee-saved registers.  For example, the
ARM registers D8-D15 are callee-saved.  This now automatically implies
that Q4-Q7 are call-preserved.

Conversely, Win64 callees save XMM6-XMM15, but the corresponding
YMM6-YMM15 registers are not call-preserved because they are not fully
defined by their sub-registers.

llvm-svn: 148363
2012-01-18 00:16:39 +00:00
Jakob Stoklund Olesen
c5fac0a05c Add TableGen support for callee saved registers.
Targets can now add CalleeSavedRegs defs to their *CallingConv.td file.
TableGen will use this to create a *_SaveList array suitable for
returning from getCalleeSavedRegs() as well as a *_RegMask bit mask
suitable for returning from getCallPreservedMask().

llvm-svn: 148346
2012-01-17 22:46:58 +00:00
Jakob Stoklund Olesen
c477c8d35e Skip the NAME field when forming tuples.
llvm-svn: 148147
2012-01-13 22:23:50 +00:00
Jakob Stoklund Olesen
9ba097a208 Delete CodeInit and CodeRecTy from TableGen.
The code type was always identical to a string anyway. Now it is simply
a synonym. The code literal syntax [{...}] is still valid.

llvm-svn: 148092
2012-01-13 03:38:34 +00:00
Jakob Stoklund Olesen
0aa2f7755a Emit a getMatchingSuperRegClass() implementation for every target.
Use information computed while inferring new register classes to emit
accurate, table-driven implementations of getMatchingSuperRegClass().

Delete the old manual, error-prone implementations in the targets.

llvm-svn: 146873
2011-12-19 16:53:34 +00:00
Jakob Stoklund Olesen
78291d0bac Synthesize register classes for TRI::getMatchingSuperRegClass().
Teach TableGen to create the missing register classes needed for
getMatchingSuperRegClass() to return maximal results.  The function is
still not auto-generated, so it still returns inexact results.

This produces these new register classes:

ARM:
    QQPR_with_dsub_0_in_DPR_8
    QQQQPR_with_dsub_0_in_DPR_8
X86:
    GR64_with_sub_32bit_in_GR32_NOAX
    GR64_with_sub_32bit_in_GR32_NOAX_and_GR32_NOSP
    GR64_with_sub_16bit_in_GR16_NOREX
    GR64_with_sub_32bit_in_GR32_NOAX_and_GR32_NOREX
    GR64_TC_and_GR64_with_sub_32bit_in_GR32_NOAX
    GR64_with_sub_32bit_in_GR32_NOAX_and_GR32_NOREX_NOSP
    GR64_TCW64_and_GR64_with_sub_32bit_in_GR32_NOAX
    GR64_TC_and_GR64_with_sub_32bit_in_GR32_NOAX_and_GR32_NOREX
    GR64_with_sub_32bit_in_GR32_TC
    GR64_with_sub_32bit_in_GR32_ABCD_and_GR32_NOAX
    GR64_with_sub_32bit_in_GR32_NOAX_and_GR32_TC
    GR64_with_sub_32bit_in_GR32_AD
    GR64_with_sub_32bit_in_GR32_AD_and_GR32_NOAX

The other targets in the tree are not weird enough to be affected.

llvm-svn: 146872
2011-12-19 16:53:28 +00:00
Jakob Stoklund Olesen
f51f7724cb Extract a method. No functional change.
llvm-svn: 146713
2011-12-16 00:12:05 +00:00
Jakob Stoklund Olesen
bc821819f3 Use the proper comparator for set_intersection.
llvm-svn: 146674
2011-12-15 19:26:23 +00:00
Jakob Stoklund Olesen
9945c85b52 Synthesize missing register class intersections.
The function TRI::getCommonSubClass(A, B) returns the largest common
sub-class of the register classes A and B.  This patch teaches TableGen
to synthesize sub-classes such that the answer is always maximal.

In other words, every register that is in both A and B will also be
present in getCommonSubClass(A, B).

This introduces these synthetic register classes:

ARM:
    GPRnopc_and_hGPR
    GPRnopc_and_hGPR
    hGPR_and_rGPR
    GPRnopc_and_hGPR
    GPRnopc_and_hGPR
    hGPR_and_rGPR
    tGPR_and_tcGPR
    hGPR_and_tcGPR

X86:
    GR32_NOAX_and_GR32_NOSP
    GR32_NOAX_and_GR32_NOREX
    GR64_NOSP_and_GR64_TC
    GR64_NOSP_and_GR64_TC
    GR64_NOREX_and_GR64_TC
    GR32_NOAX_and_GR32_NOSP
    GR32_NOAX_and_GR32_NOREX
    GR32_NOAX_and_GR32_NOREX_NOSP
    GR64_NOSP_and_GR64_TC
    GR64_NOREX_and_GR64_TC
    GR64_NOREX_NOSP_and_GR64_TC
    GR32_NOAX_and_GR32_NOSP
    GR32_NOAX_and_GR32_NOREX
    GR32_NOAX_and_GR32_NOREX_NOSP
    GR32_ABCD_and_GR32_NOAX
    GR32_NOAX_and_GR32_NOSP
    GR32_NOAX_and_GR32_NOREX
    GR32_NOAX_and_GR32_NOREX_NOSP
    GR32_ABCD_and_GR32_NOAX
    GR32_NOAX_and_GR32_TC
    GR32_NOAX_and_GR32_NOSP
    GR64_NOSP_and_GR64_TC
    GR32_NOAX_and_GR32_NOREX
    GR32_NOAX_and_GR32_NOREX_NOSP
    GR64_NOREX_and_GR64_TC
    GR64_NOREX_NOSP_and_GR64_TC
    GR32_ABCD_and_GR32_NOAX
    GR64_ABCD_and_GR64_TC
    GR32_NOAX_and_GR32_TC
    GR32_AD_and_GR32_NOAX

Other targets are unaffected.

llvm-svn: 146657
2011-12-15 16:48:55 +00:00
Jakob Stoklund Olesen
bc03793434 Extract a method.
llvm-svn: 146374
2011-12-12 16:16:24 +00:00
Jakob Stoklund Olesen
82905dfc94 Add TRI::getSubClassWithSubReg(RC, Idx) function.
This function is used to constrain a register class to a sub-class that
supports the given sub-register index.

For example, getSubClassWithSubReg(GR32, sub_8bit) -> GR32_ABCD.

The function will be used to compute register classes when emitting
INSERT_SUBREG and EXTRACT_SUBREG nodes and for register class inflation
of sub-register operations.

The version provided by TableGen is usually adequate, but targets can
override.

llvm-svn: 141142
2011-10-05 00:35:49 +00:00
Jakob Stoklund Olesen
da923230c8 Properly use const_iterator.
This should unbreak the Windows build.

llvm-svn: 141105
2011-10-04 20:18:39 +00:00
Jakob Stoklund Olesen
703cd60307 Teach TableGen to infer missing register classes.
The set of register classes should be closed under sub-register
operations and intersections. That will allow the register allocator to
model combinations of constraints accurately.

This patch implements the easiest form of register class inference:  For
every register class, and for every sub-register SubIdx, the subset of
registers in RC that have a SubIdx sub-register should also be a register
class.

This does create some new register classes for the targets in the tree:

ARM gets a new QQQQPR_with_ssub_0.  This class was omitted from the .td
file on purpose because it only has two registers.  InstrEmitter and
RegisterCoalescer have safeguards against selecting too small register
classes, so it is harmless.

PowerPC gets a G8RC_with_sub_32 class because LR is not a sub_32
sub-register of LR8.  I think that might be an omission?

X86 puts RIP in the GR64 class, and since that register doesn't have
8-bit sub-registers, we get:

  GR64_with_sub_8bit
  GR64_TC_with_sub_8bit
  GR64_NOREX_with_sub_8bit
  GR64_TC_with_sub_8bit_hi

The various CodeGen classes have already been fixed so adding new
register classes should not affect compile time.

llvm-svn: 141084
2011-10-04 15:28:49 +00:00
Jakob Stoklund Olesen
af50ba10a0 TableGen: Store all allocation orders together.
There is no need to keep the primary order separate.

llvm-svn: 141082
2011-10-04 15:28:44 +00:00
Jakob Stoklund Olesen
c36b745e2e TableGen: Privatize CodeGenRegisterClass::TheDef and Name.
When TableGen starts creating its own register classes, the synthesized
classes won't have a Record reference.  All register classes must have a
name, though.

llvm-svn: 141081
2011-10-04 15:28:08 +00:00
Jakob Stoklund Olesen
1e0d8b4237 TableGen: Don't add synthetic Records to the RecordKeeper.
The RecordKeeper could be shared by multiple target instances, causing
duplicate record errors.

llvm-svn: 141080
2011-10-04 15:27:53 +00:00
Peter Collingbourne
01246536d9 Move TableGen's parser and entry point into a library
This is the first step towards splitting LLVM and Clang's tblgen executables.

llvm-svn: 140951
2011-10-01 16:41:13 +00:00
Jakob Stoklund Olesen
05823401a6 Use precomputed BitVector for CodeGenRegisterClass::hasSubClass().
All the sub-class bit vectors are computed when first creating the
register bank.

llvm-svn: 140905
2011-09-30 23:47:05 +00:00
Jakob Stoklund Olesen
402aa89d8a Compute lists of super-classes in CodeGenRegisterClass.
Use these lists instead of computing them on the fly in
RegisterInfoEmitter.

llvm-svn: 140895
2011-09-30 22:18:45 +00:00
Jakob Stoklund Olesen
82a55057c4 Precompute a bit vector of register sub-classes.
llvm-svn: 140827
2011-09-30 00:10:40 +00:00
Jakob Stoklund Olesen
35c649f61b Order register classes topologically.
All register classes are given a lower ID than their sub-classes.
Cliques are ordered alphabetically.

This will be used to simplify some sub-class operations.

llvm-svn: 140826
2011-09-30 00:10:36 +00:00
Jakob Stoklund Olesen
d7b6708541 Switch to ArrayRef<CodeGenRegisterClass*>.
This makes it possible to allocate CodeGenRegisterClass instances
dynamically and reorder them.

llvm-svn: 140816
2011-09-29 22:28:37 +00:00
David Greene
43a26c71e8 Unconstify Inits
Remove const qualifiers from Init references, per Chris' request.

llvm-svn: 136531
2011-07-29 22:43:06 +00:00
David Greene
88abfb940e [AVX] Create Inits Via Factory Method
Replace uses of new *Init with *Init::get.  This hides the allocation
implementation so that we can unique Inits in various ways.

llvm-svn: 136486
2011-07-29 19:07:07 +00:00
David Greene
b149019c5d [AVX] Constify Inits
Make references to Inits const everywhere.  This is the final step
before making them unique.

llvm-svn: 136485
2011-07-29 19:07:05 +00:00
Jakob Stoklund Olesen
c5fe14efd2 Intern all RecTy subclass instances to avoid duplicates.
Make all of the RecTy constructors private, and use get() factory
methods instead. Return singleton instances when it makes sense.

ListTy instance pointers are stored in the element RecTy instance.

BitsRecTy instance pointers, one per length, are stored in a static vector.

Also unique DefInit instances. A Record has a unique DefInit which
has a unique RecordRecTy instance.

This saves some 200k-300k RecTy allocations when parsing ARM.td. It
reduces TableGen's heap usage by almost 50%.

llvm-svn: 135399
2011-07-18 17:02:57 +00:00
Eric Christopher
3dd1f02420 Revert r134921, 134917, 134908 and 134907. They're causing failures
in multiple buildbots.

llvm-svn: 134936
2011-07-11 23:06:52 +00:00
David Greene
e224004004 Use get(0 Instead of Create()
Respond to some feedback asking for a name change.

llvm-svn: 134921
2011-07-11 20:55:22 +00:00
David Greene
096bf5c02b [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.

llvm-svn: 134907
2011-07-11 18:25:51 +00:00
Jim Grosbach
cfcba2d22b Consolidate some TableGen diagnostic helper functions.
TableGen had diagnostic printers sprinkled about in a few places. Pull them
together into a single location in Error.cpp.

llvm-svn: 133568
2011-06-21 22:55:50 +00:00
Jakob Stoklund Olesen
22d12568aa Skip fields that don't exist in the Register class.
llvm-svn: 133470
2011-06-20 20:56:05 +00:00
Jakob Stoklund Olesen
4d1be7a5cd Add a RegisterTuples class to Target.td and TableGen.
A RegisterTuples instance is used to synthesize super-registers by
zipping together lists of sub-registers. This is useful for generating
pseudo-registers representing register sequence constraints like 'two
consecutive GPRs', or 'an even-odd pair of floating point registers'.

The RegisterTuples def can be used in register set operations when
building register classes. That is the only way of accessing the
synthesized super-registers.

For example, the ARM QQ register class of pseudo-registers could have
been formed like this:

  // Form pairs Q0_Q1, Q2_Q3, ...
  def QQPairs : RegisterTuples<[qsub_0, qsub_1],
                               [(decimate QPR, 2),
                                (decimate (shl QPR, 1), 2)]>;

  def QQ : RegisterClass<..., (add QQPairs)>;

Similarly, pseudo-registers representing '3 consecutive D-regs with
wraparound' look like:

  // Form D0_D1_D2, D1_D2_D3, ..., D30_D31_D0, D31_D0_D1.
  def DSeqTriples : RegisterTuples<[dsub_0, dsub_1, dsub_2],
                                   [(rotl DPR, 0),
                                    (rotl DPR, 1),
                                    (rotl DPR, 2)]>;

TableGen automatically computes aliasing information for the synthesized
registers.

Register tuples are still somewhat experimental. We still need to see
how they interact with MC.

llvm-svn: 133407
2011-06-20 02:50:54 +00:00
Jakob Stoklund Olesen
7aee390412 Use the correct comparator to avoid depending on pointer values.
This should fix the Linux buildbots.

llvm-svn: 133334
2011-06-18 05:44:55 +00:00
Jakob Stoklund Olesen
f190283688 Store CodeGenRegisters as pointers so they won't be reallocated.
Reuse the CodeGenRegBank DenseMap in a few places that would build their
own or use linear search.

llvm-svn: 133333
2011-06-18 04:26:06 +00:00
Jakob Stoklund Olesen
d446052d33 Remove MethodProtos/MethodBodies and allocation_order_begin/end.
Targets that need to change the default allocation order should use the
AltOrders mechanism instead. See the X86 and ARM targets for examples.

The allocation_order_begin() and allocation_order_end() methods have been
replaced with getRawAllocationOrder(), and there is further support
functions in RegisterClassInfo.

It is no longer possible to insert arbitrary code into generated
register classes. This is a feature.

llvm-svn: 133332
2011-06-18 03:08:20 +00:00
Jakob Stoklund Olesen
5da811d840 Provide AltOrders for specifying alternative allocation orders.
A register class can define AltOrders and AltOrderSelect instead of
defining method protos and bodies. The AltOrders lists can be defined
with set operations, and TableGen can verify that the alternative
allocation orders only contain valid registers.

This is currently an opt-in feature, and it is still possible to
override allocation_order_begin/end. That will not be true for long.

llvm-svn: 133320
2011-06-18 00:50:49 +00:00
Jakob Stoklund Olesen
da55d81c8f Use a SetTheory instance to expand register lists in register classes.
This prepares tablegen to compute register lists from set theoretic dag
expressions. This doesn't really make any difference as long as
Target.td still declares RegisterClass::MemberList as [Register].

llvm-svn: 133043
2011-06-15 05:09:20 +00:00
Jakob Stoklund Olesen
4d17793443 Give CodeGenRegisterClass a real sorted member set.
Make the Elements vector private and expose an ArrayRef through
getOrder() instead. getOrder will eventually provide multiple
user-specified allocation orders.

Use the sorted member set for member and subclass tests. Clean up a lot
of ad hoc searches.

llvm-svn: 133040
2011-06-15 04:50:36 +00:00
Jakob Stoklund Olesen
5942b61865 Move the list of register classes into CodeGenRegBank as well.
No functional change intended.

llvm-svn: 133029
2011-06-15 00:20:40 +00:00
Jakob Stoklund Olesen
7d0e28c893 Compute lists of sub-regs, super-regs, and overlapping regs.
Besides moving structural computations to CodeGenRegisters.cpp, this
also well-defines the order of these lists:

- Sub-register lists come from a pre-order traversal of the graph
  defined by the SubRegs lists in the .td files.

- Super-register lists are topologically ordered so no register comes
  before any of its sub-registers. When the sub-register graph is not a
  tree, independent super-registers appear in numerical order.

- Lists of overlapping registers are ordered according to register
  number.

This reverses the order of the super-regs lists, but nobody was
depending on that. The previous order of the overlaps lists was odd, and
it may have depended on the precise behavior of std::stable_sort.

The old computations are still there, but will be removed shortly.

llvm-svn: 132881
2011-06-12 03:05:52 +00:00
Jakob Stoklund Olesen
87b0b77d3f Move the list of registers into CodeGenRegBank.
Also move the sub-register index computations from RegisterInfoEmitter
into CodeGenRegBank.

llvm-svn: 132865
2011-06-11 00:28:06 +00:00
Jakob Stoklund Olesen
08f9ba1084 Move some sub-register index calculations to CodeGenRegisters.cpp
Create a new CodeGenRegBank class that will eventually hold all the code
that computes the register structure from Records.

llvm-svn: 132849
2011-06-10 18:40:00 +00:00
Jakob Stoklund Olesen
a096524531 Move TableGen's register bank classes to their own source file.
I'll be moving some more code there to gather all of the
register-specific stuff in one place. Currently it is shared between
CodeGenTarget and RegisterInfoEmitter.

The plan is that CodeGenRegisters can compute the full register bank
structure while RegisterInfoEmitter only will handle the printing part.

llvm-svn: 132788
2011-06-09 18:42:07 +00:00