我想在IOS(Xcode4.2)和Android(ndk r7)上使用统一的NEON汇编代码。但他们的宏定义是如此不同:
IOS:
.macro TestMacro 3
vext.8 $ 2,$ 0,$ 1,#1
.endm伪
ndk r7:
.macro TestMacro ref,src,dst
vext.8 \ dst,\ ref,\ src,#1
.endm伪
有什么想要统一他们吗?谢谢。
答案 0 :(得分:1)
我为ios和android
使用单独的宏定义example.S
#ifdef __MACH__
; iOS
.macro TestMacro
vext.8 $2, $0, $1, #1
.endm
#else//__MACH__
; Android NDK
.macro TestMacro ref,src,dst
vext.8 \dst,\ref,\src, #1
.endm
#endif//__MACH__
答案 1 :(得分:0)
您可以使用C预处理器启用“新”宏语法,如下所示:
#include "macros.h"
.macro M_DEMO M3ARGS
#define ref MARG0
#define src MARG1
#define dst MARG2
vext.8 dst, ref, src, #1
#undef ref
#undef src
#undef dst
.endm
macros.h
头文件包含:
#ifndef __MACROS_H__
#define __MACROS_H__
#ifdef __MACH__
/*
* iOS macro support
*/
// Number of arguments in macro definition
#define M0ARGS
#define M1ARGS
#define M2ARGS
#define M3ARGS
#define M4ARGS
#define M5ARGS
#define M6ARGS
#define M7ARGS
#define M8ARGS
#define M9ARGS
#define M10ARGS
// Macro arguments
#define MARG0 $0
#define MARG1 $1
#define MARG2 $2
#define MARG3 $3
#define MARG4 $4
#define MARG5 $5
#define MARG6 $6
#define MARG7 $7
#define MARG8 $8
#define MARG9 $9
#else
/*
* Android macro support
*/
// Number of arguments in macro definition
#define M0ARGS
#define M1ARGS $0
#define M2ARGS $0, $1
#define M3ARGS $0, $1, $2
#define M4ARGS $0, $1, $2, $3
#define M5ARGS $0, $1, $2, $3, $4
#define M6ARGS $0, $1, $2, $3, $4, $5
#define M7ARGS $0, $1, $2, $3, $4, $5, $6
#define M8ARGS $0, $1, $2, $3, $4, $5, $6, $7
#define M9ARGS $0, $1, $2, $3, $4, $5, $6, $7, $8
#define M10ARGS $0, $1, $2, $3, $4, $5, $6, $7, $8, $9
// Macro arguments
#define MARG0 \$0
#define MARG1 \$1
#define MARG2 \$2
#define MARG3 \$3
#define MARG4 \$4
#define MARG5 \$5
#define MARG6 \$6
#define MARG7 \$7
#define MARG8 \$8
#define MARG9 \$9
#endif
#endif // __MACROS_H__
答案 2 :(得分:-1)
尝试使用C / C ++源代码中的GCC内在函数,而不是编写汇编程序文件。或GCC内联asm。