LLVM OCaml绑定是否包含内在支持?

LLVM OCaml绑定是否包含内在支持?,ocaml,llvm,Ocaml,Llvm,除了is\u intrinsic函数之外,我似乎在正式的LLVM OCaml绑定中找不到对intrinsic的引用 我正在构建一个后端,需要执行一些特定于目标的代码生成(对于SSE、AVX和NEN),而内部是C++中的标准路径。 < P>免责声明:我从来没有使用LLVM。快速查看绑定文档后,答案似乎是“否”。然而,有一种对内联汇编的支持,它可能适合您的需要,也可能不适合您的需要 最后,LLVM开发人员似乎承认OCaml绑定不完整:如果您愿意,可以添加更多功能(如果您不熟悉OCaml,C绑定确实不

除了
is\u intrinsic
函数之外,我似乎在正式的LLVM OCaml绑定中找不到对intrinsic的引用


我正在构建一个后端,需要执行一些特定于目标的代码生成(对于SSE、AVX和NEN),而内部是C++中的标准路径。

< P>免责声明:我从来没有使用LLVM。快速查看绑定文档后,答案似乎是“否”。然而,有一种对内联汇编的支持,它可能适合您的需要,也可能不适合您的需要


最后,LLVM开发人员似乎承认OCaml绑定不完整:如果您愿意,可以添加更多功能(如果您不熟悉OCaml,C绑定确实不是最简单的部分,但LLVM绑定中充满了示例代码,您可能可以成功地适应其他LLVM函数),然后在LLVMdev列表中为其提供补丁。

OCaml绑定以与C语言绑定完全相同的方式支持intrinsic:

接口中没有特殊支持(如在完全C++接口中),但它们可以声明为外部,并调用与其他函数一样。

e、 g:

openllvm
让()=
让c=在中创建上下文()
设f32_t=浮动类型c
设f32x4_t=向量类型f32_t 4 in
设m=在中创建模块c“测试”
(*声明无效@printv()
*强制保存向量结果的nonce extern*)
让printv=
声明函数“printv”
(功能_类型(void_类型c)[| f32x4_t |]m in
(*声明@llvm.x86.sse.sqrt.ps()readnone*)
让sqrtps=
声明函数“llvm.x86.sse.sqrt.ps”
(功能类型f32x4_t[| f32x4_t |])m in
(*定义i32@main(){entry:*)
让main=定义函数“main”(函数类型i32_t[| |]m in
让at_entry=builder_位于
(*%sqrtps=call@llvm.x86.sse.sqrt.ps()*)
设cv1234=const_向量[| const_float f32_t 1.0;const_float f32_t 2.0;
常量浮点数f32\u t 3.0;常量浮点数f32\u t 4.0 |]in
让sqrt=build|在中的|u条目处调用sqrtps[| cv1234 |]“sqrtps”
(*调用void printv(sqrtps)*)
忽略(在输入处生成调用printv[| sqrt |]]”;
(*ret void*)
忽略(在入口处构建(const_null i32_t);
(*Print.ll至stderr*)
转储模块m
产生:

; ModuleID = 'test'

declare void @printv(<4 x float>)

declare <4 x float> @llvm.x86.sse.sqrt.ps(<4 x float>) nounwind readnone

define i32 @main() {
entry:
  %sqrtps = call <4 x float> @llvm.x86.sse.sqrt.ps(<4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00>)
  call void @printv(<4 x float> %sqrtps)
  ret i32 0
}
;ModuleID='test'
声明void@printv()
声明@llvm.x86.sse.sqrt.ps()为readnone
定义i32@main(){
条目:
%sqrtps=call@llvm.x86.sse.sqrt.ps()
调用void@printv(%sqrtps)
ret i32 0
}
它通过调用
xmm
寄存器上的
sqrtps
正确编译成x86

; ModuleID = 'test'

declare void @printv(<4 x float>)

declare <4 x float> @llvm.x86.sse.sqrt.ps(<4 x float>) nounwind readnone

define i32 @main() {
entry:
  %sqrtps = call <4 x float> @llvm.x86.sse.sqrt.ps(<4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00>)
  call void @printv(<4 x float> %sqrtps)
  ret i32 0
}