Skip to content

Commit

Permalink
Add support for LoongArch (nim-lang#19223)
Browse files Browse the repository at this point in the history
* Add support for LoongArch

* Update compiler/installer.ini

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
  • Loading branch information
2 people authored and PMunch committed Mar 28, 2022
1 parent 124ca73 commit 20893a2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions compiler/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ type
cpuPowerpc64el, cpuSparc, cpuVm, cpuHppa, cpuIa64, cpuAmd64, cpuMips,
cpuMipsel, cpuArm, cpuArm64, cpuJS, cpuNimVM, cpuAVR, cpuMSP430,
cpuSparc64, cpuMips64, cpuMips64el, cpuRiscV32, cpuRiscV64, cpuEsp, cpuWasm32,
cpuE2k
cpuE2k, cpuLoongArch64

type
TInfoCPU* = tuple[name: string, intSize: int, endian: Endianness,
Expand Down Expand Up @@ -238,7 +238,8 @@ const
(name: "riscv64", intSize: 64, endian: littleEndian, floatSize: 64, bit: 64),
(name: "esp", 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
Target* = object
Expand Down
2 changes: 1 addition & 1 deletion lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ const
## Possible values:
## `"i386"`, `"alpha"`, `"powerpc"`, `"powerpc64"`, `"powerpc64el"`,
## `"sparc"`, `"amd64"`, `"mips"`, `"mipsel"`, `"arm"`, `"arm64"`,
## `"mips64"`, `"mips64el"`, `"riscv32"`, `"riscv64"`.
## `"mips64"`, `"mips64el"`, `"riscv32"`, `"riscv64"`, '"loongarch64"'.

seqShallowFlag = low(int)
strlitFlag = 1 shl (sizeof(int)*8 - 2) # later versions of the codegen \
Expand Down
4 changes: 3 additions & 1 deletion lib/system/platforms.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ type
riscv32, ## RISC-V 32-bit processor
riscv64, ## RISC-V 64-bit processor
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.
none, dos, windows, os2, linux, morphos, skyos, solaris,
Expand Down Expand Up @@ -95,5 +96,6 @@ const
elif defined(riscv64): CpuPlatform.riscv64
elif defined(wasm32): CpuPlatform.wasm32
elif defined(e2k): CpuPlatform.e2k
elif defined(loongarch64): CpuPlatform.loongarch64
else: CpuPlatform.none
## the CPU this program will run on.
1 change: 1 addition & 0 deletions tools/nim.zsh-completion
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ _nim() {
'*--cpu=sparc64[compile for SPARC64 architecture]' \
'*--cpu=vm[compile for Nim VM]' \
'*--cpu=wasm32[compile to WASM 32]' \
'*--cpu=loongarch64[compile for LoongArch64 architecture]' \
'*--gc=refc[use reference counting garbage collection]' \
'*--gc=arc[use ARC garbage collection]' \
'*--gc=orc[use ORC garbage collection]' \
Expand Down
2 changes: 2 additions & 0 deletions tools/niminst/buildsh.nimf
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ case $ucpu in
mycpu="riscv64" ;;
*e2k* )
mycpu="e2k" ;;
*loongarch64* )
mycpu="loongarch64" ;;
*)
echo 2>&1 "Error: unknown processor: $ucpu"
exit 1
Expand Down
3 changes: 3 additions & 0 deletions tools/niminst/makefile.nimf
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ endif
ifeq ($(ucpu),e2k)
mycpu = e2k
endif
ifeq ($(ucpu),loongarch64)
mycpu = loongarch64
endif
ifndef mycpu
$(error unknown CPU architecture: $(ucpu) See makefile.nimf)
endif
Expand Down

0 comments on commit 20893a2

Please sign in to comment.