如何启用编译器内在函数? [英] How to enable intrinsics in compiler?

查看:171
本文介绍了如何启用编译器内在函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下:怎么让在C code内在

我想用特殊的DSP指令的在用于ARMv5TE

考虑 QADD 指令,它很好地工作,当我用汇编的方式,像这样的:

 内嵌INT function_qadd(int类型的,INT B){
    __asm​​__(
            QADD%0%1%2:= R(一):R(一),R(B));
    返回;
}

但是,当我试图用的 __ QADD内在而不是ASM是这样的:

  INT add_result = __qadd(5,10);
LOGI(QADD ='%D',add_result);

我得到错误:


  

错误:未定义参考__qadd


什么,我做错了,如何启用在C code内部函数?

更新:

我有NDK Android的NDK-R8C (Windows版),它的有GCC 4.6为默认


  

在GCC 4.6编译器仍然是默认的,


此外,我在android.mk明确指定

  NDK_TOOLCHAIN​​_VERSION = 4.6

我的编译器标志是:

  LOCAL_CFLAGS + = -std = C99 -ffast-数学-march =的ARMv5TE -mfpu = VFP -mfloat-ABI = softfp

此外,我检查由GCC生成的ASM code throught -S编译器标志,它产生QADD指令:

  QADD R3,R3,R2


解决方案

本征函数__qadd不适用于GCC编译器。为您所提供的文档链接指向(非免费)程序armcc编译器。

使用汇编方法是唯一可行的方法使用QADD指令,如果你使用GCC。

Who can explain: how to enable intrinsics in c code?

I would like to use special dsp instructions in armv5TE

Consider qadd instruction, it nicely works when i use assembler approach, like this:

inline int function_qadd(int a, int b) {
    __asm__ (
            "qadd %0, %1, %2" : "=r" (a) : "r" (a), "r" (b));
    return a;
}

But when i tried to use __qadd intrinsic instead of asm like this:

int add_result = __qadd(5,10);
LOGI("qadd='%d'", add_result);

i got error:

error: undefined reference to '__qadd'

What i am doing wrong, how to enable intrinsics in c code?

UPDATE:

I have ndk android-ndk-r8c (windows version), it have GCC 4.6 as default:

The GCC 4.6 compiler is still the default,

Besides i explicitly specify in android.mk

NDK_TOOLCHAIN_VERSION=4.6

My compiler flags is:

LOCAL_CFLAGS += -std=c99 -ffast-math -march=armv5te -mfpu=vfp -mfloat-abi=softfp 

Besides i check the asm code generated by gcc throught -S compiler flag, it generate qadd instruction:

qadd r3, r3, r2

解决方案

The intrinsic function __qadd is not available for the GCC compiler. The link to the documentation you've provided is for the (non-free) armcc compiler.

Using the assembler approach is the only practical way to use the qadd instruction if you're using GCC.

这篇关于如何启用编译器内在函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