Skip to content

Commit 29762d0

Browse files
committed
[MIPS] Updated MIPS N calling conventions so that fp16 arguments no longer cause a crash
1 parent 402efa7 commit 29762d0

File tree

2 files changed

+503
-246
lines changed

2 files changed

+503
-246
lines changed

llvm/lib/Target/Mips/MipsCallingConv.td

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class CCIfSubtargetNot<string F, CCAction A> : CCIfSubtarget<F, A, "!">;
2020

2121
/// Match if the original argument (before lowering) was a float.
2222
/// For example, this is true for i32's that were lowered from soft-float.
23-
class CCIfOrigArgWasNotFloat<CCAction A>
24-
: CCIf<"!static_cast<MipsCCState *>(&State)->WasOriginalArgFloat(ValNo)",
23+
class CCIfOrigArgWasFloat<CCAction A>
24+
: CCIf<"static_cast<MipsCCState *>(&State)->WasOriginalArgFloat(ValNo)",
2525
A>;
2626

2727
/// Match if the original argument (before lowering) was a 128-bit float (i.e.
@@ -134,12 +134,13 @@ def CC_MipsN : CallingConv<[
134134
CCIfSubtargetNot<"isLittle()",
135135
CCIfInReg<CCPromoteToUpperBitsInType<i64>>>>,
136136

137-
// All integers (except soft-float integers) are promoted to 64-bit.
138-
CCIfType<[i8, i16, i32], CCIfOrigArgWasNotFloat<CCPromoteToType<i64>>>,
137+
// First deal with f32s that got turned into i32s due to soft-float
138+
CCIfType<[i32],
139+
CCIfSubtarget<"useSoftFloat()",
140+
CCIfOrigArgWasFloat<CCDelegateTo<CC_MipsN_SoftFloat>>>>,
139141

140-
// The only i32's we have left are soft-float arguments.
141-
CCIfSubtarget<"useSoftFloat()", CCIfType<[i32],
142-
CCDelegateTo<CC_MipsN_SoftFloat>>>,
142+
// All remaining integers are promoted to 64-bit.
143+
CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
143144

144145
// Integer arguments are passed in integer registers.
145146
CCIfType<[i64], CCAssignToRegWithShadow<[A0_64, A1_64, A2_64, A3_64,

0 commit comments

Comments
 (0)