Commit Graph

14269 Commits

Author SHA1 Message Date
Chris Lattner
2d2970905c Implement an annoying part of the Darwin/X86 abi: the callee of a struct
return argument pops the hidden struct pointer if present, not the caller.

For example, in this testcase:

struct X { int D, E, F, G; };
struct X bar() {
  struct X a;
  a.D = 0;
  a.E = 1;
  a.F = 2;
  a.G = 3;
  return a;
}
void foo(struct X *P) {
  *P = bar();
}

We used to emit:

_foo:
        subl $28, %esp
        movl 32(%esp), %eax
        movl %eax, (%esp)
        call _bar
        addl $28, %esp
        ret
_bar:
        movl 4(%esp), %eax
        movl $0, (%eax)
        movl $1, 4(%eax)
        movl $2, 8(%eax)
        movl $3, 12(%eax)
        ret

This is correct on Linux/X86 but not Darwin/X86.  With this patch, we now
emit:

_foo:
        subl $28, %esp
        movl 32(%esp), %eax
        movl %eax, (%esp)
        call _bar
***     addl $24, %esp
        ret
_bar:
        movl 4(%esp), %eax
        movl $0, (%eax)
        movl $1, 4(%eax)
        movl $2, 8(%eax)
        movl $3, 12(%eax)
***     ret $4

For the record, GCC emits (which is functionally equivalent to our new code):

_bar:
        movl    4(%esp), %eax
        movl    $3, 12(%eax)
        movl    $2, 8(%eax)
        movl    $1, 4(%eax)
        movl    $0, (%eax)
        ret     $4
_foo:
        pushl   %esi
        subl    $40, %esp
        movl    48(%esp), %esi
        leal    16(%esp), %eax
        movl    %eax, (%esp)
        call    _bar
        subl    $4, %esp
        movl    16(%esp), %eax
        movl    %eax, (%esi)
        movl    20(%esp), %eax
        movl    %eax, 4(%esi)
        movl    24(%esp), %eax
        movl    %eax, 8(%esi)
        movl    28(%esp), %eax
        movl    %eax, 12(%esi)
        addl    $40, %esp
        popl    %esi
        ret

This fixes SingleSource/Benchmarks/CoyoteBench/fftbench with LLC and the
JIT, and fixes the X86-backend portion of PR729.  The CBE still needs to
be updated.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28438 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-23 18:50:38 +00:00
Evan Cheng
80235d508e -enable-unsafe-fp-math implies -enable-finite-only-fp-math
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28437 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-23 18:18:46 +00:00
Vladimir Prus
124729155d Fix missing include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28435 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-23 13:43:15 +00:00
Evan Cheng
f6f9581983 Incorrect SETCC CondCode used for FP comparisons.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28433 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-23 06:40:47 +00:00
Evan Cheng
95942d76f4 Added option -enable-finite-only-fp-math. When on, the codegen can assume that
FP arithmetic arguments and results are never NaNs or +=Infs. This includes
ignoring parity flag (PF) when checking for FP equality.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28432 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-23 06:39:12 +00:00
Rafael Espindola
4b442b528a implement minimal versions of
ARMAsmPrinter::runOnMachineFunction
LowerFORMAL_ARGUMENTS
ARMInstrInfo::isMoveInstr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28431 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-23 02:48:20 +00:00
Evan Cheng
435bcd7f5f A isel deficiency.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28427 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-22 05:54:49 +00:00
Evan Cheng
3c380e71e1 Back out indirect branch load folding hack. It broke some tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28425 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-21 06:28:50 +00:00
Chris Lattner
e8263e6437 Add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28424 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-21 03:57:07 +00:00
Owen Anderson
bcd8a8264e Make TargetData strings less redundant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28423 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 23:28:54 +00:00
Chris Lattner
01859e8853 Silence a bogus gcc warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28422 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 23:14:03 +00:00
Chris Lattner
f489fb24f2 Fix a parsing bug that caused 7 llvm-test regressions on PPC last night.
I'm suprised it didn't cause more!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28421 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 21:16:59 +00:00
Evan Cheng
4f7f71de43 - Use of load's chain result should be redirected to load's chain operand.
If it reads the chain result of the call, then the use, callseq_start,
  and call would form a cycle!
- Don't forget handle node replacement!
- There could also be a TokenFactor between the load and the callseq_start.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28420 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 09:21:39 +00:00
Evan Cheng
0d23bc4666 A new entry
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28419 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 07:44:53 +00:00
Evan Cheng
6b2e254437 Missing break statements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28418 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 07:44:28 +00:00
Evan Cheng
fb914c43ba Remove unused patterns.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28417 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 01:40:16 +00:00
Evan Cheng
b245d92328 Handle indirect call which folds a load manually. This never matches by
the TableGen generated code since the load's chain result is read by
the callseq_start node.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28416 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 01:36:52 +00:00
Owen Anderson
8f7f4cc1ae Sparc is big-endian.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28415 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 00:49:30 +00:00
Owen Anderson
d988b32aba Make all of the TargetMachine subclasses use the new string TargetData methods.
This is part of the on-going work on PR 761.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28414 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 00:24:56 +00:00
Chris Lattner
0deaab89fe Print csretcc calls like this:
call csretcc void %structret( { sbyte }* %P )

