Commit Graph

227 Commits

Author SHA1 Message Date
Nate Begeman
f1fe32e337 Teach ExpandShift how to handle shifts by a constant. This allows targets
like PowerPC to codegen long shifts in many fewer instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21122 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-06 21:13:14 +00:00
Nate Begeman
c105e19864 Expand SREM and UREM for targets that claim not to have them, like PowerPC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21103 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-06 00:23:54 +00:00
Nate Begeman
1867054643 Add MULHU and MULHS nodes for the high part of an (un)signed 32x32=64b
multiply.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21102 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-05 22:36:56 +00:00
Nate Begeman
79e46acd35 Handle expanding arguments to ISD::TRUNCATE. This happens on PowerPC when
you have something like i16 = truncate i64.  This fixes Regression/C/casts


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21073 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-04 00:57:08 +00:00
Chris Lattner
06098e0e9b Fix sign_extend and zero_extend of promoted value types to expanded value
types.  This occurs when casting short to long on PPC for example.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21072 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-03 23:41:52 +00:00
Chris Lattner
c0f18152d9 transform fabs/fabsf calls into FABS nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21014 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 05:26:53 +00:00
Chris Lattner
4af6e0d783 Expand fabs into fneg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21013 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 05:26:37 +00:00
Chris Lattner
b9fccc4193 Turn -0.0 - X -> fneg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21011 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 05:04:50 +00:00
Chris Lattner
2c8086f4b9 Several changes mixed up here. First when legalizing a DAG with pcmarker,
dont' regen the whole dag if unneccesary.  Second, fix and ugly bug with
the _PARTS nodes that caused legalize to produce multiples of them.
Finally, implement initial support for FABS and FNEG.  Currently FNEG is
the only one to be trusted though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21009 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 05:00:07 +00:00
Chris Lattner
ff9fd0a99c print fneg/fabs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21008 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 04:58:41 +00:00
Chris Lattner
5b359c6c4f fix some bugs in the implementation of SHL_PARTS and friends.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21004 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 04:00:59 +00:00
Chris Lattner
4759982a2d Turn expanded shift operations into (e.g.) SHL_PARTS if the target supports it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21002 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 03:38:53 +00:00
Chris Lattner
41be951a47 Print some new nodes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21001 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 03:30:42 +00:00
Chris Lattner
f4b457987f Fix a bug when inserting a libcall into a function with no other calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20999 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 03:22:40 +00:00
Nate Begeman
ea19cd51aa Fix a warning about an unhandled switch case
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20994 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 00:41:14 +00:00
Nate Begeman
fc1b1dad88 Add ISD::UNDEF node
Teach the SelectionDAG code how to expand and promote it
Have PPC32 LowerCallTo generate ISD::UNDEF for int arg regs used up by fp
  arguments, but not shadowing their value.  This allows us to do the right
  thing with both fixed and vararg floating point arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20988 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-01 22:34:39 +00:00
Andrew Lenharth
95762124a1 PCMarker support for DAG and Alpha
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20965 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-31 21:24:06 +00:00
Chris Lattner
a33ef4816d Instead of setting up the CFG edges at selectiondag construction time, set
them up after the code has been emitted.  This allows targets to select one
mbb as multiple mbb's as needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20937 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-30 01:10:47 +00:00
Chris Lattner
f51d3bd676 Fix a bug that andrew noticed where we do not correctly sign/zero extend
returned integer values all of the way to 64-bits (we only did it to 32-bits
leaving the top bits undefined).  This causes problems for targets like alpha
whose ABI's define the top bits too.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20926 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-29 19:09:56 +00:00
Chris Lattner
d4e50bb2e2 implement legalization of build_pair for nate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20901 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-28 22:03:13 +00:00
Nate Begeman
8e21e71b24 Change interface to LowerCallTo to take a boolean isVarArg argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20842 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-26 01:29:23 +00:00
Chris Lattner
e4d5c441e0 This mega patch converts us from using Function::a{iterator|begin|end} to
using Function::arg_{iterator|begin|end}.  Likewise Module::g* -> Module::global_*.

