[llvm-commits] [llvm-gcc-4.2] r96305 - in /llvm-gcc-4.2/trunk/gcc: Makefile.in config/rs6000/llvm-rs6000.cpp config/rs6000/rs6000.h llvm-abi-default.cpp llvm-abi.h llvm-convert.cpp llvm-types.cpp
Rafael Espindola
rafael.espindola at gmail.com
Mon Feb 15 17:16:54 PST 2010
Author: rafael
Date: Mon Feb 15 19:16:53 2010
New Revision: 96305
URL: http://llvm.org/viewvc/llvm-project?rev=96305&view=rev
Log:
Merge SVR4ABI and DefaultABI.
8 files changed, 134 insertions(+), 497 deletions(-)
Modified:
llvm-gcc-4.2/trunk/gcc/Makefile.in
llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp
llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h
llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/Makefile.in?rev=96305&r1=96304&r2=96305&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/Makefile.in (original)
+++ llvm-gcc-4.2/trunk/gcc/Makefile.in Mon Feb 15 19:16:53 2010
@@ -1141,7 +1141,7 @@
OBJS = $(OBJS-common) $(out_object_file) $(OBJS-archive)
# LLVM LOCAL begin
ifneq ($(LLVMOBJDIR),)
-OBJS-common += llvm-backend.o llvm-convert.o llvm-types.o llvm-debug.o llvm-linker-hack.o llvm-abi-default.o llvm-abi-linux-ppc.o
+OBJS-common += llvm-backend.o llvm-convert.o llvm-types.o llvm-debug.o llvm-linker-hack.o llvm-abi-default.o
endif
ifneq ($(LLVMOBJDIR),)
Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=96305&r1=96304&r2=96305&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Mon Feb 15 19:16:53 2010
@@ -387,6 +387,118 @@
return false;
}
+static unsigned count_num_registers_uses(std::vector<const Type*> &ScalarElts) {
+ unsigned NumGPRs = 0;
+ for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) {
+ if (NumGPRs >= 8)
+ break;
+ const Type *Ty = ScalarElts[i];
+ if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) {
+ abort();
+ } else if (isa<PointerType>(Ty)) {
+ NumGPRs++;
+ } else if (Ty->isIntegerTy()) {
+ unsigned TypeSize = Ty->getPrimitiveSizeInBits();
+ unsigned NumRegs = (TypeSize + 31) / 32;
+
+ NumGPRs += NumRegs;
+ } else if (Ty->isVoidTy()) {
+ // Padding bytes that are not passed anywhere
+ ;
+ } else {
+ // Floating point scalar argument.
+ assert(Ty->isFloatingPointTy() && Ty->isPrimitiveType() &&
+ "Expecting a floating point primitive type!");
+ }
+ }
+ return NumGPRs < 8 ? NumGPRs : 8;
+}
+
+/// _Complex arguments are never split, thus their two scalars are either
+/// passed both in argument registers or both on the stack. Also _Complex
+/// arguments are always passed in general purpose registers, never in
+/// Floating-point registers or vector registers.
+bool llvm_rs6000_try_pass_aggregate_custom(tree type,
+ std::vector<const Type*> &ScalarElts,
+ const CallingConv::ID &CC,
+ struct DefaultABIClient* C) {
+ if (!isSVR4ABI())
+ return false;
+
+ // Eight GPR's are availabe for parameter passing.
+ const unsigned NumArgRegs = 8;
+ unsigned NumGPR = count_num_registers_uses(ScalarElts);
+ const Type *Ty = ConvertType(type);
+ const Type* Int32Ty = Type::getInt32Ty(getGlobalContext());
+ if (Ty->isSingleValueType()) {
+ if (Ty->isIntegerTy()) {
+ unsigned TypeSize = Ty->getPrimitiveSizeInBits();
+
+ // Determine how many general purpose registers are needed for the
+ // argument.
+ unsigned NumRegs = (TypeSize + 31) / 32;
+
+ // Make sure argument registers are aligned. 64-bit arguments are put in
+ // a register pair which starts with an odd register number.
+ if (TypeSize == 64 && (NumGPR % 2) == 1) {
+ NumGPR++;
+ ScalarElts.push_back(Int32Ty);
+ C->HandlePad(Int32Ty);
+ }
+
+ if (NumGPR > (NumArgRegs - NumRegs)) {
+ for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) {
+ ScalarElts.push_back(Int32Ty);
+ C->HandlePad(Int32Ty);
+ }
+ }
+ } else if (!(Ty->isFloatingPointTy() ||
+ isa<VectorType>(Ty) ||
+ isa<PointerType>(Ty))) {
+ abort();
+ }
+
+ C->HandleScalarArgument(Ty, type);
+ ScalarElts.push_back(Ty);
+ return true;
+ }
+ if (TREE_CODE(type) == COMPLEX_TYPE) {
+ unsigned SrcSize = int_size_in_bytes(type);
+ unsigned NumRegs = (SrcSize + 3) / 4;
+ std::vector<const Type*> Elts;
+
+ // This looks very strange, but matches the old code.
+ if (SrcSize == 8) {
+ // Make sure argument registers are aligned. 64-bit arguments are put in
+ // a register pair which starts with an odd register number.
+ if (NumGPR % 2 == 1) {
+ NumGPR++;
+ ScalarElts.push_back(Int32Ty);
+ C->HandlePad(Int32Ty);
+ }
+ }
+
+ if (NumGPR > (NumArgRegs - NumRegs)) {
+ for (unsigned int i = 0; i < NumArgRegs - NumGPR; ++i) {
+ ScalarElts.push_back(Int32Ty);
+ C->HandlePad(Int32Ty);
+ }
+ }
+ for (unsigned int i = 0; i < NumRegs; ++i) {
+ Elts.push_back(Int32Ty);
+ }
+ const StructType *STy = StructType::get(getGlobalContext(), Elts, false);
+ for (unsigned int i = 0; i < NumRegs; ++i) {
+ C->EnterField(i, STy);
+ C->HandleScalarArgument(Int32Ty, 0);
+ ScalarElts.push_back(Int32Ty);
+ C->ExitField();
+ }
+ return true;
+ }
+ return false;
+}
+
/* Target hook for llvm-abi.h. It returns true if an aggregate of the
specified type should be passed using the byval mechanism. */
bool llvm_rs6000_should_pass_aggregate_byval(tree TreeType, const Type *Ty) {
Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h?rev=96305&r1=96304&r2=96305&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Mon Feb 15 19:16:53 2010
@@ -3488,6 +3488,15 @@
TargetIntrinsicLower(EXP, BUILTIN_CODE, DESTLOC, RESULT, DESTTY, OPS);
#ifdef LLVM_ABI_H
+
+extern bool llvm_rs6000_try_pass_aggregate_custom(tree,
+ std::vector<const Type*>&,
+ const CallingConv::ID &,
+ struct DefaultABIClient*);
+
+#define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) \
+ llvm_rs6000_try_pass_aggregate_custom((T), (E), (CC), (C))
+
extern bool llvm_rs6000_should_pass_aggregate_byval(tree, const Type *);
#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \
Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp?rev=96305&r1=96304&r2=96305&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp Mon Feb 15 19:16:53 2010
@@ -92,6 +92,9 @@
C.HandleScalarArgument(Ty, type);
ScalarElts.push_back(Ty);
}
+ } else if (LLVM_TRY_PASS_AGGREGATE_CUSTOM(type, ScalarElts,
+ C.getCallingConv(), &C)) {
+ // Nothing to do.
} else if (Ty->isSingleValueType()) {
C.HandleScalarArgument(Ty, type);
ScalarElts.push_back(Ty);
Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=96305&r1=96304&r2=96305&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Feb 15 19:16:53 2010
@@ -254,6 +254,11 @@
return NULL;
}
+#ifndef LLVM_TRY_PASS_AGGREGATE_CUSTOM
+#define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) \
+ false
+#endif
+
// LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS - Return true if this vector
// type should be passed as integer registers. Generally vectors which are
// not part of the target architecture should do this.
@@ -420,38 +425,5 @@
std::vector<const Type*> &ScalarElts);
};
-// Similar to DefaultABI but for linux ppc 32 bits
-class SVR4ABI{
- // Number of general purpose argument registers which have already been
- // assigned.
-protected:
- DefaultABIClient &C;
-public:
- SVR4ABI(DefaultABIClient &c);
-
- bool isShadowReturn() const;
- void HandleReturnType(tree type, tree fn, bool isBuiltin);
- void HandleArgument(tree type, std::vector<const Type*> &ScalarElts,
- Attributes *Attributes = NULL);
- void HandleUnion(tree type, std::vector<const Type*> &ScalarElts);
- void PassInIntegerRegisters(tree type, std::vector<const Type*> &ScalarElts,
- unsigned origSize, bool DontCheckAlignment);
- void PassInMixedRegisters(const Type *Ty, std::vector<const Type*> &OrigElts,
- std::vector<const Type*> &ScalarElts);
-
-};
-
-// Make sure the SVR4 ABI is used on 32-bit PowerPC Linux.
-#if defined(POWERPC_LINUX) && (TARGET_64BIT == 0)
-#define TheLLVMABI SVR4ABI
-#endif
-
-/// TheLLVMABI - This can be defined by targets if they want total control over
-/// ABI decisions.
-///
-#ifndef TheLLVMABI
-#define TheLLVMABI DefaultABI
-#endif
-
#endif /* LLVM_ABI_H */
/* LLVM LOCAL end (ENTIRE FILE!) */
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=96305&r1=96304&r2=96305&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Feb 15 19:16:53 2010
@@ -622,7 +622,7 @@
// Rename and alloca'ify real arguments.
FunctionPrologArgumentConversion Client(FnDecl, AI, Builder, CallingConv);
- TheLLVMABI ABIConverter(Client);
+ DefaultABI ABIConverter(Client);
// Handle the DECL_RESULT.
ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)), FnDecl,
@@ -2831,7 +2831,7 @@
FunctionCallArgumentConversion Client(CallOperands, FTy, DestLoc,
CALL_EXPR_RETURN_SLOT_OPT(exp),
Builder, CallingConvention);
- TheLLVMABI ABIConverter(Client);
+ DefaultABI ABIConverter(Client);
// Handle the result, including struct returns.
ABIConverter.HandleReturnType(TREE_TYPE(exp),
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=96305&r1=96304&r2=96305&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Feb 15 19:16:53 2010
@@ -1047,7 +1047,7 @@
PATypeHolder RetTy(Type::getVoidTy(Context));
FunctionTypeConversion Client(RetTy, ArgTys, CallingConv, true /*K&R*/);
- TheLLVMABI ABIConverter(Client);
+ DefaultABI ABIConverter(Client);
#ifdef TARGET_ADJUST_LLVM_CC
TARGET_ADJUST_LLVM_CC(CallingConv, type);
@@ -1110,7 +1110,7 @@
std::vector<PATypeHolder> ArgTypes;
bool isVarArg = false;
FunctionTypeConversion Client(RetTy, ArgTypes, CallingConv, false/*not K&R*/);
- TheLLVMABI ABIConverter(Client);
+ DefaultABI ABIConverter(Client);
// Allow the target to set the CC for things like fastcall etc.
#ifdef TARGET_ADJUST_LLVM_CC
More information about the llvm-commits
mailing list