Commit Graph

854 Commits

Author SHA1 Message Date
Alkis Evlogimenos 9d0c3d21c8 Remove unneeded check (with the recent change in live variables a use
of a physical register is always dominated by a def).

llvm-svn: 10821
2004-01-13 21:16:25 +00:00
Alkis Evlogimenos 65bc990bda Indentation and whitespace cleanups.
llvm-svn: 10820
2004-01-13 20:42:08 +00:00
Alkis Evlogimenos 6b1ec75da9 Fix bug introduced by previous commit: check if fixed intervals
overlap before adding their spill weight.

llvm-svn: 10819
2004-01-13 20:37:01 +00:00
Alkis Evlogimenos ebbd66c042 Correctly compute live variable information for physical registers
when an implicitely defined register is later used by an alias. For example:

         call foo
         %reg1024 = mov %AL

The call implicitely defines EAX but only AL is used. Before this fix
no information was available on AL. Now EAX and all its aliases except
AL get defined and die at the call instruction whereas AL lives to be
killed by the assignment.

llvm-svn: 10813
2004-01-13 06:24:30 +00:00
Alkis Evlogimenos 52a714b45b Make LiveVariables::HandlePhysRegUse and
LiveVariables::HandlePhysRegDef private they use information that is
not in memory when LiveVariables finishes the analysis.

Also update the TwoAddressInstructionPass to not use this interface.

llvm-svn: 10755
2004-01-11 09:18:45 +00:00
Chris Lattner 8043f8c294 Remove use of llvm/CodeGen/InstrSelection.h
llvm-svn: 10749
2004-01-10 19:16:26 +00:00
Chris Lattner a4ee66f3ea Finegrainify namespacification.
This should get hunked over to the Sparc backend, along with
MachineCodeForInstruction and a bunch of files in include/llvm/Codegen,
but those battles will have to wait for a later time.

llvm-svn: 10731
2004-01-09 06:30:18 +00:00
Chris Lattner 83e84166a3 Move InstrSelection into lib/Target/Sparc, as it's sparc specific
llvm-svn: 10730
2004-01-09 06:24:06 +00:00
Chris Lattner b9c7999881 Move lib/Codegen/RegAlloc into lib/Target/Sparc, as it is sparc specific
llvm-svn: 10728
2004-01-09 06:17:12 +00:00
Alkis Evlogimenos ae5b3d4f74 Add a separate list of fixed intervals. This improves the running time
of the register allocator as follows:

       before   after
mesa   2.3790  1.5994
vpr    2.6008  1.2078
gcc    1.9840  0.5273
mcf    0.2569  0.0470
eon    1.8468  1.4359
twolf  0.9475  0.2004
burg   1.6807  1.3300
lambda 1.2191  0.3764

Speedups range anyware from 30% to over 400% :-)

llvm-svn: 10712
2004-01-07 09:20:58 +00:00
Alkis Evlogimenos a64d71203e Minor cleanups.
llvm-svn: 10711
2004-01-07 05:31:12 +00:00
Alkis Evlogimenos 9f62b96206 Remove declared but undefined method.
llvm-svn: 10710
2004-01-07 02:29:33 +00:00
Alkis Evlogimenos 1e01557c4e Change implementation of LiveIntervals::overlap(). This results in a
30-50% decrease in running time of the linear scan register allocator.

llvm-svn: 10707
2004-01-07 01:45:58 +00:00
Alkis Evlogimenos 2fa1aef707 Remove simple coalescing.
llvm-svn: 10695
2004-01-05 08:24:57 +00:00
Chris Lattner fc3d0598df fix warning
llvm-svn: 10692
2004-01-05 05:42:17 +00:00
Alkis Evlogimenos 08c5311729 Currently we cannot handle two-address instructions of the form:
A = B op C where A == C, but this cannot really occur in practice
because of SSA form. Add an assert to check that just to be safe.

llvm-svn: 10682
2004-01-05 02:25:45 +00:00
Alkis Evlogimenos 5e0e67173d Update description.
llvm-svn: 10681
2004-01-04 23:09:24 +00:00
Chris Lattner 5d236005b0 Clean up a lot of the code I added yesterday by exposing the IntrinsicLowering
implementation from the TargetMachine directly.

llvm-svn: 10636
2003-12-28 21:23:38 +00:00
Alkis Evlogimenos a158dc8104 Reserve ECX and EDI instead of EBX and EDI. Since EBX is a callee
saved register it has a longer free range than ECX (which is defined
every time there is a fnuction call) which makes ECX a better register
to reserve.

