-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV] Add 32 bit GPR sub-register for Zfinx. #108336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ec90ba0
e8722ba
42807d3
846f3ba
aba0417
a50d5fd
9e0bcd6
b30ea2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,6 +156,23 @@ static ArrayRef<MCPhysReg> getArgGPR16s(const RISCVABI::ABI ABI) { | |
| return ArrayRef(ArgIGPRs); | ||
| } | ||
|
|
||
| static ArrayRef<MCPhysReg> getArgGPR32s(const RISCVABI::ABI ABI) { | ||
| // The GPRs used for passing arguments in the ILP32* and LP64* ABIs, except | ||
| // the ILP32E ABI. | ||
| static const MCPhysReg ArgIGPRs[] = {RISCV::X10_W, RISCV::X11_W, RISCV::X12_W, | ||
| RISCV::X13_W, RISCV::X14_W, RISCV::X15_W, | ||
| RISCV::X16_W, RISCV::X17_W}; | ||
| // The GPRs used for passing arguments in the ILP32E/ILP64E ABI. | ||
| static const MCPhysReg ArgEGPRs[] = {RISCV::X10_W, RISCV::X11_W, | ||
| RISCV::X12_W, RISCV::X13_W, | ||
| RISCV::X14_W, RISCV::X15_W}; | ||
|
|
||
| if (ABI == RISCVABI::ABI_ILP32E || ABI == RISCVABI::ABI_LP64E) | ||
| return ArrayRef(ArgEGPRs); | ||
|
|
||
| return ArrayRef(ArgIGPRs); | ||
| } | ||
|
|
||
| static ArrayRef<MCPhysReg> getFastCCArgGPRs(const RISCVABI::ABI ABI) { | ||
| // The GPRs used for passing arguments in the FastCC, X5 and X6 might be used | ||
| // for save-restore libcall, so we don't use them. | ||
|
|
@@ -194,6 +211,26 @@ static ArrayRef<MCPhysReg> getFastCCArgGPRF16s(const RISCVABI::ABI ABI) { | |
| return ArrayRef(FastCCIGPRs); | ||
| } | ||
|
|
||
| static ArrayRef<MCPhysReg> getFastCCArgGPRF32s(const RISCVABI::ABI ABI) { | ||
| // The GPRs used for passing arguments in the FastCC, X5 and X6 might be used | ||
| // for save-restore libcall, so we don't use them. | ||
| // Don't use X7 for fastcc, since Zicfilp uses X7 as the label register. | ||
| static const MCPhysReg FastCCIGPRs[] = { | ||
| RISCV::X10_W, RISCV::X11_W, RISCV::X12_W, RISCV::X13_W, | ||
| RISCV::X14_W, RISCV::X15_W, RISCV::X16_W, RISCV::X17_W, | ||
| RISCV::X28_W, RISCV::X29_W, RISCV::X30_W, RISCV::X31_W}; | ||
|
|
||
| // The GPRs used for passing arguments in the FastCC when using ILP32E/ILP64E. | ||
| static const MCPhysReg FastCCEGPRs[] = {RISCV::X10_W, RISCV::X11_W, | ||
| RISCV::X12_W, RISCV::X13_W, | ||
| RISCV::X14_W, RISCV::X15_W}; | ||
|
|
||
| if (ABI == RISCVABI::ABI_ILP32E || ABI == RISCVABI::ABI_LP64E) | ||
| return ArrayRef(FastCCEGPRs); | ||
|
|
||
| return ArrayRef(FastCCIGPRs); | ||
| } | ||
|
|
||
| // Pass a 2*XLEN argument that has been split into two XLEN values through | ||
| // registers or the stack as necessary. | ||
| static bool CC_RISCVAssign2XLen(unsigned XLen, CCState &State, CCValAssign VA1, | ||
|
|
@@ -364,11 +401,17 @@ bool llvm::CC_RISCV(unsigned ValNo, MVT ValVT, MVT LocVT, | |
| } | ||
| } | ||
|
|
||
| if ((ValVT == MVT::f32 && Subtarget.hasStdExtZfinx())) { | ||
topperc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (MCRegister Reg = State.AllocateReg(getArgGPR32s(ABI))) { | ||
| State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| ArrayRef<MCPhysReg> ArgGPRs = RISCV::getArgGPRs(ABI); | ||
|
|
||
| // Zfinx/Zdinx use GPR without a bitcast when possible. | ||
| if ((LocVT == MVT::f32 && XLen == 32 && Subtarget.hasStdExtZfinx()) || | ||
| (LocVT == MVT::f64 && XLen == 64 && Subtarget.hasStdExtZdinx())) { | ||
| // Zdinx use GPR without a bitcast when possible. | ||
| if (LocVT == MVT::f64 && XLen == 64 && Subtarget.hasStdExtZdinx()) { | ||
| if (MCRegister Reg = State.AllocateReg(ArgGPRs)) { | ||
| State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); | ||
| return false; | ||
|
|
@@ -616,10 +659,16 @@ bool llvm::CC_RISCV_FastCC(unsigned ValNo, MVT ValVT, MVT LocVT, | |
| } | ||
| } | ||
|
|
||
| // Check if there is an available GPRF32 before hitting the stack. | ||
| if (LocVT == MVT::f32 && Subtarget.hasStdExtZfinx()) { | ||
| if (MCRegister Reg = State.AllocateReg(getFastCCArgGPRF32s(ABI))) { | ||
| State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| // Check if there is an available GPR before hitting the stack. | ||
| if ((LocVT == MVT::f32 && Subtarget.hasStdExtZfinx()) || | ||
| (LocVT == MVT::f64 && Subtarget.is64Bit() && | ||
| Subtarget.hasStdExtZdinx())) { | ||
| if (LocVT == MVT::f64 && Subtarget.is64Bit() && Subtarget.hasStdExtZdinx()) { | ||
| if (MCRegister Reg = State.AllocateReg(getFastCCArgGPRs(ABI))) { | ||
| if (LocVT.getSizeInBits() != Subtarget.getXLen()) { | ||
| LocVT = XLenVT; | ||
|
|
@@ -723,6 +772,17 @@ bool llvm::CC_RISCV_GHC(unsigned ValNo, MVT ValVT, MVT LocVT, | |
| } | ||
| } | ||
|
|
||
| if (LocVT == MVT::f32 && Subtarget.hasStdExtZfinx()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really an issue for this review directly, but I wonder if we should be more aggressive about erroring out of the GHC calling convention for more obscure targets that are unlikely to ever need it. Is the ghc cc realistically ever going to be needed on a zfinx/zdinx system? Change looks fine though. |
||
| static const MCPhysReg GPR32List[] = { | ||
| RISCV::X9_W, RISCV::X18_W, RISCV::X19_W, RISCV::X20_W, | ||
| RISCV::X21_W, RISCV::X22_W, RISCV::X23_W, RISCV::X24_W, | ||
| RISCV::X25_W, RISCV::X26_W, RISCV::X27_W}; | ||
| if (MCRegister Reg = State.AllocateReg(GPR32List)) { | ||
| State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| if ((LocVT == MVT::f32 && Subtarget.hasStdExtZfinx()) || | ||
| (LocVT == MVT::f64 && Subtarget.hasStdExtZdinx() && | ||
topperc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Subtarget.is64Bit())) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ILP64E => LP64E