2014-03-24 16:52:30 +00:00
|
|
|
; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s
|
|
|
|
|
|
|
|
; Checks how NVPTX lowers alloca buffers and their passing to functions.
|
|
|
|
;
|
|
|
|
; Produced with the following CUDA code:
|
|
|
|
; extern "C" __attribute__((device)) void callee(float* f, char* buf);
|
|
|
|
;
|
|
|
|
; extern "C" __attribute__((global)) void kernel_func(float* a) {
|
|
|
|
; char buf[4 * sizeof(float)];
|
|
|
|
; *(reinterpret_cast<float*>(&buf[0])) = a[0];
|
|
|
|
; *(reinterpret_cast<float*>(&buf[1])) = a[1];
|
|
|
|
; *(reinterpret_cast<float*>(&buf[2])) = a[2];
|
|
|
|
; *(reinterpret_cast<float*>(&buf[3])) = a[3];
|
|
|
|
; callee(a, buf);
|
|
|
|
; }
|
|
|
|
|
|
|
|
; CHECK: .visible .entry kernel_func
|
|
|
|
define void @kernel_func(float* %a) {
|
|
|
|
entry:
|
|
|
|
%buf = alloca [16 x i8], align 4
|
|
|
|
|
|
|
|
; CHECK: .local .align 4 .b8 __local_depot0[16]
|
2014-07-16 16:26:58 +00:00
|
|
|
; CHECK: mov.u64 %rd[[BUF_REG:[0-9]+]]
|
|
|
|
; CHECK: cvta.local.u64 %SP, %rd[[BUF_REG]]
|
2014-03-24 16:52:30 +00:00
|
|
|
|
2014-07-16 16:26:58 +00:00
|
|
|
; CHECK: ld.param.u64 %rd[[A_REG:[0-9]+]], [kernel_func_param_0]
|
|
|
|
; CHECK: ld.f32 %f[[A0_REG:[0-9]+]], [%rd[[A_REG]]]
|
2014-03-24 16:52:30 +00:00
|
|
|
; CHECK: st.f32 [%SP+0], %f[[A0_REG]]
|
|
|
|
|
|
|
|
%0 = load float* %a, align 4
|
|
|
|
%1 = bitcast [16 x i8]* %buf to float*
|
|
|
|
store float %0, float* %1, align 4
|
|
|
|
%arrayidx2 = getelementptr inbounds float* %a, i64 1
|
|
|
|
%2 = load float* %arrayidx2, align 4
|
|
|
|
%arrayidx3 = getelementptr inbounds [16 x i8]* %buf, i64 0, i64 1
|
|
|
|
%3 = bitcast i8* %arrayidx3 to float*
|
|
|
|
store float %2, float* %3, align 4
|
|
|
|
%arrayidx4 = getelementptr inbounds float* %a, i64 2
|
|
|
|
%4 = load float* %arrayidx4, align 4
|
|
|
|
%arrayidx5 = getelementptr inbounds [16 x i8]* %buf, i64 0, i64 2
|
|
|
|
%5 = bitcast i8* %arrayidx5 to float*
|
|
|
|
store float %4, float* %5, align 4
|
|
|
|
%arrayidx6 = getelementptr inbounds float* %a, i64 3
|
|
|
|
%6 = load float* %arrayidx6, align 4
|
|
|
|
%arrayidx7 = getelementptr inbounds [16 x i8]* %buf, i64 0, i64 3
|
|
|
|
%7 = bitcast i8* %arrayidx7 to float*
|
|
|
|
store float %6, float* %7, align 4
|
|
|
|
|
2014-07-16 16:26:58 +00:00
|
|
|
; CHECK: add.u64 %rd[[SP_REG:[0-9]+]], %SP, 0
|
2014-03-24 16:52:30 +00:00
|
|
|
; CHECK: .param .b64 param0;
|
2014-07-16 16:26:58 +00:00
|
|
|
; CHECK-NEXT: st.param.b64 [param0+0], %rd[[A_REG]]
|
2014-03-24 16:52:30 +00:00
|
|
|
; CHECK-NEXT: .param .b64 param1;
|
2014-07-16 16:26:58 +00:00
|
|
|
; CHECK-NEXT: st.param.b64 [param1+0], %rd[[SP_REG]]
|
2014-03-24 16:52:30 +00:00
|
|
|
; CHECK-NEXT: call.uni
|
|
|
|
; CHECK-NEXT: callee,
|
|
|
|
|
|
|
|
%arraydecay = getelementptr inbounds [16 x i8]* %buf, i64 0, i64 0
|
|
|
|
call void @callee(float* %a, i8* %arraydecay) #2
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @callee(float*, i8*)
|
|
|
|
|
|
|
|
!nvvm.annotations = !{!0}
|
|
|
|
|
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
|
|
|
!0 = !{void (float*)* @kernel_func, !"kernel", i32 1}
|