Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial LoongArch64 CPU support #15628

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/src/dmd/cond.d
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ extern (C++) final class VersionCondition : DVCondition
case "LDC":
case "linux":
case "LittleEndian":
case "LoongArch32":
case "LoongArch64":
liushuyu marked this conversation as resolved.
Show resolved Hide resolved
JohanEngelen marked this conversation as resolved.
Show resolved Hide resolved
case "LoongArch_HardFloat":
case "LoongArch_SoftFloat":
case "MinGW":
case "MIPS32":
case "MIPS64":
Expand Down
98 changes: 55 additions & 43 deletions compiler/test/fail_compilation/reserved_version.d
Original file line number Diff line number Diff line change
Expand Up @@ -76,49 +76,53 @@ fail_compilation/reserved_version.d(175): Error: version identifier `SH` is rese
fail_compilation/reserved_version.d(176): Error: version identifier `Alpha` is reserved and cannot be set
fail_compilation/reserved_version.d(177): Error: version identifier `Alpha_SoftFloat` is reserved and cannot be set
fail_compilation/reserved_version.d(178): Error: version identifier `Alpha_HardFloat` is reserved and cannot be set
fail_compilation/reserved_version.d(179): Error: version identifier `LittleEndian` is reserved and cannot be set
fail_compilation/reserved_version.d(180): Error: version identifier `BigEndian` is reserved and cannot be set
fail_compilation/reserved_version.d(181): Error: version identifier `ELFv1` is reserved and cannot be set
fail_compilation/reserved_version.d(182): Error: version identifier `ELFv2` is reserved and cannot be set
fail_compilation/reserved_version.d(183): Error: version identifier `CRuntime_Bionic` is reserved and cannot be set
fail_compilation/reserved_version.d(184): Error: version identifier `CRuntime_DigitalMars` is reserved and cannot be set
fail_compilation/reserved_version.d(185): Error: version identifier `CRuntime_Glibc` is reserved and cannot be set
fail_compilation/reserved_version.d(186): Error: version identifier `CRuntime_Microsoft` is reserved and cannot be set
fail_compilation/reserved_version.d(187): Error: version identifier `CRuntime_Musl` is reserved and cannot be set
fail_compilation/reserved_version.d(188): Error: version identifier `CRuntime_Newlib` is reserved and cannot be set
fail_compilation/reserved_version.d(189): Error: version identifier `CRuntime_UClibc` is reserved and cannot be set
fail_compilation/reserved_version.d(190): Error: version identifier `CRuntime_WASI` is reserved and cannot be set
fail_compilation/reserved_version.d(191): Error: version identifier `D_Coverage` is reserved and cannot be set
fail_compilation/reserved_version.d(192): Error: version identifier `D_Ddoc` is reserved and cannot be set
fail_compilation/reserved_version.d(193): Error: version identifier `D_InlineAsm_X86` is reserved and cannot be set
fail_compilation/reserved_version.d(194): Error: version identifier `D_InlineAsm_X86_64` is reserved and cannot be set
fail_compilation/reserved_version.d(195): Error: version identifier `D_LP64` is reserved and cannot be set
fail_compilation/reserved_version.d(196): Error: version identifier `D_X32` is reserved and cannot be set
fail_compilation/reserved_version.d(197): Error: version identifier `D_HardFloat` is reserved and cannot be set
fail_compilation/reserved_version.d(198): Error: version identifier `D_SoftFloat` is reserved and cannot be set
fail_compilation/reserved_version.d(199): Error: version identifier `D_PIC` is reserved and cannot be set
fail_compilation/reserved_version.d(200): Error: version identifier `D_SIMD` is reserved and cannot be set
fail_compilation/reserved_version.d(201): Error: version identifier `D_Version2` is reserved and cannot be set
fail_compilation/reserved_version.d(202): Error: version identifier `D_NoBoundsChecks` is reserved and cannot be set
fail_compilation/reserved_version.d(205): Error: version identifier `all` is reserved and cannot be set
fail_compilation/reserved_version.d(206): Error: version identifier `none` is reserved and cannot be set
fail_compilation/reserved_version.d(207): Error: version identifier `AsmJS` is reserved and cannot be set
fail_compilation/reserved_version.d(208): Error: version identifier `Emscripten` is reserved and cannot be set
fail_compilation/reserved_version.d(209): Error: version identifier `WebAssembly` is reserved and cannot be set
fail_compilation/reserved_version.d(210): Error: version identifier `WASI` is reserved and cannot be set
fail_compilation/reserved_version.d(211): Error: version identifier `CppRuntime_Clang` is reserved and cannot be set
fail_compilation/reserved_version.d(212): Error: version identifier `CppRuntime_DigitalMars` is reserved and cannot be set
fail_compilation/reserved_version.d(213): Error: version identifier `CppRuntime_Gcc` is reserved and cannot be set
fail_compilation/reserved_version.d(214): Error: version identifier `CppRuntime_Microsoft` is reserved and cannot be set
fail_compilation/reserved_version.d(215): Error: version identifier `CppRuntime_Sun` is reserved and cannot be set
fail_compilation/reserved_version.d(216): Error: version identifier `D_PIE` is reserved and cannot be set
fail_compilation/reserved_version.d(217): Error: version identifier `AVR` is reserved and cannot be set
fail_compilation/reserved_version.d(218): Error: version identifier `D_PreConditions` is reserved and cannot be set
fail_compilation/reserved_version.d(219): Error: version identifier `D_PostConditions` is reserved and cannot be set
fail_compilation/reserved_version.d(220): Error: version identifier `D_ProfileGC` is reserved and cannot be set
fail_compilation/reserved_version.d(221): Error: version identifier `D_Invariants` is reserved and cannot be set
fail_compilation/reserved_version.d(222): Error: version identifier `D_Optimized` is reserved and cannot be set
fail_compilation/reserved_version.d(223): Error: version identifier `VisionOS` is reserved and cannot be set
fail_compilation/reserved_version.d(179): Error: version identifier `LoongArch32` is reserved and cannot be set
fail_compilation/reserved_version.d(180): Error: version identifier `LoongArch64` is reserved and cannot be set
fail_compilation/reserved_version.d(181): Error: version identifier `LoongArch_HardFloat` is reserved and cannot be set
fail_compilation/reserved_version.d(182): Error: version identifier `LoongArch_SoftFloat` is reserved and cannot be set
fail_compilation/reserved_version.d(183): Error: version identifier `LittleEndian` is reserved and cannot be set
fail_compilation/reserved_version.d(184): Error: version identifier `BigEndian` is reserved and cannot be set
fail_compilation/reserved_version.d(185): Error: version identifier `ELFv1` is reserved and cannot be set
fail_compilation/reserved_version.d(186): Error: version identifier `ELFv2` is reserved and cannot be set
fail_compilation/reserved_version.d(187): Error: version identifier `CRuntime_Bionic` is reserved and cannot be set
fail_compilation/reserved_version.d(188): Error: version identifier `CRuntime_DigitalMars` is reserved and cannot be set
fail_compilation/reserved_version.d(189): Error: version identifier `CRuntime_Glibc` is reserved and cannot be set
fail_compilation/reserved_version.d(190): Error: version identifier `CRuntime_Microsoft` is reserved and cannot be set
fail_compilation/reserved_version.d(191): Error: version identifier `CRuntime_Musl` is reserved and cannot be set
fail_compilation/reserved_version.d(192): Error: version identifier `CRuntime_Newlib` is reserved and cannot be set
fail_compilation/reserved_version.d(193): Error: version identifier `CRuntime_UClibc` is reserved and cannot be set
fail_compilation/reserved_version.d(194): Error: version identifier `CRuntime_WASI` is reserved and cannot be set
fail_compilation/reserved_version.d(195): Error: version identifier `D_Coverage` is reserved and cannot be set
fail_compilation/reserved_version.d(196): Error: version identifier `D_Ddoc` is reserved and cannot be set
fail_compilation/reserved_version.d(197): Error: version identifier `D_InlineAsm_X86` is reserved and cannot be set
fail_compilation/reserved_version.d(198): Error: version identifier `D_InlineAsm_X86_64` is reserved and cannot be set
fail_compilation/reserved_version.d(199): Error: version identifier `D_LP64` is reserved and cannot be set
fail_compilation/reserved_version.d(200): Error: version identifier `D_X32` is reserved and cannot be set
fail_compilation/reserved_version.d(201): Error: version identifier `D_HardFloat` is reserved and cannot be set
fail_compilation/reserved_version.d(202): Error: version identifier `D_SoftFloat` is reserved and cannot be set
fail_compilation/reserved_version.d(203): Error: version identifier `D_PIC` is reserved and cannot be set
fail_compilation/reserved_version.d(204): Error: version identifier `D_SIMD` is reserved and cannot be set
fail_compilation/reserved_version.d(205): Error: version identifier `D_Version2` is reserved and cannot be set
fail_compilation/reserved_version.d(206): Error: version identifier `D_NoBoundsChecks` is reserved and cannot be set
fail_compilation/reserved_version.d(209): Error: version identifier `all` is reserved and cannot be set
fail_compilation/reserved_version.d(210): Error: version identifier `none` is reserved and cannot be set
fail_compilation/reserved_version.d(211): Error: version identifier `AsmJS` is reserved and cannot be set
fail_compilation/reserved_version.d(212): Error: version identifier `Emscripten` is reserved and cannot be set
fail_compilation/reserved_version.d(213): Error: version identifier `WebAssembly` is reserved and cannot be set
fail_compilation/reserved_version.d(214): Error: version identifier `WASI` is reserved and cannot be set
fail_compilation/reserved_version.d(215): Error: version identifier `CppRuntime_Clang` is reserved and cannot be set
fail_compilation/reserved_version.d(216): Error: version identifier `CppRuntime_DigitalMars` is reserved and cannot be set
fail_compilation/reserved_version.d(217): Error: version identifier `CppRuntime_Gcc` is reserved and cannot be set
fail_compilation/reserved_version.d(218): Error: version identifier `CppRuntime_Microsoft` is reserved and cannot be set
fail_compilation/reserved_version.d(219): Error: version identifier `CppRuntime_Sun` is reserved and cannot be set
fail_compilation/reserved_version.d(220): Error: version identifier `D_PIE` is reserved and cannot be set
fail_compilation/reserved_version.d(221): Error: version identifier `AVR` is reserved and cannot be set
fail_compilation/reserved_version.d(222): Error: version identifier `D_PreConditions` is reserved and cannot be set
fail_compilation/reserved_version.d(223): Error: version identifier `D_PostConditions` is reserved and cannot be set
fail_compilation/reserved_version.d(224): Error: version identifier `D_ProfileGC` is reserved and cannot be set
fail_compilation/reserved_version.d(225): Error: version identifier `D_Invariants` is reserved and cannot be set
fail_compilation/reserved_version.d(226): Error: version identifier `D_Optimized` is reserved and cannot be set
fail_compilation/reserved_version.d(227): Error: version identifier `VisionOS` is reserved and cannot be set
---
*/

