forked from OSchip/llvm-project
Introduce CGFunctionInfo::getNumRequiredArgs(). NFC.
Save the callers from necessity to special-case on variadic functions. llvm-svn: 218625
This commit is contained in:
parent
9a220fca4a
commit
34625dda07
|
@ -406,6 +406,9 @@ public:
|
|||
|
||||
bool isVariadic() const { return Required.allowsOptionalArgs(); }
|
||||
RequiredArgs getRequiredArgs() const { return Required; }
|
||||
unsigned getNumRequiredArgs() const {
|
||||
return isVariadic() ? getRequiredArgs().getNumRequiredArgs() : arg_size();
|
||||
}
|
||||
|
||||
bool isInstanceMethod() const { return InstanceMethod; }
|
||||
|
||||
|
|
|
@ -1053,12 +1053,8 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
|
|||
}
|
||||
|
||||
// Add in all of the required arguments.
|
||||
CGFunctionInfo::const_arg_iterator it = FI.arg_begin(), ie;
|
||||
if (FI.isVariadic()) {
|
||||
ie = it + FI.getRequiredArgs().getNumRequiredArgs();
|
||||
} else {
|
||||
ie = FI.arg_end();
|
||||
}
|
||||
CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
|
||||
ie = it + FI.getNumRequiredArgs();
|
||||
for (; it != ie; ++it) {
|
||||
const ABIArgInfo &argAI = it->info;
|
||||
|
||||
|
|
|
@ -2568,23 +2568,17 @@ void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
|
|||
if (FI.getReturnInfo().isIndirect())
|
||||
--freeIntRegs;
|
||||
|
||||
bool isVariadic = FI.isVariadic();
|
||||
unsigned numRequiredArgs = 0;
|
||||
if (isVariadic)
|
||||
numRequiredArgs = FI.getRequiredArgs().getNumRequiredArgs();
|
||||
|
||||
unsigned NumRequiredArgs = FI.getNumRequiredArgs();
|
||||
// AMD64-ABI 3.2.3p3: Once arguments are classified, the registers
|
||||
// get assigned (in left-to-right order) for passing as follows...
|
||||
unsigned ArgNo = 0;
|
||||
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
|
||||
it != ie; ++it) {
|
||||
bool isNamedArg = true;
|
||||
if (isVariadic)
|
||||
isNamedArg = (it - FI.arg_begin()) <
|
||||
static_cast<signed>(numRequiredArgs);
|
||||
it != ie; ++it, ++ArgNo) {
|
||||
bool IsNamedArg = ArgNo < NumRequiredArgs;
|
||||
|
||||
unsigned neededInt, neededSSE;
|
||||
it->info = classifyArgumentType(it->type, freeIntRegs, neededInt,
|
||||
neededSSE, isNamedArg);
|
||||
neededSSE, IsNamedArg);
|
||||
|
||||
// AMD64-ABI 3.2.3p3: If there are no registers available for any
|
||||
// eightbyte of an argument, the whole argument is passed on the
|
||||
|
@ -3554,20 +3548,18 @@ private:
|
|||
|
||||
// Find the number of named arguments. Variadic arguments get special
|
||||
// treatment with the Darwin ABI.
|
||||
unsigned NumRequiredArgs = (FI.isVariadic() ?
|
||||
FI.getRequiredArgs().getNumRequiredArgs() :
|
||||
FI.arg_size());
|
||||
unsigned NumRequiredArgs = FI.getNumRequiredArgs();
|
||||
|
||||
if (!getCXXABI().classifyReturnType(FI))
|
||||
FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
|
||||
unsigned ArgNo = 0;
|
||||
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
|
||||
it != ie; ++it) {
|
||||
it != ie; ++it, ++ArgNo) {
|
||||
unsigned PreAllocation = AllocatedVFP, PreGPR = AllocatedGPR;
|
||||
bool IsHA = false, IsSmallAggr = false;
|
||||
const unsigned NumVFPs = 8;
|
||||
const unsigned NumGPRs = 8;
|
||||
bool IsNamedArg = ((it - FI.arg_begin()) <
|
||||
static_cast<signed>(NumRequiredArgs));
|
||||
bool IsNamedArg = ArgNo < NumRequiredArgs;
|
||||
it->info = classifyArgumentType(it->type, AllocatedVFP, IsHA,
|
||||
AllocatedGPR, IsSmallAggr, IsNamedArg);
|
||||
|
||||
|
|
Loading…
Reference in New Issue