llvm-svn: 10635
2003-12-28 18:03:52 +00:00
Alkis Evlogimenos 43b587d94d Add coalescing to register allocator. A hint is added to each interval
which denotes the register we would like to be assigned to (virtual or
physical). In register allocation, if this hint exists and we can map
it to a physical register (it is either a physical register or it is a
virtual register that already got assigned to a physical one) we use
that register if it is available instead of a random one in the free
pool.

llvm-svn: 10634
2003-12-28 17:58:18 +00:00
Chris Lattner 10cac58d23 Whoops, don't try to lower non intrinsic calls
llvm-svn: 10632
2003-12-28 09:53:23 +00:00
Chris Lattner 4b75e04a60 Use the intrinsic lowering functionality
llvm-svn: 10626
2003-12-28 09:43:35 +00:00
Chris Lattner 24650d2b5e Move into the VMCore library
llvm-svn: 10623
2003-12-28 08:30:20 +00:00
Chris Lattner 08c196dd4b Implement the default implementation of the intrinsic lowering class
llvm-svn: 10621
2003-12-28 08:19:41 +00:00
Chris Lattner 27dd64242b finegrainify namespacification
minor cleanups

llvm-svn: 10619
2003-12-28 07:59:53 +00:00
Alkis Evlogimenos 2e8c984c58 Improve debugging output when choosing a register to spill.
llvm-svn: 10604
2003-12-24 18:53:31 +00:00
Alkis Evlogimenos eeea81483f Do a separate pass to compute spill weights because doing it inline
with live intervals was missing registers that were used before they
were defined (in the arbitrary order live intervals numbers
instructions).

llvm-svn: 10603
2003-12-24 15:44:53 +00:00
Alkis Evlogimenos 7d7d7e89d4 Change the way free regusters are computed and perform better
allocation in the presence of preallocated intervals.

llvm-svn: 10595
2003-12-23 18:00:33 +00:00
Alkis Evlogimenos 3ec903474f Fix crash when compiling twolf.
llvm-svn: 10584
2003-12-22 13:54:29 +00:00
Alkis Evlogimenos 690e1b8de2 Remove verifyIntervals() since it doesn't actually work right now.
llvm-svn: 10570
2003-12-21 20:41:26 +00:00
Alkis Evlogimenos 2665d9c6f9 Change weight into a float so that we can take into account the
nesting level when computing it. Right now the allocator uses:

    w = sum_over_defs_uses( 10 ^ nesting level );

llvm-svn: 10569
2003-12-21 20:19:10 +00:00
Alkis Evlogimenos c09b77ea35 Add support for inactive intervals. This effectively reuses registers
for live ranges that fall into assigned registers' holes.

llvm-svn: 10566
2003-12-21 05:43:40 +00:00
Chris Lattner 4cbb97bfdd Add a new target-independent machine code freeing pass
llvm-svn: 10560
2003-12-20 10:20:58 +00:00
Chris Lattner 9a3478e022 * Finegrainify namespacification
* Move sparc specific code out of generic code
* Eliminate the getOffset() method which made INVALID_FRAME_OFFSET
  necessary, which made pulling in MAX_INT as a sentinal necessary.

llvm-svn: 10553
2003-12-20 09:17:07 +00:00
Alkis Evlogimenos 7139090fd2 Remove TwoAddressInstruction from the public headers and add an ID
instead, since this pass doesn't expose any state to its users.

llvm-svn: 10520
2003-12-18 22:40:24 +00:00
Chris Lattner 8f88cdfa22 Prune some #includes
Add a statistic for # reloads

llvm-svn: 10518
2003-12-18 20:25:31 +00:00
Alkis Evlogimenos e5e2bd6777 Modify linear scan register allocator to use the two-address
instruction pass. This also fixes all remaining bugs for this new
allocator to pass all tests under test/Programs.

llvm-svn: 10515
2003-12-18 13:15:02 +00:00
Alkis Evlogimenos 3bd69eaac5 Fix bug in reserved registers. DH actually aliases DX and EDX which
are not reserved registers.

llvm-svn: 10514
2003-12-18 13:12:18 +00:00
Alkis Evlogimenos c17d57bd82 Modify local register allocator to use the two-address instruction pass.
llvm-svn: 10513
2003-12-18 13:08:52 +00:00
Alkis Evlogimenos 725021cb6c Add TwoAddressInstructionPass to handle instructions that have two or
more operands and the two first operands are constrained to be the
same. The pass takes an instruction of the form:

        a = b op c

