Commit Graph

30432 Commits

Author SHA1 Message Date
Reid Spencer 7c16cd2746 1. Make sure all delete operators of arrays use the array form of delete.
2. Rewrite operator=(const APInt& RHS) to allow the RHS to be a different
   bit width than the LHS. This makes it possible to use APInt as the key
   of a DenseMap, as needed for the IntConstants map in Constants.cpp
3. Fix operator=(uint64_t) to clear unused bits in case the client assigns
   a value that has more bits than the APInt allows.
4. Assert that bit widths are equal in operator==
5. Revise getHashValue() to put the bit width in the low order six bits.
   This should help to make i1 0, i2 0, ... i64 0 all distinct in the
   IntConstants DenseMap.

llvm-svn: 34646
2007-02-26 23:38:21 +00:00
Evan Cheng bdec83e4d2 Joining an interval with a dead copy instruction. Shorten the live range to the last use.
llvm-svn: 34645
2007-02-26 21:37:37 +00:00
Reid Spencer 3d88599863 Fix indentation.
llvm-svn: 34643
2007-02-26 21:06:05 +00:00
Reid Spencer b2bc985a4e Implement the getHashValue method.
Fix toString use of getValue to use getZExtValue()

llvm-svn: 34642
2007-02-26 21:02:27 +00:00
Reid Spencer eed186ee58 1. Split getValue() into getSExtValue() and getZExtValue() to match
ConstantInt better.
2. Add a getHashValue() method.

llvm-svn: 34641
2007-02-26 20:57:12 +00:00
Devang Patel 97517ff930 Use efficient container SmallPtrSet
llvm-svn: 34640
2007-02-26 20:22:50 +00:00
Chris Lattner 535bd6d3ba always lower to RETFLAG, never leave it as just ret.
llvm-svn: 34639
2007-02-26 19:44:02 +00:00
Devang Patel 967b84c681 Do not unswitch loop on same value again and again.
llvm-svn: 34638
2007-02-26 19:31:58 +00:00
Chris Lattner 77f0a1553c fix attribution
llvm-svn: 34637
2007-02-26 18:56:07 +00:00
Chris Lattner 5d00a0b8a9 Add a description of the X86-64 calling convention and the return
conventions.  This doesn't do anything yet, but may in the future.

llvm-svn: 34636
2007-02-26 18:17:14 +00:00
Reid Spencer 62530f93b3 Implement inline methods that make transition of ConstantInt to use APInt
easier to comprehend and might be useful elsewhere.

