10 Commits

Author SHA1 Message Date
tangaac
64a0478e08
[LoongArch] Strengthen stack size estimation for LSX/LASX extension (#146455)
This patch adds an emergency spill slot when ran out of registers.
PR #139201 introduces `vstelm` instructions with only 8-bit imm offset, 
it causes no spill slot to store the spill registers.
2025-07-18 16:12:11 +08:00
hev
746c682c4a
[LoongArch] Introduce 32s target feature for LA32S ISA extensions (#139695)
According to the offical LoongArch reference manual, the 32-bit
LoongArch is divied into two variants: the Reduced version (LA32R) and
Standard version (LA32S). LA32S extends LA32R by adding additional
instructions, and the 64-bit version (LA64) fully includes the LA32S
instruction set.

This patch introduces a new target feature `32s` for the LoongArch
backend, enabling support for instructions specific to the LA32S
variant.

The LA32S exntension includes the following additional instructions:

- ALSL.W
- {AND,OR}N
- B{EQ,NE}Z
- BITREV.{4B,W}
- BSTR{INS,PICK}.W
- BYTEPICK.W
- CL{O,Z}.W
- CPUCFG
- CT{O,Z}.W
- EXT.W,{B,H}
- F{LD,ST}X.{D,S}
- MASK{EQ,NE}Z
- PC{ADDI,ALAU12I}
- REVB.2H
- ROTR{I},W

Additionally, LA32R defines three new instruction aliases:

- RDCNTID.W RJ => RDTIMEL.W ZERO, RJ
- RDCNTVH.W RD => RDTIMEH.W RD, ZERO
- RDCNTVL.W RD => RDTIMEL.W RD, ZERO
2025-05-20 18:28:08 +08:00
Fangrui Song
82863783a2
LoongArch: Remove VK_CALL/VK_CALL_PLT and don't print %plt
`%plt` is a redundant relocation specifier: `bl %plt(foo)` is identical
to `bl foo`. Let's replace VK_CALL/VK_CALL_PLT with R_LARCH_B26 and
remove the only specifier constants.

Pull Request: https://github.com/llvm/llvm-project/pull/138632
2025-05-07 14:30:47 +08:00
hev
2d876ed33e
[llvm][LoongArch] Changing the default code model from small to medium for 64-bit (#132173)
Link: https://discourse.llvm.org/t/rfc-changing-the-default-code-model-for-loongarch
2025-03-21 10:15:31 +08:00
wanglei
9d4f7f44b6 [test][LoongArch] Add -mattr=+d option. NFC
Because most of tests assume target-abi=`lp64d`, adding the
corresponding feature is reasonable.

rg -l loongarch -g '!*.s' | xargs sed -i '/mtriple=loongarch/ {/-mattr=/!{/target-abi/! s/mtriple=loongarch.. /&-mattr=+d /}}'
2024-05-14 20:23:04 +08:00
Weining Lu
26021577d1 [LoongArch] Optimize (and (a & ~((2^^X - 1) << Y)) to (bstrins a, zero, X+Y-1, Y)
Inspired by D158384.

Differential Revision: https://reviews.llvm.org/D158832
2023-08-28 08:36:54 +08:00
wanglei
1bb7766489 [LoongArch] Optimize stack realignment using BSTRINS instruction
Prior to this change, stack realignment was achieved using the SRLI/SLLI
instructions in two steps. With this patch, stack realignment is
optimized using a single `BSTRINS` instruction.

Reviewed By: SixWeining, xen0n

Differential Revision: https://reviews.llvm.org/D158384
2023-08-23 09:21:42 +08:00
Ben Shi
96dcd8cb94 [LoongArch] Optimize bitwise and with immediates
Optimize bitfield extractions retaining bit positions
from 'lu12i + addi + and' to 'bstrpick + slli'.

Reviewed By: xen0n, SixWeining

Differential Revision: https://reviews.llvm.org/D147368
2023-04-03 12:10:07 +08:00
Nikita Popov
779df38242 [LoongArch] Convert tests to opaque pointers (NFC) 2023-01-16 10:20:46 +01:00
wanglei
daf067da04 [LoongArch] Stack realignment support
This patch adds support for stack realignment while adding support for
variable sized objects.

Differential Revision: https://reviews.llvm.org/D136074
2022-10-21 17:30:29 +08:00