Commit Graph

196 Commits

Author SHA1 Message Date
zhoujing 87fe5f3ce8 [VENTUS][fix] Put local variables declared in kernel function into shared memory 2024-03-05 16:32:59 +08:00
zhoujingya 965f8c1fb6
Merge branch 'main' into eliminate_call_frame 2024-02-01 13:15:03 +08:00
qinfan 755797e27c [VENTUS][fix] Fix framelowering and calculation method of stack offset
1. Add VMV_V_X in emitEpilogue.
2. Change all the positive numbers added by TP to negative numbers(in LowerCall).
3. Fix the LowerCall function to generate correct store instruction transferring the function parameters.
4. Fix hasReservedCallFrame function to return false.
5. Align the convention between caller and callee in the case of passing parameters by stack.
6. Change the stack offset calculation method of TP.
7. Unify the calculation of TP stack and SP stack offset.
8. Node that needing to manually modify the calculation of sp offset in the workitem.S. Since the growth direction of the stack is different from that of the traditional RISCV, it is now stipulated that for both the SP stack and the TP stack, the data is stored where the stack pointer is not offset.
9. There is a SPAdj check in eliminateFrameIndex function. but we don't need this value at all so that adding a getSPAdjust function to return zero.
10. V33 is a wrong value when parameters pushed to TP stack so there must be a MV instruction to refresh V33 after ADJCALLSTACKDOWN.
2023-12-20 17:03:01 +08:00
zhoujingya d32d735ea4 [VENTUS][fix] Remove instructions not supported by hardware
These instructions included belows:

