2016-05-21 03:53:33 +02:00
|
|
|
; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
|
2017-01-24 23:02:15 +01:00
|
|
|
; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
|
2014-07-24 08:59:20 +02:00
|
|
|
; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}sdiv24_i8:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_f32_i32
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_i32_f32
|
2014-07-24 08:59:20 +02:00
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG-DAG: INT_TO_FLT
|
|
|
|
; EG-DAG: RECIP_IEEE
|
|
|
|
; EG: FLT_TO_INT
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @sdiv24_i8(i8 addrspace(1)* %out, i8 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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i8, i8 addrspace(1)* %in, i8 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i8, i8 addrspace(1) * %in
|
|
|
|
%den = load i8, i8 addrspace(1) * %den_ptr
|
2014-07-24 08:59:20 +02:00
|
|
|
%result = sdiv i8 %num, %den
|
|
|
|
store i8 %result, i8 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}sdiv24_i16:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_f32_i32
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_i32_f32
|
2014-07-24 08:59:20 +02:00
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG-DAG: INT_TO_FLT
|
|
|
|
; EG-DAG: RECIP_IEEE
|
|
|
|
; EG: FLT_TO_INT
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @sdiv24_i16(i16 addrspace(1)* %out, i16 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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i16, i16 addrspace(1)* %in, i16 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i16, i16 addrspace(1) * %in, align 2
|
|
|
|
%den = load i16, i16 addrspace(1) * %den_ptr, align 2
|
2014-07-24 08:59:20 +02:00
|
|
|
%result = sdiv i16 %num, %den
|
|
|
|
store i16 %result, i16 addrspace(1)* %out, align 2
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}sdiv24_i32:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_f32_i32
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_i32_f32
|
2014-07-24 08:59:20 +02:00
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG-DAG: INT_TO_FLT
|
|
|
|
; EG-DAG: RECIP_IEEE
|
|
|
|
; EG: FLT_TO_INT
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @sdiv24_i32(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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
2014-07-24 08:59:20 +02:00
|
|
|
%num.i24.0 = shl i32 %num, 8
|
|
|
|
%den.i24.0 = shl i32 %den, 8
|
|
|
|
%num.i24 = ashr i32 %num.i24.0, 8
|
|
|
|
%den.i24 = ashr i32 %den.i24.0, 8
|
|
|
|
%result = sdiv i32 %num.i24, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}sdiv25_i32:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI-NOT: v_cvt_f32_i32
|
|
|
|
; SI-NOT: v_rcp_f32
|
2014-07-24 08:59:20 +02:00
|
|
|
|
|
|
|
; EG-NOT: INT_TO_FLT
|
|
|
|
; EG-NOT: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @sdiv25_i32(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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
2014-07-24 08:59:20 +02:00
|
|
|
%num.i24.0 = shl i32 %num, 7
|
|
|
|
%den.i24.0 = shl i32 %den, 7
|
|
|
|
%num.i24 = ashr i32 %num.i24.0, 7
|
|
|
|
%den.i24 = ashr i32 %den.i24.0, 7
|
|
|
|
%result = sdiv i32 %num.i24, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}test_no_sdiv24_i32_1:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI-NOT: v_cvt_f32_i32
|
|
|
|
; SI-NOT: v_rcp_f32
|
2014-07-24 08:59:20 +02:00
|
|
|
|
|
|
|
; EG-NOT: INT_TO_FLT
|
|
|
|
; EG-NOT: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @test_no_sdiv24_i32_1(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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
2014-07-24 08:59:20 +02:00
|
|
|
%num.i24.0 = shl i32 %num, 8
|
|
|
|
%den.i24.0 = shl i32 %den, 7
|
|
|
|
%num.i24 = ashr i32 %num.i24.0, 8
|
|
|
|
%den.i24 = ashr i32 %den.i24.0, 7
|
|
|
|
%result = sdiv i32 %num.i24, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}test_no_sdiv24_i32_2:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI-NOT: v_cvt_f32_i32
|
|
|
|
; SI-NOT: v_rcp_f32
|
2014-07-24 08:59:20 +02:00
|
|
|
|
|
|
|
; EG-NOT: INT_TO_FLT
|
|
|
|
; EG-NOT: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @test_no_sdiv24_i32_2(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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
2014-07-24 08:59:20 +02:00
|
|
|
%num.i24.0 = shl i32 %num, 7
|
|
|
|
%den.i24.0 = shl i32 %den, 8
|
|
|
|
%num.i24 = ashr i32 %num.i24.0, 7
|
|
|
|
%den.i24 = ashr i32 %den.i24.0, 8
|
|
|
|
%result = sdiv i32 %num.i24, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
2014-08-12 19:31:17 +02:00
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}srem24_i8:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_f32_i32
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_i32_f32
|
2014-08-12 19:31:17 +02:00
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG-DAG: INT_TO_FLT
|
|
|
|
; EG-DAG: RECIP_IEEE
|
|
|
|
; EG: FLT_TO_INT
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @srem24_i8(i8 addrspace(1)* %out, i8 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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i8, i8 addrspace(1)* %in, i8 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i8, i8 addrspace(1) * %in
|
|
|
|
%den = load i8, i8 addrspace(1) * %den_ptr
|
2014-08-12 19:31:17 +02:00
|
|
|
%result = srem i8 %num, %den
|
|
|
|
store i8 %result, i8 addrspace(1)* %out
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}srem24_i16:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_f32_i32
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_i32_f32
|
2014-08-12 19:31:17 +02:00
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG-DAG: INT_TO_FLT
|
|
|
|
; EG-DAG: RECIP_IEEE
|
|
|
|
; EG: FLT_TO_INT
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @srem24_i16(i16 addrspace(1)* %out, i16 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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i16, i16 addrspace(1)* %in, i16 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i16, i16 addrspace(1) * %in, align 2
|
|
|
|
%den = load i16, i16 addrspace(1) * %den_ptr, align 2
|
2014-08-12 19:31:17 +02:00
|
|
|
%result = srem i16 %num, %den
|
|
|
|
store i16 %result, i16 addrspace(1)* %out, align 2
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2014-10-01 19:15:17 +02:00
|
|
|
; FUNC-LABEL: {{^}}srem24_i32:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_f32_i32
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI: v_cvt_i32_f32
|
2014-08-12 19:31:17 +02:00
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG-DAG: INT_TO_FLT
|
|
|
|
; EG-DAG: RECIP_IEEE
|
|
|
|
; EG: FLT_TO_INT
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @srem24_i32(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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
2014-08-12 19:31:17 +02:00
|
|
|
%num.i24.0 = shl i32 %num, 8
|
|
|
|
%den.i24.0 = shl i32 %den, 8
|
|
|
|
%num.i24 = ashr i32 %num.i24.0, 8
|
|
|
|
%den.i24 = ashr i32 %den.i24.0, 8
|
|
|
|
%result = srem i32 %num.i24, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-05-21 03:53:33 +02:00
|
|
|
; FUNC-LABEL: {{^}}no_srem25_i32:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI-NOT: v_cvt_f32_i32
|
|
|
|
; SI-NOT: v_rcp_f32
|
2014-08-12 19:31:17 +02:00
|
|
|
|
|
|
|
; EG-NOT: INT_TO_FLT
|
|
|
|
; EG-NOT: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @no_srem25_i32(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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
2014-08-12 19:31:17 +02:00
|
|
|
%num.i24.0 = shl i32 %num, 7
|
|
|
|
%den.i24.0 = shl i32 %den, 7
|
|
|
|
%num.i24 = ashr i32 %num.i24.0, 7
|
|
|
|
%den.i24 = ashr i32 %den.i24.0, 7
|
|
|
|
%result = srem i32 %num.i24, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-05-21 03:53:33 +02:00
|
|
|
; FUNC-LABEL: {{^}}no_sdiv25_i24_i25_i32:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI-NOT: v_cvt_f32_i32
|
|
|
|
; SI-NOT: v_rcp_f32
|
2014-08-12 19:31:17 +02:00
|
|
|
|
|
|
|
; EG-NOT: INT_TO_FLT
|
|
|
|
; EG-NOT: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @no_sdiv25_i24_i25_i32(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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
2014-08-12 19:31:17 +02:00
|
|
|
%num.i24.0 = shl i32 %num, 8
|
2016-05-21 03:53:33 +02:00
|
|
|
%den.i25.0 = shl i32 %den, 7
|
2014-08-12 19:31:17 +02:00
|
|
|
%num.i24 = ashr i32 %num.i24.0, 8
|
2016-05-21 03:53:33 +02:00
|
|
|
%den.i25 = ashr i32 %den.i25.0, 7
|
|
|
|
%result = sdiv i32 %num.i24, %den.i25
|
2014-08-12 19:31:17 +02:00
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-05-21 03:53:33 +02:00
|
|
|
; FUNC-LABEL: {{^}}no_sdiv25_i25_i24_i32:
|
2014-11-05 15:50:53 +01:00
|
|
|
; SI-NOT: v_cvt_f32_i32
|
|
|
|
; SI-NOT: v_rcp_f32
|
2014-08-12 19:31:17 +02:00
|
|
|
|
|
|
|
; EG-NOT: INT_TO_FLT
|
|
|
|
; EG-NOT: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @no_sdiv25_i25_i24_i32(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
llvm-svn: 230786
2015-02-27 20:29:02 +01:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
2015-02-27 22:17:42 +01:00
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
2016-05-21 03:53:33 +02:00
|
|
|
%num.i25.0 = shl i32 %num, 7
|
2014-08-12 19:31:17 +02:00
|
|
|
%den.i24.0 = shl i32 %den, 8
|
2016-05-21 03:53:33 +02:00
|
|
|
%num.i25 = ashr i32 %num.i25.0, 7
|
2014-08-12 19:31:17 +02:00
|
|
|
%den.i24 = ashr i32 %den.i24.0, 8
|
2016-05-21 03:53:33 +02:00
|
|
|
%result = sdiv i32 %num.i25, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}no_srem25_i24_i25_i32:
|
|
|
|
; SI-NOT: v_cvt_f32_i32
|
|
|
|
; SI-NOT: v_rcp_f32
|
|
|
|
|
|
|
|
; EG-NOT: INT_TO_FLT
|
|
|
|
; EG-NOT: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @no_srem25_i24_i25_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
2016-05-21 03:53:33 +02:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
|
|
|
%num.i24.0 = shl i32 %num, 8
|
|
|
|
%den.i25.0 = shl i32 %den, 7
|
|
|
|
%num.i24 = ashr i32 %num.i24.0, 8
|
|
|
|
%den.i25 = ashr i32 %den.i25.0, 7
|
|
|
|
%result = srem i32 %num.i24, %den.i25
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}no_srem25_i25_i24_i32:
|
|
|
|
; SI-NOT: v_cvt_f32_i32
|
|
|
|
; SI-NOT: v_rcp_f32
|
|
|
|
|
|
|
|
; EG-NOT: INT_TO_FLT
|
|
|
|
; EG-NOT: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @no_srem25_i25_i24_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
2016-05-21 03:53:33 +02:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
|
|
|
%num.i25.0 = shl i32 %num, 7
|
|
|
|
%den.i24.0 = shl i32 %den, 8
|
|
|
|
%num.i25 = ashr i32 %num.i25.0, 7
|
|
|
|
%den.i24 = ashr i32 %den.i24.0, 8
|
|
|
|
%result = srem i32 %num.i25, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}srem25_i24_i11_i32:
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2016-05-21 03:53:33 +02:00
|
|
|
; SI: v_bfe_i32 v{{[0-9]+}}, v{{[0-9]+}}, 0, 24
|
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @srem25_i24_i11_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
2016-05-21 03:53:33 +02:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
|
|
|
%num.i24.0 = shl i32 %num, 8
|
|
|
|
%den.i11.0 = shl i32 %den, 21
|
|
|
|
%num.i24 = ashr i32 %num.i24.0, 8
|
|
|
|
%den.i11 = ashr i32 %den.i11.0, 21
|
|
|
|
%result = srem i32 %num.i24, %den.i11
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}srem25_i11_i24_i32:
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2016-05-21 03:53:33 +02:00
|
|
|
; SI: v_bfe_i32 v{{[0-9]+}}, v{{[0-9]+}}, 0, 24
|
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @srem25_i11_i24_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
2016-05-21 03:53:33 +02:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
|
|
|
%num.i11.0 = shl i32 %num, 21
|
|
|
|
%den.i24.0 = shl i32 %den, 8
|
|
|
|
%num.i11 = ashr i32 %num.i11.0, 21
|
|
|
|
%den.i24 = ashr i32 %den.i24.0, 8
|
|
|
|
%result = srem i32 %num.i11, %den.i24
|
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; FUNC-LABEL: {{^}}srem25_i17_i12_i32:
|
|
|
|
; SI: v_cvt_f32_i32
|
2018-06-27 17:33:33 +02:00
|
|
|
; SI: v_rcp_iflag_f32
|
2016-05-21 03:53:33 +02:00
|
|
|
; SI: v_bfe_i32 v{{[0-9]+}}, v{{[0-9]+}}, 0, 17
|
|
|
|
|
|
|
|
; EG: INT_TO_FLT
|
|
|
|
; EG: RECIP_IEEE
|
2017-03-21 22:39:51 +01:00
|
|
|
define amdgpu_kernel void @srem25_i17_i12_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
|
2016-05-21 03:53:33 +02:00
|
|
|
%den_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
|
|
|
|
%num = load i32, i32 addrspace(1) * %in, align 4
|
|
|
|
%den = load i32, i32 addrspace(1) * %den_ptr, align 4
|
|
|
|
%num.i17.0 = shl i32 %num, 15
|
|
|
|
%den.i12.0 = shl i32 %den, 20
|
|
|
|
%num.i17 = ashr i32 %num.i17.0, 15
|
|
|
|
%den.i12 = ashr i32 %den.i12.0, 20
|
|
|
|
%result = sdiv i32 %num.i17, %den.i12
|
2014-08-12 19:31:17 +02:00
|
|
|
store i32 %result, i32 addrspace(1)* %out, align 4
|
|
|
|
ret void
|
|
|
|
}
|