This patch is contributed by Gabor Greif, thanks!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20597 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-15 04:54:21 +00:00
Chris Lattner
ee639f1760 Fix a bug where we would incorrectly do a sign ext instead of a zero ext
because we were checking the wrong thing.  Thanks to andrew for pointing
this out!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20554 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-10 20:55:51 +00:00
Chris Lattner
14723c264d constant fold FP_ROUND_INREG, ZERO_EXTEND_INREG, and SIGN_EXTEND_INREG
This allows the alpha backend to compile:

bool %test(uint %P) {
        %c = seteq uint %P, 0
        ret bool %c
}

into:

test:
        ldgp $29, 0($27)
        ZAP $16,240,$0
        CMPEQ $0,0,$0
        AND $0,1,$0
        ret $31,($26),1

instead of:

test:
        ldgp $29, 0($27)
        ZAP $16,240,$0
        ldiq $1,0
        ZAP $1,240,$1
        CMPEQ $0,$1,$0
        AND $0,1,$0
        ret $31,($26),1

... and fixes PR534.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20534 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-09 18:37:12 +00:00
Chris Lattner
84734ce8ef Fix a bug in the 'store fpimm, ptr' -> 'store intimm, ptr' handling code.
Changing 'op' here caused us to not enter the store into a map, causing
reemission of the code!!  In practice, a simple loop like this:

