Add support for LoongArch (#19223)

* Add support for LoongArch

* Update compiler/installer.ini

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
wenghongquan 2021-12-09 21:00:33 +08:00 • committed by GitHub
commit 742e9d65ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 4 deletions

View file

@ -202,7 +202,7 @@ type
cpuPowerpc64el, cpuSparc, cpuVm, cpuHppa, cpuIa64, cpuAmd64, cpuMips, cpuPowerpc64el, cpuSparc, cpuVm, cpuHppa, cpuIa64, cpuAmd64, cpuMips,
cpuMipsel, cpuArm, cpuArm64, cpuJS, cpuNimVM, cpuAVR, cpuMSP430, cpuMipsel, cpuArm, cpuArm64, cpuJS, cpuNimVM, cpuAVR, cpuMSP430,
cpuSparc64, cpuMips64, cpuMips64el, cpuRiscV32, cpuRiscV64, cpuEsp, cpuWasm32, cpuSparc64, cpuMips64, cpuMips64el, cpuRiscV32, cpuRiscV64, cpuEsp, cpuWasm32,
cpuE2k cpuE2k, cpuLoongArch64
type type
TInfoCPU* = tuple[name: string, intSize: int, endian: Endianness, TInfoCPU* = tuple[name: string, intSize: int, endian: Endianness,
@ -238,7 +238,8 @@ const
(name: "riscv64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64), (name: "riscv64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
(name: "esp", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32), (name: "esp", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32),
(name: "wasm32", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32), (name: "wasm32", intSize: 32, endian: littleEndian, floatSize: 64, bit: 32),
(name: "e2k", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64)] (name: "e2k", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
(name: "loongarch64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64)]
type type
Target* = object Target* = object

View file

@ -1126,7 +1126,7 @@ const
## Possible values: ## Possible values:
## `"i386"`, `"alpha"`, `"powerpc"`, `"powerpc64"`, `"powerpc64el"`, ## `"i386"`, `"alpha"`, `"powerpc"`, `"powerpc64"`, `"powerpc64el"`,
## `"sparc"`, `"amd64"`, `"mips"`, `"mipsel"`, `"arm"`, `"arm64"`, ## `"sparc"`, `"amd64"`, `"mips"`, `"mipsel"`, `"arm"`, `"arm64"`,
## `"mips64"`, `"mips64el"`, `"riscv32"`, `"riscv64"`. ## `"mips64"`, `"mips64el"`, `"riscv32"`, `"riscv64"`, '"loongarch64"'.
seqShallowFlag = low(int) seqShallowFlag = low(int)
strlitFlag = 1 shl (sizeof(int)*8 - 2) # later versions of the codegen \ strlitFlag = 1 shl (sizeof(int)*8 - 2) # later versions of the codegen \

View file

@ -36,7 +36,8 @@ type
riscv32, ## RISC-V 32-bit processor riscv32, ## RISC-V 32-bit processor
riscv64, ## RISC-V 64-bit processor riscv64, ## RISC-V 64-bit processor
wasm32, ## WASM, 32-bit wasm32, ## WASM, 32-bit
e2k ## MCST Elbrus 2000 e2k, ## MCST Elbrus 2000
loongarch64 ## LoongArch 64-bit processor
OsPlatform* {.pure.} = enum ## the OS this program will run on. OsPlatform* {.pure.} = enum ## the OS this program will run on.
none, dos, windows, os2, linux, morphos, skyos, solaris, none, dos, windows, os2, linux, morphos, skyos, solaris,
@ -95,5 +96,6 @@ const
elif defined(riscv64): CpuPlatform.riscv64 elif defined(riscv64): CpuPlatform.riscv64
elif defined(wasm32): CpuPlatform.wasm32 elif defined(wasm32): CpuPlatform.wasm32
elif defined(e2k): CpuPlatform.e2k elif defined(e2k): CpuPlatform.e2k
elif defined(loongarch64): CpuPlatform.loongarch64
else: CpuPlatform.none else: CpuPlatform.none
## the CPU this program will run on. ## the CPU this program will run on.

View file

@ -95,6 +95,7 @@ _nim() {
'*--cpu=sparc64[compile for SPARC64 architecture]' \ '*--cpu=sparc64[compile for SPARC64 architecture]' \
'*--cpu=vm[compile for Nim VM]' \ '*--cpu=vm[compile for Nim VM]' \
'*--cpu=wasm32[compile to WASM 32]' \ '*--cpu=wasm32[compile to WASM 32]' \
'*--cpu=loongarch64[compile for LoongArch64 architecture]' \
'*--gc=refc[use reference counting garbage collection]' \ '*--gc=refc[use reference counting garbage collection]' \
'*--gc=arc[use ARC garbage collection]' \ '*--gc=arc[use ARC garbage collection]' \
'*--gc=orc[use ORC garbage collection]' \ '*--gc=orc[use ORC garbage collection]' \

View file

@ -229,6 +229,8 @@ case $ucpu in
mycpu="riscv64" ;; mycpu="riscv64" ;;
*e2k* ) *e2k* )
mycpu="e2k" ;; mycpu="e2k" ;;
*loongarch64* )
mycpu="loongarch64" ;;
*) *)
echo 2>&1 "Error: unknown processor: $ucpu" echo 2>&1 "Error: unknown processor: $ucpu"
exit 1 exit 1

View file

@ -169,6 +169,9 @@ endif
ifeq ($(ucpu),e2k) ifeq ($(ucpu),e2k)
mycpu = e2k mycpu = e2k
endif endif
ifeq ($(ucpu),loongarch64)
mycpu = loongarch64
endif
ifndef mycpu ifndef mycpu
$(error unknown CPU architecture: $(ucpu) See makefile.nimf) $(error unknown CPU architecture: $(ucpu) See makefile.nimf)
endif endif