Message ID | 20230630021614.57201-1-panchenghui@loongson.cn |
---|---|
Headers | show |
Series | Add Loongson SX/ASX instruction support to LoongArch target. | expand |
On Fri, 2023-06-30 at 10:16 +0800, Chenghui Pan wrote: > These patches add the Loongson SX/ASX instruction support to the > LoongArch > target, and can be utilized by using the new "-mlsx" and > "-mlasx" option. > > Patches are bootstrapped and tested on loongarch64-linux-gnu target. > > Lulu Cheng (6): > LoongArch: Added Loongson SX vector directive compilation framework. > LoongArch: Added Loongson SX base instruction support. > LoongArch: Added Loongson SX directive builtin function support. > LoongArch: Added Loongson ASX vector directive compilation framework. > LoongArch: Added Loongson ASX base instruction support. > LoongArch: Added Loongson ASX directive builtin function support. These seems too long for review. Could we separate them into multiple pieces, for example: - The first patch just adds "-mlsx" and "-mlasx" options. - The second patch adds memory load and store instructions, and block move & store operations using these instructions. - The third patch adds integer vector add/subtraction/multiplication instructions. - The fourth patch adds integer vector division instructions (division is "complex" so IMO it worthy a separate patch) - ... - The (n-1)-th patch adds remaining instructions (impossible or difficult to be modeled with RTL templates) as UNSPECs. - The n-th patch adds the built-ins. > > gcc/config.gcc | 2 +- > gcc/config/loongarch/constraints.md | 128 +- > .../loongarch/genopts/loongarch-strings | 4 + > gcc/config/loongarch/genopts/loongarch.opt.in | 16 +- > gcc/config/loongarch/lasx.md | 5147 ++++++++++++++++ > gcc/config/loongarch/lasxintrin.h | 5342 > +++++++++++++++++ > gcc/config/loongarch/loongarch-builtins.cc | 2686 ++++++++- > gcc/config/loongarch/loongarch-c.cc | 18 + > gcc/config/loongarch/loongarch-def.c | 6 + > gcc/config/loongarch/loongarch-def.h | 9 +- > gcc/config/loongarch/loongarch-driver.cc | 10 + > gcc/config/loongarch/loongarch-driver.h | 2 + > gcc/config/loongarch/loongarch-ftypes.def | 666 +- > gcc/config/loongarch/loongarch-modes.def | 39 + > gcc/config/loongarch/loongarch-opts.cc | 89 +- > gcc/config/loongarch/loongarch-opts.h | 3 + > gcc/config/loongarch/loongarch-protos.h | 35 + > gcc/config/loongarch/loongarch-str.h | 3 + > gcc/config/loongarch/loongarch.cc | 4615 +++++++++++++- > gcc/config/loongarch/loongarch.h | 117 +- > gcc/config/loongarch/loongarch.md | 56 +- > gcc/config/loongarch/loongarch.opt | 16 +- > gcc/config/loongarch/lsx.md | 4490 ++++++++++++++ > gcc/config/loongarch/lsxintrin.h | 5181 ++++++++++++++++ > gcc/config/loongarch/predicates.md | 333 +- > 25 files changed, 28723 insertions(+), 290 deletions(-) > create mode 100644 gcc/config/loongarch/lasx.md > create mode 100644 gcc/config/loongarch/lasxintrin.h > create mode 100644 gcc/config/loongarch/lsx.md > create mode 100644 gcc/config/loongarch/lsxintrin.h >
A question: is vld/vst guaranteed to be atomic if the accessed address is aligned? If true we can use them to implement lock-free 128-bit atomic load and store. See https://gcc.gnu.org/bugzilla/PR104688 for the background, and some people really hate using a lock for atomics. On Fri, 2023-06-30 at 10:16 +0800, Chenghui Pan wrote: > These patches add the Loongson SX/ASX instruction support to the > LoongArch > target, and can be utilized by using the new "-mlsx" and > "-mlasx" option. > > Patches are bootstrapped and tested on loongarch64-linux-gnu target. > > Lulu Cheng (6): > LoongArch: Added Loongson SX vector directive compilation framework. > LoongArch: Added Loongson SX base instruction support. > LoongArch: Added Loongson SX directive builtin function support. > LoongArch: Added Loongson ASX vector directive compilation > framework. > LoongArch: Added Loongson ASX base instruction support. > LoongArch: Added Loongson ASX directive builtin function support. > > gcc/config.gcc | 2 +- > gcc/config/loongarch/constraints.md | 128 +- > .../loongarch/genopts/loongarch-strings | 4 + > gcc/config/loongarch/genopts/loongarch.opt.in | 16 +- > gcc/config/loongarch/lasx.md | 5147 ++++++++++++++++ > gcc/config/loongarch/lasxintrin.h | 5342 > +++++++++++++++++ > gcc/config/loongarch/loongarch-builtins.cc | 2686 ++++++++- > gcc/config/loongarch/loongarch-c.cc | 18 + > gcc/config/loongarch/loongarch-def.c | 6 + > gcc/config/loongarch/loongarch-def.h | 9 +- > gcc/config/loongarch/loongarch-driver.cc | 10 + > gcc/config/loongarch/loongarch-driver.h | 2 + > gcc/config/loongarch/loongarch-ftypes.def | 666 +- > gcc/config/loongarch/loongarch-modes.def | 39 + > gcc/config/loongarch/loongarch-opts.cc | 89 +- > gcc/config/loongarch/loongarch-opts.h | 3 + > gcc/config/loongarch/loongarch-protos.h | 35 + > gcc/config/loongarch/loongarch-str.h | 3 + > gcc/config/loongarch/loongarch.cc | 4615 +++++++++++++- > gcc/config/loongarch/loongarch.h | 117 +- > gcc/config/loongarch/loongarch.md | 56 +- > gcc/config/loongarch/loongarch.opt | 16 +- > gcc/config/loongarch/lsx.md | 4490 ++++++++++++++ > gcc/config/loongarch/lsxintrin.h | 5181 ++++++++++++++++ > gcc/config/loongarch/predicates.md | 333 +- > 25 files changed, 28723 insertions(+), 290 deletions(-) > create mode 100644 gcc/config/loongarch/lasx.md > create mode 100644 gcc/config/loongarch/lasxintrin.h > create mode 100644 gcc/config/loongarch/lsx.md > create mode 100644 gcc/config/loongarch/lsxintrin.h >
No, vld/vst can't guaranteed to be atomic in this condition. Seems we can't implement this on LoongArch for now. On 2023/7/5 20:57, Xi Ruoyao wrote: > A question: is vld/vst guaranteed to be atomic if the accessed address > is aligned? If true we can use them to implement lock-free 128-bit > atomic load and store. See https://gcc.gnu.org/bugzilla/PR104688 for > the background, and some people really hate using a lock for atomics. > > On Fri, 2023-06-30 at 10:16 +0800, Chenghui Pan wrote: >> These patches add the Loongson SX/ASX instruction support to the >> LoongArch >> target, and can be utilized by using the new "-mlsx" and >> "-mlasx" option. >> >> Patches are bootstrapped and tested on loongarch64-linux-gnu target. >> >> Lulu Cheng (6): >> LoongArch: Added Loongson SX vector directive compilation framework. >> LoongArch: Added Loongson SX base instruction support. >> LoongArch: Added Loongson SX directive builtin function support. >> LoongArch: Added Loongson ASX vector directive compilation >> framework. >> LoongArch: Added Loongson ASX base instruction support. >> LoongArch: Added Loongson ASX directive builtin function support. >> >> gcc/config.gcc | 2 +- >> gcc/config/loongarch/constraints.md | 128 +- >> .../loongarch/genopts/loongarch-strings | 4 + >> gcc/config/loongarch/genopts/loongarch.opt.in | 16 +- >> gcc/config/loongarch/lasx.md | 5147 ++++++++++++++++ >> gcc/config/loongarch/lasxintrin.h | 5342 >> +++++++++++++++++ >> gcc/config/loongarch/loongarch-builtins.cc | 2686 ++++++++- >> gcc/config/loongarch/loongarch-c.cc | 18 + >> gcc/config/loongarch/loongarch-def.c | 6 + >> gcc/config/loongarch/loongarch-def.h | 9 +- >> gcc/config/loongarch/loongarch-driver.cc | 10 + >> gcc/config/loongarch/loongarch-driver.h | 2 + >> gcc/config/loongarch/loongarch-ftypes.def | 666 +- >> gcc/config/loongarch/loongarch-modes.def | 39 + >> gcc/config/loongarch/loongarch-opts.cc | 89 +- >> gcc/config/loongarch/loongarch-opts.h | 3 + >> gcc/config/loongarch/loongarch-protos.h | 35 + >> gcc/config/loongarch/loongarch-str.h | 3 + >> gcc/config/loongarch/loongarch.cc | 4615 +++++++++++++- >> gcc/config/loongarch/loongarch.h | 117 +- >> gcc/config/loongarch/loongarch.md | 56 +- >> gcc/config/loongarch/loongarch.opt | 16 +- >> gcc/config/loongarch/lsx.md | 4490 ++++++++++++++ >> gcc/config/loongarch/lsxintrin.h | 5181 ++++++++++++++++ >> gcc/config/loongarch/predicates.md | 333 +- >> 25 files changed, 28723 insertions(+), 290 deletions(-) >> create mode 100644 gcc/config/loongarch/lasx.md >> create mode 100644 gcc/config/loongarch/lasxintrin.h >> create mode 100644 gcc/config/loongarch/lsx.md >> create mode 100644 gcc/config/loongarch/lsxintrin.h >>