2015-02-27 18:32:11 +00:00
|
|
|
; RUN: llc < %s -fast-isel -fast-isel-abort=1 -verify-machineinstrs -march=x86 -mattr=sse2 -no-integrated-as
|
|
|
|
; RUN: llc < %s -fast-isel -fast-isel-abort=1 -verify-machineinstrs -mtriple=x86_64-apple-darwin10 -no-integrated-as
|
2008-08-19 22:37:59 +00:00
|
|
|
|
|
|
|
; This tests very minimal fast-isel functionality.
|
|
|
|
|
2008-09-03 06:44:39 +00:00
|
|
|
define i32* @foo(i32* %p, i32* %q, i32** %z) nounwind {
|
2008-08-19 22:37:59 +00:00
|
|
|
entry:
|
2015-02-27 21:17:42 +00:00
|
|
|
%r = load i32, i32* %p
|
|
|
|
%s = load i32, i32* %q
|
|
|
|
%y = load i32*, i32** %z
|
2008-08-19 22:37:59 +00:00
|
|
|
br label %fast
|
|
|
|
|
|
|
|
fast:
|
2008-08-20 00:11:48 +00:00
|
|
|
%t0 = add i32 %r, %s
|
|
|
|
%t1 = mul i32 %t0, %s
|
|
|
|
%t2 = sub i32 %t1, %s
|
|
|
|
%t3 = and i32 %t2, %s
|
2010-01-12 17:46:16 +00:00
|
|
|
%t4 = xor i32 %t3, 3
|
2008-08-20 00:11:48 +00:00
|
|
|
%t5 = xor i32 %t4, %s
|
2008-08-21 01:41:07 +00:00
|
|
|
%t6 = add i32 %t5, 2
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
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
|
|
|
%t7 = getelementptr i32, i32* %y, i32 1
|
|
|
|
%t8 = getelementptr i32, i32* %t7, i32 %t6
|
2011-04-26 17:18:34 +00:00
|
|
|
call void asm sideeffect "hello world", ""()
|
2008-08-19 22:37:59 +00:00
|
|
|
br label %exit
|
|
|
|
|
|
|
|
exit:
|
2008-08-21 17:25:26 +00:00
|
|
|
ret i32* %t8
|
2008-08-19 22:37:59 +00:00
|
|
|
}
|
2008-08-20 00:11:48 +00:00
|
|
|
|
2011-05-18 00:00:10 +00:00
|
|
|
define void @bar(double* %p, double* %q) nounwind {
|
2008-08-20 00:23:20 +00:00
|
|
|
entry:
|
2015-02-27 21:17:42 +00:00
|
|
|
%r = load double, double* %p
|
|
|
|
%s = load double, double* %q
|
2008-08-20 00:23:20 +00:00
|
|
|
br label %fast
|
|
|
|
|
|
|
|
fast:
|
2009-06-04 22:49:04 +00:00
|
|
|
%t0 = fadd double %r, %s
|
|
|
|
%t1 = fmul double %t0, %s
|
|
|
|
%t2 = fsub double %t1, %s
|
|
|
|
%t3 = fadd double %t2, 707.0
|
2008-08-20 00:23:20 +00:00
|
|
|
br label %exit
|
|
|
|
|
|
|
|
exit:
|
2011-05-18 00:00:10 +00:00
|
|
|
store double %t3, double* %q
|
|
|
|
ret void
|
2008-08-20 00:23:20 +00:00
|
|
|
}
|
|
|
|
|
2008-09-03 06:44:39 +00:00
|
|
|
define i32 @cast() nounwind {
|
2008-08-25 20:20:32 +00:00
|
|
|
entry:
|
|
|
|
%tmp2 = bitcast i32 0 to i32
|
|
|
|
ret i32 %tmp2
|
|
|
|
}
|
2009-03-13 23:53:06 +00:00
|
|
|
|
2010-07-10 09:00:22 +00:00
|
|
|
define void @ptrtoint_i1(i8* %p, i1* %q) nounwind {
|
2009-03-13 23:53:06 +00:00
|
|
|
%t = ptrtoint i8* %p to i1
|
2010-07-10 09:00:22 +00:00
|
|
|
store i1 %t, i1* %q
|
|
|
|
ret void
|
2009-03-13 23:53:06 +00:00
|
|
|
}
|
2009-03-13 23:54:51 +00:00
|
|
|
define i8* @inttoptr_i1(i1 %p) nounwind {
|
2009-03-13 23:53:06 +00:00
|
|
|
%t = inttoptr i1 %p to i8*
|
|
|
|
ret i8* %t
|
|
|
|
}
|
2009-03-13 23:54:51 +00:00
|
|
|
define i32 @ptrtoint_i32(i8* %p) nounwind {
|
|
|
|
%t = ptrtoint i8* %p to i32
|
|
|
|
ret i32 %t
|
|
|
|
}
|
|
|
|
define i8* @inttoptr_i32(i32 %p) nounwind {
|
|
|
|
%t = inttoptr i32 %p to i8*
|
|
|
|
ret i8* %t
|
|
|
|
}
|
2009-08-27 00:31:47 +00:00
|
|
|
|
2011-05-18 00:00:10 +00:00
|
|
|
define void @trunc_i32_i8(i32 %x, i8* %p) nounwind {
|
2010-04-09 15:03:55 +00:00
|
|
|
%tmp1 = trunc i32 %x to i8
|
2011-05-18 00:00:10 +00:00
|
|
|
store i8 %tmp1, i8* %p
|
|
|
|
ret void
|
2010-04-09 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 00:00:10 +00:00
|
|
|
define void @trunc_i16_i8(i16 signext %x, i8* %p) nounwind {
|
2010-04-09 15:03:55 +00:00
|
|
|
%tmp1 = trunc i16 %x to i8
|
2011-05-18 00:00:10 +00:00
|
|
|
store i8 %tmp1, i8* %p
|
|
|
|
ret void
|
2010-04-09 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 00:00:10 +00:00
|
|
|
define void @shl_i8(i8 %a, i8 %c, i8* %p) nounwind {
|
|
|
|
%tmp = shl i8 %a, %c
|
|
|
|
store i8 %tmp, i8* %p
|
|
|
|
ret void
|
2010-04-09 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
2011-05-18 00:00:10 +00:00
|
|
|
define void @mul_i8(i8 %a, i8* %p) nounwind {
|
|
|
|
%tmp = mul i8 %a, 17
|
|
|
|
store i8 %tmp, i8* %p
|
|
|
|
ret void
|
2010-04-09 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
2010-07-10 09:00:22 +00:00
|
|
|
define void @load_store_i1(i1* %p, i1* %q) nounwind {
|
2015-02-27 21:17:42 +00:00
|
|
|
%t = load i1, i1* %p
|
2010-07-10 09:00:22 +00:00
|
|
|
store i1 %t, i1* %q
|
|
|
|
ret void
|
2010-07-09 16:37:18 +00:00
|
|
|
}
|
2011-04-22 21:59:37 +00:00
|
|
|
|
|
|
|
@crash_test1x = external global <2 x i32>, align 8
|
|
|
|
|
|
|
|
define void @crash_test1() nounwind ssp {
|
2015-02-27 21:17:42 +00:00
|
|
|
%tmp = load <2 x i32>, <2 x i32>* @crash_test1x, align 8
|
2011-04-22 21:59:37 +00:00
|
|
|
%neg = xor <2 x i32> %tmp, <i32 -1, i32 -1>
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2012-02-18 00:05:45 +00:00
|
|
|
declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
|
|
|
|
|
|
|
|
define i64* @life() nounwind {
|
|
|
|
%a1 = alloca i64*, align 8
|
|
|
|
%a2 = bitcast i64** %a1 to i8*
|
|
|
|
call void @llvm.lifetime.start(i64 -1, i8* %a2) nounwind
|
2015-02-27 21:17:42 +00:00
|
|
|
%a3 = load i64*, i64** %a1, align 8
|
2012-02-18 00:05:45 +00:00
|
|
|
ret i64* %a3
|
|
|
|
}
|
|
|
|
|
2012-07-06 17:33:39 +00:00
|
|
|
declare void @llvm.donothing() readnone
|
|
|
|
|
|
|
|
; CHECK: donada
|
|
|
|
define void @donada() nounwind {
|
|
|
|
entry:
|
|
|
|
call void @llvm.donothing()
|
|
|
|
ret void
|
|
|
|
}
|