LLVM backend for 6502
Go to file
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
autoconf For PR784: 2006-05-21 10:40:20 +00:00
docs Describe how to add a custom test. 2006-05-23 01:40:20 +00:00
examples Catch a potentially thrown exception. 2006-05-14 19:08:39 +00:00
include/llvm -enable-unsafe-fp-math implies -enable-finite-only-fp-math 2006-05-23 18:18:46 +00:00
lib Implement an annoying part of the Darwin/X86 abi: the callee of a struct 2006-05-23 18:50:38 +00:00
projects Avoid defining dead result 2006-05-12 17:29:40 +00:00
runtime Invert the tests on LLVMGCC_MAJVERS to check for value 4 instead of value 2006-04-07 21:45:23 +00:00
test Added a test case for FP equality check. 2006-05-23 06:41:23 +00:00
tools Remove the llvm-db and bugpoint restrictions from the win32 platform so 2006-05-17 21:20:50 +00:00
utils Now that iPTR is a fully resolved type. We end up losing the type check for 2006-05-19 07:24:32 +00:00
win32 Keep Visual Studio happy. 2006-05-03 00:28:50 +00:00
Xcode Misc. project changes. html + build config changes supplied by Devang. 2006-04-08 06:04:56 +00:00
.cvsignore Ignore stuff built by "make dist". 2006-04-07 15:55:18 +00:00
configure For PR784: 2006-05-21 10:40:20 +00:00
CREDITS.TXT Add my homepage, as a test that commit access works 2006-05-16 05:36:15 +00:00
LICENSE.TXT Changing domain name 2006-04-20 05:51:53 +00:00
llvm.spec For PR723: 2006-04-07 16:07:37 +00:00
llvm.spec.in For PR723: 2006-04-07 16:07:37 +00:00
Makefile Make some changes suggested by Chris: 2006-05-17 22:55:35 +00:00
Makefile.common Update comments to reflect new variable names. Patch contributed by 2005-02-14 16:02:19 +00:00
Makefile.config.in Fix a comment. 2006-04-09 23:39:43 +00:00
Makefile.rules Make some changes suggested by Chris: 2006-05-17 22:55:35 +00:00
README.txt Make the text of this file a little more useful. 2004-09-02 22:49:27 +00:00

Low Level Virtual Machine (LLVM)
================================

This directory and its subdirectories contain source code for the Low Level 
Virtual Machine, a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments. 

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the HTML documentation provided in docs/index.html for further
assistance with LLVM.