File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
compiler-rt/lib/scudo/standalone Expand file tree Collapse file tree 3 files changed +22
-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,15 @@ bool hasHardwareCRC32() {
75
77
return !!(getauxval (AT_HWCAP) & HWCAP_CRC32);
76
78
#endif // SCUDO_FUCHSIA
77
79
}
80
+ #elif defined(__loongarch__)
81
+ // Query HWCAP for platform capability, according to *Software Development and
82
+ // Build Convention for LoongArch Architectures* v0.1, Section 9.1.
83
+ //
84
+ // Link:
85
+ // https://github.com/loongson/la-softdev-convention/blob/v0.1/la-softdev-convention.adoc#kernel-development
86
+ bool hasHardwareCRC32 () {
87
+ return !!(getauxval (AT_HWCAP) & HWCAP_LOONGARCH_CRC32);
88
+ }
78
89
#else
79
90
// No hardware CRC32 implemented in Scudo for other architectures.
80
91
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,11 @@ 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.
23
+ return static_cast <u32 >(CRC32_INTRINSIC (Data, Crc));
24
+ }
25
+ #endif // defined(__loongarch__)
26
+
20
27
} // namespace scudo
You can’t perform that action at this time.
0 commit comments