and transforms it into:

        a = b
        a = a op c

and also preserves live variables.

llvm-svn: 10512
2003-12-18 13:06:04 +00:00
Alkis Evlogimenos 4d87219486 Rename LiveIntervals::expired() to LiveIntervals::expiredAt().
llvm-svn: 10511
2003-12-18 08:56:11 +00:00
Alkis Evlogimenos 15b8036b29 When a variable is killed and redifined in a basic block only one
killing instruction is tracked. This causes the LiveIntervals to
create bogus intervals. The workaound is to add a range to the
interval from the redefinition to the end of the basic block.

llvm-svn: 10510
2003-12-18 08:53:43 +00:00
Alkis Evlogimenos 40874c708f Handle multiple virtual register definitions gracefully.
Move some of the longer LiveIntervals::Interval method out of the
header and add debug information to them. Fix bug and simplify range
merging code.

llvm-svn: 10509
2003-12-18 08:48:48 +00:00
Alkis Evlogimenos 8870674da7 Change preserve all claim to just preserve live variables and phielimination.
llvm-svn: 10469
2003-12-15 04:55:38 +00:00
Alkis Evlogimenos aaba4639f8 Change interface of MachineOperand as follows:
a) remove opIsUse(), opIsDefOnly(), opIsDefAndUse()
    b) add isUse(), isDef()
    c) rename opHiBits32() to isHiBits32(),
              opLoBits32() to isLoBits32(),
              opHiBits64() to isHiBits64(),
              opLoBits64() to isLoBits64().

This results to much more readable code, for example compare
"op.opIsDef() || op.opIsDefAndUse()" to "op.isDef()" a pattern used
very often in the code.

llvm-svn: 10461
2003-12-14 13:24:17 +00:00
Alkis Evlogimenos 4f7f017ab5 When reserving a preallocated register spill the aliases of this
register too.

llvm-svn: 10450
2003-12-13 11:58:10 +00:00
Alkis Evlogimenos 7dbdf3839c Ignore non-allocatable physical registers in live interval analysis.
llvm-svn: 10449
2003-12-13 11:11:02 +00:00
Alkis Evlogimenos ed53b35076 Expire any active intervals left when register allocation is done.
llvm-svn: 10448
2003-12-13 05:50:19 +00:00
Alkis Evlogimenos e6dc614c3c Add instruction numbers to debugging output.
llvm-svn: 10447
2003-12-13 05:48:57 +00:00
Alkis Evlogimenos 06f379a278 Handle explicit physical register defs.
llvm-svn: 10445
2003-12-13 05:26:39 +00:00
Alkis Evlogimenos 9bced9455a Remove unecessary if statements when looping on ImplicitDefs.
llvm-svn: 10444
2003-12-13 01:20:58 +00:00
John Criswell fb55ac24ec This appears to fix Bug 172 and does not break any other feature tests or
regression tests.

llvm-svn: 10388
2003-12-10 22:51:41 +00:00
Alkis Evlogimenos e59ad4b441 Make assertion stricter. Since the source operands are allocated at
this point, the second operand must be a physical register (it cannot
be a virtual one).

llvm-svn: 10292
2003-12-05 11:31:39 +00:00
Alkis Evlogimenos f8fe176204 Fix bug in register spilling when a preallocated live range overlaps a
potential register assignment.

llvm-svn: 10291
2003-12-05 11:17:55 +00:00
Alkis Evlogimenos 2de099e54f Move operator<<(std::ostream&, const LiveInterval&) out of the header file.
llvm-svn: 10290
2003-12-05 10:38:28 +00:00
Alkis Evlogimenos ed28ca93ef Sort live intervals by increasing start point.
llvm-svn: 10289
2003-12-05 10:32:01 +00:00
Alkis Evlogimenos 5fe0031c68 Improve debugging output and clean up some code.
llvm-svn: 10288
2003-12-04 03:57:28 +00:00
Alkis Evlogimenos 26f17e73eb Print instructions before register allocation is performed. Also fix
bug where spill instructions were added to the next basic block
instead of the end of the current one if the instruction that required
the spill was the last in the block.

