1+ #pragma once
2+
3+ #if __SIZEOF_POINTER__ == 8
4+ # define SNMALLOC_VA_BITS_64
5+ #else
6+ # define SNMALLOC_VA_BITS_32
7+ #endif
8+
9+ #include < cstddef>
10+ namespace snmalloc
11+ {
12+ /* *
13+ * Loongarch-specific architecture abstraction layer.
14+ */
15+ class AAL_LoongArch
16+ {
17+ public:
18+ /* *
19+ * Bitmap of AalFeature flags
20+ */
21+ static constexpr uint64_t aal_features =
22+ IntegerPointers | NoCpuCycleCounters;
23+
24+ static constexpr enum AalName aal_name = LoongArch;
25+
26+ static constexpr size_t smallest_page_size = 0x1000 ;
27+
28+ /* *
29+ * On pipelined processors, notify the core that we are in a spin loop and
30+ * that speculative execution past this point may not be a performance gain.
31+ */
32+ static inline void pause ()
33+ {
34+ __asm__ __volatile__ (" dbar 0" : : : " memory" );
35+ }
36+
37+ /* *
38+ * PRELD reads a cache-line of data from memory in advance into the Cache.
39+ * The access address is the 12bit immediate number of the value in the
40+ * general register rj plus the symbol extension.
41+ *
42+ * The processor learns from the hint in the PRELD instruction what type
43+ * will be acquired and which level of Cache the data to be taken back fill
44+ * in, hint has 32 optional values (0 to 31), 0 represents load to level 1
45+ * Cache If the Cache attribute of the access address of the PRELD
46+ * instruction is not cached, then the instruction cannot generate a memory
47+ * access action and is treated as a NOP instruction. The PRELD instruction
48+ * will not trigger any exceptions related to MMU or address.
49+ */
50+ static inline void prefetch (void * ptr)
51+ {
52+ __asm__ volatile (" preld 0, %0, 0" : " =r" (ptr));
53+ }
54+ };
55+
56+ using AAL_Arch = AAL_LoongArch;
57+ } // namespace snmalloc
0 commit comments