[PATCH v2] LoongArch: Optimize the implementation of stack check.

2022-10-13 Thread Lulu Cheng
The old stack stack was performed before the stack was dropped, which would cause the detection tool to report a memory leak. The current stack check scheme is as follows: '-fstack-clash-protection': 1. When the frame->total_size is smaller than the guard page size, the stack is dropped accord

[PATCH v3] LoongArch: Libvtv add loongarch support.

2022-10-28 Thread Lulu Cheng
After several considerations, I decided to set VTV_PAGE_SIZE to 16KB under loongarch64. v1 - > v2: 1. When the macro __loongarch_lp64 is defined, the VTV_PAGE_SIZE is set to 64K. 2. In the vtv_malloc.cc file __vtv_malloc_init function, it does not check whether VTV_PAGE_SIZE is equal to the

[PATCH v4] Libvtv: Add loongarch support.

2022-10-28 Thread Lulu Cheng
v1 - > v2: 1. When the macro __loongarch_lp64 is defined, the VTV_PAGE_SIZE is set to 64K. 2. In the vtv_malloc.cc file __vtv_malloc_init function, it does not check whether VTV_PAGE_SIZE is equal to the system page size, if the macro __loongarch_lp64 is defined. v2 -> v3: Set VTV_PAGE_SIZ

[PATCH v1 0/2] Optimize immediate load. Add prefetch insns.

2022-10-29 Thread Lulu Cheng
.html) 2. Add prefetch insns. *** BLURB HERE *** Lulu Cheng (2): LoongArch: Optimize immediate load. LoongArch: Add prefetch insns. gcc/config/loongarch/constraints.md | 7 +- gcc/config/loongarch/loongarch-def.c | 2 + gcc/config/loongarch/loongarch-protos.h | 1

[PATCH v1 2/2] LoongArch: Add prefetch insns.

2022-10-29 Thread Lulu Cheng
Co-Authored-By: xujiahao gcc/ChangeLog: * config/loongarch/loongarch-def.c: Initial number of parallel prefetch. * config/loongarch/loongarch-protos.h (loongarch_prefetch_cookie): Function declaration. * config/loongarch/loongarch-tune.h (struct loongarch_cache):

[PATCH v1 1/2] LoongArch: Optimize immediate load.

2022-10-29 Thread Lulu Cheng
Fixed an issue where the compiler would not take four 64-bit immediate load instructions out of the loop. gcc/ChangeLog: * config/loongarch/constraints.md (x): New constraint. * config/loongarch/loongarch.cc (struct loongarch_integer_op): Define a new member curr_value, th

Re: [PATCH v1 2/2] LoongArch: Add prefetch insns.

2022-10-29 Thread Lulu Cheng
Sorry for the problem in this patch. I will send it again after modification. 在 2022/10/29 下午3:05, Lulu Cheng 写道: Co-Authored-By: xujiahao gcc/ChangeLog: * config/loongarch/loongarch-def.c: Initial number of parallel prefetch. * config/loongarch/loongarch-protos.h

Re:[pushed] [PATCH v4] Libvtv: Add loongarch support.

2022-10-31 Thread Lulu Cheng
Pushed to r13-3571. 在 2022/10/29 下午2:53, Lulu Cheng 写道: v1 - > v2: 1. When the macro __loongarch_lp64 is defined, the VTV_PAGE_SIZE is set to 64K. 2. In the vtv_malloc.cc file __vtv_malloc_init function, it does not check whether VTV_PAGE_SIZE is equal to the system page size, if the ma

[PATCH v2] LoongArch: Optimize immediate load.

2022-10-31 Thread Lulu Cheng
v1 -> v2: 1. Change the code format. 2. Fix bugs in the code. Both regression tests and spec2006 passed. The problem mentioned in the link does not move the four immediate load instructions out of the loop. It has been optimized. Now, as in the test case, four immediate load instructions are gene

Re: [PATCH v2] LoongArch: Optimize immediate load.

