Skip to content

Commit 5750b59

Browse files
BeMgakadutta
authored andcommitted
[clang][RISCV] support BITINT with mixed-type (llvm#156592)
Implement riscv-non-isa/riscv-elf-psabi-doc#419. This patch makes the type extension based on the variable type for BIGINT, rather than using sign extension for all cases.
1 parent b9cb7bf commit 5750b59

File tree

3 files changed

+358
-16
lines changed

3 files changed

+358
-16
lines changed

clang/lib/CodeGen/Targets/RISCV.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -680,22 +680,22 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
680680
if (const auto *ED = Ty->getAsEnumDecl())
681681
Ty = ED->getIntegerType();
682682

683-
// All integral types are promoted to XLen width
684-
if (Size < XLen && Ty->isIntegralOrEnumerationType()) {
685-
return extendType(Ty, CGT.ConvertType(Ty));
686-
}
687-
688683
if (const auto *EIT = Ty->getAs<BitIntType>()) {
689-
if (EIT->getNumBits() < XLen)
684+
685+
if (XLen == 64 && EIT->getNumBits() == 32)
690686
return extendType(Ty, CGT.ConvertType(Ty));
691-
if (EIT->getNumBits() > 128 ||
692-
(!getContext().getTargetInfo().hasInt128Type() &&
693-
EIT->getNumBits() > 64))
694-
return getNaturalAlignIndirect(
695-
Ty, /*AddrSpace=*/getDataLayout().getAllocaAddrSpace(),
696-
/*ByVal=*/false);
687+
688+
if (EIT->getNumBits() <= 2 * XLen)
689+
return ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty));
690+
return getNaturalAlignIndirect(
691+
Ty, /*AddrSpace=*/getDataLayout().getAllocaAddrSpace(),
692+
/*ByVal=*/false);
697693
}
698694

695+
// All integral types are promoted to XLen width
696+
if (Size < XLen && Ty->isIntegralOrEnumerationType())
697+
return extendType(Ty, CGT.ConvertType(Ty));
698+
699699
return ABIArgInfo::getDirect();
700700
}
701701

0 commit comments

Comments
 (0)