10#ifndef _LOONGARCH_BASE_INTRIN_H
11#define _LOONGARCH_BASE_INTRIN_H
22#if __loongarch_grlen == 64
23typedef struct drdtime {
25 unsigned long dtimeid;
28extern __inline __drdtime_t
29 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
31 __drdtime_t __drdtime;
33 "rdtime.d %[val], %[tid]\n\t"
34 : [val]
"=&r"(__drdtime.dvalue), [tid]
"=&r"(__drdtime.dtimeid));
43 __asm__
volatile(
"rdtimeh.w %[val], %[tid]\n\t"
44 : [val]
"=&r"(__rdtime.
value), [tid]
"=&r"(__rdtime.
timeid));
49 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
52 __asm__
volatile(
"rdtimel.w %[val], %[tid]\n\t"
53 : [val]
"=&r"(__rdtime.
value), [tid]
"=&r"(__rdtime.
timeid));
57#if __loongarch_grlen == 64
59 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
60 __crc_w_b_w(
char _1,
int _2) {
61 return (
int)__builtin_loongarch_crc_w_b_w((
char)_1, (
int)
_2);
65 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
66 __crc_w_h_w(
short _1,
int _2) {
67 return (
int)__builtin_loongarch_crc_w_h_w((
short)_1, (
int)
_2);
71 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
72 __crc_w_w_w(
int _1,
int _2) {
73 return (
int)__builtin_loongarch_crc_w_w_w((
int)_1, (
int)
_2);
77 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
78 __crc_w_d_w(
long int _1,
int _2) {
79 return (
int)__builtin_loongarch_crc_w_d_w((
long int)_1, (
int)
_2);
83 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
84 __crcc_w_b_w(
char _1,
int _2) {
85 return (
int)__builtin_loongarch_crcc_w_b_w((
char)_1, (
int)
_2);
89 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
90 __crcc_w_h_w(
short _1,
int _2) {
91 return (
int)__builtin_loongarch_crcc_w_h_w((
short)_1, (
int)
_2);
95 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
96 __crcc_w_w_w(
int _1,
int _2) {
97 return (
int)__builtin_loongarch_crcc_w_w_w((
int)_1, (
int)
_2);
101 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
102 __crcc_w_d_w(
long int _1,
int _2) {
103 return (
int)__builtin_loongarch_crcc_w_d_w((
long int)_1, (
int)
_2);
107#define __break( _1) __builtin_loongarch_break((_1))
109#if __loongarch_grlen == 32
110#define __cacop_w( _1, _2, _3) \
111 ((void)__builtin_loongarch_cacop_w((_1), (unsigned int)(_2), (_3)))
114#if __loongarch_grlen == 64
115#define __cacop_d( _1, _2, _3) \
116 ((void)__builtin_loongarch_cacop_d((_1), (unsigned long int)(_2), (_3)))
119#define __dbar( _1) __builtin_loongarch_dbar((_1))
121#define __ibar( _1) __builtin_loongarch_ibar((_1))
123#define __movfcsr2gr( _1) __builtin_loongarch_movfcsr2gr((_1));
125#define __movgr2fcsr( _1, _2) \
126 __builtin_loongarch_movgr2fcsr((_1), (unsigned int)_2);
128#define __syscall( _1) __builtin_loongarch_syscall((_1))
130#define __csrrd_w( _1) ((unsigned int)__builtin_loongarch_csrrd_w((_1)))
132#define __csrwr_w( _1, _2) \
133 ((unsigned int)__builtin_loongarch_csrwr_w((unsigned int)(_1), (_2)))
135#define __csrxchg_w( _1, _2, _3) \
136 ((unsigned int)__builtin_loongarch_csrxchg_w((unsigned int)(_1), \
137 (unsigned int)(_2), (_3)))
139#if __loongarch_grlen == 64
140#define __csrrd_d( _1) \
141 ((unsigned long int)__builtin_loongarch_csrrd_d((_1)))
143#define __csrwr_d( _1, _2) \
144 ((unsigned long int)__builtin_loongarch_csrwr_d((unsigned long int)(_1), \
147#define __csrxchg_d( _1, _2, \
149 ((unsigned long int)__builtin_loongarch_csrxchg_d( \
150 (unsigned long int)(_1), (unsigned long int)(_2), (_3)))
153extern __inline
unsigned char
154 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
155 __iocsrrd_b(
unsigned int _1) {
156 return (
unsigned char)__builtin_loongarch_iocsrrd_b((
unsigned int)_1);
159extern __inline
unsigned short
160 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
161 __iocsrrd_h(
unsigned int _1) {
162 return (
unsigned short)__builtin_loongarch_iocsrrd_h((
unsigned int)_1);
165extern __inline
unsigned int
166 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
167 __iocsrrd_w(
unsigned int _1) {
168 return (
unsigned int)__builtin_loongarch_iocsrrd_w((
unsigned int)_1);
171#if __loongarch_grlen == 64
172extern __inline
unsigned long int
173 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
174 __iocsrrd_d(
unsigned int _1) {
175 return (
unsigned long int)__builtin_loongarch_iocsrrd_d((
unsigned int)_1);
180 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
181 __iocsrwr_b(
unsigned char _1,
unsigned int _2) {
182 __builtin_loongarch_iocsrwr_b((
unsigned char)_1, (
unsigned int)
_2);
186 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
187 __iocsrwr_h(
unsigned short _1,
unsigned int _2) {
188 __builtin_loongarch_iocsrwr_h((
unsigned short)_1, (
unsigned int)
_2);
192 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
193 __iocsrwr_w(
unsigned int _1,
unsigned int _2) {
194 __builtin_loongarch_iocsrwr_w((
unsigned int)_1, (
unsigned int)
_2);
197extern __inline
unsigned int
198 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
199 __cpucfg(
unsigned int _1) {
200 return (
unsigned int)__builtin_loongarch_cpucfg((
unsigned int)_1);
203#if __loongarch_grlen == 64
205 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
206 __iocsrwr_d(
unsigned long int _1,
unsigned int _2) {
207 __builtin_loongarch_iocsrwr_d((
unsigned long int)_1, (
unsigned int)
_2);
211 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
212 __asrtgt_d(
long int _1,
long int _2) {
213 __builtin_loongarch_asrtgt_d((
long int)_1, (
long int)
_2);
217 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
218 __asrtle_d(
long int _1,
long int _2) {
219 __builtin_loongarch_asrtle_d((
long int)_1, (
long int)
_2);
223#if __loongarch_grlen == 64
224#define __lddir_d( _1, _2) \
225 ((long int)__builtin_loongarch_lddir_d((long int)(_1), (_2)))
227#define __ldpte_d( _1, _2) \
228 ((void)__builtin_loongarch_ldpte_d((long int)(_1), (_2)))
231#define __frecipe_s( _1) \
232 (float)__builtin_loongarch_frecipe_s((float)_1)
234#define __frecipe_d( _1) \
235 (double)__builtin_loongarch_frecipe_d((double)_1)
237#define __frsqrte_s( _1) \
238 (float)__builtin_loongarch_frsqrte_s((float)_1)
240#define __frsqrte_d( _1) \
241 (double)__builtin_loongarch_frsqrte_d((double)_1)
_Float16 __2f16 __attribute__((ext_vector_type(2)))
Zeroes the upper 128 bits (bits 255:128) of all YMM registers.
__inline void unsigned int _2