Skip to content

Commit

Permalink
Homogenize "__asm__ volatile" vs "asm volatile"
Browse files Browse the repository at this point in the history
According to https://gcc.gnu.org/onlinedocs/gcc/extensions-to-the-c-language-family/how-to-use-inline-assembly-language-in-c-code.html

For the C language, the asm keyword is a GNU extension. When
writing C code that can be compiled with -ansi and the -std options
that select C dialects without GNU extensions, use __asm__ instead
of asm (see Alternate Keywords). For the C++ language, asm is a
standard keyword, but __asm__ can be used for code compiled with
-fno-asm.

Change-Id: I4af950e67c857c890290c1e3d9cc886da0748784
  • Loading branch information
vrabaud committed Sep 6, 2023
1 parent 68e2713 commit 7ba44f8
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/dsp/msa_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,25 @@
#define ST_UW(...) ST_W(v4u32, __VA_ARGS__)
#define ST_SW(...) ST_W(v4i32, __VA_ARGS__)

#define MSA_LOAD_FUNC(TYPE, INSTR, FUNC_NAME) \
static inline TYPE FUNC_NAME(const void* const psrc) { \
const uint8_t* const psrc_m = (const uint8_t*)psrc; \
TYPE val_m; \
asm volatile ( \
"" #INSTR " %[val_m], %[psrc_m] \n\t" \
: [val_m] "=r" (val_m) \
: [psrc_m] "m" (*psrc_m)); \
return val_m; \
#define MSA_LOAD_FUNC(TYPE, INSTR, FUNC_NAME) \
static inline TYPE FUNC_NAME(const void* const psrc) { \
const uint8_t* const psrc_m = (const uint8_t*)psrc; \
TYPE val_m; \
__asm__ volatile("" #INSTR " %[val_m], %[psrc_m] \n\t" \
: [val_m] "=r"(val_m) \
: [psrc_m] "m"(*psrc_m)); \
return val_m; \
}

#define MSA_LOAD(psrc, FUNC_NAME) FUNC_NAME(psrc)

#define MSA_STORE_FUNC(TYPE, INSTR, FUNC_NAME) \
static inline void FUNC_NAME(TYPE val, void* const pdst) { \
uint8_t* const pdst_m = (uint8_t*)pdst; \
TYPE val_m = val; \
asm volatile ( \
" " #INSTR " %[val_m], %[pdst_m] \n\t" \
: [pdst_m] "=m" (*pdst_m) \
: [val_m] "r" (val_m)); \
#define MSA_STORE_FUNC(TYPE, INSTR, FUNC_NAME) \
static inline void FUNC_NAME(TYPE val, void* const pdst) { \
uint8_t* const pdst_m = (uint8_t*)pdst; \
TYPE val_m = val; \
__asm__ volatile(" " #INSTR " %[val_m], %[pdst_m] \n\t" \
: [pdst_m] "=m"(*pdst_m) \
: [val_m] "r"(val_m)); \
}

#define MSA_STORE(val, pdst, FUNC_NAME) FUNC_NAME(val, pdst)
Expand Down

0 comments on commit 7ba44f8

Please sign in to comment.