Expand Down Expand Up @@ -199,6 +203,10 @@ version = SH;
version = Alpha;
version = Alpha_SoftFloat;
version = Alpha_HardFloat;
version = LoongArch32;
version = LoongArch64;
version = LoongArch_HardFloat;
version = LoongArch_SoftFloat;
version = LittleEndian;
version = BigEndian;
version = ELFv1;
Expand Down Expand Up @@ -315,6 +323,10 @@ debug = WASI;
debug = Alpha;
debug = Alpha_SoftFloat;
debug = Alpha_HardFloat;
debug = LoongArch32;
debug = LoongArch64;
debug = LoongArch_HardFloat;
debug = LoongArch_SoftFloat;
debug = LittleEndian;
debug = BigEndian;
debug = ELFv1;
Expand Down
12 changes: 12 additions & 0 deletions compiler/test/fail_compilation/reserved_version_switch.d
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
// REQUIRED_ARGS: -version=Alpha
// REQUIRED_ARGS: -version=Alpha_SoftFloat
// REQUIRED_ARGS: -version=Alpha_HardFloat
// REQUIRED_ARGS: -version=LoongArch32
// REQUIRED_ARGS: -version=LoongArch64
// REQUIRED_ARGS: -version=LoongArch_HardFloat
// REQUIRED_ARGS: -version=LoongArch_SoftFloat
// REQUIRED_ARGS: -version=LittleEndian
// REQUIRED_ARGS: -version=BigEndian
// REQUIRED_ARGS: -version=ELFv1
Expand Down Expand Up @@ -175,6 +179,10 @@
// REQUIRED_ARGS: -debug=Alpha
// REQUIRED_ARGS: -debug=Alpha_SoftFloat
// REQUIRED_ARGS: -debug=Alpha_HardFloat
// REQUIRED_ARGS: -debug=LoongArch32
// REQUIRED_ARGS: -debug=LoongArch64
// REQUIRED_ARGS: -debug=LoongArch_HardFloat
// REQUIRED_ARGS: -debug=LoongArch_SoftFloat
// REQUIRED_ARGS: -debug=LittleEndian
// REQUIRED_ARGS: -debug=BigEndian
// REQUIRED_ARGS: -debug=ELFv1
Expand Down Expand Up @@ -286,6 +294,10 @@ Error: version identifier `WASI` is reserved and cannot be set
Error: version identifier `Alpha` is reserved and cannot be set
Error: version identifier `Alpha_SoftFloat` is reserved and cannot be set
Error: version identifier `Alpha_HardFloat` is reserved and cannot be set
Error: version identifier `LoongArch32` is reserved and cannot be set
Error: version identifier `LoongArch64` is reserved and cannot be set
Error: version identifier `LoongArch_HardFloat` is reserved and cannot be set
Error: version identifier `LoongArch_SoftFloat` is reserved and cannot be set
Error: version identifier `LittleEndian` is reserved and cannot be set
Error: version identifier `BigEndian` is reserved and cannot be set
Error: version identifier `ELFv1` is reserved and cannot be set
Expand Down
3 changes: 3 additions & 0 deletions druntime/benchmark/gcbench/vdparser.extra/vdc/versions.d
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ static @property int[string] sPredefinedVersions()
"Alpha" : -1,
"Alpha_SoftFloat" : -1,
"Alpha_HardFloat" : -1,
"LoongArch64": -1,
"LoongArch_HardFloat": -1,
"LoongArch_SoftFloat": -1,