2022-11-01 Thread Lulu Cheng
在 2022/11/1 下午4:02, Xi Ruoyao 写道: On Tue, 2022-11-01 at 14:19 +0800, Lulu Cheng wrote: +;; Load immediate to the 32-63 bits of the source register. +(define_insn_and_split "load_hi32" +  [(set (match_operand:DI 0 "register_operand" "=r") +   (ior:DI +  

[PATCH v3] LoongArch: Optimize immediate load.

2022-11-01 Thread Lulu Cheng
v1 -> v2: 1. Change the code format. 2. Fix bugs in the code. v2 -> v3: Modifying a code implementation of an undefined behavior. Both regression tests and spec2006 passed. The problem mentioned in the link does not move the four immediate load instructions out of the loop. It has been optimized

Re: [PATCH] LoongArch: Provide fmin/fmax RTL pattern

2022-08-16 Thread Lulu Cheng
Looks good to me. 在 2022/8/16 下午4:08, Xi Ruoyao 写道: A simple optimization. Ok for trunk? -- >8 -- We already had smin/smax RTL pattern using fmin/fmax instruction. But for smin/smax, it's unspecified what will happen if either operand is NaN. So we would generate calls to libc fmin/fmax fu

Re: [commited PATCH] LoongArch: Get __tls_get_addr address through got table when disable plt.

2022-08-17 Thread Lulu Cheng
2022/8/11 下午7:35, Lulu Cheng 写道: thread.c: __attribute__ ((tls_model ("global-dynamic"))) __thread int a; void test (void) { a = 10; } Compile the tests with -fno-plt, error message is as follows: thread.c: In function 'test': thread.c:7:1: error: unrecog

Re: [PATCH v6] LoongArch: add addr_global attribute

2022-08-17 Thread Lulu Cheng
在 2022/8/18 上午10:56, Hans-Peter Nilsson 写道: On Mon, 15 Aug 2022, Xi Ruoyao via Gcc-patches wrote: Can we make a final solution to this soon? Now the merge window of Linux 6.0 is closed and we have two Linux kernel releases not possible to be built with Binutils or GCC with new relocation typ

[PATCH v1] LoongArch: Add support code model extreme.

2022-08-18 Thread Lulu Cheng
Use five instructions to calculate a signed 64-bit offset relative to the pc. gcc/ChangeLog: * config/loongarch/loongarch-opts.cc: Allow cmodel to be extreme. * config/loongarch/loongarch.cc (loongarch_call_tls_get_addr): Add extreme support for TLS GD and LD types.

Re: [PATCH v1] LoongArch: Add support code model extreme.

2022-08-18 Thread Lulu Cheng
在 2022/8/18 下午7:37, Xi Ruoyao 写道: + if (opts->x_flag_plt) + error ("code model %qs and %qs not support %s mode", +"tiny-static", "extreme", "plt"); I think we can ignore the effect of -fplt if code model is extreme, instead of forcing everyone to explicitly add -f

Re: [PATCH v1] LoongArch: Add support code model extreme.

2022-08-18 Thread Lulu Cheng
在 2022/8/18 下午8:52, Xi Ruoyao 写道: On Thu, 2022-08-18 at 19:49 +0800, Lulu Cheng wrote: I think we can ignore the effect of -fplt if code model is extreme, instead of forcing everyone to explicitly add -fno-plt. The "large" code model of x86_64 also does not limit the address ra

[PATCH v2] LoongArch: Add support code model extreme.

2022-08-18 Thread Lulu Cheng
v1 -> v2: - Modify some description information. - Add options -W[no]extreme-plt, warn about code model extreme not support plt mode, and then disable plt. --- Use five instructions to calculate a signed 64-bit offset relative to the pc. gcc/ChangeLog:

[PATCH v3] LoongArch: Add support code model extreme.

2022-08-19 Thread Lulu Cheng
v1 -> v2: - Modify some description information. - Add options -W[no]extreme-plt, warn about code model extreme not support plt mode, and then disable plt. v2 -> v3: - When -mcmodel=extreme, default set to -fno-plt mode, if the user forces to use '-mcmodel=extreme -fplt', an error will be reporte

[PATCH v4] LoongArch: Add support code model extreme.

2022-08-20 Thread Lulu Cheng
v1 -> v2: - Modify some description information. - Add options -W[no]extreme-plt, warn about code model extreme not support plt mode, and then disable plt. v2 -> v3: - When -mcmodel=extreme, default set to -fno-plt mode, if the user forces to use '-mcmodel=extreme -fplt', an error will be reporte

Re: [commited PATCH v4] LoongArch: Add support code model extreme.

2022-08-20 Thread Lulu Cheng
Pushd to r13-2128. 在 2022/8/20 下午4:39, Lulu Cheng 写道: v1 -> v2: - Modify some description information. - Add options -W[no]extreme-plt, warn about code model extreme not support plt mode, and then disable plt. v2 -> v3: - When -mcmodel=extreme, default set to -fno-plt mode, if the user

[PATCH v1] LoongArch: Add new code model 'emdium'.

2022-08-20 Thread Lulu Cheng
The function jump instruction in normal mode is 'bl', so the scope of the function jump is +-128MB. Now we've added support for 'medium' mode, this mode is to complete the function jump through two instructions: pcalau12i + jirl So in this mode the function jump range is increased to +-2GB

Re: LoongArch: add model attribute

2022-08-23 Thread Lulu Cheng
在 2022/8/23 下午10:51, Xi Ruoyao 写道: diff --git a/gcc/config/loongarch/loongarch-protos.h b/gcc/config/loongarch/loongarch-protos.h index cadaad7519c..4e925aa3876 100644 --- a/gcc/config/loongarch/loongarch-protos.h +++ b/gcc/config/loongarch/loongarch-protos.h @@ -30,6 +30,12 @@ along with GCC;

Re: [commited PATCH v1] LoongArch: Add new code model 'medium'.

2022-08-23 Thread Lulu Cheng
Pushed to r13-2165. 在 2022/8/20 下午5:18, Huacai Chen 写道: Hi, Lulu, I think there is a typo in your subject line. Huacai On Sat, Aug 20, 2022 at 5:05 PM Lulu Cheng wrote: The function jump instruction in normal mode is 'bl', so the scope of the function jump is +-128MB. Now w

Re: [PATCH 1/2] LoongArch: Avoid RTL flag check failure in loongarch_classify_symbol

2022-08-25 Thread Lulu Cheng
在 2022/8/24 下午10:03, Xi Ruoyao 写道: SYMBOL_REF_TLS_MODEL invokes SYMBOL_REF_FLAGS, and SYMBOL_REF_FLAGS invokes RTL_FLAG_CHECK1 and aborts when RTL code is not SYMBOL_REF. r13-1833 removed "gcc_assert (SYMBOL_REF_P (x))" before invoking "SYMBOL_REF_TLS_MODEL (x)", indicating that it's now possi

Re: [PATCH v2 2/2 resend] LoongArch: add model attribute

2022-08-25 Thread Lulu Cheng
在 2022/8/24 下午10:12, Xi Ruoyao 写道: On Wed, 2022-08-24 at 22:08 +0800, Xi Ruoyao wrote: v1 -> v2:  * Avoid introduce of SYMBOL_PCREL32, use SYMBOL_PCREL for 32-bit PC    relative.  * Rebase onto a bug fix ([1/2] in the series) to avoid merge conflict.  * Fix missed ChangeLog entries. Rese

Re: [PATCH v2 2/2 resend] LoongArch: add model attribute

2022-08-25 Thread Lulu Cheng
在 2022/8/25 下午7:41, Xi Ruoyao 写道: On Thu, 2022-08-25 at 17:12 +0800, Xi Ruoyao via Gcc-patches wrote: On Thu, 2022-08-25 at 16:53 +0800, Lulu Cheng wrote: I think this should add a sentence: "Currently, the identifier name can only be one of small or extreme." I'll ad

Re: [PATCH] LoongArch: testsuite: refine __tls_get_addr tests with tls_native

2022-08-28 Thread Lulu Cheng
LGTM! Thanks. 在 2022/8/24 下午10:09, Xi Ruoyao 写道: If GCC is not built with a working linker for the target (developers occansionally build such a "minimal" GCC for testing and debugging), TLS will be emulated and __tls_get_addr won't be used. Refine those tests depending on __tls_get_addr with

Re: [PATCH] libsanitizer: enable libubsan and libasan for loongarch64-*-linux*

2022-08-30 Thread Lulu Cheng
OK! Thanks! 在 2022/8/31 下午1:54, Xi Ruoyao 写道: The LoongArch support for libubsan and libasan has been added in: - https://reviews.llvm.org/D129371 - https://reviews.llvm.org/D129418 and we've merged them in r13-2269. It's time to enable them. No unexpected failures in GCC asan.exp and ubsan

Re: [PATCH] LoongArch: add -mdirect-extern-access option

2022-09-03 Thread Lulu Cheng
I think the following modification should be added: git diff loongarch/predicates.md +;; Do not use GOT to access external symbols, when define +;; TARGET_DIRECT_EXTERN_ACCESS. +  (define_predicate "is_const_call_local_symbol"    (and (match_operand 0 "const_call_insn_operand")     (ior (mat

Re: [PATCH] LoongArch: add -mdirect-extern-access option

2022-09-03 Thread Lulu Cheng
在 2022/9/4 上午10:51, Xi Ruoyao 写道: On Sun, 2022-09-04 at 10:26 +0800, Lulu Cheng wrote: If the above modifications are not added, the function call is:  bl %plt(test1) now is :  bl test1 Regarding "%plt(...)", in the binutils code: /* For compatible old asm code. */

Re: [PATCH] LoongArch: add -mdirect-extern-access option

2022-09-04 Thread Lulu Cheng
在 2022/9/4 下午2:35, Xi Ruoyao 写道: On Sun, 2022-09-04 at 11:22 +0800, Lulu Cheng wrote: 在 2022/9/4 上午10:51, Xi Ruoyao 写道: On Sun, 2022-09-04 at 10:26 +0800, Lulu Cheng wrote: If the above modifications are not added, the function call is:  bl %plt(test1) now is :  bl test1

Re: [PATCH v2] LoongArch: add -mdirect-extern-access option

2022-09-04 Thread Lulu Cheng
LGTM! Thanks! 在 2022/9/4 下午9:18, Xi Ruoyao 写道: v1 -> v2: Move TARGET_DIRECT_EXTERN_ACCESS check from loongarch_classify_symbol to loongarch_symbol_binds_local_p, so "%plt" is not output if -mdirect-extern-access used. -- >8 -- As a new target, LoongArch does not use copy relocation as it's

[PATCH] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.

2022-09-07 Thread Lulu Cheng
gcc/ChangeLog: PR target/106828 * config/loongarch/loongarch.cc (loongarch_asan_shadow_offset): New. (TARGET_ASAN_SHADOW_OFFSET): New. gcc/testsuite/ChangeLog: PR target/106828 * g++.target/loongarch/pr106828.C: New test. --- gcc/config/loongarch/loongarc

[PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.

2022-09-07 Thread Lulu Cheng
Sorry, asan shadow offset is wrong in v1. In the file asan_mapping.h line 207: #define ASAN_SHADOW_OFFSET_CONST 0x4000 So it's should be 1<<46. gcc/ChangeLog: PR target/106828 * config/loongarch/loongarch.cc (loongarch

Re: [commited PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.

2022-09-07 Thread Lulu Cheng
在 2022/9/7 下午4:02, Xi Ruoyao 写道: On Wed, 2022-09-07 at 15:39 +0800, Lulu Cheng wrote: Sorry, asan shadow offset is wrong in v1. In the file asan_mapping.h line 207: #    define ASAN_SHADOW_OFFSET_CONST 0x4000 So it's should be 1<<46. LGTM. I forgot to i

Re: [PATCH v2] LoongArch: Fix pr106828 by define hook TARGET_ASAN_SHADOW_OFFSET in loongarch backend.

2022-09-07 Thread Lulu Cheng
Sorry, I will correct this typo. Thanks! 在 2022/9/7 下午5:58, Martin Liška 写道: On 9/7/22 09:39, Lulu Cheng wrote: |+ This value is taken from the file libsanitizer/asan/asan_mappint.h. */| s/asan_mappint.h/asan_mapping.h Cheers, Martin

Re: [PATCH] loongarch: ignore zero-size fields in calling convention

2022-04-25 Thread Lulu Cheng
This modification will cause the ABI to change, we are discussing solutions. And we will give a conclusion at the latest tommorrow. Thanks! 在 2022/4/25 下午1:57, Xi Ruoyao 写道: Ping. Normally we shouldn't ping a patch after only a few days, but we're running out of time to catch GCC 12 milestone

Re: [PATCH] loongarch: ignore zero-size fields in calling convention

2022-04-26 Thread Lulu Cheng
hink the modification should be below. if (!TYPE_P (TREE_TYPE (f)))    return -1; Thanks! Lulu Cheng

[PATCH 1/2] LoongArch: Add '(clobber (mem:BLK (scratch)))' to PLV instruction templates.

2022-04-27 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.md: Add '(clobber (mem:BLK (scratch)))' to PLV instruction templates. --- gcc/config/loongarch/loongarch.md | 40 +-- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/gcc/config/loongarch/loonga

[PATCH 2/2] LoongArch: Add fdiv define_expand template.

2022-04-27 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.md: Add fdiv define_expand template, then generate floating-point division and floating-point reciprocal instructions. --- gcc/config/loongarch/loongarch.md | 6 ++ 1 file changed, 6 insertions(+) diff --git a/gcc/config/loo

Re: [PATCH v2] loongarch: ignore zero-size fields in calling convention

2022-04-27 Thread Lulu Cheng
OK! 在 2022/4/27 下午7:45, Xi Ruoyao 写道: On Wed, 2022-04-27 at 14:57 +0800, Lulu Cheng wrote: I think the modification should be below. if (!TYPE_P (TREE_TYPE (f)))     return -1; I think (!TYPE_P (TREE_TYPE (f)) will never be true (the code handling calling

Re: [PATCH v2] loongarch: ignore zero-size fields in calling convention

2022-04-27 Thread Lulu Cheng
I have pushed upstream. Thanks. Lulu Cheng 在 2022/4/27 下午7:45, Xi Ruoyao 写道: On Wed, 2022-04-27 at 14:57 +0800, Lulu Cheng wrote: I think the modification should be below. if (!TYPE_P (TREE_TYPE (f)))     return -1; I think (!TYPE_P (TREE_TYPE (f)) will never be

[PATCH v1] LoongArch: Fixed an issue with the implementation of the template atomic_compare_and_swapsi.

2024-03-06 Thread Lulu Cheng
If the hardware does not support LAMCAS, atomic_compare_and_swapsi needs to be implemented through "ll.w+sc.w". In the implementation of the instruction sequence, it is necessary to determine whether the two registers are equal. Since LoongArch's comparison instructions do not distinguish between

[PATCH] LoongArch: testsuite: Add compilation options to the regname-fp-s9.c.

2024-03-06 Thread Lulu Cheng
When the value of the macro DEFAULT_CFLAGS is set to '-ansi -pedantic-errors', regname-s9-fp.c will test to fail. To solve this problem, add the compilation option '-Wno-pedantic -std=gnu90' to this test case. gcc/testsuite/ChangeLog: * gcc.target/loongarch/regname-fp-s9.c: Add compilatio

[PATCH] LoongArch: gcc12: Implement option save/restore.

2024-03-16 Thread Lulu Cheng
LTO option streaming and target attributes both require per-function target configuration, which is achieved via option save/restore. We implement TARGET_OPTION_{SAVE,RESTORE} to switch the la_target context in addition to other automatically maintained option states (via the "Save" option propert

[PATCH] LoongArch: gcc13: Implement option save/restore.

2024-03-16 Thread Lulu Cheng
LTO option streaming and target attributes both require per-function target configuration, which is achieved via option save/restore. We implement TARGET_OPTION_{SAVE,RESTORE} to switch the la_target context in addition to other automatically maintained option states (via the "Save" option propert

[PATCH] LoongArch: Add descriptions of the compilation options.

2024-03-30 Thread Lulu Cheng
Add descriptions for the compilation options '-mfrecipe' '-mdiv32' '-mlam-bh' '-mlamcas' and '-mld-seq-sa'. gcc/ChangeLog: * doc/invoke.texi: Add descriptions for the compilation options. --- gcc/doc/invoke.texi | 45 +++-- 1 file changed,

[PATCH] Regenerate loongarch.opt.urls.

2024-03-31 Thread Lulu Cheng
Fixes: d28ea8e5a704 ("LoongArch: Split loongarch_option_override_internal into smaller procedures") gcc/ChangeLog: * config/loongarch/loongarch.opt.urls: Regenerate. --- gcc/config/loongarch/loongarch.opt.urls | 19 +-- 1 file changed, 17 insertions(

[PATCH v1] LoongArch: Set default alignment for functions jumps and loops [PR112919].

2024-04-02 Thread Lulu Cheng
Xi Ruoyao set the alignment rules under LA464 in commit r14-1839, but the macro ASM_OUTPUT_ALIGN_WITH_NOP was removed in R14-4674, which affected the alignment rules. So I set different aligns on LA464 and LA664 again to test the performance of spec2006, and modify the alignment based on the test

Re:[pushed] [PATCH] LoongArch: Remove unused code

2024-04-02 Thread Lulu Cheng
Pushed to r14-9766. 在 2024/4/2 下午2:33, Jiahao Xu 写道: For machines that satisfy ISA_HAS_LSX && !TARGET_64BIT, we will not support them now and in the future, so this patch removes these unused code. gcc/ChangeLog: * config/loongarch/lasx.md: Remove unused code. * config/loongar

Re:[pushed] [PATCH v1] LoongArch: Set default alignment for functions jumps and loops [PR112919].

2024-04-07 Thread Lulu Cheng
在 2024/4/6 下午5:53, Xi Ruoyao 写道: On Tue, 2024-04-02 at 15:03 +0800, Lulu Cheng wrote: +/* Alignment for functions loops and jumps for best performance.  For new +   uarchs the value should be measured via benchmarking.  See the documentation +   for -falign-functions -falign-loops and -falign

[PATCH] LoongArch: Add indexes for some compilation options.

2024-04-09 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.opt.urls: Regenerate. * config/mn10300/mn10300.opt.urls: Likewise. * config/msp430/msp430.opt.urls: Likewise. * config/nds32/nds32-elf.opt.urls: Likewise. * config/nds32/nds32-linux.opt.urls: Likewise. * co

Re:[pushed] [PATCH v2] LoongArch: Enable switchable target

2024-04-09 Thread Lulu Cheng
Pushed to r14-9866. 在 2024/4/8 下午4:45, Yang Yujie 写道: This patch fixes the back-end context switching in cases where functions should be built with their own target contexts instead of the global one, such as LTO linking and functions with target attributes (TBD). PR target/113233 gcc/

[PATCH v2] LoongArch: libsanitizer: Enable Lsan and Tsan for loongarch64.

2024-02-03 Thread Lulu Cheng
From: chenguoqi libsanitizer/ChangeLog: * configure.tgt: Enable tsan and lsan for loongarch64. * tsan/Makefile.am (EXTRA_libtsan_la_SOURCES): Add tsan_rtl_loongarch64.S. * tsan/Makefile.in: Regenerate. --- libsanitizer/configure.tgt| 5 + libsanitizer/tsa

[PATCH 1/2] LoongArch: Fix wrong return value type of __iocsrrd_h.

2024-02-05 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/larchintrin.h (__iocsrrd_h): Modify the function return value type to unsigned short. --- gcc/config/loongarch/larchintrin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/config/loongarch/larchintrin.h b/gcc/config/loong

[PATCH 2/2] LoongArch: Remove redundant symbol type conversions in larchintrin.h.

2024-02-05 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/larchintrin.h (__movgr2fcsr): Remove redundant symbol type conversions. (__cacop_d): Likewise. (__cpucfg): Likewise. (__asrtle_d): Likewise. (__asrtgt_d): Likewise. (__lddir_d): Likewise. (__ldpte_d):

[PATCH v1 4/4] LoongArch: Define HAVE_AS_TLS to 0 if it's undefined [PR112299]

2024-02-20 Thread Lulu Cheng
From: Xi Ruoyao Now loongarch.md uses HAVE_AS_TLS, we need this to fix the failure building a cross compiler if the cross assembler is not installed yet. gcc/ChangeLog: PR target/112299 * config/loongarch/loongarch-opts.h (HAVE_AS_TLS): Define to 0 if not defined yet. (

[PATCH v1 1/4] LoongArch: Delete macro definition ASM_OUTPUT_ALIGN_WITH_NOP.

2024-02-20 Thread Lulu Cheng
There are two reasons for removing this macro definition: 1. The default in the assembler is to use the nop instruction for filling. 2. For assembly directives: .align [abs-expr[, abs-expr[, abs-expr]]] The third expression it is the maximum number of bytes that should be skipped by this alig

[PATCH v1 0/4] Fix a series of problems caused by

2024-02-20 Thread Lulu Cheng
ditional branch relaxation. (cherry pick r14-5434) PR112299 is also fixed here. Lulu Cheng (2): LoongArch: Delete macro definition ASM_OUTPUT_ALIGN_WITH_NOP. LoongArch: Check whether binutils supports the relax function. If supported, explicit relocs are turned off by default. Xi Ruoyao (

[PATCH v1 3/4] LoongArch: Disable relaxation if the assembler don't support conditional branch relaxation [PR112330]

2024-02-20 Thread Lulu Cheng
From: Xi Ruoyao As the commit message of r14-4674 has indicated, if the assembler does not support conditional branch relaxation, a relocation overflow may happen on conditional branches when relaxation is enabled because the number of NOP instructions inserted by the assembler will be more than

[PATCH v1 2/4] LoongArch: Check whether binutils supports the relax function. If supported, explicit relocs are turned off by default.

2024-02-20 Thread Lulu Cheng
gcc/ChangeLog: * config.in: Regenerate. * config/loongarch/genopts/loongarch.opt.in: Add compilation option mrelax. And set the initial value of explicit-relocs according to the detection status. * config/loongarch/gnu-user.h: When compiling with -mno-relax,

[PATCH v1 0/4] Fix a series of problems caused by

2024-02-20 Thread Lulu Cheng
ditional branch relaxation. (cherry pick r14-5434) PR112299 is also fixed here. Lulu Cheng (2): LoongArch: Delete macro definition ASM_OUTPUT_ALIGN_WITH_NOP. LoongArch: Check whether binutils supports the relax function. If supported, explicit relocs are turned off by default. Xi Ruoyao (

[PATCH v1 1/4] LoongArch: Delete macro definition ASM_OUTPUT_ALIGN_WITH_NOP.

2024-02-20 Thread Lulu Cheng
There are two reasons for removing this macro definition: 1. The default in the assembler is to use the nop instruction for filling. 2. For assembly directives: .align [abs-expr[, abs-expr[, abs-expr]]] The third expression it is the maximum number of bytes that should be skipped by this alig

[PATCH v1 4/4] LoongArch: Define HAVE_AS_TLS to 0 if it's undefined [PR112299]

2024-02-20 Thread Lulu Cheng
From: Xi Ruoyao Now loongarch.md uses HAVE_AS_TLS, we need this to fix the failure building a cross compiler if the cross assembler is not installed yet. gcc/ChangeLog: PR target/112299 * config/loongarch/loongarch-opts.h (HAVE_AS_TLS): Define to 0 if not defined yet. (

[PATCH v1 2/4] LoongArch: Check whether binutils supports the relax function. If supported, explicit relocs are turned off by default.

2024-02-20 Thread Lulu Cheng
gcc/ChangeLog: * config.in: Regenerate. * config/loongarch/genopts/loongarch.opt.in: Add compilation option mrelax. And set the initial value of explicit-relocs according to the detection status. * config/loongarch/gnu-user.h: When compiling with -mno-relax,

[PATCH v1 3/4] LoongArch: Disable relaxation if the assembler don't support conditional branch relaxation [PR112330]

2024-02-20 Thread Lulu Cheng
From: Xi Ruoyao As the commit message of r14-4674 has indicated, if the assembler does not support conditional branch relaxation, a relocation overflow may happen on conditional branches when relaxation is enabled because the number of NOP instructions inserted by the assembler will be more than

[PATCH v1 0/4] Fix a series of problems caused by ASM_OUTPUT_ALIGN_WITH_NOP (release/gcc-12).

2024-02-20 Thread Lulu Cheng
ditional branch relaxation. (cherry pick r14-5434) PR112299 is also fixed here. Lulu Cheng (2): LoongArch: Delete macro definition ASM_OUTPUT_ALIGN_WITH_NOP. LoongArch: Check whether binutils supports the relax function. If supported, explicit relocs are turned off by default. Xi Ruoyao (

[PATCH v1 1/4] LoongArch: Delete macro definition ASM_OUTPUT_ALIGN_WITH_NOP.

2024-02-20 Thread Lulu Cheng
There are two reasons for removing this macro definition: 1. The default in the assembler is to use the nop instruction for filling. 2. For assembly directives: .align [abs-expr[, abs-expr[, abs-expr]]] The third expression it is the maximum number of bytes that should be skipped by this alig

[PATCH v1 2/4] LoongArch: Check whether binutils supports the relax function. If supported, explicit relocs are turned off by default.

2024-02-20 Thread Lulu Cheng
gcc/ChangeLog: * config.in: Regenerate. * config/loongarch/genopts/loongarch.opt.in: Add compilation option mrelax. And set the initial value of explicit-relocs according to the detection status. * config/loongarch/gnu-user.h: When compiling with -mno-relax,

[PATCH v1 3/4] LoongArch: Disable relaxation if the assembler don't support conditional branch relaxation [PR112330]

2024-02-20 Thread Lulu Cheng
From: Xi Ruoyao As the commit message of r14-4674 has indicated, if the assembler does not support conditional branch relaxation, a relocation overflow may happen on conditional branches when relaxation is enabled because the number of NOP instructions inserted by the assembler will be more than

[PATCH v1 4/4] LoongArch: Define HAVE_AS_TLS to 0 if it's undefined [PR112299]

2024-02-20 Thread Lulu Cheng
From: Xi Ruoyao Now loongarch.md uses HAVE_AS_TLS, we need this to fix the failure building a cross compiler if the cross assembler is not installed yet. gcc/ChangeLog: PR target/112299 * config/loongarch/loongarch-opts.h (HAVE_AS_TLS): Define to 0 if not defined yet. (

[PATCH v1] LoongArch: When checking whether the assembler supports conditional branch relaxation, add compilation parameter "--fatal-warnings" to the assembler.

2024-02-20 Thread Lulu Cheng
In binutils 2.40 and earlier versions, only a warning will be reported when a relocation immediate value is out of bounds. As a result, the value of the macro HAVE_AS_COND_BRANCH_RELAXATION will also be defined as 1 when the assembler does not support conditional branch relaxation. Therefore, add t

[PATCH] LoongArch: Assign the '/u' attribute to the mem to which the global offset table belongs.

2024-01-12 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_split_symbol): Assign the '/u' attribute to the mem. gcc/testsuite/ChangeLog: * g++.target/loongarch/got-load.C: New test. --- gcc/config/loongarch/loongarch.cc | 5 + gcc/testsuite/g++.target/loo

[PATCH] LoongArch: Disable TLS type symbols from generating non-zero offsets.

2024-01-22 Thread Lulu Cheng
TLS gd ld and ie type symbols will generate corresponding GOT entries, so non-zero offsets cannot be generated. The address of TLS le type symbol+addend is not implemented in binutils, so non-zero offset is not generated here for the time being. gcc/ChangeLog: * config/loongarch/loongarch

[PATCH v4 0/4] When cmodel=extreme, add macro support and only support macros.

2024-01-25 Thread Lulu Cheng
s of a test case. v1 -> v2: 1. Use the temporarily allocated registers as intermediate registers to implement the extreme macro. 2. Fixed bugs in v1 test cases. Lulu Cheng (4): LoongArch: Merge template got_load_tls_{ld/gd/le/ie}. LoongArch: Add the macro implementation of mcmode

[PATCH v4 3/4] LoongArch: Enable explicit reloc for extreme TLS GD/LD with -mexplicit-relocs=auto.

2024-01-25 Thread Lulu Cheng
Binutils does not support relaxation using four instructions to obtain symbol addresses gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_explicit_relocs_p): When the code model of the symbol is extreme and -mexplicit-relocs=auto, the macro instruction loading symb

[PATCH v4 4/4] LoongArch: Added support for loading __get_tls_addr symbol address using call36.

2024-01-25 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_call_tls_get_addr): Add support for call36. gcc/testsuite/ChangeLog: * gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c: New test. --- gcc/config/loongarch/loongarch.cc | 20 +++

[PATCH v4 2/4] LoongArch: Add the macro implementation of mcmodel=extreme.

2024-01-25 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch-protos.h (loongarch_symbol_extreme_p): Add function declaration. * config/loongarch/loongarch.cc (loongarch_symbolic_constant_p): For SYMBOL_PCREL64, non-zero addend of "la.local $rd,$rt,sym+addend" is not allowed

[PATCH v4 1/4] LoongArch: Merge template got_load_tls_{ld/gd/le/ie}.

2024-01-25 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_load_tls): Load all types of tls symbols through one function. (loongarch_got_load_tls_gd): Delete. (loongarch_got_load_tls_ld): Delete. (loongarch_got_load_tls_ie): Delete. (loongarch_got_loa

[PATCH v5 4/5] LoongArch: Added support for loading __get_tls_addr symbol address using call36.

2024-01-29 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_call_tls_get_addr): Add support for call36. gcc/testsuite/ChangeLog: * gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c: New test. --- gcc/config/loongarch/loongarch.cc | 22 +++

[PATCH v5 0/5] When cmodel=extreme, add macro implementation and fix problems with explicit relos implementation.

2024-01-29 Thread Lulu Cheng
plicit reloc for extreme TLS GD/LD with -mexplicit-relocs=auto. v2 -> v3: 1. Modify the detection rules of a test case. v1 -> v2: 1. Use the temporarily allocated registers as intermediate registers to implement the extreme macro. 2. Fixed bugs in v1 test cases. Lulu Cheng (

[PATCH v5 2/5] LoongArch: Add the macro implementation of mcmodel=extreme.

2024-01-29 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch-protos.h (loongarch_symbol_extreme_p): Add function declaration. * config/loongarch/loongarch.cc (loongarch_symbolic_constant_p): For SYMBOL_PCREL64, non-zero addend of "la.local $rd,$rt,sym+addend" is not allowed

[PATCH v5 3/5] LoongArch: Enable explicit reloc for extreme TLS GD/LD with -mexplicit-relocs=auto.

2024-01-29 Thread Lulu Cheng
Binutils does not support relaxation using four instructions to obtain symbol addresses gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_explicit_relocs_p): When the code model of the symbol is extreme and -mexplicit-relocs=auto, the macro instruction loading symb

[PATCH v5 5/5] LoongArch: Don't split the instructions containing relocs for extreme code model.

2024-01-29 Thread Lulu Cheng
From: Xi Ruoyao The ABI mandates the pcalau12i/addi.d/lu32i.d/lu52i.d instructions for addressing a symbol to be adjacent. So model them as "one large instruction", i.e. define_insn, with two output registers. The real address is the sum of these two registers. The advantage of this approach i

[PATCH v5 1/5] LoongArch: Merge template got_load_tls_{ld/gd/le/ie}.

2024-01-29 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_load_tls): Load all types of tls symbols through one function. (loongarch_got_load_tls_gd): Delete. (loongarch_got_load_tls_ld): Delete. (loongarch_got_load_tls_ie): Delete. (loongarch_got_loa

[PATCH] LoongArch: libsanitizer: Enable build lsan and tsan for loongarch64.

2024-01-29 Thread Lulu Cheng
From: chenguoqi libsanitizer/ChangeLog: * configure.tgt: Enable tsan and lsan for loongarch64. * tsan/Makefile.am: Add tsan_rtl_loongarch64.S to EXTRA_libtsan_la_SOURCES. * tsan/Makefile.in: Regenerate. --- libsanitizer/configure.tgt| 5 + libsanitizer/tsan/Make

[PATCH] LoongArch: Modify the address calculation logic for obtaining array element values through fp.

2024-01-29 Thread Lulu Cheng
Modify address calculation logic from (((a x C) + fp) + offset) to ((fp + offset) + a x C). Thereby modifying the register dependencies and optimizing the code. The value of C is 2 4 or 8. The following is the assembly code before and after a loop modification in spec2006 401.bzip:

[PATCH v2] LoongArch: Modify the address calculation logic for obtaining array element values through fp.

2024-01-29 Thread Lulu Cheng
Modify address calculation logic from (((a x C) + fp) + offset) to ((fp + offset) + a x C). Thereby modifying the register dependencies and optimizing the code. The value of C is 2 4 or 8. The following is the assembly code before and after a loop modification in spec2006 401.bzip:

[PATCH] LoongArch: Added TLS Le Relax support.

2023-12-19 Thread Lulu Cheng
Check whether the assembler supports tls le relax. If it supports it, the assembly instruction sequence of tls le relax will be generated by default. The original way to obtain the tls le symbol address: lu12i.w $rd, %le_hi20(sym) ori $rd, $rd, %le_lo12(sym) add.{w/d} $rd, $rd, $tp I

[PATCH 0/2] When cmodel=extreme, add macro support and only

2023-12-27 Thread Lulu Cheng
cmodel=extreme. https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#extreme-code-model Lulu Cheng (2): LoongArch: Add the macro implementation of mcmodel=extreme. LoongArch: When the code model is extreme, the symbol address is obtained through macro instructions regardless of

[PATCH 2/2] LoongArch: When the code model is extreme, the symbol address is obtained through macro instructions regardless of the value of -mexplicit-relocs.

2023-12-27 Thread Lulu Cheng
Instructions pcalau12i, addi.d, lu32i.d and lu52i.d must be adjancent so that the linker can infer the PC of pcalau12i to apply relocations to lu32i.d and lu52i.d. Otherwise, the results would be incorrect if these four instructions are not in the same 4KiB page. See the link for details: https:

[PATCH 1/2] LoongArch: Add the macro implementation of mcmodel=extreme.

2023-12-27 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_symbolic_constant_p): Remove the sym+addend form from the SYMBOL_PCREL64 type symbol. (loongarch_option_override_internal): Supports option combinations of -cmodel=extreme and -mexplicit-relocs=none.

[PATCH] LoongArch: Fixed the problem of incorrect judgment of the immediate field of the [x]vld/[x]vst instruction.

2024-01-03 Thread Lulu Cheng
The [x]vld/[x]vst directive is defined as follows: [x]vld/[x]vst {x/v}d, rj, si12 When not modified, the immediate field of [x]vld/[x]vst is between 10 and 14 bits depending on the type. However, in loongarch_valid_offset_p, the immediate field is restricted first, so there is no error. However,

[PATCH v2 0/2] When cmodel=extreme, add macro support and only support macros.

2024-01-04 Thread Lulu Cheng
cmodel=extreme. https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#extreme-code-model v1 -> v2: 1. Use the temporarily allocated registers as intermediate registers to implement the extreme macro. 2. Fixed bugs in v1 test cases. Lulu Cheng (2): LoongArch: Add the ma

[PATCH v2 2/2] LoongArch: When the code model is extreme, the symbol address is obtained through macro instructions regardless of the value of -mexplicit-relocs.

2024-01-04 Thread Lulu Cheng
Instructions pcalau12i, addi.d, lu32i.d and lu52i.d must be adjancent so that the linker can infer the PC of pcalau12i to apply relocations to lu32i.d and lu52i.d. Otherwise, the results would be incorrect if these four instructions are not in the same 4KiB page. See the link for details: https:

[PATCH v2 1/2] LoongArch: Add the macro implementation of mcmodel=extreme.

2024-01-04 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_symbolic_constant_p): Remove the sym+addend form from the SYMBOL_PCREL64 type symbol. (loongarch_output_mi_thunk): Add code model extreme support. (loongarch_option_override_internal): Supports option combina

[PATCH v3 2/2] LoongArch: When the code model is extreme, the symbol address is obtained through macro instructions regardless of the value of -mexplicit-relocs.

2024-01-04 Thread Lulu Cheng
Instructions pcalau12i, addi.d, lu32i.d and lu52i.d must be adjancent so that the linker can infer the PC of pcalau12i to apply relocations to lu32i.d and lu52i.d. Otherwise, the results would be incorrect if these four instructions are not in the same 4KiB page. See the link for details: https:

[PATCH v3 0/2] When cmodel=extreme, add macro support and only support macros.

2024-01-04 Thread Lulu Cheng
a test case. Lulu Cheng (2): LoongArch: Add the macro implementation of mcmodel=extreme. LoongArch: When the code model is extreme, the symbol address is obtained through macro instructions regardless of the value of -mexplicit-relocs. gcc/config/loongarch/loongarch.cc

[PATCH v3 1/2] LoongArch: Add the macro implementation of mcmodel=extreme.

2024-01-04 Thread Lulu Cheng
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_symbolic_constant_p): Remove the sym+addend form from the SYMBOL_PCREL64 type symbol. (loongarch_output_mi_thunk): Add code model extreme support. (loongarch_option_override_internal): Supports option combina

<    1   2   3   4   5   >