2013-07-16 09:46:55 +00:00
|
|
|
; RUN: llc < %s -mtriple=armv7-apple-darwin | FileCheck %s
|
|
|
|
; RUN: llc < %s -mtriple=thumbv7-apple-darwin > %t
|
|
|
|
; RUN: FileCheck %s < %t
|
|
|
|
; RUN: FileCheck %s < %t --check-prefix=CHECK-T2ADDRMODE
|
|
|
|
|
|
|
|
%0 = type { i32, i32 }
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: f0:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK: ldrexd
|
|
|
|
define i64 @f0(i8* %p) nounwind readonly {
|
|
|
|
entry:
|
|
|
|
%ldrexd = tail call %0 @llvm.arm.ldrexd(i8* %p)
|
|
|
|
%0 = extractvalue %0 %ldrexd, 1
|
|
|
|
%1 = extractvalue %0 %ldrexd, 0
|
|
|
|
%2 = zext i32 %0 to i64
|
|
|
|
%3 = zext i32 %1 to i64
|
|
|
|
%shl = shl nuw i64 %2, 32
|
|
|
|
%4 = or i64 %shl, %3
|
|
|
|
ret i64 %4
|
|
|
|
}
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: f1:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK: strexd
|
|
|
|
define i32 @f1(i8* %ptr, i64 %val) nounwind {
|
|
|
|
entry:
|
|
|
|
%tmp4 = trunc i64 %val to i32
|
|
|
|
%tmp6 = lshr i64 %val, 32
|
|
|
|
%tmp7 = trunc i64 %tmp6 to i32
|
|
|
|
%strexd = tail call i32 @llvm.arm.strexd(i32 %tmp4, i32 %tmp7, i8* %ptr)
|
|
|
|
ret i32 %strexd
|
|
|
|
}
|
|
|
|
|
|
|
|
declare %0 @llvm.arm.ldrexd(i8*) nounwind readonly
|
|
|
|
declare i32 @llvm.arm.strexd(i32, i32, i8*) nounwind
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: test_load_i8:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK: ldrexb r0, [r0]
|
|
|
|
; CHECK-NOT: uxtb
|
2014-04-03 15:10:35 +00:00
|
|
|
; CHECK-NOT: and
|
|
|
|
define zeroext i8 @test_load_i8(i8* %addr) {
|
2013-07-16 09:46:55 +00:00
|
|
|
%val = call i32 @llvm.arm.ldrex.p0i8(i8* %addr)
|
2014-04-03 15:10:35 +00:00
|
|
|
%val8 = trunc i32 %val to i8
|
|
|
|
ret i8 %val8
|
2013-07-16 09:46:55 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: test_load_i16:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK: ldrexh r0, [r0]
|
|
|
|
; CHECK-NOT: uxth
|
2014-04-03 15:10:35 +00:00
|
|
|
; CHECK-NOT: and
|
|
|
|
define zeroext i16 @test_load_i16(i16* %addr) {
|
2013-07-16 09:46:55 +00:00
|
|
|
%val = call i32 @llvm.arm.ldrex.p0i16(i16* %addr)
|
2014-04-03 15:10:35 +00:00
|
|
|
%val16 = trunc i32 %val to i16
|
|
|
|
ret i16 %val16
|
2013-07-16 09:46:55 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: test_load_i32:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK: ldrex r0, [r0]
|
|
|
|
define i32 @test_load_i32(i32* %addr) {
|
|
|
|
%val = call i32 @llvm.arm.ldrex.p0i32(i32* %addr)
|
|
|
|
ret i32 %val
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @llvm.arm.ldrex.p0i8(i8*) nounwind readonly
|
|
|
|
declare i32 @llvm.arm.ldrex.p0i16(i16*) nounwind readonly
|
|
|
|
declare i32 @llvm.arm.ldrex.p0i32(i32*) nounwind readonly
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: test_store_i8:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK-NOT: uxtb
|
|
|
|
; CHECK: strexb r0, r1, [r2]
|
|
|
|
define i32 @test_store_i8(i32, i8 %val, i8* %addr) {
|
|
|
|
%extval = zext i8 %val to i32
|
|
|
|
%res = call i32 @llvm.arm.strex.p0i8(i32 %extval, i8* %addr)
|
|
|
|
ret i32 %res
|
|
|
|
}
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: test_store_i16:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK-NOT: uxth
|
|
|
|
; CHECK: strexh r0, r1, [r2]
|
|
|
|
define i32 @test_store_i16(i32, i16 %val, i16* %addr) {
|
|
|
|
%extval = zext i16 %val to i32
|
|
|
|
%res = call i32 @llvm.arm.strex.p0i16(i32 %extval, i16* %addr)
|
|
|
|
ret i32 %res
|
|
|
|
}
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: test_store_i32:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK: strex r0, r1, [r2]
|
|
|
|
define i32 @test_store_i32(i32, i32 %val, i32* %addr) {
|
|
|
|
%res = call i32 @llvm.arm.strex.p0i32(i32 %val, i32* %addr)
|
|
|
|
ret i32 %res
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @llvm.arm.strex.p0i8(i32, i8*) nounwind
|
|
|
|
declare i32 @llvm.arm.strex.p0i16(i32, i16*) nounwind
|
|
|
|
declare i32 @llvm.arm.strex.p0i32(i32, i32*) nounwind
|
|
|
|
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-LABEL: test_clear:
|
2013-07-16 09:46:55 +00:00
|
|
|
; CHECK: clrex
|
|
|
|
define void @test_clear() {
|
|
|
|
call void @llvm.arm.clrex()
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @llvm.arm.clrex() nounwind
|
|
|
|
|
|
|
|
@base = global i32* null
|
|
|
|
|
|
|
|
define void @excl_addrmode() {
|
2013-07-18 18:35:22 +00:00
|
|
|
; CHECK-T2ADDRMODE-LABEL: excl_addrmode:
|
2015-02-27 21:17:42 +00:00
|
|
|
%base1020 = load i32*, i32** @base
|
[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
|
|
|
%offset1020 = getelementptr i32, i32* %base1020, i32 255
|
2013-07-16 09:46:55 +00:00
|
|
|
call i32 @llvm.arm.ldrex.p0i32(i32* %offset1020)
|
|
|
|
call i32 @llvm.arm.strex.p0i32(i32 0, i32* %offset1020)
|
|
|
|
; CHECK-T2ADDRMODE: ldrex {{r[0-9]+}}, [{{r[0-9]+}}, #1020]
|
|
|
|
; CHECK-T2ADDRMODE: strex {{r[0-9]+}}, {{r[0-9]+}}, [{{r[0-9]+}}, #1020]
|
|
|
|
|
2015-02-27 21:17:42 +00:00
|
|
|
%base1024 = load i32*, i32** @base
|
[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
|
|
|
%offset1024 = getelementptr i32, i32* %base1024, i32 256
|
2013-07-16 09:46:55 +00:00
|
|
|
call i32 @llvm.arm.ldrex.p0i32(i32* %offset1024)
|
|
|
|
call i32 @llvm.arm.strex.p0i32(i32 0, i32* %offset1024)
|
|
|
|
; CHECK-T2ADDRMODE: add.w r[[ADDR:[0-9]+]], {{r[0-9]+}}, #1024
|
|
|
|
; CHECK-T2ADDRMODE: ldrex {{r[0-9]+}}, [r[[ADDR]]]
|
|
|
|
; CHECK-T2ADDRMODE: strex {{r[0-9]+}}, {{r[0-9]+}}, [r[[ADDR]]]
|
|
|
|
|
2015-02-27 21:17:42 +00:00
|
|
|
%base1 = load i32*, i32** @base
|
2013-07-16 09:46:55 +00:00
|
|
|
%addr8 = bitcast i32* %base1 to i8*
|
[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
|
|
|
%offset1_8 = getelementptr i8, i8* %addr8, i32 1
|
2013-07-16 09:46:55 +00:00
|
|
|
%offset1 = bitcast i8* %offset1_8 to i32*
|
|
|
|
call i32 @llvm.arm.ldrex.p0i32(i32* %offset1)
|
|
|
|
call i32 @llvm.arm.strex.p0i32(i32 0, i32* %offset1)
|
|
|
|
; CHECK-T2ADDRMODE: adds r[[ADDR:[0-9]+]], #1
|
|
|
|
; CHECK-T2ADDRMODE: ldrex {{r[0-9]+}}, [r[[ADDR]]]
|
|
|
|
; CHECK-T2ADDRMODE: strex {{r[0-9]+}}, {{r[0-9]+}}, [r[[ADDR]]]
|
|
|
|
|
|
|
|
%local = alloca i8, i32 1024
|
|
|
|
%local32 = bitcast i8* %local to i32*
|
|
|
|
call i32 @llvm.arm.ldrex.p0i32(i32* %local32)
|
|
|
|
call i32 @llvm.arm.strex.p0i32(i32 0, i32* %local32)
|
|
|
|
; CHECK-T2ADDRMODE: mov r[[ADDR:[0-9]+]], sp
|
|
|
|
; CHECK-T2ADDRMODE: ldrex {{r[0-9]+}}, [r[[ADDR]]]
|
|
|
|
; CHECK-T2ADDRMODE: strex {{r[0-9]+}}, {{r[0-9]+}}, [r[[ADDR]]]
|
|
|
|
|
|
|
|
ret void
|
|
|
|
}
|
2014-04-03 15:10:35 +00:00
|
|
|
|
|
|
|
; LLVM should know, even across basic blocks, that ldrex is setting the high
|
|
|
|
; bits of its i32 to 0. There should be no zero-extend operation.
|
|
|
|
define zeroext i8 @test_cross_block_zext_i8(i1 %tst, i8* %addr) {
|
|
|
|
; CHECK: test_cross_block_zext_i8:
|
|
|
|
; CHECK-NOT: uxtb
|
|
|
|
; CHECK-NOT: and
|
|
|
|
; CHECK: bx lr
|
|
|
|
%val = call i32 @llvm.arm.ldrex.p0i8(i8* %addr)
|
|
|
|
br i1 %tst, label %end, label %mid
|
|
|
|
mid:
|
|
|
|
ret i8 42
|
|
|
|
end:
|
|
|
|
%val8 = trunc i32 %val to i8
|
|
|
|
ret i8 %val8
|
|
|
|
}
|