15 Commits

Author SHA1 Message Date
Craig Topper
bc91f3cdd5
[RISCV] Add 32 bit GPR sub-register for Zfinx. (#108336)
This patches adds a 32 bit register class for use with Zfinx instructions. This makes them more similar to F instructions and allows us to only spill 32 bits.
    
I've added CodeGenOnly instructions for load/store using GPRF32 as that gave better results than insert_subreg/extract_subreg.
    
Function arguments use this new GPRF32 register class for f32 arguments with Zfinx. Eliminating the need to use RISCVISD::FMV* nodes.
    
This is similar to #107446 which adds a 16 bit register class.
2024-10-01 22:09:27 -07:00
Craig Topper
8a7843ca0f
[RISCV] Add 16 bit GPR sub-register for Zhinx. (#107446)
This patches adds a 16 bit register class for use with Zhinx
instructions. This makes them more similar to Zfh instructions and
allows us to only spill 16 bits.

I've added CodeGenOnly instructions for load/store using GPRF16 as that
gave better results than insert_subreg/extract_subreg. I'm using FSGNJ
for GPRF16 copy with Zhinx as that gave better results. Zhinxmin will
use ADDI+subreg operations.

Function arguments use this new GPRF16 register class for f16 arguments
with Zhinxmin. Eliminating the need to use RISCVISD::FMV* nodes.

I plan to extend this idea to Zfinx next.
2024-09-26 22:56:12 -07:00
Alex Bradbury
a43a2981e4 [RISCV][NFC] Fix typo: ILP64E => LP64E 2024-09-26 14:15:07 +01:00
Craig Topper
ee4582f9c8
[RISCV] Use CCValAssign::getCustomReg for fixed vector arguments/returns with RVV. (#108470)
We need to insert a insert_subvector or extract_subvector which feels
pretty custom.

This should make it easier to support fixed vector arguments for GISel.
2024-09-13 07:23:44 -07:00
Craig Topper
859b785bb6
[RISCV] Restructure CC_RISCV_FastCC to reduce code duplication. NFC (#107671)
Move GPR handling closer to the end so we can share it with the indirect
handling for vector. Use a single block for storing any type to the
stack.
2024-09-12 08:29:18 -07:00
Craig Topper
14b43563d1
[RISCV] Separate more of scalar FP in CC_RISCV. NFC (#107908)
Scalar FP calling convention has gotten more complicated with recent
changes to Zfinx/Zdinx, proposed addition of a GPRF16 register class,
and using customReg for f16/bf16 and other FP types small than XLen.

The previous code tried to share a single getReg and getMem call for
many different cases. This patch separates all the FP register handling
to the top of the function with their own getReg calls. The only
exception is f64 with XLen==32, when we are out of FPRs or not able to
use FPRs due to ABI.

The way I've structured this, we no longer need to correct the LocVT for
FP back to ValVT before the call to getMem.
2024-09-10 09:29:03 -07:00
Craig Topper
0e775b8c6f [RISCV] Move fixed vector LocVT change in CC_RISCV. NFC
We don't need to change the LocVT unless we succesfully allocated
a register.
2024-09-07 12:47:24 -07:00
Craig Topper
1b8e26ff26 [RISCV] Use RISCVSubtarget to get XLen in CC_RISCV. NFC 2024-09-07 10:31:58 -07:00
Craig Topper
f93114d700 [RISCV] Use int64_t for offsets returned from CCState::AllocateStack. NFC
AllocateStack returns int64_t and CCValAssign::getMem expects an
int64_t. The interfaces used unsigned prior to
da42b2846c82063bd1bce78d6a046f78f218eb72.

Offsets for RISC-V should be positive and less than 32-bits so this
shouldn't be a functional change.
2024-09-06 18:39:41 -07:00
Craig Topper
d5ef3f8c94
[RISCV] Support fastcc passing scalable vectors indirectly with no free GPRs. (#107623)
We can still pass indirectly by putting the pointer on the stack. This
is what we do in the normal calling convention.
2024-09-06 17:10:01 -07:00
Craig Topper
748ae69b5d [RISCV] Add fastcc support for bf16 with Zfbfmin. 2024-09-06 16:50:25 -07:00
Craig Topper
49660e5565
[RISCV] Pass f32/f64 directly without a bitcast for Zfinx/Zdinx. (#107464)
With Zfinx/Zdinx, f32/f64 are legal types for a GPR, we don't need a
bitcast.

This avoids turning fneg/fabs into bitwise operations purely because of
these bitcasts. If the bitwise operations are faster for some reason on
a Zfinx CPU, then that seems like it should be done for all fneg/fabs,
not just ones near function arguments/returns.

I don't have much interest in Zfinx, this just makes the code more
similar to what I proposed for Zhinx in #107446.
2024-09-06 15:50:29 -07:00
Craig Topper
fd13cc03bd [RISCV] Use Subtarget variable instaed of TLI.getSubtarget(). NFC 2024-09-06 10:13:26 -07:00
Craig Topper
62180dfd8d
[RISCV] Reduce the interface to RISCVCCAssignFn. NFC (#107503)
DataLayout, ABI, and TargetLowering can all be obtained via the
MachineFunction reference in the State object. This is how the targets
that use TableGen for CC handlers get these objects.

This might be a little slower, but it simplies all the callers in
SelectionDAG and GlobalISel.
2024-09-06 09:28:33 -07:00
Craig Topper
093b8bfe6b
[RISCV] Separate the calling convention handlers into their own file. NFC (#107484)
These are used by both SelectionDAG and GlobalISel and are separate from
RISCVTargetLowering.

Having a separate file is how other targets are structured. Though other
targets generate most of their calling convention code through tablegen.

I moved the `CC_RISV` functions from the `llvm::RISCV` namespace to
`llvm::`. That's what the tablegen code on other targets does and the
functions already have RISCV in their name. `RISCVCCAssignFn` is moved
from `RISCVTargetLowering` to the `llvm` namespace.
2024-09-05 22:29:23 -07:00