Skip to content

Commit 98568fb

Browse files
committed
Merge pull request dotnet#5386 from briansull/arm32-hfa-fix
Fix for HFA args on ARM32
2 parents 4b7c2f4 + b450c17 commit 98568fb

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/jit/codegencommon.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -4019,6 +4019,8 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg,
40194019
}
40204020
else
40214021
{
4022+
// Currently all non-HFA multireg structs are two registers in size (i.e. two slots)
4023+
assert(varDsc->lvSize() == (2 * TARGET_POINTER_SIZE));
40224024
// We have a non-HFA multireg argument, set slots to two
40234025
slots = 2;
40244026
}
@@ -4361,16 +4363,22 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg,
43614363
{
43624364
storeType = TYP_I_IMPL; // Default store type for a struct type is a pointer sized integer
43634365
#if FEATURE_MULTIREG_ARGS
4364-
// Must be <= 32 bytes or else it wouldn't be passed in registers
4366+
// Must be <= MAX_PASS_MULTIREG_BYTES or else it wouldn't be passed in registers
43654367
noway_assert(varDsc->lvSize() <= MAX_PASS_MULTIREG_BYTES);
43664368
#endif // FEATURE_MULTIREG_ARGS
43674369
#ifdef FEATURE_UNIX_AMD64_STRUCT_PASSING
43684370
storeType = regArgTab[argNum].type;
43694371
#endif // !FEATURE_UNIX_AMD64_STRUCT_PASSING
43704372
if (varDsc->lvIsHfaRegArg())
43714373
{
4374+
#ifdef _TARGET_ARM_
4375+
// On ARM32 the storeType for HFA args is always TYP_FLOAT
4376+
storeType = TYP_FLOAT;
4377+
slotSize = (unsigned)emitActualTypeSize(storeType);
4378+
#else // _TARGET_ARM64_
43724379
storeType = genActualType(varDsc->GetHfaType());
4373-
slotSize = (unsigned) emitActualTypeSize(storeType);
4380+
slotSize = (unsigned)emitActualTypeSize(storeType);
4381+
#endif // _TARGET_ARM64_
43744382
}
43754383
}
43764384
else // Not a struct type

src/jit/compiler.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,16 @@ class LclVarDsc
388388
#endif
389389
}
390390

391-
// Returns 1-4 indicating the number of register slots used by the HFA
391+
// on Arm64 - Returns 1-4 indicating the number of register slots used by the HFA
392+
// on Arm32 - Returns the total number of single FP register slots used by the HFA, max is 8
393+
//
392394
unsigned lvHfaSlots() const
393395
{
394396
assert(lvIsHfa());
395397
assert(lvType==TYP_STRUCT);
398+
#ifdef _TARGET_ARM_
399+
return lvExactSize / sizeof(float);
400+
#else // _TARGET_ARM64_
396401
if (lvHfaTypeIsFloat())
397402
{
398403
return lvExactSize / sizeof(float);
@@ -401,6 +406,7 @@ class LclVarDsc
401406
{
402407
return lvExactSize / sizeof(double);
403408
}
409+
#endif // _TARGET_ARM64_
404410
}
405411

406412
private:

0 commit comments

Comments
 (0)