2015-01-07 02:00:21 +08:00
|
|
|
; RUN: llc -O0 -march=amdgcn -mcpu=bonaire -mattr=-promote-alloca < %s | FileCheck -check-prefix=CHECK -check-prefix=CHECK-NO-PROMOTE %s
|
|
|
|
; RUN: llc -O0 -march=amdgcn -mcpu=bonaire -mattr=+promote-alloca < %s | FileCheck -check-prefix=CHECK -check-prefix=CHECK-PROMOTE %s
|
2015-01-28 01:27:15 +08:00
|
|
|
; RUN: llc -O0 -march=amdgcn -mcpu=tonga -mattr=-promote-alloca < %s | FileCheck -check-prefix=CHECK -check-prefix=CHECK-NO-PROMOTE %s
|
|
|
|
; RUN: llc -O0 -march=amdgcn -mcpu=tonga -mattr=+promote-alloca < %s | FileCheck -check-prefix=CHECK -check-prefix=CHECK-PROMOTE %s
|
2014-09-15 23:41:53 +08:00
|
|
|
|
|
|
|
; Disable optimizations in case there are optimizations added that
|
|
|
|
; specialize away generic pointer accesses.
|
|
|
|
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; CHECK-LABEL: {{^}}branch_use_flat_i32:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_store_dword {{v[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, [M0, FLAT_SCRATCH]
|
|
|
|
; CHECK: s_endpgm
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @branch_use_flat_i32(i32 addrspace(1)* noalias %out, i32 addrspace(1)* %gptr, i32 addrspace(3)* %lptr, i32 %x, i32 %c) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ne i32 %c, 0
|
|
|
|
br i1 %cmp, label %local, label %global
|
|
|
|
|
|
|
|
local:
|
|
|
|
%flat_local = addrspacecast i32 addrspace(3)* %lptr to i32 addrspace(4)*
|
|
|
|
br label %end
|
|
|
|
|
|
|
|
global:
|
|
|
|
%flat_global = addrspacecast i32 addrspace(1)* %gptr to i32 addrspace(4)*
|
|
|
|
br label %end
|
|
|
|
|
|
|
|
end:
|
|
|
|
%fptr = phi i32 addrspace(4)* [ %flat_local, %local ], [ %flat_global, %global ]
|
|
|
|
store i32 %x, i32 addrspace(4)* %fptr, align 4
|
2015-02-28 05:17:42 +08:00
|
|
|
; %val = load i32, i32 addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
; store i32 %val, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; These testcases might become useless when there are optimizations to
|
|
|
|
; remove generic pointers.
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; CHECK-LABEL: {{^}}store_flat_i32:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: v_mov_b32_e32 v[[DATA:[0-9]+]], {{s[0-9]+}}
|
|
|
|
; CHECK: v_mov_b32_e32 v[[LO_VREG:[0-9]+]], {{s[0-9]+}}
|
|
|
|
; CHECK: v_mov_b32_e32 v[[HI_VREG:[0-9]+]], {{s[0-9]+}}
|
|
|
|
; CHECK: flat_store_dword v[[DATA]], v{{\[}}[[LO_VREG]]:[[HI_VREG]]{{\]}}
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @store_flat_i32(i32 addrspace(1)* %gptr, i32 %x) #0 {
|
|
|
|
%fptr = addrspacecast i32 addrspace(1)* %gptr to i32 addrspace(4)*
|
|
|
|
store i32 %x, i32 addrspace(4)* %fptr, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; CHECK-LABEL: {{^}}store_flat_i64:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_store_dwordx2
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @store_flat_i64(i64 addrspace(1)* %gptr, i64 %x) #0 {
|
|
|
|
%fptr = addrspacecast i64 addrspace(1)* %gptr to i64 addrspace(4)*
|
|
|
|
store i64 %x, i64 addrspace(4)* %fptr, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; CHECK-LABEL: {{^}}store_flat_v4i32:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_store_dwordx4
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @store_flat_v4i32(<4 x i32> addrspace(1)* %gptr, <4 x i32> %x) #0 {
|
|
|
|
%fptr = addrspacecast <4 x i32> addrspace(1)* %gptr to <4 x i32> addrspace(4)*
|
|
|
|
store <4 x i32> %x, <4 x i32> addrspace(4)* %fptr, align 16
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; CHECK-LABEL: {{^}}store_flat_trunc_i16:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_store_short
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @store_flat_trunc_i16(i16 addrspace(1)* %gptr, i32 %x) #0 {
|
|
|
|
%fptr = addrspacecast i16 addrspace(1)* %gptr to i16 addrspace(4)*
|
|
|
|
%y = trunc i32 %x to i16
|
|
|
|
store i16 %y, i16 addrspace(4)* %fptr, align 2
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-02 01:15:17 +08:00
|
|
|
; CHECK-LABEL: {{^}}store_flat_trunc_i8:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_store_byte
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @store_flat_trunc_i8(i8 addrspace(1)* %gptr, i32 %x) #0 {
|
|
|
|
%fptr = addrspacecast i8 addrspace(1)* %gptr to i8 addrspace(4)*
|
|
|
|
%y = trunc i32 %x to i8
|
|
|
|
store i8 %y, i8 addrspace(4)* %fptr, align 2
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL @load_flat_i32:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_load_dword
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @load_flat_i32(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %gptr) #0 {
|
|
|
|
%fptr = addrspacecast i32 addrspace(1)* %gptr to i32 addrspace(4)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%fload = load i32, i32 addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
store i32 %fload, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL @load_flat_i64:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_load_dwordx2
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @load_flat_i64(i64 addrspace(1)* noalias %out, i64 addrspace(1)* noalias %gptr) #0 {
|
|
|
|
%fptr = addrspacecast i64 addrspace(1)* %gptr to i64 addrspace(4)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%fload = load i64, i64 addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
store i64 %fload, i64 addrspace(1)* %out, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL @load_flat_v4i32:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_load_dwordx4
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @load_flat_v4i32(<4 x i32> addrspace(1)* noalias %out, <4 x i32> addrspace(1)* noalias %gptr) #0 {
|
|
|
|
%fptr = addrspacecast <4 x i32> addrspace(1)* %gptr to <4 x i32> addrspace(4)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%fload = load <4 x i32>, <4 x i32> addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
store <4 x i32> %fload, <4 x i32> addrspace(1)* %out, align 8
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL @sextload_flat_i8:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_load_sbyte
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @sextload_flat_i8(i32 addrspace(1)* noalias %out, i8 addrspace(1)* noalias %gptr) #0 {
|
|
|
|
%fptr = addrspacecast i8 addrspace(1)* %gptr to i8 addrspace(4)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%fload = load i8, i8 addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
%ext = sext i8 %fload to i32
|
|
|
|
store i32 %ext, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL @zextload_flat_i8:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_load_ubyte
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @zextload_flat_i8(i32 addrspace(1)* noalias %out, i8 addrspace(1)* noalias %gptr) #0 {
|
|
|
|
%fptr = addrspacecast i8 addrspace(1)* %gptr to i8 addrspace(4)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%fload = load i8, i8 addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
%ext = zext i8 %fload to i32
|
|
|
|
store i32 %ext, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL @sextload_flat_i16:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_load_sshort
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @sextload_flat_i16(i32 addrspace(1)* noalias %out, i16 addrspace(1)* noalias %gptr) #0 {
|
|
|
|
%fptr = addrspacecast i16 addrspace(1)* %gptr to i16 addrspace(4)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%fload = load i16, i16 addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
%ext = sext i16 %fload to i32
|
|
|
|
store i32 %ext, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL @zextload_flat_i16:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_load_ushort
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @zextload_flat_i16(i32 addrspace(1)* noalias %out, i16 addrspace(1)* noalias %gptr) #0 {
|
|
|
|
%fptr = addrspacecast i16 addrspace(1)* %gptr to i16 addrspace(4)*
|
2015-02-28 05:17:42 +08:00
|
|
|
%fload = load i16, i16 addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
%ext = zext i16 %fload to i32
|
|
|
|
store i32 %ext, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; TODO: This should not be zero when registers are used for small
|
|
|
|
; scratch allocations again.
|
|
|
|
|
|
|
|
; Check for prologue initializing special SGPRs pointing to scratch.
|
2014-10-02 01:15:17 +08:00
|
|
|
; CHECK-LABEL: {{^}}store_flat_scratch:
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: s_movk_i32 flat_scratch_lo, 0
|
2014-11-14 04:44:23 +08:00
|
|
|
; CHECK-NO-PROMOTE: s_movk_i32 flat_scratch_hi, 0x28{{$}}
|
|
|
|
; CHECK-PROMOTE: s_movk_i32 flat_scratch_hi, 0x0{{$}}
|
2014-11-05 22:50:53 +08:00
|
|
|
; CHECK: flat_store_dword
|
|
|
|
; CHECK: s_barrier
|
|
|
|
; CHECK: flat_load_dword
|
2014-09-15 23:41:53 +08:00
|
|
|
define void @store_flat_scratch(i32 addrspace(1)* noalias %out, i32) #0 {
|
|
|
|
%alloca = alloca i32, i32 9, align 4
|
|
|
|
%x = call i32 @llvm.r600.read.tidig.x() #3
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%pptr = getelementptr i32, i32* %alloca, i32 %x
|
2014-09-15 23:41:53 +08:00
|
|
|
%fptr = addrspacecast i32* %pptr to i32 addrspace(4)*
|
|
|
|
store i32 %x, i32 addrspace(4)* %fptr
|
|
|
|
; Dummy call
|
|
|
|
call void @llvm.AMDGPU.barrier.local() #1
|
2015-02-28 05:17:42 +08:00
|
|
|
%reload = load i32, i32 addrspace(4)* %fptr, align 4
|
2014-09-15 23:41:53 +08:00
|
|
|
store i32 %reload, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @llvm.AMDGPU.barrier.local() #1
|
|
|
|
declare i32 @llvm.r600.read.tidig.x() #3
|
|
|
|
|
|
|
|
attributes #0 = { nounwind }
|
|
|
|
attributes #1 = { nounwind noduplicate }
|
|
|
|
attributes #3 = { nounwind readnone }
|