llvm-svn: 10272
2003-11-30 23:40:39 +00:00
Alkis Evlogimenos 0aa40f8db0 Remove "numReloaded" statistic.
llvm-svn: 10268
2003-11-30 05:15:36 +00:00
Alkis Evlogimenos 0e9ded74c0 Merging the linear scan register allocator in trunk. It currently passes most tests under test/Programs/SingleSource/Benchmarks/Shootout so development will continue on trunk. The allocator is not enabled by default. You will need to pass -regallo=linearscan to lli or llc to use it.
llvm-svn: 10103
2003-11-20 03:32:25 +00:00
Brian Gaeke 960707c335 Put all LLVM code into the llvm namespace, as per bug 109.
llvm-svn: 9903
2003-11-11 22:41:34 +00:00
Brian Gaeke 8f53a89edf Fix problems linking against the reoptimizer; _llvm_regAllocState must have
externally-visible linkage, and SaveStateToModule must default to true for llc.
I don't remember why I made it const; perhaps it should be deconstified.

llvm-svn: 9858
2003-11-10 07:12:01 +00:00
Brian Gaeke c0c23c29aa Operand numbers are now ints. Save the register allocation of the value
each instruction produces as "operand" -1, and the other operands as 0
.. n, as before. PhyRegAlloc::saveState() is refactored into
PhyRegAlloc::saveStateForValue().

llvm-svn: 9842
2003-11-10 00:05:26 +00:00
Misha Brukman 2b8724acc6 Let's not forget about our friends -- Constant Pool indices.
llvm-svn: 9750
2003-11-06 00:04:11 +00:00
Chris Lattner a9e7fe9ea2 Do not use a class before it is defined.
Be gcc 3.4 clean

llvm-svn: 9727
2003-11-05 06:25:06 +00:00
Brian Gaeke 69c2841b2a Update verifySavedState()'s comment, so that it reflects its current
status.  In doFinalization(), skip over external functions, just like
Anand's mapping info does.

llvm-svn: 9703
2003-11-04 22:42:41 +00:00
Brian Gaeke 2a262ef095 Add comments.
llvm-svn: 9697
2003-11-04 18:25:56 +00:00
Brian Gaeke 8541bd9db9 Include llvm/CodeGen/MachineCodeForInstruction.h. Use it to start
implementing verifySavedState().

In saveState(), use the new AllocInfo::AllocStateTy enum, and increment
Insn each time through the loop.

llvm-svn: 9617
2003-10-30 21:21:33 +00:00
Brian Gaeke 727ec9bec5 Make AllocState an enum.
Move the stringifying method for that enum into class AllocInfo.

llvm-svn: 9616
2003-10-30 21:21:22 +00:00
Brian Gaeke eca381c7e8 Publicize the type of FnAllocState.
Prototype option to save state in a global instead of as a Constant in
 the Module. (Turned off, for now, with the on/off switch welded in the off
 position. You get the idea.)

llvm-svn: 9500
2003-10-24 21:21:58 +00:00
Chris Lattner 9ab7fbef60 standardize command line option names
llvm-svn: 9496
2003-10-24 20:05:58 +00:00
Brian Gaeke 24fb8f07f3 Move the implementations of ==, != on AllocInfos here, from UnpackTraceFunction.
llvm-svn: 9452
2003-10-23 20:39:18 +00:00
Brian Gaeke 390d31cde4 Move AllocInfo structure to a private AllocInfo.h header file.
Make FnAllocState contain vectors of AllocInfo, instead of LLVM Constants.
Give doFinalization a method comment, and let it do the work of converting
 AllocInfos to LLVM Constants.

llvm-svn: 9451
2003-10-23 20:32:55 +00:00
Brian Gaeke a6bfe8eb9e Make FnAllocState contain vectors of AllocInfo, instead of LLVM Constants.
llvm-svn: 9450
2003-10-23 20:32:02 +00:00
Brian Gaeke 8e766c7ab3 New file, containing AllocInfo structure.
llvm-svn: 9449
2003-10-23 20:31:51 +00:00
Misha Brukman 88df876012 * Eliminate `using' directive
* Fix order of #includes
* Make code layout more consistent
* Eliminate extraneous whitespace and comment-lines

llvm-svn: 9433
2003-10-23 18:10:02 +00:00
Misha Brukman dc07775d58 * Fix order of #include files
* Doxygen-ify method comments

llvm-svn: 9432
2003-10-23 18:06:27 +00:00
Misha Brukman 0b624fefb7 * Order #includes as per style guide
* Doxygen-ify comments
* Make code layout more consistent

llvm-svn: 9431
2003-10-23 18:03:50 +00:00
Misha Brukman 28ba80e648 * Use C++ style comments instead of C-style
* Make file description more readable
* Make code layout more consistent, include comment in assert so it's visible
  during execution if it hits

llvm-svn: 9430
2003-10-23 18:02:47 +00:00
Misha Brukman 7d56d2c6fb * Eliminate `using' directive
* Make code layout more consistent

