2012-08-24 20:40:15 +00:00
|
|
|
; RUN: llc -march=mipsel -O0 < %s | FileCheck %s -check-prefix=None
|
|
|
|
; RUN: llc -march=mipsel < %s | FileCheck %s -check-prefix=Default
|
2013-03-01 00:16:31 +00:00
|
|
|
; RUN: llc -march=mipsel -O1 -relocation-model=static < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefix=STATICO1
|
2013-03-01 00:50:52 +00:00
|
|
|
; RUN: llc -march=mipsel -disable-mips-df-forward-search=false \
|
|
|
|
; RUN: -relocation-model=static < %s | FileCheck %s -check-prefix=FORWARD
|
2013-03-01 02:03:51 +00:00
|
|
|
; RUN: llc -march=mipsel -disable-mips-df-backward-search \
|
|
|
|
; RUN: -disable-mips-df-succbb-search=false < %s | \
|
|
|
|
; RUN: FileCheck %s -check-prefix=SUCCBB
|
2011-09-29 23:52:13 +00:00
|
|
|
|
|
|
|
define void @foo1() nounwind {
|
|
|
|
entry:
|
2012-08-24 20:40:15 +00:00
|
|
|
; Default: jalr
|
|
|
|
; Default-NOT: nop
|
|
|
|
; Default: jr
|
|
|
|
; Default-NOT: nop
|
|
|
|
; Default: .end
|
|
|
|
; None: jalr
|
|
|
|
; None: nop
|
|
|
|
; None: jr
|
|
|
|
; None: nop
|
|
|
|
; None: .end
|
2011-09-29 23:52:13 +00:00
|
|
|
|
|
|
|
tail call void @foo2(i32 3) nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @foo2(i32)
|
2012-11-03 00:53:12 +00:00
|
|
|
|
|
|
|
; Check that cvt.d.w goes into jalr's delay slot.
|
|
|
|
;
|
|
|
|
define void @foo3(i32 %a) nounwind {
|
|
|
|
entry:
|
2013-07-14 06:24:09 +00:00
|
|
|
; Default-LABEL: foo3:
|
2012-11-03 00:53:12 +00:00
|
|
|
; Default: jalr
|
|
|
|
; Default: cvt.d.w
|
|
|
|
|
|
|
|
%conv = sitofp i32 %a to double
|
|
|
|
tail call void @foo4(double %conv) nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @foo4(double)
|
|
|
|
|
2012-11-16 02:39:34 +00:00
|
|
|
@g2 = external global i32
|
|
|
|
@g1 = external global i32
|
|
|
|
@g3 = external global i32
|
|
|
|
|
|
|
|
; Check that branch delay slot can be filled with an instruction with operand
|
|
|
|
; $1.
|
|
|
|
;
|
2013-07-14 06:24:09 +00:00
|
|
|
; Default-LABEL: foo5:
|
2012-11-16 02:39:34 +00:00
|
|
|
; Default-NOT: nop
|
|
|
|
|
|
|
|
define void @foo5(i32 %a) nounwind {
|
|
|
|
entry:
|
2015-02-27 21:17:42 +00:00
|
|
|
%0 = load i32, i32* @g2, align 4
|
2012-11-16 02:39:34 +00:00
|
|
|
%tobool = icmp eq i32 %a, 0
|
|
|
|
br i1 %tobool, label %if.else, label %if.then
|
|
|
|
|
|
|
|
if.then:
|
2015-02-27 21:17:42 +00:00
|
|
|
%1 = load i32, i32* @g1, align 4
|
2012-11-16 02:39:34 +00:00
|
|
|
%add = add nsw i32 %1, %0
|
|
|
|
store i32 %add, i32* @g1, align 4
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.else:
|
2015-02-27 21:17:42 +00:00
|
|
|
%2 = load i32, i32* @g3, align 4
|
2012-11-16 02:39:34 +00:00
|
|
|
%sub = sub nsw i32 %2, %0
|
|
|
|
store i32 %sub, i32* @g3, align 4
|
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2013-01-25 00:20:39 +00:00
|
|
|
; Check that delay slot filler can place mov.s or mov.d in delay slot.
|
|
|
|
;
|
2013-07-14 06:24:09 +00:00
|
|
|
; Default-LABEL: foo6:
|
2013-01-25 00:20:39 +00:00
|
|
|
; Default-NOT: nop
|
2013-03-01 02:03:51 +00:00
|
|
|
; Default: .end foo6
|
2013-01-25 00:20:39 +00:00
|
|
|
|
|
|
|
define void @foo6(float %a0, double %a1) nounwind {
|
|
|
|
entry:
|
|
|
|
tail call void @foo7(double %a1, float %a0) nounwind
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @foo7(double, float)
|
|
|
|
|
2013-03-01 00:16:31 +00:00
|
|
|
; Check that a store can move past other memory instructions.
|
|
|
|
;
|
2013-07-14 06:24:09 +00:00
|
|
|
; STATICO1-LABEL: foo8:
|
2013-03-01 00:16:31 +00:00
|
|
|
; STATICO1: jalr ${{[0-9]+}}
|
|
|
|
; STATICO1-NEXT: sw ${{[0-9]+}}, %lo(g1)
|
|
|
|
|
|
|
|
@foo9 = common global void ()* null, align 4
|
|
|
|
|
|
|
|
define i32 @foo8(i32 %a) nounwind {
|
|
|
|
entry:
|
|
|
|
store i32 %a, i32* @g1, align 4
|
2015-02-27 21:17:42 +00:00
|
|
|
%0 = load void ()*, void ()** @foo9, align 4
|
2013-03-01 00:16:31 +00:00
|
|
|
tail call void %0() nounwind
|
2015-02-27 21:17:42 +00:00
|
|
|
%1 = load i32, i32* @g1, align 4
|
2013-03-01 00:16:31 +00:00
|
|
|
%add = add nsw i32 %1, %a
|
|
|
|
ret i32 %add
|
|
|
|
}
|
2013-03-01 00:50:52 +00:00
|
|
|
|
|
|
|
; Test searchForward. Check that the second jal's slot is filled with another
|
|
|
|
; instruction in the same block.
|
|
|
|
;
|
2013-07-14 06:24:09 +00:00
|
|
|
; FORWARD-LABEL: foo10:
|
2013-03-01 00:50:52 +00:00
|
|
|
; FORWARD: jal foo11
|
|
|
|
; FORWARD: jal foo11
|
|
|
|
; FORWARD-NOT: nop
|
2013-03-01 02:03:51 +00:00
|
|
|
; FORWARD: end foo10
|
2013-03-01 00:50:52 +00:00
|
|
|
|
|
|
|
define void @foo10() nounwind {
|
|
|
|
entry:
|
|
|
|
tail call void @foo11() nounwind
|
|
|
|
tail call void @foo11() nounwind
|
|
|
|
store i32 0, i32* @g1, align 4
|
|
|
|
tail call void @foo11() nounwind
|
|
|
|
store i32 0, i32* @g1, align 4
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @foo11()
|
2013-03-01 02:03:51 +00:00
|
|
|
|
|
|
|
; Check that delay slots of branches in both the entry block and loop body are
|
|
|
|
; filled.
|
|
|
|
;
|
2013-07-14 06:24:09 +00:00
|
|
|
; SUCCBB-LABEL: succbbs_loop1:
|
2013-05-21 17:13:47 +00:00
|
|
|
; SUCCBB: blez $5, $BB
|
2013-03-01 02:03:51 +00:00
|
|
|
; SUCCBB-NEXT: addiu
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187229 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 18:34:25 +00:00
|
|
|
; SUCCBB: bnez ${{[0-9]+}}, $BB
|
2013-03-01 02:03:51 +00:00
|
|
|
; SUCCBB-NEXT: addiu
|
|
|
|
|
|
|
|
define i32 @succbbs_loop1(i32* nocapture %a, i32 %n) {
|
|
|
|
entry:
|
|
|
|
%cmp4 = icmp sgt i32 %n, 0
|
|
|
|
br i1 %cmp4, label %for.body, label %for.end
|
|
|
|
|
|
|
|
for.body: ; preds = %entry, %for.body
|
|
|
|
%s.06 = phi i32 [ %add, %for.body ], [ 0, %entry ]
|
|
|
|
%i.05 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
|
[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
|
|
|
%arrayidx = getelementptr inbounds i32, i32* %a, i32 %i.05
|
2015-02-27 21:17:42 +00:00
|
|
|
%0 = load i32, i32* %arrayidx, align 4
|
2013-03-01 02:03:51 +00:00
|
|
|
%add = add nsw i32 %0, %s.06
|
|
|
|
%inc = add nsw i32 %i.05, 1
|
|
|
|
%exitcond = icmp eq i32 %inc, %n
|
|
|
|
br i1 %exitcond, label %for.end, label %for.body
|
|
|
|
|
|
|
|
for.end: ; preds = %for.body, %entry
|
|
|
|
%s.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
|
|
|
|
ret i32 %s.0.lcssa
|
|
|
|
}
|
|
|
|
|
|
|
|
; Check that the first branch has its slot filled.
|
|
|
|
;
|
2013-07-14 06:24:09 +00:00
|
|
|
; SUCCBB-LABEL: succbbs_br1:
|
[mips] Print instructions "beq", "bne" and "or" using assembler pseudo
instructions "beqz", "bnez" and "move", when possible.
beq $2, $zero, $L1 => beqz $2, $L1
bne $2, $zero, $L1 => bnez $2, $L1
or $2, $3, $zero => move $2, $3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187229 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 18:34:25 +00:00
|
|
|
; SUCCBB: beqz ${{[0-9]+}}, $BB
|
2013-09-28 00:12:32 +00:00
|
|
|
; SUCCBB-NEXT: lw ${{[0-9]+}}, %got(foo101)(${{[0-9]+}})
|
|
|
|
|
|
|
|
define internal fastcc void @foo101() {
|
|
|
|
entry:
|
|
|
|
tail call void @foo100()
|
|
|
|
tail call void @foo100()
|
|
|
|
ret void
|
|
|
|
}
|
2013-03-01 02:03:51 +00:00
|
|
|
|
|
|
|
define void @succbbs_br1(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%tobool = icmp eq i32 %a, 0
|
|
|
|
br i1 %tobool, label %if.end, label %if.then
|
|
|
|
|
|
|
|
if.then: ; preds = %entry
|
2013-09-28 00:12:32 +00:00
|
|
|
tail call fastcc void @foo101()
|
2013-03-01 02:03:51 +00:00
|
|
|
br label %if.end
|
|
|
|
|
|
|
|
if.end: ; preds = %entry, %if.then
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @foo100()
|