1- //! `LoongArch ` intrinsics
1+ //! `LoongArch64 ` intrinsics
22
33mod lasx;
44mod lsx;
@@ -20,82 +20,24 @@ pub unsafe fn rdtime_d() -> (i64, isize) {
2020 ( val, tid)
2121}
2222
23- /// Reads the lower 32-bit stable counter value and the counter ID
24- #[ inline]
25- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
26- pub unsafe fn rdtimel_w ( ) -> ( i32 , isize ) {
27- let val: i32 ;
28- let tid: isize ;
29- asm ! ( "rdtimel.w {}, {}" , out( reg) val, out( reg) tid, options( readonly, nostack) ) ;
30- ( val, tid)
31- }
32-
33- /// Reads the upper 32-bit stable counter value and the counter ID
34- #[ inline]
35- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
36- pub unsafe fn rdtimeh_w ( ) -> ( i32 , isize ) {
37- let val: i32 ;
38- let tid: isize ;
39- asm ! ( "rdtimeh.w {}, {}" , out( reg) val, out( reg) tid, options( readonly, nostack) ) ;
40- ( val, tid)
41- }
42-
4323#[ allow( improper_ctypes) ]
4424unsafe extern "unadjusted" {
45- #[ link_name = "llvm.loongarch.crc.w.b.w" ]
46- fn __crc_w_b_w ( a : i32 , b : i32 ) -> i32 ;
47- #[ link_name = "llvm.loongarch.crc.w.h.w" ]
48- fn __crc_w_h_w ( a : i32 , b : i32 ) -> i32 ;
49- #[ link_name = "llvm.loongarch.crc.w.w.w" ]
50- fn __crc_w_w_w ( a : i32 , b : i32 ) -> i32 ;
5125 #[ link_name = "llvm.loongarch.crc.w.d.w" ]
5226 fn __crc_w_d_w ( a : i64 , b : i32 ) -> i32 ;
53- #[ link_name = "llvm.loongarch.crcc.w.b.w" ]
54- fn __crcc_w_b_w ( a : i32 , b : i32 ) -> i32 ;
55- #[ link_name = "llvm.loongarch.crcc.w.h.w" ]
56- fn __crcc_w_h_w ( a : i32 , b : i32 ) -> i32 ;
57- #[ link_name = "llvm.loongarch.crcc.w.w.w" ]
58- fn __crcc_w_w_w ( a : i32 , b : i32 ) -> i32 ;
5927 #[ link_name = "llvm.loongarch.crcc.w.d.w" ]
6028 fn __crcc_w_d_w ( a : i64 , b : i32 ) -> i32 ;
6129 #[ link_name = "llvm.loongarch.cacop.d" ]
6230 fn __cacop ( a : i64 , b : i64 , c : i64 ) ;
63- #[ link_name = "llvm.loongarch.dbar" ]
64- fn __dbar ( a : i32 ) ;
65- #[ link_name = "llvm.loongarch.ibar" ]
66- fn __ibar ( a : i32 ) ;
67- #[ link_name = "llvm.loongarch.movgr2fcsr" ]
68- fn __movgr2fcsr ( a : i32 , b : i32 ) ;
69- #[ link_name = "llvm.loongarch.movfcsr2gr" ]
70- fn __movfcsr2gr ( a : i32 ) -> i32 ;
7131 #[ link_name = "llvm.loongarch.csrrd.d" ]
7232 fn __csrrd ( a : i32 ) -> i64 ;
7333 #[ link_name = "llvm.loongarch.csrwr.d" ]
7434 fn __csrwr ( a : i64 , b : i32 ) -> i64 ;
7535 #[ link_name = "llvm.loongarch.csrxchg.d" ]
7636 fn __csrxchg ( a : i64 , b : i64 , c : i32 ) -> i64 ;
77- #[ link_name = "llvm.loongarch.iocsrrd.b" ]
78- fn __iocsrrd_b ( a : i32 ) -> i32 ;
79- #[ link_name = "llvm.loongarch.iocsrrd.h" ]
80- fn __iocsrrd_h ( a : i32 ) -> i32 ;
81- #[ link_name = "llvm.loongarch.iocsrrd.w" ]
82- fn __iocsrrd_w ( a : i32 ) -> i32 ;
8337 #[ link_name = "llvm.loongarch.iocsrrd.d" ]
8438 fn __iocsrrd_d ( a : i32 ) -> i64 ;
85- #[ link_name = "llvm.loongarch.iocsrwr.b" ]
86- fn __iocsrwr_b ( a : i32 , b : i32 ) ;
87- #[ link_name = "llvm.loongarch.iocsrwr.h" ]
88- fn __iocsrwr_h ( a : i32 , b : i32 ) ;
89- #[ link_name = "llvm.loongarch.iocsrwr.w" ]
90- fn __iocsrwr_w ( a : i32 , b : i32 ) ;
9139 #[ link_name = "llvm.loongarch.iocsrwr.d" ]
9240 fn __iocsrwr_d ( a : i64 , b : i32 ) ;
93- #[ link_name = "llvm.loongarch.break" ]
94- fn __break ( a : i32 ) ;
95- #[ link_name = "llvm.loongarch.cpucfg" ]
96- fn __cpucfg ( a : i32 ) -> i32 ;
97- #[ link_name = "llvm.loongarch.syscall" ]
98- fn __syscall ( a : i32 ) ;
9941 #[ link_name = "llvm.loongarch.asrtle.d" ]
10042 fn __asrtle ( a : i64 , b : i64 ) ;
10143 #[ link_name = "llvm.loongarch.asrtgt.d" ]
@@ -104,35 +46,6 @@ unsafe extern "unadjusted" {
10446 fn __lddir ( a : i64 , b : i64 ) -> i64 ;
10547 #[ link_name = "llvm.loongarch.ldpte.d" ]
10648 fn __ldpte ( a : i64 , b : i64 ) ;
107- #[ link_name = "llvm.loongarch.frecipe.s" ]
108- fn __frecipe_s ( a : f32 ) -> f32 ;
109- #[ link_name = "llvm.loongarch.frecipe.d" ]
110- fn __frecipe_d ( a : f64 ) -> f64 ;
111- #[ link_name = "llvm.loongarch.frsqrte.s" ]
112- fn __frsqrte_s ( a : f32 ) -> f32 ;
113- #[ link_name = "llvm.loongarch.frsqrte.d" ]
114- fn __frsqrte_d ( a : f64 ) -> f64 ;
115- }
116-
117- /// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
118- #[ inline]
119- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
120- pub unsafe fn crc_w_b_w ( a : i32 , b : i32 ) -> i32 {
121- __crc_w_b_w ( a, b)
122- }
123-
124- /// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
125- #[ inline]
126- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
127- pub unsafe fn crc_w_h_w ( a : i32 , b : i32 ) -> i32 {
128- __crc_w_h_w ( a, b)
129- }
130-
131- /// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
132- #[ inline]
133- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
134- pub unsafe fn crc_w_w_w ( a : i32 , b : i32 ) -> i32 {
135- __crc_w_w_w ( a, b)
13649}
13750
13851/// Calculate the CRC value using the IEEE 802.3 polynomial (0xEDB88320)
@@ -142,27 +55,6 @@ pub unsafe fn crc_w_d_w(a: i64, b: i32) -> i32 {
14255 __crc_w_d_w ( a, b)
14356}
14457
145- /// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
146- #[ inline]
147- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
148- pub unsafe fn crcc_w_b_w ( a : i32 , b : i32 ) -> i32 {
149- __crcc_w_b_w ( a, b)
150- }
151-
152- /// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
153- #[ inline]
154- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
155- pub unsafe fn crcc_w_h_w ( a : i32 , b : i32 ) -> i32 {
156- __crcc_w_h_w ( a, b)
157- }
158-
159- /// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
160- #[ inline]
161- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
162- pub unsafe fn crcc_w_w_w ( a : i32 , b : i32 ) -> i32 {
163- __crcc_w_w_w ( a, b)
164- }
165-
16658/// Calculate the CRC value using the Castagnoli polynomial (0x82F63B78)
16759#[ inline]
16860#[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
@@ -178,38 +70,6 @@ pub unsafe fn cacop<const IMM12: i64>(a: i64, b: i64) {
17870 __cacop ( a, b, IMM12 ) ;
17971}
18072
181- /// Generates the memory barrier instruction
182- #[ inline]
183- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
184- pub unsafe fn dbar < const IMM15 : i32 > ( ) {
185- static_assert_uimm_bits ! ( IMM15 , 15 ) ;
186- __dbar ( IMM15 ) ;
187- }
188-
189- /// Generates the instruction-fetch barrier instruction
190- #[ inline]
191- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
192- pub unsafe fn ibar < const IMM15 : i32 > ( ) {
193- static_assert_uimm_bits ! ( IMM15 , 15 ) ;
194- __ibar ( IMM15 ) ;
195- }
196-
197- /// Moves data from a GPR to the FCSR
198- #[ inline]
199- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
200- pub unsafe fn movgr2fcsr < const IMM5 : i32 > ( a : i32 ) {
201- static_assert_uimm_bits ! ( IMM5 , 5 ) ;
202- __movgr2fcsr ( IMM5 , a) ;
203- }
204-
205- /// Moves data from a FCSR to the GPR
206- #[ inline]
207- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
208- pub unsafe fn movfcsr2gr < const IMM5 : i32 > ( ) -> i32 {
209- static_assert_uimm_bits ! ( IMM5 , 5 ) ;
210- __movfcsr2gr ( IMM5 )
211- }
212-
21373/// Reads the CSR
21474#[ inline]
21575#[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
@@ -234,85 +94,20 @@ pub unsafe fn csrxchg<const IMM14: i32>(a: i64, b: i64) -> i64 {
23494 __csrxchg ( a, b, IMM14 )
23595}
23696
237- /// Reads the 8-bit IO-CSR
238- #[ inline]
239- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
240- pub unsafe fn iocsrrd_b ( a : i32 ) -> i32 {
241- __iocsrrd_b ( a)
242- }
243-
244- /// Reads the 16-bit IO-CSR
245- #[ inline]
246- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
247- pub unsafe fn iocsrrd_h ( a : i32 ) -> i32 {
248- __iocsrrd_h ( a)
249- }
250-
251- /// Reads the 32-bit IO-CSR
252- #[ inline]
253- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
254- pub unsafe fn iocsrrd_w ( a : i32 ) -> i32 {
255- __iocsrrd_w ( a)
256- }
257-
25897/// Reads the 64-bit IO-CSR
25998#[ inline]
26099#[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
261100pub unsafe fn iocsrrd_d ( a : i32 ) -> i64 {
262101 __iocsrrd_d ( a)
263102}
264103
265- /// Writes the 8-bit IO-CSR
266- #[ inline]
267- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
268- pub unsafe fn iocsrwr_b ( a : i32 , b : i32 ) {
269- __iocsrwr_b ( a, b)
270- }
271-
272- /// Writes the 16-bit IO-CSR
273- #[ inline]
274- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
275- pub unsafe fn iocsrwr_h ( a : i32 , b : i32 ) {
276- __iocsrwr_h ( a, b)
277- }
278-
279- /// Writes the 32-bit IO-CSR
280- #[ inline]
281- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
282- pub unsafe fn iocsrwr_w ( a : i32 , b : i32 ) {
283- __iocsrwr_w ( a, b)
284- }
285-
286104/// Writes the 64-bit IO-CSR
287105#[ inline]
288106#[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
289107pub unsafe fn iocsrwr_d ( a : i64 , b : i32 ) {
290108 __iocsrwr_d ( a, b)
291109}
292110
293- /// Generates the breakpoint instruction
294- #[ inline]
295- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
296- pub unsafe fn brk < const IMM15 : i32 > ( ) {
297- static_assert_uimm_bits ! ( IMM15 , 15 ) ;
298- __break ( IMM15 ) ;
299- }
300-
301- /// Reads the CPU configuration register
302- #[ inline]
303- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
304- pub unsafe fn cpucfg ( a : i32 ) -> i32 {
305- __cpucfg ( a)
306- }
307-
308- /// Generates the syscall instruction
309- #[ inline]
310- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
311- pub unsafe fn syscall < const IMM15 : i32 > ( ) {
312- static_assert_uimm_bits ! ( IMM15 , 15 ) ;
313- __syscall ( IMM15 ) ;
314- }
315-
316111/// Generates the less-than-or-equal asseration instruction
317112#[ inline]
318113#[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
@@ -342,35 +137,3 @@ pub unsafe fn lddir<const B: i64>(a: i64) -> i64 {
342137pub unsafe fn ldpte < const B : i64 > ( a : i64 ) {
343138 __ldpte ( a, B )
344139}
345-
346- /// Calculate the approximate single-precision result of 1.0 divided
347- #[ inline]
348- #[ target_feature( enable = "frecipe" ) ]
349- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
350- pub unsafe fn frecipe_s ( a : f32 ) -> f32 {
351- __frecipe_s ( a)
352- }
353-
354- /// Calculate the approximate double-precision result of 1.0 divided
355- #[ inline]
356- #[ target_feature( enable = "frecipe" ) ]
357- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
358- pub unsafe fn frecipe_d ( a : f64 ) -> f64 {
359- __frecipe_d ( a)
360- }
361-
362- /// Calculate the approximate single-precision result of dividing 1.0 by the square root
363- #[ inline]
364- #[ target_feature( enable = "frecipe" ) ]
365- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
366- pub unsafe fn frsqrte_s ( a : f32 ) -> f32 {
367- __frsqrte_s ( a)
368- }
369-
370- /// Calculate the approximate double-precision result of dividing 1.0 by the square root
371- #[ inline]
372- #[ target_feature( enable = "frecipe" ) ]
373- #[ unstable( feature = "stdarch_loongarch" , issue = "117427" ) ]
374- pub unsafe fn frsqrte_d ( a : f64 ) -> f64 {
375- __frsqrte_d ( a)
376- }
0 commit comments