什么是内在函数? [英] What are intrinsics?
问题描述
任何人都可以解释它们是什么,为什么我需要它们?如果需要使用内在函数,我应该构建什么样的应用程序?
Can anyone explain what they are and why I would need them? What kind of applications am I building if I need to use intrinsics?
推荐答案
通常, intrinsics是指所构建的函数-in-即编译器可以/将生成内联而不是在库中调用实际函数的大多数标准库函数。例如,对于x86,像这样的调用: memset(array1,10,0)
可以像这样编译:
Normally, "intrinsics" refers to functions that are built-in -- i.e. most standard library functions that the compiler can/will generate inline instead of calling an actual function in the library. For example, a call like: memset(array1, 10, 0)
could be compiled for an x86 as something like:
mov ecx, 10
xor eax, eax
mov edi, offset FLAT:array1
rep stosb
这样的内部特性纯粹是一种优化。 需要内部函数很可能是编译器支持内部函数的一种情况,这些内部函数可以让您生成编译器无法(或通常不会)直接生成的代码。举一个显而易见的例子,很多x86编译器都具有 MMX Intrinsics,可让您使用实际上只是MMX指令直接表示的函数。
Intrinsics like this are purely an optimization. "Needing" intrinsics would most likely be a situation where the compiler supports intrinsics that let you generate code that the compiler can't (or usually won't) generate directly. For an obvious example, quite a few compilers for x86 have "MMX Intrinsics" that let you use "functions" that are really just direct representations of MMX instructions.
这篇关于什么是内在函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!