Author: pingbak Date: Thu Feb 7 19:11:33 2008 New Revision: 46871 URL: http://llvm.org/viewvc/llvm-project?rev=46871&view=rev Log: Move llvm_x86_should_pass_aggregate_in_memory so that it is declared before it is used.
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=46871&r1=46870&r2=46871&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Thu Feb 7 19:11:33 2008 @@ -690,6 +690,48 @@ } /* Target hook for llvm-abi.h. It returns true if an aggregate of the + specified type should be passed in a number of registers of mixed types. + It also returns a vector of types that correspond to the registers used + for parameter passing. This is only called for x86-32. */ +bool +llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, + std::vector<const Type*> &Elts){ + // If this is a small fixed size type, investigate it. + HOST_WIDE_INT SrcSize = int_size_in_bytes(TreeType); + if (SrcSize <= 0 || SrcSize > 16) + return false; + + // X86-32 passes aggregates on the stack. If this is an extremely simple + // aggregate whose elements would be passed the same if passed as scalars, + // pass them that way in order to promote SROA on the caller and callee side. + // Note that we can't support passing all structs this way. For example, + // {i16, i16} should be passed in on 32-bit unit, which is not how "i16, i16" + // would be passed as stand-alone arguments. + const StructType *STy = dyn_cast<StructType>(Ty); + if (!STy || STy->isPacked()) return false; + + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { + const Type *EltTy = STy->getElementType(i); + // 32 and 64-bit integers are fine, as are float, double, and long double. + if (EltTy == Type::Int32Ty || + EltTy == Type::Int64Ty || + EltTy->isFloatingPoint() || + isa<PointerType>(EltTy)) { + Elts.push_back(EltTy); + continue; + } + + // TODO: Vectors are also ok to pass if they don't require extra alignment. + // TODO: We can also pass structs like {i8, i32}. + + Elts.clear(); + return false; + } + + return true; +} + +/* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed in memory. */ bool llvm_x86_should_pass_aggregate_in_memory(tree TreeType, const Type *Ty) { enum machine_mode Mode = ix86_getNaturalModeForType(TreeType); @@ -800,46 +842,4 @@ } return true; } - -/* Target hook for llvm-abi.h. It returns true if an aggregate of the - specified type should be passed in a number of registers of mixed types. - It also returns a vector of types that correspond to the registers used - for parameter passing. This is only called for x86-32. */ -bool -llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, - std::vector<const Type*> &Elts){ - // If this is a small fixed size type, investigate it. - HOST_WIDE_INT SrcSize = int_size_in_bytes(TreeType); - if (SrcSize <= 0 || SrcSize > 16) - return false; - - // X86-32 passes aggregates on the stack. If this is an extremely simple - // aggregate whose elements would be passed the same if passed as scalars, - // pass them that way in order to promote SROA on the caller and callee side. - // Note that we can't support passing all structs this way. For example, - // {i16, i16} should be passed in on 32-bit unit, which is not how "i16, i16" - // would be passed as stand-alone arguments. - const StructType *STy = dyn_cast<StructType>(Ty); - if (!STy || STy->isPacked()) return false; - - for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { - const Type *EltTy = STy->getElementType(i); - // 32 and 64-bit integers are fine, as are float, double, and long double. - if (EltTy == Type::Int32Ty || - EltTy == Type::Int64Ty || - EltTy->isFloatingPoint() || - isa<PointerType>(EltTy)) { - Elts.push_back(EltTy); - continue; - } - - // TODO: Vectors are also ok to pass if they don't require extra alignment. - // TODO: We can also pass structs like {i8, i32}. - - Elts.clear(); - return false; - } - - return true; -} /* LLVM LOCAL end (ENTIRE FILE!) */ _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits