How exactly does one use the new R600 backend inside LLVM 3.3 to generate a binary suitable for passing to the OpenCL clCreateProgramWithBinary API on an AMD card? Are there any code samples for how to do this?
I have seen a clang command line for how to compile for AMD, but I havent seen anywhere how to use the output with the driver.
Thanks very much.
You can read the test cases in the llvm/test/CodeGen/R600
.
For example:
add.ll
;RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s
;CHECK: ADD_INT T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
;CHECK: ADD_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
;CHECK: ADD_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
;CHECK: ADD_INT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
define void @test(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
%b_ptr = getelementptr <4 x i32> addrspace(1)* %in, i32 1
%a = load <4 x i32> addrspace(1) * %in
%b = load <4 x i32> addrspace(1) * %b_ptr
%result = add <4 x i32> %a, %b
store <4 x i32> %result, <4 x i32> addrspace(1)* %out
ret void
}
Then you can just directly use the output through clCreateProgramWithBinary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With