2015-02-03 21:53:27 +00:00
|
|
|
; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck --check-prefix=EG --check-prefix=FUNC %s
|
|
|
|
; RUN: llc < %s -march=amdgcn -mcpu=verde -verify-machineinstrs | FileCheck --check-prefix=SI --check-prefix=FUNC %s
|
|
|
|
; RUN: llc < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck --check-prefix=SI --check-prefix=FUNC %s
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
;FUNC-LABEL: {{^}}test1:
|
2015-02-03 21:53:27 +00:00
|
|
|
;EG: ADD_INT {{[* ]*}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
|
2013-10-11 21:03:41 +00:00
|
|
|
|
2015-02-03 21:53:27 +00:00
|
|
|
;SI: v_add_i32_e32 [[REG:v[0-9]+]], {{v[0-9]+, v[0-9]+}}
|
|
|
|
;SI-NOT: [[REG]]
|
|
|
|
;SI: buffer_store_dword [[REG]],
|
2013-10-11 21:03:41 +00:00
|
|
|
define void @test1(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 21:17:42 +00:00
|
|
|
%a = load i32, i32 addrspace(1)* %in
|
|
|
|
%b = load i32, i32 addrspace(1)* %b_ptr
|
2013-10-11 21:03:41 +00:00
|
|
|
%result = add i32 %a, %b
|
|
|
|
store i32 %result, i32 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
;FUNC-LABEL: {{^}}test2:
|
2015-02-03 21:53:27 +00:00
|
|
|
;EG: ADD_INT {{[* ]*}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
|
|
|
|
;EG: ADD_INT {{[* ]*}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2015-02-03 21:53:27 +00:00
|
|
|
;SI: v_add_i32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
|
|
|
|
;SI: v_add_i32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
|
2013-06-20 21:55:30 +00:00
|
|
|
|
|
|
|
define void @test2(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %in) {
|
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%b_ptr = getelementptr <2 x i32>, <2 x i32> addrspace(1)* %in, i32 1
|
2015-02-27 21:17:42 +00:00
|
|
|
%a = load <2 x i32>, <2 x i32> addrspace(1)* %in
|
|
|
|
%b = load <2 x i32>, <2 x i32> addrspace(1)* %b_ptr
|
2013-06-20 21:55:30 +00:00
|
|
|
%result = add <2 x i32> %a, %b
|
|
|
|
store <2 x i32> %result, <2 x i32> addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
;FUNC-LABEL: {{^}}test4:
|
2015-02-03 21:53:27 +00:00
|
|
|
;EG: ADD_INT {{[* ]*}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
|
|
|
|
;EG: ADD_INT {{[* ]*}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
|
|
|
|
;EG: ADD_INT {{[* ]*}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
|
|
|
|
;EG: ADD_INT {{[* ]*}}T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
|
2013-06-20 21:55:30 +00:00
|
|
|
|
2015-02-03 21:53:27 +00:00
|
|
|
;SI: v_add_i32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
|
|
|
|
;SI: v_add_i32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
|
|
|
|
;SI: v_add_i32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
|
|
|
|
;SI: v_add_i32_e32 v{{[0-9]+, v[0-9]+, v[0-9]+}}
|
2013-06-20 21:55:30 +00:00
|
|
|
|
|
|
|
define void @test4(<4 x i32> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
|
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230786 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-27 19:29:02 +00:00
|
|
|
%b_ptr = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %in, i32 1
|
2015-02-27 21:17:42 +00:00
|
|
|
%a = load <4 x i32>, <4 x i32> addrspace(1)* %in
|
|
|
|
%b = load <4 x i32>, <4 x i32> addrspace(1)* %b_ptr
|
2012-12-11 21:25:42 +00:00
|
|
|
%result = add <4 x i32> %a, %b
|
|
|
|
store <4 x i32> %result, <4 x i32> addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
2014-02-13 23:34:15 +00:00
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}test8:
|
2015-02-03 21:53:27 +00:00
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
2014-02-13 23:34:15 +00:00
|
|
|
define void @test8(<8 x i32> addrspace(1)* %out, <8 x i32> %a, <8 x i32> %b) {
|
|
|
|
entry:
|
|
|
|
%0 = add <8 x i32> %a, %b
|
|
|
|
store <8 x i32> %0, <8 x i32> addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
2014-02-25 21:36:18 +00:00
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}test16:
|
2015-02-03 21:53:27 +00:00
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; EG: ADD_INT
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
|
|
|
; SI: s_add_i32
|
2014-02-28 21:36:37 +00:00
|
|
|
define void @test16(<16 x i32> addrspace(1)* %out, <16 x i32> %a, <16 x i32> %b) {
|
|
|
|
entry:
|
|
|
|
%0 = add <16 x i32> %a, %b
|
|
|
|
store <16 x i32> %0, <16 x i32> addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}add64:
|
2015-02-03 21:53:27 +00:00
|
|
|
; SI: s_add_u32
|
|
|
|
; SI: s_addc_u32
|
2014-02-25 21:36:18 +00:00
|
|
|
define void @add64(i64 addrspace(1)* %out, i64 %a, i64 %b) {
|
|
|
|
entry:
|
|
|
|
%0 = add i64 %a, %b
|
|
|
|
store i64 %0, i64 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
2014-03-07 20:12:39 +00:00
|
|
|
|
2014-11-05 14:50:53 +00:00
|
|
|
; The v_addc_u32 and v_add_i32 instruction can't read SGPRs, because they
|
2014-03-07 20:12:39 +00:00
|
|
|
; use VCC. The test is designed so that %a will be stored in an SGPR and
|
|
|
|
; %0 will be stored in a VGPR, so the comiler will be forced to copy %a
|
|
|
|
; to a VGPR before doing the add.
|
|
|
|
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}add64_sgpr_vgpr:
|
2015-02-03 21:53:27 +00:00
|
|
|
; SI-NOT: v_addc_u32_e32 s
|
2014-03-07 20:12:39 +00:00
|
|
|
define void @add64_sgpr_vgpr(i64 addrspace(1)* %out, i64 %a, i64 addrspace(1)* %in) {
|
|
|
|
entry:
|
2015-02-27 21:17:42 +00:00
|
|
|
%0 = load i64, i64 addrspace(1)* %in
|
2014-03-07 20:12:39 +00:00
|
|
|
%1 = add i64 %a, %0
|
|
|
|
store i64 %1, i64 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
2014-05-15 14:41:54 +00:00
|
|
|
|
2014-09-24 01:33:28 +00:00
|
|
|
; Test i64 add inside a branch.
|
2014-10-01 17:15:17 +00:00
|
|
|
; FUNC-LABEL: {{^}}add64_in_branch:
|
2015-02-03 21:53:27 +00:00
|
|
|
; SI: s_add_u32
|
|
|
|
; SI: s_addc_u32
|
2014-05-15 14:41:54 +00:00
|
|
|
define void @add64_in_branch(i64 addrspace(1)* %out, i64 addrspace(1)* %in, i64 %a, i64 %b, i64 %c) {
|
|
|
|
entry:
|
|
|
|
%0 = icmp eq i64 %a, 0
|
|
|
|
br i1 %0, label %if, label %else
|
|
|
|
|
|
|
|
if:
|
2015-02-27 21:17:42 +00:00
|
|
|
%1 = load i64, i64 addrspace(1)* %in
|
2014-05-15 14:41:54 +00:00
|
|
|
br label %endif
|
|
|
|
|
|
|
|
else:
|
|
|
|
%2 = add i64 %a, %b
|
|
|
|
br label %endif
|
|
|
|
|
|
|
|
endif:
|
|
|
|
%3 = phi i64 [%1, %if], [%2, %else]
|
|
|
|
store i64 %3, i64 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|