instead of this:

        callcsretcc  void %structret( { sbyte }* %P )


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28412 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:58:52 +00:00
Chris Lattner
ebf8e6cd92 Fix misencoding of calling conventions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28411 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:57:37 +00:00
Chris Lattner
7dd29aadf9 pretty print csretcc for calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28410 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:54:03 +00:00
Chris Lattner
cdbaeb52ae CSRet allows varargs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28409 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:34:04 +00:00
Chris Lattner
25f88aa7ad Asmprint csret nicely
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28408 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:29:57 +00:00
Chris Lattner
7546619743 Regenerate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28407 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:28:53 +00:00
Chris Lattner
515906d106 Add support for parsing csret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28406 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:28:34 +00:00
Chris Lattner
80105ddf51 csret functions can be varargs (as can target cc's). Verify restrictions on
csret functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28405 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:25:17 +00:00
Chris Lattner
f00f68ad0d Add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28402 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 21:01:38 +00:00
Chris Lattner
778ae71f37 Add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28401 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 20:55:31 +00:00
Chris Lattner
c11ab17a8e Split the SSE readme items out into their own README.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28400 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 20:51:43 +00:00
Chris Lattner
2420d81247 Split FP-stack notes out of the main readme. Next up: splitting out SSE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28399 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 20:45:52 +00:00
Chris Lattner
870cf1b715 Move a target-independent note out of the X86 readme.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28398 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 20:45:08 +00:00
Chris Lattner
de050a7509 Particularly ugly code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28397 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 19:41:33 +00:00
Reid Spencer
bc2eba1ca2 Fix a doxygen problem and break lines at 80 columns
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28395 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 19:09:46 +00:00
Evan Cheng
6de0163201 These can be transformed into lea as well. Not that we use this feature
currently...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28393 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 18:43:41 +00:00
Evan Cheng
09e3c80984 - Use exact-width integer types, e.g. int32_t, to avoid confusion.
- Fix a couple of minor bugs in i16immSExt8 and i16immZExt8.
- Added loadiPTR fragment used for indirect jumps and calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28392 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 18:40:54 +00:00
Evan Cheng
fc8feb184e Explicitly specify MOV32mi can only be used store 32-bit GV, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28390 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-19 07:30:36 +00:00
Rafael Espindola
dc124a234a implement movri
add a stub LowerFORMAL_ARGUMENTS


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28388 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 21:45:49 +00:00
Evan Cheng
ffd4364bb0 Added a Flags field to TargetOperandInfo. Currently the only flag is
M_LOOK_UP_PTR_REG_CLASS which allows the register class of the operand to be
resolved via a callback at runtime.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28387 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 20:44:26 +00:00
Evan Cheng
21d03f2de0 lib/Target/Target.td
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28386 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 20:42:07 +00:00
Chris Lattner
16abfdfc22 add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28384 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 18:26:13 +00:00
Chris Lattner
3f705e660a add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28383 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 17:38:16 +00:00
Andrew Lenharth
d56aa55358 Fix a bogus gcc warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28382 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 17:29:34 +00:00
Evan Cheng
751458dac9 ImmMask should be 3 for a two-bit field; Compact X86II
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28381 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 06:27:15 +00:00
Owen Anderson
ac4c75ba82 Fix some think-o's in my last commit. Thanks to Chris for pointing them out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28380 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 05:46:08 +00:00
Owen Anderson
1d8b8535ec Change Module to use TargetData-compatible strings internally.
This is part of the on-going work on PR 761.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28379 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 02:10:31 +00:00
Evan Cheng
0f3ac8d8d4 getCalleeSaveRegs and getCalleeSaveRegClasses are no long TableGen'd.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28378 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 00:12:58 +00:00
Evan Cheng
0cfd73a9c1 Remove CalleeSavedRegisters from class Target.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28377 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-18 00:09:53 +00:00
Reid Spencer
dd1aac36a1 Make some changes suggested by Chris:
1. Remove the LLVM_DO_NOT_BUILD feature (not needed any more)
2. Ensure that lib/VMCore gets built first. This needs to be done because
   VMCore now uses tblgen to generate the Intrinsics header which are
   needed in other libraries. In parallel builds, this can cause problems.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28374 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-17 22:55:35 +00:00
Owen Anderson
84cc6dbd25 Fix a stupid bug when parsing TargetData strings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28373 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-17 21:56:02 +00:00