no_exit:                ; preds = %no_exit, %entry
        %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=3]
        %tmp.4 = getelementptr "complex long double"* %P, uint %indvar, uint 0          ; <double*> [#uses=1]
        store double 0.000000e+00, double* %tmp.4
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=2]
        %exitcond = seteq uint %indvar.next, %N         ; <bool> [#uses=1]
        br bool %exitcond, label %return, label %no_exit

was being code gen'd to:

.LBBtest_1:     # no_exit
        movl %edx, %esi
        shll $4, %esi
        movl $0, 4(%eax,%esi)
        movl $0, (%eax,%esi)
        incl %edx
        movl $0, (%eax,%esi)
        movl $0, 4(%eax,%esi)
        cmpl %ecx, %edx
        jne .LBBtest_1  # no_exit

Note that we are doing 4 32-bit stores instead of 2.  Now we generate:

.LBBtest_1:     # no_exit
        movl %edx, %esi
        incl %esi
        shll $4, %edx
        movl $0, (%eax,%edx)
        movl $0, 4(%eax,%edx)
        cmpl %ecx, %esi
        movl %esi, %edx
        jne .LBBtest_1  # no_exit

This is much happier, though it would be even better if the increment of ESI
was scheduled after the compare :-/


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20265 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-22 07:23:39 +00:00
Misha Brukman
d3f03e4b50 Fix compilation errors with VS 2005, patch by Aaron Gray.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20231 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-17 21:39:27 +00:00
Chris Lattner
d8658616cf Don't rely on doubles comparing identical to each other, which doesn't work
for 0.0 and -0.0.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20230 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-17 20:17:32 +00:00
Chris Lattner
aa781b3404 Don't sink argument loads into loops or other bad places. This disables folding of argument loads with instructions that are not in the entry block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20228 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-17 19:40:32 +00:00
Chris Lattner
595dc5408a Fix a case where were incorrectly compiled cast from short to int on 64-bit
targets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20030 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-04 18:39:19 +00:00
Chris Lattner
272455b404 Fix yet another memset issue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19986 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-02 03:44:41 +00:00
Chris Lattner
deb692e756 Fix some bugs andrew noticed legalizing memset for alpha
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19969 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-01 18:38:28 +00:00
Chris Lattner
99939d39c9 Alpha doesn't have a native f32 extload instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19880 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 22:58:25 +00:00
Chris Lattner
e76ad6de40 implement legalization of truncates whose results and sources need to be
truncated, e.g. (truncate:i8 something:i16) on a 32 or 64-bit RISC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19879 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 22:52:50 +00:00
Chris Lattner
e560521f1a Get alpha working with memset/memcpy/memmove
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19878 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 22:29:18 +00:00
Chris Lattner
13c184de29 CopyFromReg produces two values. Make sure that we remember that both are
legalized, and actually return the correct result when we legalize the chain first.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19866 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 06:27:38 +00:00
Chris Lattner
fed5577066 Silence optimized warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19797 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-23 23:19:44 +00:00
Chris Lattner
9c32d3b798 Adjust to changes in SelectionDAG interfaces
The first half of correct chain insertion for libcalls. This is not enough
to fix Fhourstones yet though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19781 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-23 04:42:50 +00:00
Chris Lattner
b48da39536 Remove the 3 HACK HACK HACKs I put in before, fixing them properly with
the new TLI that is available.

Implement support for handling out of range shifts.  This allows us to
compile this code (a 64-bit rotate):

unsigned long long f3(unsigned long long x) {
  return (x << 32) | (x >> (64-32));
}

into this:

f3:
        mov %EDX, DWORD PTR [%ESP + 4]
        mov %EAX, DWORD PTR [%ESP + 8]
        ret

GCC produces this:

$ gcc t.c -masm=intel -O3 -S -o - -fomit-frame-pointer
..
f3:
        push    %ebx
        mov     %ebx, DWORD PTR [%esp+12]
        mov     %ecx, DWORD PTR [%esp+8]
        mov     %eax, %ebx
        mov     %edx, %ecx
        pop     %ebx
        ret

The Simple ISEL produces (eww gross):

f3:
        sub %ESP, 4
        mov DWORD PTR [%ESP], %ESI
        mov %EDX, DWORD PTR [%ESP + 8]
        mov %ECX, DWORD PTR [%ESP + 12]
        mov %EAX, 0
        mov %ESI, 0
        or %EAX, %ECX
        or %EDX, %ESI
        mov %ESI, DWORD PTR [%ESP]
        add %ESP, 4
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19780 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-23 04:39:44 +00:00
Chris Lattner
ac9dc08c7f Adjust to changes in SelectionDAG interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19779 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-23 04:36:26 +00:00
Chris Lattner
68cd65ea68 Get this to work for 64-bit systems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19763 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-22 23:04:37 +00:00
Chris Lattner
7cd50cf286 More bugfixes for IA64 shifts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19739 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-22 00:33:03 +00:00
Chris Lattner
27ff112948 Fix problems with non-x86 targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19738 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-22 00:31:52 +00:00
Chris Lattner
a7306db5f7 Add a nasty hack to fix Alpha/IA64 multiplies by a power of two.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19737 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-22 00:20:42 +00:00
Chris Lattner
9bb86f46e1 Remove unneeded line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19736 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-21 23:43:12 +00:00
Chris Lattner
1e7ceaf0a0 test commit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19735 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-21 23:38:56 +00:00
Chris Lattner
a93ec3ebfb Unary token factor nodes are unneeded.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19727 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-21 18:01:22 +00:00
Chris Lattner
77e77a6aa0 Refactor libcall code a bit. Initial implementation of expanding int -> FP
operations for 64-bit integers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19724 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-21 06:05:23 +00:00
Chris Lattner
e5544f851a Simplify the shift-expansion code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19721 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-20 20:29:23 +00:00
Chris Lattner
84f6788044 Expand add/sub into ADD_PARTS/SUB_PARTS instead of a non-existant libcall.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19715 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-20 18:52:28 +00:00
Chris Lattner
17eee18f40 implement add_parts/sub_parts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19714 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-20 18:50:55 +00:00
Chris Lattner
2c49f27955 Support targets that do not use i8 shift amounts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19707 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 22:31:21 +00:00
Chris Lattner
3d9dffc586 Add support for targets that pass args in registers to calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19703 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 20:24:35 +00:00
Chris Lattner
1e81b9e511 Fold single use token factor nodes into other token factor nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19701 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 19:10:54 +00:00
Chris Lattner
ec39a45bdb Realize the individual pieces of an expanded copytoreg/store/load are
independent of each other.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19700 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 18:02:17 +00:00
Chris Lattner
39908e0ce0 Know some identities about tokenfactor nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19699 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 18:01:40 +00:00
Chris Lattner
88218ef706 Know some simple identities. This improves codegen for (1LL << N).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19698 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 17:29:49 +00:00
Chris Lattner
e34b396ab7 Implement a way of expanding shifts. This applies to targets that offer
select operations or to shifts that are by a constant.  This automatically
implements (with no special code) all of the special cases for shift by 32,
shift by < 32 and shift by > 32.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19679 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 04:19:40 +00:00
Chris Lattner
d6e496732b Add a hook to find out how the target handles shift amounts that are out of
range.  Either they are undefined (the default), they mask the shift amount
to the size of the register (X86, Alpha, etc), or they extend the shift (PPC).

This defaults to undefined, which is conservatively correct.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19677 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 03:36:14 +00:00
Chris Lattner
d5d5682512 Zero is cheaper than sign extend.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19675 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 21:57:59 +00:00
Chris Lattner
47e9223e06 Fix some fixmes (promoting bools for select and brcond), fix promotion
of zero and sign extends.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19671 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 19:27:06 +00:00
Chris Lattner
4a9b4f1943 Keep track of the retval type as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19670 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 19:26:36 +00:00
Chris Lattner
ef5cd1d3cf Teach legalize to promote copy(from|to)reg, instead of making the isel pass
do it.  This results in better code on X86 for floats (because if strict
precision is not required, we can elide some more expensive double -> float
conversions like the old isel did), and allows other targets to emit
CopyFromRegs that are not legal for arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19668 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 17:54:55 +00:00
Chris Lattner
82fbfb6984 Teach legalize to promote SetCC results.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19657 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 02:59:52 +00:00
Chris Lattner
f30b73b1c6 Allow setcc operations to have nonbool types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19656 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 02:52:03 +00:00
Chris Lattner
6e4e7652d8 Fix the completely broken FP constant folds for setcc's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19651 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 02:11:55 +00:00
Chris Lattner
d3948116b8 Non-volatile loads can be freely reordered against each other. This fixes
X86/reg-pressure.ll again, and allows us to do nice things in other cases.
For example, we now codegen this sort of thing:

int %loadload(int *%X, int* %Y) {
  %Z = load int* %Y
  %Y = load int* %X      ;; load between %Z and store
  %Q = add int %Z, 1
  store int %Q, int* %Y
  ret int %Y
}

Into this:

loadload:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %EAX, DWORD PTR [%EAX]
        mov %ECX, DWORD PTR [%ESP + 8]
        inc DWORD PTR [%ECX]
        ret

where we weren't able to form the 'inc [mem]' before.  This also lets the
instruction selector emit loads in any order it wants to, which can be good
for register pressure as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19644 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-17 22:19:26 +00:00
Chris Lattner
a651cf67b7 Don't call SelectionDAG.getRoot() directly, go through a forwarding method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19642 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-17 19:43:36 +00:00
Chris Lattner
0afa8e348e Implement a target independent optimization to codegen arguments only into
the basic block that uses them if possible.  This is a big win on X86, as it
lets us fold the argument loads into instructions and reduce register pressure
(by not loading all of the arguments in the entry block).

For this (contrived to show the optimization) testcase:

int %argtest(int %A, int %B) {
        %X = sub int 12345, %A
        br label %L
L:
        %Y = add int %X, %B
        ret int %Y
}

we used to produce:

argtest:
        mov %ECX, DWORD PTR [%ESP + 4]
        mov %EAX, 12345
        sub %EAX, %ECX
        mov %EDX, DWORD PTR [%ESP + 8]
.LBBargtest_1:  # L
        add %EAX, %EDX
        ret


now we produce:

argtest:
        mov %EAX, 12345
        sub %EAX, DWORD PTR [%ESP + 4]
.LBBargtest_1:  # L
        add %EAX, DWORD PTR [%ESP + 8]
        ret

This also fixes the FIXME in the code.

BTW, this occurs in real code.  164.gzip shrinks from 8623 to 8608 lines of
.s file.  The stack frame in huft_build shrinks from 1644->1628 bytes,
inflate_codes shrinks from 116->108 bytes, and inflate_block from 2620->2612,
due to fewer spills.

Take that alkis. :-)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19639 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-17 17:55:19 +00:00
Chris Lattner
068a81e9fc Refactor code into a new method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19635 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-17 17:15:02 +00:00
Chris Lattner
714b69d047 Shift and setcc types default to the pointer type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19619 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 23:59:48 +00:00
Chris Lattner
8ac532c55e Implement legalize of call nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19617 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 19:46:48 +00:00
Chris Lattner
55ba8fba75 Revamp supported ops. Instead of just being supported or not, we now keep
track of how to deal with it, and provide the target with a hook that they
can use to legalize arbitrary operations in arbitrary ways.

