2016-02-11 14:02:01 +08:00
|
|
|
; RUN: llc -march=amdgcn -verify-machineinstrs -enable-misched -asm-verbose < %s | FileCheck -check-prefix=SI %s
|
2014-04-30 23:31:33 +08:00
|
|
|
|
2016-02-11 14:02:01 +08:00
|
|
|
declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
2014-12-03 13:22:35 +08:00
|
|
|
|
2016-08-23 03:33:16 +08:00
|
|
|
; SI-LABEL: {{^}}test_if:
|
2014-04-30 23:31:33 +08:00
|
|
|
; Make sure the i1 values created by the cfg structurizer pass are
|
|
|
|
; moved using VALU instructions
|
2016-08-23 03:33:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
; waitcnt should be inserted after exec modification
|
|
|
|
; SI: v_cmp_lt_i32_e32 vcc, 0,
|
2016-11-22 09:42:34 +08:00
|
|
|
; SI-NEXT: s_and_saveexec_b64 [[SAVE1:s\[[0-9]+:[0-9]+\]]], vcc
|
|
|
|
; SI-NEXT: s_xor_b64 [[SAVE2:s\[[0-9]+:[0-9]+\]]], exec, [[SAVE1]]
|
2016-08-23 03:33:16 +08:00
|
|
|
; SI-NEXT: ; mask branch [[FLOW_BB:BB[0-9]+_[0-9]+]]
|
|
|
|
; SI-NEXT: s_cbranch_execz [[FLOW_BB]]
|
|
|
|
|
|
|
|
; SI-NEXT: BB{{[0-9]+}}_1: ; %LeafBlock3
|
2014-11-05 22:50:53 +08:00
|
|
|
; SI-NOT: s_mov_b64 s[{{[0-9]:[0-9]}}], -1
|
|
|
|
; SI: v_mov_b32_e32 v{{[0-9]}}, -1
|
2016-08-23 03:33:16 +08:00
|
|
|
; SI: s_and_saveexec_b64
|
|
|
|
; SI-NEXT: ; mask branch
|
|
|
|
|
|
|
|
; v_mov should be after exec modification
|
|
|
|
; SI: [[FLOW_BB]]:
|
2016-11-22 09:42:34 +08:00
|
|
|
; SI-NEXT: s_or_saveexec_b64 [[SAVE3:s\[[0-9]+:[0-9]+\]]], [[SAVE2]]
|
2016-08-23 03:33:16 +08:00
|
|
|
; SI-NEXT: v_mov_b32_e32 v{{[0-9]+}}
|
2016-11-22 09:42:34 +08:00
|
|
|
; SI-NEXT: s_xor_b64 exec, exec, [[SAVE3]]
|
2016-08-23 03:33:16 +08:00
|
|
|
; SI-NEXT: ; mask branch
|
|
|
|
;
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @test_if(i32 %b, i32 addrspace(1)* %src, i32 addrspace(1)* %dst) #1 {
|
2014-04-30 23:31:33 +08:00
|
|
|
entry:
|
2016-02-13 07:45:29 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
|
|
|
switch i32 %tid, label %default [
|
2014-04-30 23:31:33 +08:00
|
|
|
i32 0, label %case0
|
|
|
|
i32 1, label %case1
|
|
|
|
]
|
|
|
|
|
|
|
|
case0:
|
[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
|
|
|
%arrayidx1 = getelementptr i32, i32 addrspace(1)* %dst, i32 %b
|
2016-08-23 03:33:16 +08:00
|
|
|
store i32 13, i32 addrspace(1)* %arrayidx1, align 4
|
2014-04-30 23:31:33 +08:00
|
|
|
br label %end
|
|
|
|
|
|
|
|
case1:
|
[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
|
|
|
%arrayidx5 = getelementptr i32, i32 addrspace(1)* %dst, i32 %b
|
2016-08-23 03:33:16 +08:00
|
|
|
store i32 17, i32 addrspace(1)* %arrayidx5, align 4
|
2014-04-30 23:31:33 +08:00
|
|
|
br label %end
|
|
|
|
|
|
|
|
default:
|
2016-02-13 07:45:29 +08:00
|
|
|
%cmp8 = icmp eq i32 %tid, 2
|
[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
|
|
|
%arrayidx10 = getelementptr i32, i32 addrspace(1)* %dst, i32 %b
|
2014-04-30 23:31:33 +08:00
|
|
|
br i1 %cmp8, label %if, label %else
|
|
|
|
|
|
|
|
if:
|
2016-08-23 03:33:16 +08:00
|
|
|
store i32 19, i32 addrspace(1)* %arrayidx10, align 4
|
2014-04-30 23:31:33 +08:00
|
|
|
br label %end
|
|
|
|
|
|
|
|
else:
|
2016-08-23 03:33:16 +08:00
|
|
|
store i32 21, i32 addrspace(1)* %arrayidx10, align 4
|
2014-04-30 23:31:33 +08:00
|
|
|
br label %end
|
|
|
|
|
|
|
|
end:
|
|
|
|
ret void
|
|
|
|
}
|
2014-12-03 13:22:35 +08:00
|
|
|
|
2017-03-25 03:52:05 +08:00
|
|
|
; SI-LABEL: {{^}}simple_test_v_if:
|
2016-09-30 09:50:20 +08:00
|
|
|
; SI: v_cmp_ne_u32_e32 vcc, 0, v{{[0-9]+}}
|
2015-03-24 02:45:30 +08:00
|
|
|
; SI: s_and_saveexec_b64 [[BR_SREG:s\[[0-9]+:[0-9]+\]]], vcc
|
2017-07-27 05:29:15 +08:00
|
|
|
; SI-NEXT: ; mask branch [[EXIT:BB[0-9]+_[0-9]+]]
|
2014-12-03 13:22:35 +08:00
|
|
|
|
2017-03-25 03:52:05 +08:00
|
|
|
; SI-NEXT: BB{{[0-9]+_[0-9]+}}:
|
2014-12-03 13:22:35 +08:00
|
|
|
; SI: buffer_store_dword
|
|
|
|
|
2017-03-25 03:52:05 +08:00
|
|
|
; SI-NEXT: {{^}}[[EXIT]]:
|
2014-12-03 13:22:35 +08:00
|
|
|
; SI: s_endpgm
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @simple_test_v_if(i32 addrspace(1)* %dst, i32 addrspace(1)* %src) #1 {
|
2016-02-11 14:02:01 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
2014-12-03 13:22:35 +08:00
|
|
|
%is.0 = icmp ne i32 %tid, 0
|
2017-03-25 03:52:05 +08:00
|
|
|
br i1 %is.0, label %then, label %exit
|
|
|
|
|
|
|
|
then:
|
|
|
|
%gep = getelementptr i32, i32 addrspace(1)* %dst, i32 %tid
|
|
|
|
store i32 999, i32 addrspace(1)* %gep
|
|
|
|
br label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FIXME: It would be better to endpgm in the then block.
|
|
|
|
|
|
|
|
; SI-LABEL: {{^}}simple_test_v_if_ret_else_ret:
|
|
|
|
; SI: v_cmp_ne_u32_e32 vcc, 0, v{{[0-9]+}}
|
|
|
|
; SI: s_and_saveexec_b64 [[BR_SREG:s\[[0-9]+:[0-9]+\]]], vcc
|
2017-07-27 05:29:15 +08:00
|
|
|
; SI-NEXT: ; mask branch [[EXIT:BB[0-9]+_[0-9]+]]
|
2017-03-25 03:52:05 +08:00
|
|
|
|
|
|
|
; SI-NEXT: BB{{[0-9]+_[0-9]+}}:
|
|
|
|
; SI: buffer_store_dword
|
|
|
|
|
|
|
|
; SI-NEXT: {{^}}[[EXIT]]:
|
|
|
|
; SI: s_endpgm
|
|
|
|
define amdgpu_kernel void @simple_test_v_if_ret_else_ret(i32 addrspace(1)* %dst, i32 addrspace(1)* %src) #1 {
|
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%is.0 = icmp ne i32 %tid, 0
|
|
|
|
br i1 %is.0, label %then, label %exit
|
|
|
|
|
|
|
|
then:
|
|
|
|
%gep = getelementptr i32, i32 addrspace(1)* %dst, i32 %tid
|
|
|
|
store i32 999, i32 addrspace(1)* %gep
|
|
|
|
ret void
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Final block has more than a ret to execute. This was miscompiled
|
|
|
|
; before function exit blocks were unified since the endpgm would
|
|
|
|
; terminate the then wavefront before reaching the store.
|
|
|
|
|
|
|
|
; SI-LABEL: {{^}}simple_test_v_if_ret_else_code_ret:
|
|
|
|
; SI: v_cmp_eq_u32_e32 vcc, 0, v{{[0-9]+}}
|
|
|
|
; SI: s_and_saveexec_b64 [[BR_SREG:s\[[0-9]+:[0-9]+\]]], vcc
|
|
|
|
; SI: s_xor_b64 [[BR_SREG]], exec, [[BR_SREG]]
|
|
|
|
; SI: ; mask branch [[FLOW:BB[0-9]+_[0-9]+]]
|
|
|
|
|
|
|
|
; SI-NEXT: {{^BB[0-9]+_[0-9]+}}: ; %exit
|
|
|
|
; SI: ds_write_b32
|
|
|
|
|
|
|
|
; SI-NEXT: {{^}}[[FLOW]]:
|
|
|
|
; SI-NEXT: s_or_saveexec_b64
|
|
|
|
; SI-NEXT: s_xor_b64 exec, exec
|
|
|
|
; SI-NEXT: ; mask branch [[UNIFIED_RETURN:BB[0-9]+_[0-9]+]]
|
|
|
|
|
|
|
|
; SI-NEXT: {{^BB[0-9]+_[0-9]+}}: ; %then
|
2017-06-02 22:19:25 +08:00
|
|
|
; SI: s_waitcnt
|
|
|
|
; SI-NEXT: buffer_store_dword
|
2017-03-25 03:52:05 +08:00
|
|
|
|
|
|
|
; SI-NEXT: {{^}}[[UNIFIED_RETURN]]: ; %UnifiedReturnBlock
|
|
|
|
; SI: s_endpgm
|
|
|
|
define amdgpu_kernel void @simple_test_v_if_ret_else_code_ret(i32 addrspace(1)* %dst, i32 addrspace(1)* %src) #1 {
|
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x()
|
|
|
|
%is.0 = icmp ne i32 %tid, 0
|
|
|
|
br i1 %is.0, label %then, label %exit
|
2014-12-03 13:22:35 +08:00
|
|
|
|
2017-03-25 03:52:05 +08:00
|
|
|
then:
|
[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
|
|
|
%gep = getelementptr i32, i32 addrspace(1)* %dst, i32 %tid
|
2014-12-03 13:22:35 +08:00
|
|
|
store i32 999, i32 addrspace(1)* %gep
|
|
|
|
ret void
|
|
|
|
|
|
|
|
exit:
|
2017-03-25 03:52:05 +08:00
|
|
|
store volatile i32 7, i32 addrspace(3)* undef
|
2014-12-03 13:22:35 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-08-11 03:11:42 +08:00
|
|
|
; SI-LABEL: {{^}}simple_test_v_loop:
|
2016-09-30 09:50:20 +08:00
|
|
|
; SI: v_cmp_ne_u32_e32 vcc, 0, v{{[0-9]+}}
|
2015-03-24 02:45:30 +08:00
|
|
|
; SI: s_and_saveexec_b64 [[BR_SREG:s\[[0-9]+:[0-9]+\]]], vcc
|
2017-07-27 05:29:15 +08:00
|
|
|
; SI-NEXT: ; mask branch
|
|
|
|
; SI-NEXT: s_cbranch_execz [[LABEL_EXIT:BB[0-9]+_[0-9]+]]
|
2014-12-03 13:22:35 +08:00
|
|
|
|
|
|
|
; SI: s_mov_b64 {{s\[[0-9]+:[0-9]+\]}}, 0{{$}}
|
|
|
|
|
2016-05-21 08:29:27 +08:00
|
|
|
; SI: [[LABEL_LOOP:BB[0-9]+_[0-9]+]]:
|
2014-12-03 13:22:35 +08:00
|
|
|
; SI: buffer_load_dword
|
2015-11-07 01:54:43 +08:00
|
|
|
; SI-DAG: buffer_store_dword
|
2017-04-13 07:51:47 +08:00
|
|
|
; SI-DAG: v_cmp_eq_u32_e32 vcc, 0x100
|
|
|
|
; SI: s_cbranch_vccz [[LABEL_LOOP]]
|
2016-05-21 08:29:27 +08:00
|
|
|
; SI: [[LABEL_EXIT]]:
|
2016-02-13 07:45:29 +08:00
|
|
|
; SI: s_endpgm
|
2014-12-03 13:22:35 +08:00
|
|
|
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @simple_test_v_loop(i32 addrspace(1)* %dst, i32 addrspace(1)* %src) #1 {
|
2014-12-03 13:22:35 +08:00
|
|
|
entry:
|
2016-02-11 14:02:01 +08:00
|
|
|
%tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
|
2014-12-03 13:22:35 +08:00
|
|
|
%is.0 = icmp ne i32 %tid, 0
|
|
|
|
%limit = add i32 %tid, 64
|
|
|
|
br i1 %is.0, label %loop, label %exit
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%i = phi i32 [%tid, %entry], [%i.inc, %loop]
|
[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
|
|
|
%gep.src = getelementptr i32, i32 addrspace(1)* %src, i32 %i
|
|
|
|
%gep.dst = getelementptr i32, i32 addrspace(1)* %dst, i32 %i
|
2015-02-28 05:17:42 +08:00
|
|
|
%load = load i32, i32 addrspace(1)* %src
|
2014-12-03 13:22:35 +08:00
|
|
|
store i32 %load, i32 addrspace(1)* %gep.dst
|
|
|
|
%i.inc = add nsw i32 %i, 1
|
|
|
|
%cmp = icmp eq i32 %limit, %i.inc
|
|
|
|
br i1 %cmp, label %exit, label %loop
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-08-11 03:11:42 +08:00
|
|
|
; SI-LABEL: {{^}}multi_vcond_loop:
|
2014-12-03 13:22:35 +08:00
|
|
|
|
|
|
|
; Load loop limit from buffer
|
|
|
|
; Branch to exit if uniformly not taken
|
|
|
|
; SI: ; BB#0:
|
|
|
|
; SI: buffer_load_dword [[VBOUND:v[0-9]+]]
|
2015-03-24 02:45:30 +08:00
|
|
|
; SI: v_cmp_lt_i32_e32 vcc
|
|
|
|
; SI: s_and_saveexec_b64 [[OUTER_CMP_SREG:s\[[0-9]+:[0-9]+\]]], vcc
|
2017-07-27 05:29:15 +08:00
|
|
|
; SI-NEXT: ; mask branch
|
|
|
|
; SI-NEXT: s_cbranch_execz [[LABEL_EXIT:BB[0-9]+_[0-9]+]]
|
2014-12-03 13:22:35 +08:00
|
|
|
|
|
|
|
; Initialize inner condition to false
|
2016-08-11 03:11:42 +08:00
|
|
|
; SI: BB{{[0-9]+_[0-9]+}}: ; %bb10.preheader
|
2014-12-03 13:22:35 +08:00
|
|
|
; SI: s_mov_b64 [[ZERO:s\[[0-9]+:[0-9]+\]]], 0{{$}}
|
|
|
|
; SI: s_mov_b64 [[COND_STATE:s\[[0-9]+:[0-9]+\]]], [[ZERO]]
|
|
|
|
|
|
|
|
; Clear exec bits for workitems that load -1s
|
2016-05-21 08:29:27 +08:00
|
|
|
; SI: [[LABEL_LOOP:BB[0-9]+_[0-9]+]]:
|
2014-12-03 13:22:35 +08:00
|
|
|
; SI: buffer_load_dword [[B:v[0-9]+]]
|
2015-01-30 00:55:25 +08:00
|
|
|
; SI: buffer_load_dword [[A:v[0-9]+]]
|
2016-09-30 09:50:20 +08:00
|
|
|
; SI-DAG: v_cmp_ne_u32_e64 [[NEG1_CHECK_0:s\[[0-9]+:[0-9]+\]]], -1, [[A]]
|
|
|
|
; SI-DAG: v_cmp_ne_u32_e32 [[NEG1_CHECK_1:vcc]], -1, [[B]]
|
2014-12-03 13:22:35 +08:00
|
|
|
; SI: s_and_b64 [[ORNEG1:s\[[0-9]+:[0-9]+\]]], [[NEG1_CHECK_1]], [[NEG1_CHECK_0]]
|
2015-09-26 00:58:25 +08:00
|
|
|
; SI: s_and_saveexec_b64 [[ORNEG2:s\[[0-9]+:[0-9]+\]]], [[ORNEG1]]
|
2016-11-22 09:42:34 +08:00
|
|
|
; SI: s_xor_b64 [[ORNEG3:s\[[0-9]+:[0-9]+\]]], exec, [[ORNEG2]]
|
2016-05-21 08:29:27 +08:00
|
|
|
; SI: s_cbranch_execz [[LABEL_FLOW:BB[0-9]+_[0-9]+]]
|
2014-12-03 13:22:35 +08:00
|
|
|
|
2016-08-11 03:11:42 +08:00
|
|
|
; SI: BB{{[0-9]+_[0-9]+}}: ; %bb20
|
2014-12-03 13:22:35 +08:00
|
|
|
; SI: buffer_store_dword
|
2017-03-11 08:29:27 +08:00
|
|
|
; SI: v_cmp_ge_i64_e{{32|64}} [[CMP:s\[[0-9]+:[0-9]+\]|vcc]]
|
2016-03-29 02:18:41 +08:00
|
|
|
; SI: s_or_b64 [[TMP:s\[[0-9]+:[0-9]+\]]], [[CMP]], [[COND_STATE]]
|
2014-12-03 13:22:35 +08:00
|
|
|
|
2016-05-21 08:29:27 +08:00
|
|
|
; SI: [[LABEL_FLOW]]:
|
2016-08-23 03:33:16 +08:00
|
|
|
; SI-NEXT: ; in Loop: Header=[[LABEL_LOOP]]
|
2016-11-22 09:42:34 +08:00
|
|
|
; SI-NEXT: s_or_b64 exec, exec, [[ORNEG3]]
|
|
|
|
; SI-NEXT: s_or_b64 [[COND_STATE]], [[ORNEG3]], [[TMP]]
|
2016-08-23 03:33:16 +08:00
|
|
|
; SI-NEXT: s_andn2_b64 exec, exec, [[COND_STATE]]
|
|
|
|
; SI-NEXT: s_cbranch_execnz [[LABEL_LOOP]]
|
2014-12-03 13:22:35 +08:00
|
|
|
|
2016-05-21 08:29:27 +08:00
|
|
|
; SI: [[LABEL_EXIT]]:
|
2014-12-03 13:22:35 +08:00
|
|
|
; SI-NOT: [[COND_STATE]]
|
|
|
|
; SI: s_endpgm
|
|
|
|
|
2017-03-22 05:39:51 +08:00
|
|
|
define amdgpu_kernel void @multi_vcond_loop(i32 addrspace(1)* noalias nocapture %arg, i32 addrspace(1)* noalias nocapture readonly %arg1, i32 addrspace(1)* noalias nocapture readonly %arg2, i32 addrspace(1)* noalias nocapture readonly %arg3) #1 {
|
2014-12-03 13:22:35 +08:00
|
|
|
bb:
|
2016-02-11 14:02:01 +08:00
|
|
|
%tmp = tail call i32 @llvm.amdgcn.workitem.id.x() #0
|
2014-12-03 13:22:35 +08:00
|
|
|
%tmp4 = sext i32 %tmp to i64
|
[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
|
|
|
%tmp5 = getelementptr inbounds i32, i32 addrspace(1)* %arg3, i64 %tmp4
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp6 = load i32, i32 addrspace(1)* %tmp5, align 4
|
2014-12-03 13:22:35 +08:00
|
|
|
%tmp7 = icmp sgt i32 %tmp6, 0
|
|
|
|
%tmp8 = sext i32 %tmp6 to i64
|
|
|
|
br i1 %tmp7, label %bb10, label %bb26
|
|
|
|
|
|
|
|
bb10: ; preds = %bb, %bb20
|
|
|
|
%tmp11 = phi i64 [ %tmp23, %bb20 ], [ 0, %bb ]
|
|
|
|
%tmp12 = add nsw i64 %tmp11, %tmp4
|
[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
|
|
|
%tmp13 = getelementptr inbounds i32, i32 addrspace(1)* %arg1, i64 %tmp12
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp14 = load i32, i32 addrspace(1)* %tmp13, align 4
|
[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
|
|
|
%tmp15 = getelementptr inbounds i32, i32 addrspace(1)* %arg2, i64 %tmp12
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp16 = load i32, i32 addrspace(1)* %tmp15, align 4
|
2014-12-03 13:22:35 +08:00
|
|
|
%tmp17 = icmp ne i32 %tmp14, -1
|
|
|
|
%tmp18 = icmp ne i32 %tmp16, -1
|
|
|
|
%tmp19 = and i1 %tmp17, %tmp18
|
|
|
|
br i1 %tmp19, label %bb20, label %bb26
|
|
|
|
|
|
|
|
bb20: ; preds = %bb10
|
|
|
|
%tmp21 = add nsw i32 %tmp16, %tmp14
|
[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
|
|
|
%tmp22 = getelementptr inbounds i32, i32 addrspace(1)* %arg, i64 %tmp12
|
2014-12-03 13:22:35 +08:00
|
|
|
store i32 %tmp21, i32 addrspace(1)* %tmp22, align 4
|
|
|
|
%tmp23 = add nuw nsw i64 %tmp11, 1
|
|
|
|
%tmp24 = icmp slt i64 %tmp23, %tmp8
|
|
|
|
br i1 %tmp24, label %bb10, label %bb26
|
|
|
|
|
|
|
|
bb26: ; preds = %bb10, %bb20, %bb
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind readnone }
|
|
|
|
attributes #1 = { nounwind }
|