* float load/store instructions
* vfmv instruction
* "Single-Width Floating-Point/Integer Type-Convert Instructions" in RISCV manual
2023-11-24 17:26:50 +08:00
zhoujingya f85215d671
Revert "[VENTUS][fix] Add subregclass and flag to distinguish GPR and GPRF32" (#68)
This reverts commit 5e424e2b64.
2023-11-24 15:18:18 +08:00
qinfan 8fb493873a [VENTUS][RISCV][fix] Add subregclass and flag to distinguish GPR and GPRF32
Add subregclass and flag to distinguish GPR and GPRF32
2023-10-26 09:46:07 +08:00
zhoujingya f48875e9fe Revert "[VENTUS][fix] Add subregclass and flag to distinguish GPR and GPRF32"
This reverts commit 5e424e2b64.
2023-10-16 16:45:15 +08:00
qinfan 5e424e2b64 [VENTUS][fix] Add subregclass and flag to distinguish GPR and GPRF32
Summary: fix float COPY instruction bug

Test Plan: fix float COPY instruction bug

Reviewers: zhoujing

Differential Revision: http://www.tpt.com/D747
2023-10-16 13:51:10 +08:00
zhoujingya 294b5b4e5e [VENTUS][fix] Remove illegal VMV_X_S/VFMV_F_S instructions' definition and patterns
https://github.com/THU-DSP-LAB/llvm-project/issues/31
2023-10-10 17:30:47 +08:00
zhoujingya f9a20984b5 [VENTUS][fix] Comment out illegal fmv.w.x instruction and change vmv instructions' format
https://github.com/THU-DSP-LAB/llvm-project/issues/30
2023-10-09 14:04:55 +08:00
zhoujingya 2b376d146a Revert "[VENTUS][RISCV][fix] Fix the float COPY instruction bug"
This reverts commit 80a3ef9b04.
2023-10-08 17:35:20 +08:00
qinfan 80a3ef9b04 [VENTUS][RISCV][fix] Fix the float COPY instruction bug
Fix the translation error of the COPY instruction in IR. Previously,
the COPY instruction for float registers would be translated into vmv incorrectly.
This is because the GPRF class inherits from the GPR class, so float registers
were also considered GPR. Now an additional check has been added to translate
COPY instructions accurately.
2023-10-08 11:28:04 +08:00
zhoujing 50b23dc21a [VENTUS][fix] Deprecating vmv.s.x and use vmv.v.x instead
As required, vmv.s.x instruction may will later be deprecated
2023-08-01 13:25:24 +08:00
zhoujing 0780087477 [VENTUS][RISCV][fix] Fix the register usage calculation of VGPR/GPR 2023-07-26 17:31:13 +08:00
yanming 7f38ea8deb [VENTUS][RISCV] Clean divergent branch analysis. 2023-06-27 14:21:24 +08:00
yanming 58ce5c83b8 [VENTUS][RISCV] Fix VBranch instruction info and select codegen patterns. 2023-06-27 11:12:37 +08:00
yanming 6189c2e9e7 [VENTUS][RISCV] Add SETRPC and JOIN instruction definition. 2023-06-26 15:40:37 +08:00
zhoujing f494e20d44 [VENTUS][RISCV][fix] Fix private memory access instructions' codegen errors
We changed the private memory access' encoding in this commit `6da666856b`,
this commit is to fix the codegen bugs by that commit
2023-06-25 10:59:21 +08:00
zhoujing 513412bb33 [VENTUS][RISCV][fix] Fix building libclc errors 2023-06-16 17:42:22 +08:00
zhoujing 6636793f64 Merge libclc-vector-support 2023-06-16 09:41:08 +08:00
zhoujing 70ca64bbc8 [VENTUS][RISCV][fix] Add more load/store opcode for stack spill action 2023-06-14 11:12:37 +08:00
zhoujing 180b3d4429 [VENTUS][RISCV][feat] Add VGPRSpill stack id for ventus
There are two stacks in ventus for registers spill, SGPRSpill and VGPRSpill,
SGPRSpill is for global/constant memory related GPR registers spill, VGPRSpill
is for private/shared memory related VGPR registers spill
2023-06-07 11:57:20 +08:00
Aries 438f1c92c4 Fix some build warnings 2023-01-19 09:45:27 +08:00
Aries a173844ae5 Grow Ventus GPGPU stack upwards instead of downwards 2023-01-04 10:29:53 +08:00
zhoujing 734f087a82 Update test cases and fix the bug of wrong move from GPR to VGPR 2022-12-29 13:46:34 +08:00
Aries 9925e4e511 Define callee saved registers for Ventus GPGPU.
Initially implemented 2 stacks support for sGPR spill/restore stack and per-thread stack,
but stack size calculation is computed as a sum of 2 stacks(this works but wastes lot of
spaces).
Now TP register is used as per-thread stack pointer, SP register is used for sGPR spill/restore.
Clean up RVV related stack frame code etc.
2022-12-28 16:37:38 +08:00
Aries 228be521e5 Add initial different stack frame support for sALU and vALU.
FIXME: The stack pointer RISCV::X4 for vALU is not yet correctly used, but related infrastructure
should work(MFI.isEntryFunction() is used to check RISCV::X2 or RISCV::X4 to be used as stack pointer).
2022-12-27 18:28:51 +08:00
Aries 9be2c54215 Add initial vGPR + sGPRF32 (zfinx) support 2022-12-27 12:00:30 +08:00
Aries c734a517f4 Fix bug in building VSUXEI32 MI for stack slot load/restore 2022-12-23 10:17:52 +08:00
Aries 73846a1613 Do not try to merge branches for vALU execution path,
as explicit branch and join instructions are required for SIMT stack working correctly.
2022-12-22 17:42:10 +08:00
Aries cb6f30fbd7 Add initial support to lower ISD::SELECT into branch instructions in divergent execution path. 2022-12-22 17:17:02 +08:00
Aries 05bc6809f7 Correctly create VMV_S_X instruction to pass machine instr verification pass. 2022-12-22 11:49:07 +08:00
Aries 86ffbad424 Fix vALU stack load/store instruction generation. 2022-12-22 10:21:33 +08:00
Aries 93ce3641ec Fix bug in creating sGPR to vGPR register copy instruction. 2022-12-22 09:24:18 +08:00
Aries 8c531048c2 Initially add vector load/store instruction and related codegen 2022-12-21 16:27:39 +08:00
Aries dee3135130 Drafting divergent related code, not working yet. 2022-12-19 18:11:34 +08:00
Aries c6b68cbedb Support move between vGPR and sGPR.
Fix a few bugs in calling convention related lowering functions.
2022-12-19 14:21:26 +08:00
Aries f1eff7fcfe Very very early step to remove RVV features from code base. 2022-12-16 17:33:54 +08:00
Fangrui Song b0df70403d [Target] llvm::Optional => std::optional
The updated functions are mostly internal with a few exceptions (virtual functions in
TargetInstrInfo.h, TargetRegisterInfo.h).
To minimize changes to LLVMCodeGen, GlobalISel files are skipped.

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-04 22:43:14 +00:00
Kazu Hirata 20cde15415 [Target] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02 20:36:06 -08:00
Anton Sidorenko a21bbc24d3 [MachineCombiner][RISCV] Make hasReassociableSibling virtual and override it for RISCV
To check reassociation correctness for RISCV, we must ensure that the root and
it's sibling have equal rounding modes (for floating point instructions).
`hasReassociableSibling` is a good place to make additional target-dependend
checks.

This patch allows us to enable default machine combiner mechanism to gather
reassociation candidates on RISCV.

Differential Revision: https://reviews.llvm.org/D138302
2022-12-01 16:30:51 +03:00
WuXinlong 219417b2c6 [RISCV] Add CodeGen support and MC testcase of RISCV Zca Extension
This patch add the support of RISCV Zca ext

`Zca` is a subset of C extension instructions that are compatible with the Zc extension.

So this patch implements Zca code generation with reference to the C extension and sets the 2-byte alignment for the Zca extension, just like C extension does.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D130483
2022-11-22 17:22:26 +08:00
Anton Sidorenko b6c790736e [MachineCombiner][RISCV] Add fmadd/fmsub/fnmsub instructions patterns
This patch adds tranformation of fmul+fadd/fsub chains to fused multiply
instructions:
  * fmul+fadd->fmadd
  * fmul+fsub->fmsub/fnmsub

We also will try to combine these instructions if the fmul has more than one use
and cannot be deleted. However, removing the dependence between fmul and fadd can
still be profitable, and we rely on machine combiner approximations of scheduling.

Differential Revision: https://reviews.llvm.org/D136764
2022-11-17 13:24:04 +03:00
Anton Sidorenko 1978b4d968 [MachineCombiner][RISCV] Enable MachineCombiner for RISCV
Initial implementation to match basic FP reassociation patterns.

Differential Revision: https://reviews.llvm.org/D135264
2022-10-18 18:56:32 +03:00
Anton Afanasyev e175f99c49 Revert "[MachineCombiner][RISCV] Enable MachineCombiner for RISCV"
This reverts commit 3112cf3b00.
Test breakage: https://lab.llvm.org/buildbot/#/builders/16/builds/36631
2022-10-18 15:57:11 +03:00
Anton Sidorenko 3112cf3b00 [MachineCombiner][RISCV] Enable MachineCombiner for RISCV
Initial implementation to match basic FP reassociation patterns.

Differential Revision: https://reviews.llvm.org/D135264
2022-10-18 15:31:03 +03:00
Craig Topper 2b32e4f98b [RISCV] Add basic support for the sifive-7-series short forward branch optimization.
sifive-7-series has macrofusion support to convert a branch over
a single instruction into a conditional instruction. This can be
an improvement if the branch is hard to predict.

This patch adds support for the most basic case, a branch over a
move instruction. This is implemented as a pseudo instruction so
we can hide the control flow until all code motion passes complete.

I've disabled a recent select optimization if this feature is enabled
in the subtarget.

Related gcc patch for the same optimization https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg211045.html

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D135814
2022-10-17 13:56:22 -07:00
Philip Reames 027516553d [RISCV] Verify that policy operands only exist on instructions with tied passthru operands
This is a non-trivial property relied upon by D135396. I wrote this to convince myself it was true.

Differential Revision: https://reviews.llvm.org/D135403
2022-10-06 15:18:43 -07:00
Craig Topper 31bca38ad1 [RISCV] Pass the destination register to getVLENFactoredAmount instead of returning it. NFC
This is a refactor for another patch. For now we move the vreg
creation to the caller.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D135008
2022-10-03 10:59:35 -07:00
Philip Reames e41765aa4d [RISCV] Verify consistency of a couple TSFlags related to vector operands
Various bits of existing code assume the presence of one operand implies the presence of another.  Add verifier rules to catch violations.

Differential Revision: https://reviews.llvm.org/D133810
2022-09-22 08:35:17 -07:00