Skip to content

Commit 643e471

Browse files
authored
[RISCV][GISel] Add calling convention support for half (#94110)
This patch adds initial support to the half type on RISC-V.
1 parent a43d999 commit 643e471

File tree

3 files changed

+520
-2
lines changed

3 files changed

+520
-2
lines changed

llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static bool isSupportedArgumentType(Type *T, const RISCVSubtarget &Subtarget,
340340
// supported yet.
341341
if (T->isIntegerTy())
342342
return T->getIntegerBitWidth() <= Subtarget.getXLen() * 2;
343-
if (T->isFloatTy() || T->isDoubleTy())
343+
if (T->isHalfTy() || T->isFloatTy() || T->isDoubleTy())
344344
return true;
345345
if (T->isPointerTy())
346346
return true;
@@ -361,7 +361,7 @@ static bool isSupportedReturnType(Type *T, const RISCVSubtarget &Subtarget,
361361
// supported yet.
362362
if (T->isIntegerTy())
363363
return T->getIntegerBitWidth() <= Subtarget.getXLen() * 2;
364-
if (T->isFloatTy() || T->isDoubleTy())
364+
if (T->isHalfTy() || T->isFloatTy() || T->isDoubleTy())
365365
return true;
366366
if (T->isPointerTy())
367367
return true;

llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,8 @@ const TargetRegisterClass *RISCVInstructionSelector::getRegClassForTypeOnBank(
849849
}
850850

851851
if (RB.getID() == RISCV::FPRBRegBankID) {
852+
if (Ty.getSizeInBits() == 16)
853+
return &RISCV::FPR16RegClass;
852854
if (Ty.getSizeInBits() == 32)
853855
return &RISCV::FPR32RegClass;
854856
if (Ty.getSizeInBits() == 64)

0 commit comments

Comments
 (0)