Implement LowerReturn_64 for SPARC v9.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sat, 6 Apr 2013 23:57:33 +0000 (23:57 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sat, 6 Apr 2013 23:57:33 +0000 (23:57 +0000)
commit53d4bcf35e7bc362e9340085264c2f4acd3c912b
treecf7bbcd228d9e6d8946bbda34ed8dd4df523fd1b
parent2b9355f2d9888d6a011353610b9ca24818de59a2
Implement LowerReturn_64 for SPARC v9.

Integer return values are sign or zero extended by the callee, and
structs up to 32 bytes in size can be returned in registers.

The CC_Sparc64 CallingConv definition is shared between
LowerFormalArguments_64 and LowerReturn_64. Function arguments and
return values are passed in the same registers.

The inreg flag is also used for return values. This is required to handle
C functions returning structs containing floats and ints:

  struct ifp {
    int i;
    float f;
  };

  struct ifp f(void);

LLVM IR:

  define inreg { i32, float } @f() {
     ...
     ret { i32, float } %retval
  }

The ABI requires that %retval.i is returned in the high bits of %i0
while %retval.f goes in %f1.

Without the inreg return value attribute, %retval.i would go in %i0 and
%retval.f would go in %f3 which is a more efficient way of returning
%multiple values, but it is not ABI compliant for returning C structs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178966 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/Sparc/SparcISelLowering.cpp
lib/Target/Sparc/SparcISelLowering.h
lib/Target/Sparc/SparcInstr64Bit.td
test/CodeGen/SPARC/64abi.ll