File tree 3 files changed +29
-0
lines changed
compiler-rt/lib/scudo/standalone 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 19
19
#else
20
20
#include < sys/auxv.h>
21
21
#endif
22
+ #elif defined(__loongarch__)
23
+ #include < sys/auxv.h>
22
24
#endif
23
25
24
26
namespace scudo {
@@ -75,6 +77,20 @@ bool hasHardwareCRC32() {
75
77
return !!(getauxval (AT_HWCAP) & HWCAP_CRC32);
76
78
#endif // SCUDO_FUCHSIA
77
79
}
80
+ #elif defined(__loongarch__)
81
+ // The definition is only pulled in by <sys/auxv.h> since glibc 2.38, so
82
+ // supply it if missing.
83
+ #ifndef HWCAP_LOONGARCH_CRC32
84
+ #define HWCAP_LOONGARCH_CRC32 (1 << 6 )
85
+ #endif
86
+ // Query HWCAP for platform capability, according to *Software Development and
87
+ // Build Convention for LoongArch Architectures* v0.1, Section 9.1.
88
+ //
89
+ // Link:
90
+ // https://github.com/loongson/la-softdev-convention/blob/v0.1/la-softdev-convention.adoc#kernel-development
91
+ bool hasHardwareCRC32 () {
92
+ return !!(getauxval (AT_HWCAP) & HWCAP_LOONGARCH_CRC32);
93
+ }
78
94
#else
79
95
// No hardware CRC32 implemented in Scudo for other architectures.
80
96
bool hasHardwareCRC32 () { return false ; }
Original file line number Diff line number Diff line change 30
30
#include < arm_acle.h>
31
31
#define CRC32_INTRINSIC FIRST_32_SECOND_64 (__crc32cw, __crc32cd)
32
32
#endif
33
+ #ifdef __loongarch__
34
+ #include < larchintrin.h>
35
+ #define CRC32_INTRINSIC FIRST_32_SECOND_64 (__crcc_w_w_w, __crcc_w_d_w)
36
+ #endif
33
37
34
38
namespace scudo {
35
39
Original file line number Diff line number Diff line change @@ -17,4 +17,13 @@ u32 computeHardwareCRC32(u32 Crc, uptr Data) {
17
17
#endif // defined(__CRC32__) || defined(__SSE4_2__) ||
18
18
// defined(__ARM_FEATURE_CRC32)
19
19
20
+ #if defined(__loongarch__)
21
+ u32 computeHardwareCRC32 (u32 Crc, uptr Data) {
22
+ // The LoongArch CRC intrinsics have the two input arguments swapped, and
23
+ // expect them to be signed.
24
+ return static_cast <u32>(
25
+ CRC32_INTRINSIC (static_cast <long >(Data), static_cast <int >(Crc)));
26
+ }
27
+ #endif // defined(__loongarch__)
28
+
20
29
} // namespace scudo
You can’t perform that action at this time.
0 commit comments