llvm-svn: 9427
2003-10-23 17:43:17 +00:00
Misha Brukman c7b1bce283 Make code layout more consistent.
llvm-svn: 9426
2003-10-23 17:39:37 +00:00
Brian Gaeke f140b28c16 Change the type of FnAllocState.
llvm-svn: 9388
2003-10-22 20:44:29 +00:00
Brian Gaeke 41fe18cbaa Don't worry about converting each function's reg. alloc. state into One Big
Constant early on, because we can do it in doFinalization.

Tighten up a comment.

llvm-svn: 9387
2003-10-22 20:44:23 +00:00
Brian Gaeke f29231ec3a Add prototype for verifySavedState().
llvm-svn: 9386
2003-10-22 20:23:13 +00:00
Brian Gaeke e3cf072d9e Doxygenify method comments.
Try to improve method comments a little.
Get rid of some excess whitespace; put braces on previous line when possible.
Add stub for method to verify the work of saveState().

llvm-svn: 9385
2003-10-22 20:22:53 +00:00
John Criswell 9583cfafc5 Added LLVM copyright notice.
llvm-svn: 9324
2003-10-21 15:29:18 +00:00
John Criswell 29265fe981 Added LLVM copyright header.
llvm-svn: 9321
2003-10-21 15:17:13 +00:00
John Criswell 4436c49787 Added LLVM copyright notice to Makefiles.
llvm-svn: 9312
2003-10-20 22:26:57 +00:00
John Criswell 482202a601 Added LLVM project notice to the top of every C++ source file.
Header files will be on the way.

llvm-svn: 9298
2003-10-20 19:43:21 +00:00
Chris Lattner b94550e537 Change the Opcode enum for PHI nodes from "Instruction::PHINode" to "Instruction::PHI" to be more consistent with the other instructions.
llvm-svn: 9269
2003-10-19 21:34:28 +00:00
Chris Lattner 9177d11367 #include vector which we will need here soon
llvm-svn: 9144
2003-10-15 22:09:32 +00:00
Chris Lattner f95d9b99b3 Decrease usage of use_size()
llvm-svn: 9135
2003-10-15 16:48:29 +00:00
Chris Lattner 44d2c3514a Regularize header file comments
llvm-svn: 9071
2003-10-13 03:32:08 +00:00
Misha Brukman 80f283b316 * Doxygenified comments
* Wrap code at 80 columns
* Ordered includes according to LLVM style guide

llvm-svn: 9020
2003-10-10 17:41:32 +00:00
Alkis Evlogimenos 5f1f337d95 Change MRegisterDesc::AliasSet, TargetInstrDescriptor::ImplicitDefs
and TargetInstrDescriptor::ImplicitUses to always point to a null
terminated array and never be null. So there is no need to check for
pointer validity when iterating over those sets. Code that looked
like:

if (const unsigned* AS = TID.ImplicitDefs) {
  for (int i = 0; AS[i]; ++i) {
    // use AS[i]
  }
}

was changed to:

for (const unsigned* AS = TID.ImplicitDefs; *AS; ++AS) {
  // use *AS
}

llvm-svn: 8960
2003-10-08 05:20:08 +00:00
Alkis Evlogimenos 5facafaabe Moved enum and command-line option in separate file. Also added function that returns the user selected register allocator to the caller.
llvm-svn: 8819
2003-10-02 16:57:49 +00:00
Chris Lattner 1f8d21e233 include passes.h which defines the interface this file exposes
llvm-svn: 8793
2003-09-30 20:13:59 +00:00
Brian Gaeke 974bc6682e Update head-of-file comment.
llvm-svn: 8699
2003-09-24 18:16:23 +00:00
Brian Gaeke 1542a8b820 Untabify tabs in stuff I've recently added.
Check in my register allocator state-saving code.

llvm-svn: 8698
2003-09-24 18:08:54 +00:00
Brian Gaeke 82585e030c Use getRegClassID() instead of getRegClass()->getID(), since it's there.
Shorten the markSuggestedColorUsable method.
Add a switch for saving reg. alloc. state (coming soon).

llvm-svn: 8697
2003-09-24 17:50:28 +00:00