2013-05-10 00:43:42 +08:00
|
|
|
; RUN: llc < %s -march=xcore | FileCheck %s
|
2013-12-02 18:18:14 +08:00
|
|
|
; RUN: llc < %s -march=xcore -disable-fp-elim | FileCheck %s -check-prefix=CHECKFP
|
2013-05-10 00:43:42 +08:00
|
|
|
|
2013-12-02 19:05:28 +08:00
|
|
|
; When using SP for small frames, we don't need any scratch registers (SR).
|
|
|
|
; When using SP for large frames, we may need two scratch registers.
|
|
|
|
; When using FP, for large or small frames, we may need one scratch register.
|
2013-12-02 18:18:14 +08:00
|
|
|
|
2013-12-02 19:05:28 +08:00
|
|
|
; FP + small frame: spill FP+SR = entsp 2
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECKFP-LABEL: f1:
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP: entsp 2
|
|
|
|
; CHECKFP-NEXT: stw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: ldaw r10, sp[0]
|
|
|
|
; CHECKFP: set sp, r10
|
|
|
|
; CHECKFP-NEXT: ldw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: retsp 2
|
|
|
|
;
|
2013-12-02 19:05:28 +08:00
|
|
|
; !FP + small frame: no spills = no stack adjustment needed
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECK-LABEL: f1:
|
2013-05-10 00:43:42 +08:00
|
|
|
; CHECK: stw lr, sp[0]
|
|
|
|
; CHECK: ldw lr, sp[0]
|
|
|
|
; CHECK-NEXT: retsp 0
|
|
|
|
define void @f1() nounwind {
|
|
|
|
entry:
|
|
|
|
tail call void asm sideeffect "", "~{lr}"() nounwind
|
|
|
|
ret void
|
|
|
|
}
|
2013-07-17 18:58:37 +08:00
|
|
|
|
2013-12-02 18:18:14 +08:00
|
|
|
|
2013-12-02 19:05:28 +08:00
|
|
|
; FP + small frame: spill FP+SR+R0+LR = entsp 3 + extsp 1
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECKFP-LABEL: f3:
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP: entsp 3
|
|
|
|
; CHECKFP-NEXT: stw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: ldaw r10, sp[0]
|
|
|
|
; CHECKFP-NEXT: stw [[REG:r[4-9]+]], r10[2]
|
|
|
|
; CHECKFP-NEXT: mov [[REG]], r0
|
|
|
|
; CHECKFP-NEXT: extsp 1
|
|
|
|
; CHECKFP-NEXT: bl f2
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[1]
|
|
|
|
; CHECKFP-NEXT: mov r0, [[REG]]
|
|
|
|
; CHECKFP-NEXT: ldw [[REG]], r10[2]
|
|
|
|
; CHECKFP-NEXT: set sp, r10
|
|
|
|
; CHECKFP-NEXT: ldw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: retsp 3
|
|
|
|
;
|
2013-12-02 19:05:28 +08:00
|
|
|
; !FP + small frame: spill R0+LR = entsp 2
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECK-LABEL: f3:
|
2013-07-17 18:58:37 +08:00
|
|
|
; CHECK: entsp 2
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECK-NEXT: stw [[REG:r[4-9]+]], sp[1]
|
|
|
|
; CHECK-NEXT: mov [[REG]], r0
|
|
|
|
; CHECK-NEXT: bl f2
|
|
|
|
; CHECK-NEXT: mov r0, [[REG]]
|
|
|
|
; CHECK-NEXT: ldw [[REG]], sp[1]
|
|
|
|
; CHECK-NEXT: retsp 2
|
2013-07-17 18:58:37 +08:00
|
|
|
declare void @f2()
|
|
|
|
define i32 @f3(i32 %i) nounwind {
|
|
|
|
entry:
|
|
|
|
call void @f2()
|
|
|
|
ret i32 %i
|
|
|
|
}
|
2013-12-02 18:18:14 +08:00
|
|
|
|
|
|
|
|
2013-12-02 19:05:28 +08:00
|
|
|
; FP + large frame: spill FP+SR = entsp 2 + 100000
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECKFP-LABEL: f4:
|
2014-01-06 22:20:47 +08:00
|
|
|
; CHECKFP: entsp 65535
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP-NEXT: .cfi_def_cfa_offset 262140
|
2014-01-06 22:20:47 +08:00
|
|
|
; CHECKFP-NEXT: .cfi_offset 15, 0
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP-NEXT: extsp 34467
|
|
|
|
; CHECKFP-NEXT: .cfi_def_cfa_offset 400008
|
|
|
|
; CHECKFP-NEXT: stw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: .cfi_offset 10, -400004
|
|
|
|
; CHECKFP-NEXT: ldaw r10, sp[0]
|
|
|
|
; CHECKFP-NEXT: .cfi_def_cfa_register 10
|
|
|
|
; CHECKFP-NEXT: set sp, r10
|
|
|
|
; CHECKFP-NEXT: ldw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[65535]
|
2014-01-06 22:20:47 +08:00
|
|
|
; CHECKFP-NEXT: retsp 34467
|
2013-12-02 18:18:14 +08:00
|
|
|
;
|
2013-12-02 19:05:28 +08:00
|
|
|
; !FP + large frame: spill SR+SR = entsp 2 + 100000
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECK-LABEL: f4:
|
2014-01-06 22:20:47 +08:00
|
|
|
; CHECK: entsp 65535
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 262140
|
2014-01-06 22:20:47 +08:00
|
|
|
; CHECK-NEXT: .cfi_offset 15, 0
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECK-NEXT: extsp 34467
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 400008
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECK-NEXT: ldaw sp, sp[65535]
|
2014-01-06 22:20:47 +08:00
|
|
|
; CHECK-NEXT: retsp 34467
|
2013-12-02 18:18:14 +08:00
|
|
|
define void @f4() {
|
|
|
|
entry:
|
2013-12-02 19:05:28 +08:00
|
|
|
%0 = alloca [100000 x i32]
|
2013-12-02 18:18:14 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-02 19:05:28 +08:00
|
|
|
; FP + large frame: spill FP+SR+R4+LR = entsp 3 + 200000 + extsp 1
|
|
|
|
; CHECKFP: .section .cp.rodata.cst4,"aMc",@progbits,4
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECKFP-NEXT: .p2align 2
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECKFP-NEXT: .LCPI[[CNST0:[0-9_]+]]:
|
|
|
|
; CHECKFP-NEXT: .long 200002
|
|
|
|
; CHECKFP-NEXT: .LCPI[[CNST1:[0-9_]+]]:
|
|
|
|
; CHECKFP-NEXT: .long 200001
|
|
|
|
; CHECKFP-NEXT: .text
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECKFP-LABEL: f6:
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP: entsp 65535
|
|
|
|
; CHECKFP-NEXT: .cfi_def_cfa_offset 262140
|
|
|
|
; CHECKFP-NEXT: .cfi_offset 15, 0
|
|
|
|
; CHECKFP-NEXT: extsp 65535
|
|
|
|
; CHECKFP-NEXT: .cfi_def_cfa_offset 524280
|
|
|
|
; CHECKFP-NEXT: extsp 65535
|
|
|
|
; CHECKFP-NEXT: .cfi_def_cfa_offset 786420
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECKFP-NEXT: extsp 3398
|
|
|
|
; CHECKFP-NEXT: .cfi_def_cfa_offset 800012
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP-NEXT: stw r10, sp[1]
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECKFP-NEXT: .cfi_offset 10, -800008
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP-NEXT: ldaw r10, sp[0]
|
|
|
|
; CHECKFP-NEXT: .cfi_def_cfa_register 10
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECKFP-NEXT: ldw r1, cp[.LCPI[[CNST0]]]
|
|
|
|
; CHECKFP-NEXT: stw [[REG:r[4-9]+]], r10[r1]
|
|
|
|
; CHECKFP-NEXT: .cfi_offset 4, -4
|
|
|
|
; CHECKFP-NEXT: mov [[REG]], r0
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP-NEXT: extsp 1
|
|
|
|
; CHECKFP-NEXT: ldaw r0, r10[2]
|
|
|
|
; CHECKFP-NEXT: bl f5
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[1]
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECKFP-NEXT: ldw r1, cp[.LCPI3_1]
|
|
|
|
; CHECKFP-NEXT: ldaw r0, r10[r1]
|
|
|
|
; CHECKFP-NEXT: extsp 1
|
|
|
|
; CHECKFP-NEXT: bl f5
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[1]
|
|
|
|
; CHECKFP-NEXT: mov r0, [[REG]]
|
|
|
|
; CHECKFP-NEXT: ldw r1, cp[.LCPI[[CNST0]]]
|
|
|
|
; CHECKFP-NEXT: ldw [[REG]], r10[r1]
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECKFP-NEXT: set sp, r10
|
|
|
|
; CHECKFP-NEXT: ldw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[65535]
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[65535]
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[65535]
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECKFP-NEXT: retsp 3398
|
2013-12-02 18:18:14 +08:00
|
|
|
;
|
2013-12-02 19:05:28 +08:00
|
|
|
; !FP + large frame: spill SR+SR+R4+LR = entsp 4 + 200000
|
|
|
|
; CHECK: .section .cp.rodata.cst4,"aMc",@progbits,4
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK-NEXT: .p2align 2
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECK-NEXT: .LCPI[[CNST0:[0-9_]+]]:
|
|
|
|
; CHECK-NEXT: .long 200003
|
|
|
|
; CHECK-NEXT: .LCPI[[CNST1:[0-9_]+]]:
|
|
|
|
; CHECK-NEXT: .long 200002
|
|
|
|
; CHECK-NEXT: .text
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECK-LABEL: f6:
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECK: entsp 65535
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 262140
|
|
|
|
; CHECK-NEXT: .cfi_offset 15, 0
|
|
|
|
; CHECK-NEXT: extsp 65535
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 524280
|
|
|
|
; CHECK-NEXT: extsp 65535
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 786420
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECK-NEXT: extsp 3399
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 800016
|
|
|
|
; CHECK-NEXT: ldaw r1, sp[0]
|
|
|
|
; CHECK-NEXT: ldw r2, cp[.LCPI[[CNST0]]]
|
|
|
|
; CHECK-NEXT: stw [[REG:r[4-9]+]], r1[r2]
|
|
|
|
; CHECK-NEXT: .cfi_offset 4, -4
|
|
|
|
; CHECK-NEXT: mov [[REG]], r0
|
|
|
|
; CHECK-NEXT: ldaw r0, sp[3]
|
|
|
|
; CHECK-NEXT: bl f5
|
|
|
|
; CHECK-NEXT: ldaw r0, sp[0]
|
|
|
|
; CHECK-NEXT: ldw r1, cp[.LCPI[[CNST1]]]
|
|
|
|
; CHECK-NEXT: ldaw r0, r0[r1]
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECK-NEXT: bl f5
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECK-NEXT: mov r0, [[REG]]
|
|
|
|
; CHECK-NEXT: ldaw [[REG]], sp[0]
|
|
|
|
; CHECK-NEXT: ldw r1, cp[.LCPI[[CNST0]]]
|
|
|
|
; CHECK-NEXT: ldw [[REG]], [[REG]][r1]
|
2013-12-02 18:18:14 +08:00
|
|
|
; CHECK-NEXT: ldaw sp, sp[65535]
|
|
|
|
; CHECK-NEXT: ldaw sp, sp[65535]
|
|
|
|
; CHECK-NEXT: ldaw sp, sp[65535]
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECK-NEXT: retsp 3399
|
2013-12-02 18:18:14 +08:00
|
|
|
declare void @f5(i32*)
|
2013-12-02 19:05:28 +08:00
|
|
|
define i32 @f6(i32 %i) {
|
|
|
|
entry:
|
|
|
|
%0 = alloca [200000 x i32]
|
[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
|
|
|
%1 = getelementptr inbounds [200000 x i32], [200000 x i32]* %0, i32 0, i32 0
|
2013-12-02 19:05:28 +08:00
|
|
|
call void @f5(i32* %1)
|
[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
|
|
|
%2 = getelementptr inbounds [200000 x i32], [200000 x i32]* %0, i32 0, i32 199999
|
2013-12-02 19:05:28 +08:00
|
|
|
call void @f5(i32* %2)
|
|
|
|
ret i32 %i
|
|
|
|
}
|
|
|
|
|
2014-04-14 20:30:35 +08:00
|
|
|
; FP + large frame: spill FP+SR+LR = entsp 2 + 256 + extsp 1
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECKFP-LABEL: f8:
|
2014-04-14 20:30:35 +08:00
|
|
|
; CHECKFP: entsp 258
|
|
|
|
; CHECKFP-NEXT: stw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: ldaw r10, sp[0]
|
|
|
|
; CHECKFP-NEXT: mkmsk [[REG:r[0-9]+]], 8
|
|
|
|
; CHECKFP-NEXT: ldaw r0, r10{{\[}}[[REG]]{{\]}}
|
|
|
|
; CHECKFP-NEXT: extsp 1
|
|
|
|
; CHECKFP-NEXT: bl f5
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[1]
|
|
|
|
; CHECKFP-NEXT: set sp, r10
|
|
|
|
; CHECKFP-NEXT: ldw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: retsp 258
|
|
|
|
;
|
|
|
|
; !FP + large frame: spill SR+SR+LR = entsp 3 + 256
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECK-LABEL: f8:
|
2014-04-14 20:30:35 +08:00
|
|
|
; CHECK: entsp 257
|
|
|
|
; CHECK-NEXT: ldaw r0, sp[254]
|
|
|
|
; CHECK-NEXT: bl f5
|
|
|
|
; CHECK-NEXT: retsp 257
|
|
|
|
define void @f8() nounwind {
|
|
|
|
entry:
|
|
|
|
%0 = alloca [256 x i32]
|
[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
|
|
|
%1 = getelementptr inbounds [256 x i32], [256 x i32]* %0, i32 0, i32 253
|
2014-04-14 20:30:35 +08:00
|
|
|
call void @f5(i32* %1)
|
|
|
|
ret void
|
|
|
|
}
|
2013-12-02 19:05:28 +08:00
|
|
|
|
|
|
|
; FP + large frame: spill FP+SR+LR = entsp 2 + 32768 + extsp 1
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECKFP-LABEL: f9:
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECKFP: entsp 32770
|
|
|
|
; CHECKFP-NEXT: stw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: ldaw r10, sp[0]
|
2014-04-14 20:30:35 +08:00
|
|
|
; CHECKFP-NEXT: ldc [[REG:r[0-9]+]], 32767
|
|
|
|
; CHECKFP-NEXT: ldaw r0, r10{{\[}}[[REG]]{{\]}}
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECKFP-NEXT: extsp 1
|
|
|
|
; CHECKFP-NEXT: bl f5
|
|
|
|
; CHECKFP-NEXT: ldaw sp, sp[1]
|
|
|
|
; CHECKFP-NEXT: set sp, r10
|
|
|
|
; CHECKFP-NEXT: ldw r10, sp[1]
|
|
|
|
; CHECKFP-NEXT: retsp 32770
|
|
|
|
;
|
|
|
|
; !FP + large frame: spill SR+SR+LR = entsp 3 + 32768
|
2017-05-24 05:22:16 +08:00
|
|
|
; CHECK-LABEL: f9:
|
2013-12-02 19:05:28 +08:00
|
|
|
; CHECK: entsp 32771
|
|
|
|
; CHECK-NEXT: ldaw r0, sp[32768]
|
|
|
|
; CHECK-NEXT: bl f5
|
|
|
|
; CHECK-NEXT: retsp 32771
|
2014-04-14 20:30:35 +08:00
|
|
|
define void @f9() nounwind {
|
2013-12-02 18:18:14 +08:00
|
|
|
entry:
|
2013-12-02 19:05:28 +08:00
|
|
|
%0 = alloca [32768 x i32]
|
[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
|
|
|
%1 = getelementptr inbounds [32768 x i32], [32768 x i32]* %0, i32 0, i32 32765
|
2013-12-02 18:18:14 +08:00
|
|
|
call void @f5(i32* %1)
|
|
|
|
ret void
|
|
|
|
}
|