brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 0706882 Raw
55 lines · plain
1; Test the NVVM reflect pass functionality: verifying that reflect calls are replaced with 2; appropriate values based on command-line options. Verify that we can handle custom reflect arguments3; that aren't __CUDA_ARCH or __CUDA_FTZ. If that argument is given a value on the command-line,4; the reflect call should be replaced with that value. Otherwise, the reflect call should be replaced with 0.5 6; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda \7; RUN:   -nvvm-reflect-add __CUDA_FTZ=1 -nvvm-reflect-add __CUDA_ARCH=350 %s -S \8; RUN:   | FileCheck %s --check-prefixes=COMMON,FTZ1,ARCH350,CUSTOM-ABSENT9; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda \10; RUN:   -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 %s -S \11; RUN:   | FileCheck %s --check-prefixes=COMMON,FTZ0,ARCH520,CUSTOM-ABSENT12; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda \13; RUN:   -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 \14; RUN:   -nvvm-reflect-add __CUSTOM_VALUE=42 %s -S \15; RUN:   | FileCheck %s --check-prefixes=COMMON,CUSTOM-PRESENT16 17; To ensure that command line options override module options, create a copy of this test file 18; with module options appended and rerun some tests.19 20; RUN: cat %s > %t.options21; RUN: echo '!llvm.module.flags = !{!0}' >> %t.options22; RUN: echo '!0 = !{i32 4, !"nvvm-reflect-ftz", i32 1}' >> %t.options23; RUN: opt -passes=nvvm-reflect -mtriple=nvptx-nvidia-cuda \24; RUN:   -nvvm-reflect-add __CUDA_FTZ=0 -nvvm-reflect-add __CUDA_ARCH=520 %t.options -S \25; RUN:   | FileCheck %s --check-prefixes=COMMON,FTZ0,ARCH52026 27declare i32 @__nvvm_reflect(ptr)28@ftz = private unnamed_addr addrspace(1) constant [11 x i8] c"__CUDA_FTZ\00"29@arch = private unnamed_addr addrspace(1) constant [12 x i8] c"__CUDA_ARCH\00"30@custom = private unnamed_addr addrspace(1) constant [15 x i8] c"__CUSTOM_VALUE\00"31 32; COMMON-LABEL: define i32 @test_ftz()33; FTZ1: ret i32 134; FTZ0: ret i32 035define i32 @test_ftz() {36  %1 = call i32 @__nvvm_reflect(ptr addrspacecast (ptr addrspace(1) @ftz to ptr))37  ret i32 %138}39 40; COMMON-LABEL: define i32 @test_arch()41; ARCH350: ret i32 35042; ARCH520: ret i32 52043define i32 @test_arch() {44  %1 = call i32 @__nvvm_reflect(ptr addrspacecast (ptr addrspace(1) @arch to ptr))45  ret i32 %146}47 48; COMMON-LABEL: define i32 @test_custom()49; CUSTOM-ABSENT: ret i32 050; CUSTOM-PRESENT: ret i32 4251define i32 @test_custom() {52  %1 = call i32 @__nvvm_reflect(ptr addrspacecast (ptr addrspace(1) @custom to ptr))53  ret i32 %154}55