@@ -2470,13 +2470,12 @@ GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
24702470 return llvm::Type::getDoubleTy (getVMContext ());
24712471}
24722472
2473-
24742473// / GetINTEGERTypeAtOffset - The ABI specifies that a value should be passed in
2475- // / an 8-byte GPR . This means that we either have a scalar or we are talking
2476- // / about the high or low part of an up-to-16-byte struct. This routine picks
2477- // / the best LLVM IR type to represent this, which may be i64 or may be anything
2478- // / else that the backend will pass in a GPR that works better (e.g. i8, %foo*,
2479- // / etc).
2474+ // / one or more 8-byte GPRs . This means that we either have a scalar or we are
2475+ // / talking about the high and/ or low part of an up-to-16-byte struct. This
2476+ // / routine picks the best LLVM IR type to represent this, which may be i64 or
2477+ // / may be anything else that the backend will pass in GPRs that works better
2478+ // / (e.g. i8, %foo*, etc).
24802479// /
24812480// / PrefType is an LLVM IR type that corresponds to (part of) the IR type for
24822481// / the source type. IROffset is an offset in bytes into the LLVM IR type that
@@ -2534,6 +2533,13 @@ GetINTEGERTypeAtOffset(llvm::Type *IRType, unsigned IROffset,
25342533 SourceOffset);
25352534 }
25362535
2536+ // if we have a 128-bit integer, we can pass it safely using an i128
2537+ // so we return that
2538+ if (IRType->isIntegerTy (128 )) {
2539+ assert (IROffset == 0 );
2540+ return IRType;
2541+ }
2542+
25372543 // Okay, we don't have any better idea of what to pass, so we pass this in an
25382544 // integer register that isn't too big to fit the rest of the struct.
25392545 unsigned TySizeInBytes =
@@ -2591,8 +2597,7 @@ GetX86_64ByValArgumentPair(llvm::Type *Lo, llvm::Type *Hi,
25912597 return Result;
25922598}
25932599
2594- ABIArgInfo X86_64ABIInfo::
2595- classifyReturnType (QualType RetTy) const {
2600+ ABIArgInfo X86_64ABIInfo::classifyReturnType (QualType RetTy) const {
25962601 // AMD64-ABI 3.2.3p4: Rule 1. Classify the return type with the
25972602 // classification algorithm.
25982603 X86_64ABIInfo::Class Lo, Hi;
@@ -2638,6 +2643,12 @@ classifyReturnType(QualType RetTy) const {
26382643 isPromotableIntegerTypeForABI (RetTy))
26392644 return ABIArgInfo::getExtend (RetTy);
26402645 }
2646+
2647+ if (ResType->isIntegerTy (128 )) {
2648+ // i128 are passed directly
2649+ assert (Hi == Integer);
2650+ return ABIArgInfo::getDirect (ResType);
2651+ }
26412652 break ;
26422653
26432654 // AMD64-ABI 3.2.3p4: Rule 4. If the class is SSE, the next
@@ -2783,6 +2794,11 @@ X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned freeIntRegs,
27832794 return ABIArgInfo::getExtend (Ty, CGT.ConvertType (Ty));
27842795 }
27852796
2797+ if (ResType->isIntegerTy (128 )) {
2798+ assert (Hi == Integer);
2799+ ++neededInt;
2800+ return ABIArgInfo::getDirect (ResType);
2801+ }
27862802 break ;
27872803
27882804 // AMD64-ABI 3.2.3p3: Rule 3. If the class is SSE, the next
0 commit comments