llvm-svn: 34635
2007-02-26 17:50:32 +00:00
Reid Spencer f09418d428 Re-enable this. The header was committed.
llvm-svn: 34634
2007-02-26 08:10:54 +00:00
Chris Lattner ff19957468 switch to smallvector
llvm-svn: 34633
2007-02-26 07:59:53 +00:00
Chris Lattner d9fc268035 another missing header :( :( :(
llvm-svn: 34632
2007-02-26 07:51:00 +00:00
Chris Lattner 294780829a initial hack at splitting the x86-64 calling convention info out from the
mechanics that process it.  I'm still not happy with this, but it's a step
in the right direction.

llvm-svn: 34631
2007-02-26 07:50:02 +00:00
Reid Spencer 862ee00550 Make isNegative() a const function since it doesn't modify the APInt.
llvm-svn: 34630
2007-02-26 07:45:40 +00:00
Reid Spencer aa8dcfe441 1. Remove redundant calls to clearUsedBits().
2. Fix countTrailingZeros to use a faster algorithm.
3. Simplify sext() slightly by using isNegative().
4. Implement ashr using word-at-a-time logic instead of bit-at-a-time
5. Rename locals named isNegative so they don't clash with method name.
6. Fix fromString to compute negated value correctly.

llvm-svn: 34629
2007-02-26 07:44:38 +00:00
Chris Lattner d41bff0f97 the truncate must always be done, it's only the assert that is conditional.
llvm-svn: 34628
2007-02-26 05:21:05 +00:00
Chris Lattner dd89d9c648 reapply my previous patch with a bugfix.
llvm-svn: 34627
2007-02-26 05:02:39 +00:00
Chris Lattner b5359f0994 revert my previous change, something strange is happening.
llvm-svn: 34626
2007-02-26 04:43:19 +00:00
Chris Lattner 74f5bcf8eb add an accessor.
llvm-svn: 34625
2007-02-26 04:01:25 +00:00
Chris Lattner 68a8bcce99 emit an enum value for the # of target registers.
llvm-svn: 34624
2007-02-26 03:34:38 +00:00
Chris Lattner 1db979bae8 in X86-64 CCC, i8/i16 arguments are already properly zext/sext'd on input.
Capture this so that downstream zext/sext's are optimized out.  This
compiles:
  int test(short X) { return (int)X; }

to:

_test:
        movl %edi, %eax
        ret

instead of:

_test:
        movswl %di, %eax
        ret


GCC produces this bizarre code:

_test:
        movw    %di, -12(%rsp)
        movswl  -12(%rsp),%eax
        ret

llvm-svn: 34623
2007-02-26 03:18:56 +00:00
Chris Lattner 900b4f62be new testcase
llvm-svn: 34622
2007-02-26 03:16:20 +00:00
Chris Lattner fce448f856 Fold (sext (truncate x)) more aggressively, by avoiding creation of a
sextinreg if not needed.   This is useful in two cases: before legalize,
it avoids creating a sextinreg that will be trivially removed.  After legalize
if the target doesn't support sextinreg, the trunc/sext would not have been
removed before.

llvm-svn: 34621
2007-02-26 03:13:59 +00:00
Chris Lattner ab5d0ac02c track signedness of formal argument, though we have a fixme here.
llvm-svn: 34620
2007-02-26 02:56:58 +00:00
Reid Spencer 5aa8560eab Add an isNegative method to determine if the APInt's value is negative.
This is much less expensive than a test against zero.

llvm-svn: 34619
2007-02-26 01:20:59 +00:00
Reid Spencer 44eef169fa Rewrite lshr to not do bit by bit copy but to copy and shift whole words.
This makes it much more efficient.

llvm-svn: 34618
2007-02-26 01:19:48 +00:00
Reid Spencer fb55b7b99d Fix sext operation. Shifting by zero would leave an incorrect mask.
llvm-svn: 34617
2007-02-25 23:54:00 +00:00
Reid Spencer b6b5cc3e2f 1. Fix the flip() method to correctly flip all words of the APInt.
2. Implement the trunc, sext, and zext operations.
3. Improve fromString to accept negative values as input.

llvm-svn: 34616
2007-02-25 23:44:53 +00:00
Chris Lattner 8924332e22 Fix an X86-64 abi bug. We now compile:
void foo(short);
void bar(unsigned short A) {
  foo(A);
}

into:

_bar:
        subq $8, %rsp
        movswl %di, %edi
        call _foo
        addq $8, %rsp
        ret

instead of:

_bar:
        subq $8, %rsp
        call _foo
        addq $8, %rsp
        ret

Testcase here: test/CodeGen/X86/x86-64-shortint.ll

llvm-svn: 34615
2007-02-25 23:10:46 +00:00
Chris Lattner c864f6a786 new testcase
llvm-svn: 34614
2007-02-25 23:08:29 +00:00
Chris Lattner 3e0703357f fix CodeGen/X86/2007-02-25-FastCCStack.ll, a regression from my patch last
night:  fastcc returns should only go in XMM0 if we have SSE2 or above.

llvm-svn: 34613
2007-02-25 22:23:46 +00:00
Chris Lattner 39a72143cb new testcase
llvm-svn: 34612
2007-02-25 22:23:15 +00:00
Chris Lattner eef0a351b1 new testcase
llvm-svn: 34611
2007-02-25 22:02:01 +00:00
Jim Laskey 14059d958a Fix for PR1224.
llvm-svn: 34610
2007-02-25 21:43:59 +00:00
Jim Laskey 619d4bddc7 Test for PR1224.
llvm-svn: 34609
2007-02-25 21:43:21 +00:00
Chris Lattner 76ac8f82bd Rework GlobalValue::removeDeadConstantUsers to always remove dead constant
exprs hanging off a global, even if the global is not otherwise dead.  This
requires some tricky iterator gymnastics.

This implements Transforms/GlobalOpt/constantexpr-dangle.ll by deleting a
constantexpr that made it appear that the address of the function was taken.

llvm-svn: 34608
2007-02-25 21:06:13 +00:00
Chris Lattner 49c505c6e6 new testcase. @foo should be marked fastcc by globalopt
llvm-svn: 34607
2007-02-25 21:04:39 +00:00
Chris Lattner b377a7ca11 disable some noisy debug output
llvm-svn: 34606
2007-02-25 20:42:59 +00:00
Chris Lattner 1ee61ab414 no really, this is the right patch
llvm-svn: 34605
2007-02-25 20:01:40 +00:00
Chris Lattner 4d2f5f8740 always promote float varargs to double.
llvm-svn: 34604
2007-02-25 19:59:18 +00:00
Reid Spencer a41e93be3d 1. Provide more detail in file comment.
2. Move comments for methods to .h file, delete them in .cpp file.
3. All places that were doing manual clear of high order bits now call the
   clearUnusedBits() method in order to not depend on undefined behavior
   of the >> operator when the number of bits shifted equals the word size.
4. Reduced # of loc by using the new result of clearUnusedBits() method.
5. Simplified logic (decreased indentation) in a few places.
6. Added code comments to larger functions that needed them.
7. Added FIXME notes about weak implementations of things (e.g. bit-by-bit
   shift right is sub-optimal).

llvm-svn: 34603
2007-02-25 19:32:03 +00:00
Reid Spencer a7bd1d0b04 Fix clearUnusedBits to not depend on "undefined behavior" of >> operator
when the bit size is equal to the word size. This happens to work out okay
on x86, but might not on other platforms. The change just detects when
there are no bits to clear (because BitWidth is a multiple of the word size)
and returns early.

Also, move some comments from .cpp file into header.

llvm-svn: 34602
2007-02-25 19:26:01 +00:00
Chris Lattner 84ab9a556c one important bugfix: PPC32 didn't have both elf and macho support for
external symbols and global addresses.  Add the missing ones.

one important workaround: PPCISD::CALL is matched by both PPCcall_ELF
and PPCcall_Macho, disable the _ELF patterns for now.

llvm-svn: 34601
2007-02-25 19:20:53 +00:00
Chris Lattner 93a7145ebe add -enable-eh
llvm-svn: 34600
2007-02-25 18:50:48 +00:00
Chris Lattner 8c504cf9a0 optimize duplicate ValueMap lookups
llvm-svn: 34599
2007-02-25 18:40:32 +00:00
Dale Johannesen c2f3d015e0 cosmetic changes from review of last patch. obvious
llvm-svn: 34598
2007-02-25 18:31:31 +00:00
Evan Cheng 38fd9b074f A couple of more places where a register liveness has been extended and its last kill should be updated accordingly.
llvm-svn: 34597
2007-02-25 09:51:27 +00:00
Evan Cheng fb2333a333 Add an assertion.
llvm-svn: 34596
2007-02-25 09:47:31 +00:00