1 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s --check-prefixes=CHECK,NOALIGN4
2 ; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 -nvptx-force-min-byval-param-align | FileCheck %s --check-prefixes=CHECK,ALIGN4
3 ; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_20 | %ptxas-verify %}
4 ; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_20 -nvptx-force-min-byval-param-align | %ptxas-verify %}
6 ;;; Need 4-byte alignment on ptr passed byval
7 define ptx_device void @t1(ptr byval(float) %x) {
9 ; CHECK: .param .align 4 .b8 t1_param_0[4]
14 ;;; Need 8-byte alignment on ptr passed byval
15 define ptx_device void @t2(ptr byval(double) %x) {
17 ; CHECK: .param .align 8 .b8 t2_param_0[8]
22 ;;; Need 4-byte alignment on float2* passed byval
23 %struct.float2 = type { float, float }
24 define ptx_device void @t3(ptr byval(%struct.float2) %x) {
26 ; CHECK: .param .align 4 .b8 t3_param_0[8]
30 define ptx_device void @t4(ptr byval(i8) %x) {
32 ; NOALIGN4: .param .align 1 .b8 t4_param_0[1]
33 ; ALIGN4: .param .align 4 .b8 t4_param_0[1]
37 ;;; Make sure we adjust alignment at the call site as well.
38 define ptx_device void @t5(ptr align 2 byval(i8) %x) {
40 ; NOALIGN4: .param .align 2 .b8 t5_param_0[1]
41 ; ALIGN4: .param .align 4 .b8 t5_param_0[1]
43 ; NOALIGN4: .param .align 1 .b8 param0[1];
44 ; ALIGN4: .param .align 4 .b8 param0[1];
46 call void @t4(ptr byval(i8) %x)
50 ;;; Make sure we adjust alignment for a function prototype
51 ;;; in case of an inderect call.
53 declare ptr @getfp(i32 %n)
54 %struct.half2 = type { half, half }
55 define ptx_device void @t6() {
57 %fp = call ptr @getfp(i32 0)
58 ; CHECK: prototype_2 : .callprototype ()_ (.param .align 8 .b8 _[8]);
59 call void %fp(ptr byval(double) null);
61 %fp2 = call ptr @getfp(i32 1)
62 ; NOALIGN4: prototype_4 : .callprototype ()_ (.param .align 2 .b8 _[4]);
63 ; ALIGN4: prototype_4 : .callprototype ()_ (.param .align 4 .b8 _[4]);
64 call void %fp(ptr byval(%struct.half2) null);
66 %fp3 = call ptr @getfp(i32 2)
67 ; NOALIGN4: prototype_6 : .callprototype ()_ (.param .align 1 .b8 _[1]);
68 ; ALIGN4: prototype_6 : .callprototype ()_ (.param .align 4 .b8 _[1]);
69 call void %fp(ptr byval(i8) null);