"LittleEndian" : 1,
"BigEndian" : -1,
Expand Down
103 changes: 103 additions & 0 deletions druntime/src/core/stdc/errno.d
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,109 @@ else version (linux)
enum ERFKILL = 132; ///
enum EHWPOISON = 133; ///
}
else version (LoongArch64)
{
enum EDEADLK = 35; ///
enum ENAMETOOLONG = 36; ///
enum ENOLCK = 37; ///
enum ENOSYS = 38; ///
enum ENOTEMPTY = 39; ///
enum ELOOP = 40; ///
enum EWOULDBLOCK = EAGAIN; ///
enum ENOMSG = 42; ///
enum EIDRM = 43; ///
enum ECHRNG = 44; ///
enum EL2NSYNC = 45; ///
enum EL3HLT = 46; ///
enum EL3RST = 47; ///
enum ELNRNG = 48; ///
enum EUNATCH = 49; ///
enum ENOCSI = 50; ///
enum EL2HLT = 51; ///
enum EBADE = 52; ///
enum EBADR = 53; ///
enum EXFULL = 54; ///
enum ENOANO = 55; ///
enum EBADRQC = 56; ///
enum EBADSLT = 57; ///
enum EDEADLOCK = EDEADLK; ///
enum EBFONT = 59; ///
enum ENOSTR = 60; ///
enum ENODATA = 61; ///
enum ETIME = 62; ///
enum ENOSR = 63; ///
enum ENONET = 64; ///
enum ENOPKG = 65; ///
enum EREMOTE = 66; ///
enum ENOLINK = 67; ///
enum EADV = 68; ///
enum ESRMNT = 69; ///
enum ECOMM = 70; ///
enum EPROTO = 71; ///
enum EMULTIHOP = 72; ///
enum EDOTDOT = 73; ///
enum EBADMSG = 74; ///
enum EOVERFLOW = 75; ///
enum ENOTUNIQ = 76; ///
enum EBADFD = 77; ///
enum EREMCHG = 78; ///
enum ELIBACC = 79; ///
enum ELIBBAD = 80; ///
enum ELIBSCN = 81; ///
enum ELIBMAX = 82; ///
enum ELIBEXEC = 83; ///
enum EILSEQ = 84; ///
enum ERESTART = 85; ///
enum ESTRPIPE = 86; ///
enum EUSERS = 87; ///
enum ENOTSOCK = 88; ///
enum EDESTADDRREQ = 89; ///
enum EMSGSIZE = 90; ///
enum EPROTOTYPE = 91; ///
enum ENOPROTOOPT = 92; ///
enum EPROTONOSUPPORT = 93; ///
enum ESOCKTNOSUPPORT = 94; ///
enum EOPNOTSUPP = 95; ///
enum ENOTSUP = EOPNOTSUPP; ///
enum EPFNOSUPPORT = 96; ///
enum EAFNOSUPPORT = 97; ///
enum EADDRINUSE = 98; ///
enum EADDRNOTAVAIL = 99; ///
enum ENETDOWN = 100; ///
enum ENETUNREACH = 101; ///
enum ENETRESET = 102; ///
enum ECONNABORTED = 103; ///
enum ECONNRESET = 104; ///
enum ENOBUFS = 105; ///
enum EISCONN = 106; ///
enum ENOTCONN = 107; ///
enum ESHUTDOWN = 108; ///
enum ETOOMANYREFS = 109; ///
enum ETIMEDOUT = 110; ///
enum ECONNREFUSED = 111; ///
enum EHOSTDOWN = 112; ///
enum EHOSTUNREACH = 113; ///
enum EALREADY = 114; ///
enum EINPROGRESS = 115; ///
enum ESTALE = 116; ///
enum EUCLEAN = 117; ///
enum ENOTNAM = 118; ///
enum ENAVAIL = 119; ///
enum EISNAM = 120; ///
enum EREMOTEIO = 121; ///
enum EDQUOT = 122; ///
enum ENOMEDIUM = 123; ///
enum EMEDIUMTYPE = 124; ///
enum ECANCELED = 125; ///
enum ENOKEY = 126; ///
enum EKEYEXPIRED = 127; ///
enum EKEYREVOKED = 128; ///
enum EKEYREJECTED = 129; ///
enum EOWNERDEAD = 130; ///
enum ENOTRECOVERABLE = 131; ///
enum ERFKILL = 132; ///
enum EHWPOISON = 133; ///
}
else
{
static assert(false, "Architecture not supported.");
Expand Down
31 changes: 31 additions & 0 deletions druntime/src/core/stdc/fenv.d
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ version (GNUFP)

alias fexcept_t = uint;
}
else version (LoongArch64)
{
struct fenv_t
{
uint __fp_control_register;
}

alias fexcept_t = uint;
}
else
{
static assert(0, "Unimplemented architecture");
Expand Down Expand Up @@ -786,6 +795,28 @@ else
FE_TOWARDZERO = 0x1, ///
}
}
else version (LoongArch64)
{
// Define bits representing exceptions in the FPSR status word.
enum
{
FE_INEXACT = 0x010000, ///
FE_UNDERFLOW = 0x020000, ///
FE_OVERFLOW = 0x040000, ///
FE_DIVBYZERO = 0x080000, ///
FE_INVALID = 0x100000, ///
FE_ALL_EXCEPT = 0x1f0000, ///
}

// Define bits representing rounding modes in the FPCR Rmode field.
enum
{
FE_TONEAREST = 0x000, ///
FE_TOWARDZERO = 0x100, ///
FE_DOWNWARD = 0x200, ///
FE_UPWARD = 0x300, ///
}
}
else
{
static assert(0, "Unimplemented architecture");
Expand Down
Loading