Implement custom lowering for a couple of ops, implement promotion for select
operations (which x86 needs).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19613 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 07:29:19 +00:00
Chris Lattner
171453a284 add method stub
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19612 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 07:28:41 +00:00
Chris Lattner
4b7899343e Don't mash stuff together.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19611 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 07:28:31 +00:00
Chris Lattner
cba82f9339 Use enums, move virtual dtor out of line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19610 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 07:28:11 +00:00
Chris Lattner
f8161d83f0 Implement some more missing promotions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19606 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 05:06:12 +00:00
Chris Lattner
9467497ae2 Clarify assertion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19597 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 02:23:34 +00:00
Chris Lattner
7636512f59 Add assertions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19596 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 02:23:22 +00:00
Chris Lattner
c8ea3c4710 Add support for promoted registers being live across blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19595 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 02:23:07 +00:00
Chris Lattner
cfdfe4ce4a Set up identity transforms.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19584 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 01:20:18 +00:00
Chris Lattner
71c42a0190 Move some information into the TargetLowering object.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19583 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 01:11:45 +00:00
Chris Lattner
98e5c0e5e4 Use the new TLI method to get this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19582 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 01:11:19 +00:00
Chris Lattner
bb97d81cc8 Move some information out of LegalizeDAG into the generic Target interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19581 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 01:10:58 +00:00
Chris Lattner
1713e73b8a legalize a bunch of operations that I missed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19580 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 00:38:00 +00:00
Chris Lattner
fb849800ea Add support for targets that require promotions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19579 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 00:37:38 +00:00
Chris Lattner
ff3e50cc39 Fix some serious bugs in promotion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19578 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 00:17:42 +00:00
Chris Lattner
950aa3ca2c Eliminate unneeded extensions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19577 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-16 00:17:20 +00:00
Chris Lattner
8b6fa22e72 Implement promotion of a whole bunch more operators. I think that this is
basically everything.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19576 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-15 22:16:26 +00:00
Chris Lattner
8a389bb376 Print extra type for nodes with extra type info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19575 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-15 21:11:37 +00:00
Chris Lattner
45b8caf1c5 Add support for legalizing FP_ROUND_INREG, SIGN_EXTEND_INREG, and
ZERO_EXTEND_INREG for targets that don't support them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19573 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-15 07:15:18 +00:00
Chris Lattner
4ea6924444 Common code factored out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19572 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-15 07:14:32 +00:00
Chris Lattner
0f69b29108 Add support for promoting ADD/MUL.
Add support for new SIGN_EXTEND_INREG, ZERO_EXTEND_INREG, and FP_ROUND_INREG operators.
Realize that if we do any promotions, we need to iterate SelectionDAG
construction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19569 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-15 06:18:18 +00:00
Chris Lattner
859157daee Add new SIGN_EXTEND_INREG, ZERO_EXTEND_INREG, and FP_ROUND_INREG operators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19568 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-15 06:17:04 +00:00
Chris Lattner
03c8546ec5 Add intitial support for promoting some operators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19565 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-15 05:21:40 +00:00
Chris Lattner
69a52155d2 Adjust to CopyFromReg changes, implement deletion of truncating/extending
stores/loads.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19562 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-14 22:38:01 +00:00
Chris Lattner
2ee743ff9b Start implementing truncating stores and extending loads.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19559 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-14 22:08:15 +00:00
Chris Lattner
18c2f13e0f Add new ImplicitDef node, rename CopyRegSDNode class to RegSDNode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19535 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 20:50:02 +00:00
Chris Lattner
5a6c6d98d5 Don't forget the existing root.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19531 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 19:53:14 +00:00
Chris Lattner
ddb870b065 Codegen independent ops as being independent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19528 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 17:59:43 +00:00
Chris Lattner
a385e9b20f Legalize new node, add assertion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19527 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 17:59:25 +00:00