Home | History | Annotate | Download | only in AMDGPU
      1 ; RUN: llc -march=r600 -mcpu=juniper < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
      2 
      3 ; === WIDTH ==================================================================
      4 ; 9 implicit args = 9 dwords to first image argument.
      5 ; First width at dword index 9+1 -> KC0[2].Z
      6 
      7 ; FUNC-LABEL: {{^}}width_2d:
      8 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
      9 ; EG: MOV * [[VAL]], KC0[2].Z
     10 define void @width_2d (%opencl.image2d_t addrspace(1)* %in,
     11                        i32 addrspace(1)* %out) {
     12 entry:
     13   %0 = call [3 x i32] @llvm.OpenCL.image.get.size.2d(
     14       %opencl.image2d_t addrspace(1)* %in) #0
     15   %1 = extractvalue [3 x i32] %0, 0
     16   store i32 %1, i32 addrspace(1)* %out
     17   ret void
     18 }
     19 
     20 ; FUNC-LABEL: {{^}}width_3d:
     21 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
     22 ; EG: MOV * [[VAL]], KC0[2].Z
     23 define void @width_3d (%opencl.image3d_t addrspace(1)* %in,
     24                        i32 addrspace(1)* %out) {
     25 entry:
     26   %0 = call [3 x i32] @llvm.OpenCL.image.get.size.3d(
     27       %opencl.image3d_t addrspace(1)* %in) #0
     28   %1 = extractvalue [3 x i32] %0, 0
     29   store i32 %1, i32 addrspace(1)* %out
     30   ret void
     31 }
     32 
     33 
     34 ; === HEIGHT =================================================================
     35 ; First height at dword index 9+2 -> KC0[2].W
     36 
     37 ; FUNC-LABEL: {{^}}height_2d:
     38 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
     39 ; EG: MOV * [[VAL]], KC0[2].W
     40 define void @height_2d (%opencl.image2d_t addrspace(1)* %in,
     41                         i32 addrspace(1)* %out) {
     42 entry:
     43   %0 = call [3 x i32] @llvm.OpenCL.image.get.size.2d(
     44       %opencl.image2d_t addrspace(1)* %in) #0
     45   %1 = extractvalue [3 x i32] %0, 1
     46   store i32 %1, i32 addrspace(1)* %out
     47   ret void
     48 }
     49 
     50 ; FUNC-LABEL: {{^}}height_3d:
     51 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
     52 ; EG: MOV * [[VAL]], KC0[2].W
     53 define void @height_3d (%opencl.image3d_t addrspace(1)* %in,
     54                         i32 addrspace(1)* %out) {
     55 entry:
     56   %0 = call [3 x i32] @llvm.OpenCL.image.get.size.3d(
     57       %opencl.image3d_t addrspace(1)* %in) #0
     58   %1 = extractvalue [3 x i32] %0, 1
     59   store i32 %1, i32 addrspace(1)* %out
     60   ret void
     61 }
     62 
     63 
     64 ; === DEPTH ==================================================================
     65 ; First depth at dword index 9+3 -> KC0[3].X
     66 
     67 ; FUNC-LABEL: {{^}}depth_3d:
     68 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
     69 ; EG: MOV * [[VAL]], KC0[3].X
     70 define void @depth_3d (%opencl.image3d_t addrspace(1)* %in,
     71                        i32 addrspace(1)* %out) {
     72 entry:
     73   %0 = call [3 x i32] @llvm.OpenCL.image.get.size.3d(
     74       %opencl.image3d_t addrspace(1)* %in) #0
     75   %1 = extractvalue [3 x i32] %0, 2
     76   store i32 %1, i32 addrspace(1)* %out
     77   ret void
     78 }
     79 
     80 
     81 ; === CHANNEL DATA TYPE ======================================================
     82 ; First channel data type at dword index 9+4 -> KC0[3].Y
     83 
     84 ; FUNC-LABEL: {{^}}data_type_2d:
     85 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
     86 ; EG: MOV * [[VAL]], KC0[3].Y
     87 define void @data_type_2d (%opencl.image2d_t addrspace(1)* %in,
     88                            i32 addrspace(1)* %out) {
     89 entry:
     90   %0 = call [2 x i32] @llvm.OpenCL.image.get.format.2d(
     91       %opencl.image2d_t addrspace(1)* %in) #0
     92   %1 = extractvalue [2 x i32] %0, 0
     93   store i32 %1, i32 addrspace(1)* %out
     94   ret void
     95 }
     96 
     97 ; FUNC-LABEL: {{^}}data_type_3d:
     98 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
     99 ; EG: MOV * [[VAL]], KC0[3].Y
    100 define void @data_type_3d (%opencl.image3d_t addrspace(1)* %in,
    101                                      i32 addrspace(1)* %out) {
    102 entry:
    103   %0 = call [2 x i32] @llvm.OpenCL.image.get.format.3d(
    104       %opencl.image3d_t addrspace(1)* %in) #0
    105   %1 = extractvalue [2 x i32] %0, 0
    106   store i32 %1, i32 addrspace(1)* %out
    107   ret void
    108 }
    109 
    110 
    111 ; === CHANNEL ORDER ==========================================================
    112 ; First channel order at dword index 9+5 -> KC0[3].Z
    113 
    114 ; FUNC-LABEL: {{^}}channel_order_2d:
    115 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
    116 ; EG: MOV * [[VAL]], KC0[3].Z
    117 define void @channel_order_2d (%opencl.image2d_t addrspace(1)* %in,
    118                                i32 addrspace(1)* %out) {
    119 entry:
    120   %0 = call [2 x i32] @llvm.OpenCL.image.get.format.2d(
    121       %opencl.image2d_t addrspace(1)* %in) #0
    122   %1 = extractvalue [2 x i32] %0, 1
    123   store i32 %1, i32 addrspace(1)* %out
    124   ret void
    125 }
    126 
    127 ; FUNC-LABEL: {{^}}channel_order_3d:
    128 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
    129 ; EG: MOV * [[VAL]], KC0[3].Z
    130 define void @channel_order_3d (%opencl.image3d_t addrspace(1)* %in,
    131                                          i32 addrspace(1)* %out) {
    132 entry:
    133   %0 = call [2 x i32] @llvm.OpenCL.image.get.format.3d(
    134       %opencl.image3d_t addrspace(1)* %in) #0
    135   %1 = extractvalue [2 x i32] %0, 1
    136   store i32 %1, i32 addrspace(1)* %out
    137   ret void
    138 }
    139 
    140 
    141 ; === 2ND IMAGE ==============================================================
    142 ; 9 implicit args + 2 explicit args + 5 implicit args for 1st image argument
    143 ;   = 16 dwords to 2nd image argument.
    144 ; Height of the second image is at 16+2 -> KC0[4].Z
    145 ;
    146 ; FUNC-LABEL: {{^}}image_arg_2nd:
    147 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
    148 ; EG: MOV * [[VAL]], KC0[4].Z
    149 define void @image_arg_2nd (%opencl.image3d_t addrspace(1)* %in1,
    150                             i32 %x,
    151                             %opencl.image2d_t addrspace(1)* %in2,
    152                             i32 addrspace(1)* %out) {
    153 entry:
    154   %0 = call [3 x i32] @llvm.OpenCL.image.get.size.2d(
    155       %opencl.image2d_t addrspace(1)* %in2) #0
    156   %1 = extractvalue [3 x i32] %0, 1
    157   store i32 %1, i32 addrspace(1)* %out
    158   ret void
    159 }
    160 
    161 %opencl.image2d_t = type opaque
    162 %opencl.image3d_t = type opaque
    163 
    164 declare [3 x i32] @llvm.OpenCL.image.get.size.2d(%opencl.image2d_t addrspace(1)*) #0
    165 declare [3 x i32] @llvm.OpenCL.image.get.size.3d(%opencl.image3d_t addrspace(1)*) #0
    166 declare [2 x i32] @llvm.OpenCL.image.get.format.2d(%opencl.image2d_t addrspace(1)*) #0
    167 declare [2 x i32] @llvm.OpenCL.image.get.format.3d(%opencl.image3d_t addrspace(1)*) #0
    168 
    169 attributes #0 = { readnone }
    170 
    171 !opencl.kernels = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
    172 !0 = !{void (%opencl.image2d_t addrspace(1)*, i32 addrspace(1)*)* @width_2d,
    173        !10, !20, !30, !40, !50}
    174 !1 = !{void (%opencl.image3d_t addrspace(1)*, i32 addrspace(1)*)* @width_3d,
    175        !10, !21, !31, !41, !50}
    176 !2 = !{void (%opencl.image2d_t addrspace(1)*, i32 addrspace(1)*)* @height_2d,
    177        !10, !20, !30, !40, !50}
    178 !3 = !{void (%opencl.image3d_t addrspace(1)*, i32 addrspace(1)*)* @height_3d,
    179        !10, !21, !31, !41, !50}
    180 !4 = !{void (%opencl.image3d_t addrspace(1)*, i32 addrspace(1)*)* @depth_3d,
    181        !10, !21, !31, !41, !50}
    182 !5 = !{void (%opencl.image2d_t addrspace(1)*, i32 addrspace(1)*)* @data_type_2d,
    183        !10, !20, !30, !40, !50}
    184 !6 = !{void (%opencl.image3d_t addrspace(1)*, i32 addrspace(1)*)* @data_type_3d,
    185        !10, !21, !31, !41, !50}
    186 !7 = !{void (%opencl.image2d_t addrspace(1)*, i32 addrspace(1)*)* @channel_order_2d,
    187        !10, !20, !30, !40, !50}
    188 !8 = !{void (%opencl.image3d_t addrspace(1)*, i32 addrspace(1)*)* @channel_order_3d,
    189        !10, !21, !31, !41, !50}
    190 !9 = !{void (%opencl.image3d_t addrspace(1)*, i32, %opencl.image2d_t addrspace(1)*,
    191       i32 addrspace(1)*)* @image_arg_2nd, !12, !22, !32, !42, !52}
    192 
    193 !10 = !{!"kernel_arg_addr_space", i32 1, i32 1}
    194 !20 = !{!"kernel_arg_access_qual", !"read_only", !"none"}
    195 !21 = !{!"kernel_arg_access_qual", !"read_only", !"none"}
    196 !30 = !{!"kernel_arg_type", !"image2d_t", !"int*"}
    197 !31 = !{!"kernel_arg_type", !"image3d_t", !"int*"}
    198 !40 = !{!"kernel_arg_base_type", !"image2d_t", !"int*"}
    199 !41 = !{!"kernel_arg_base_type", !"image3d_t", !"int*"}
    200 !50 = !{!"kernel_arg_type_qual", !"", !""}
    201 
    202 !12 = !{!"kernel_arg_addr_space", i32 1, i32 0, i32 1, i32 1}
    203 !22 = !{!"kernel_arg_access_qual", !"read_only", !"none", !"write_only", !"none"}
    204 !32 = !{!"kernel_arg_type", !"image3d_t", !"sampler_t", !"image2d_t", !"int*"}
    205 !42 = !{!"kernel_arg_base_type", !"image3d_t", !"sampler_t", !"image2d_t", !"int*"}
    206 !52 = !{!"kernel_arg_type_qual", !"", !"", !"", !""}
    207