2013-12-02 18:18:24 +08:00
|
|
|
|
2013-12-02 18:18:31 +08:00
|
|
|
; RUN: not llc < %s -march=xcore -code-model=medium 2>&1 | FileCheck %s -check-prefix=BAD_CM
|
|
|
|
; RUN: not llc < %s -march=xcore -code-model=kernel 2>&1 | FileCheck %s -check-prefix=BAD_CM
|
2018-12-07 20:10:23 +08:00
|
|
|
; RUN: not llc < %s -march=xcore -code-model=tiny 2>&1 | FileCheck %s -check-prefix=BAD_CM
|
2013-12-02 18:18:31 +08:00
|
|
|
; BAD_CM: Target only supports CodeModel Small or Large
|
|
|
|
|
|
|
|
|
2017-08-03 10:16:21 +08:00
|
|
|
; RUN: llc < %s -march=xcore | FileCheck %s
|
2013-12-02 18:18:31 +08:00
|
|
|
; RUN: llc < %s -march=xcore -code-model=small | FileCheck %s
|
|
|
|
; RUN: llc < %s -march=xcore -code-model=large | FileCheck %s -check-prefix=LARGE
|
2013-12-02 18:18:24 +08:00
|
|
|
|
2013-12-02 18:18:37 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: test:
|
|
|
|
; CHECK: zext r0, 1
|
|
|
|
; CHECK: bt r0, [[JUMP:.LBB[0-9_]*]]
|
|
|
|
; CHECK: ldaw r0, dp[A2]
|
|
|
|
; CHECK: retsp 0
|
|
|
|
; CHECK: [[JUMP]]
|
|
|
|
; CHECK: ldaw r0, dp[A1]
|
|
|
|
; CHECK: retsp 0
|
|
|
|
; LARGE-LABEL: test:
|
|
|
|
; LARGE: zext r0, 1
|
|
|
|
; LARGE: ldaw r11, cp[.LCPI{{[0-9_]*}}]
|
|
|
|
; LARGE: mov r1, r11
|
|
|
|
; LARGE: ldaw r11, cp[.LCPI{{[0-9_]*}}]
|
|
|
|
; LARGE: bt r0, [[JUMP:.LBB[0-9_]*]]
|
|
|
|
; LARGE: mov r11, r1
|
|
|
|
; LARGE: [[JUMP]]
|
|
|
|
; LARGE: ldw r0, r11[0]
|
|
|
|
; LARGE: retsp 0
|
|
|
|
@A1 = external global [50000 x i32]
|
|
|
|
@A2 = external global [50000 x i32]
|
|
|
|
define [50000 x i32]* @test(i1 %bool) nounwind {
|
|
|
|
entry:
|
|
|
|
%Addr = select i1 %bool, [50000 x i32]* @A1, [50000 x i32]* @A2
|
|
|
|
ret [50000 x i32]* %Addr
|
|
|
|
}
|
|
|
|
|
2014-01-06 22:20:32 +08:00
|
|
|
|
2013-12-02 18:18:24 +08:00
|
|
|
; CHECK: .section .cp.rodata.cst4,"aMc",@progbits,4
|
|
|
|
; CHECK: .long 65536
|
|
|
|
; CHECK: .text
|
|
|
|
; CHECK-LABEL: f:
|
|
|
|
; CHECK: ldc r1, 65532
|
|
|
|
; CHECK: add r1, r0, r1
|
|
|
|
; CHECK: ldw r1, r1[0]
|
2013-12-02 18:18:37 +08:00
|
|
|
; CHECK: ldw r2, cp[.LCPI{{[0-9_]*}}]
|
2013-12-02 18:18:24 +08:00
|
|
|
; CHECK: add r0, r0, r2
|
|
|
|
; CHECK: ldw r0, r0[0]
|
|
|
|
; CHECK: add r0, r1, r0
|
|
|
|
; CHECK: ldw r1, dp[l]
|
|
|
|
; CHECK: add r0, r0, r1
|
|
|
|
; CHECK: ldw r1, dp[l+4]
|
|
|
|
; CHECK: add r0, r0, r1
|
|
|
|
; CHECK: ldw r1, dp[l+392]
|
|
|
|
; CHECK: add r0, r0, r1
|
|
|
|
; CHECK: ldw r1, dp[l+396]
|
|
|
|
; CHECK: add r0, r0, r1
|
|
|
|
; CHECK: ldw r1, dp[s]
|
|
|
|
; CHECK: add r0, r0, r1
|
|
|
|
; CHECK: ldw r1, dp[s+36]
|
|
|
|
; CHECK: add r0, r0, r1
|
|
|
|
; CHECK: retsp 0
|
2013-12-02 18:18:31 +08:00
|
|
|
;
|
|
|
|
; LARGE: .section .cp.rodata.cst4,"aMc",@progbits,4
|
|
|
|
; LARGE: .long 65536
|
|
|
|
; LARGE: .section .cp.rodata,"ac",@progbits
|
|
|
|
; LARGE: .long l
|
|
|
|
; LARGE: .long l+4
|
|
|
|
; LARGE: .long l+392
|
|
|
|
; LARGE: .long l+396
|
|
|
|
; LARGE: .text
|
|
|
|
; LARGE-LABEL: f:
|
|
|
|
; LARGE: ldc r1, 65532
|
|
|
|
; LARGE: add r1, r0, r1
|
|
|
|
; LARGE: ldw r1, r1[0]
|
2013-12-02 18:18:37 +08:00
|
|
|
; LARGE: ldw r2, cp[.LCPI{{[0-9_]*}}]
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE: add r0, r0, r2
|
|
|
|
; LARGE: ldw r0, r0[0]
|
|
|
|
; LARGE: add r0, r1, r0
|
2013-12-02 18:18:37 +08:00
|
|
|
; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE: ldw r1, r1[0]
|
|
|
|
; LARGE: add r0, r0, r1
|
2013-12-02 18:18:37 +08:00
|
|
|
; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE: ldw r1, r1[0]
|
|
|
|
; LARGE: add r0, r0, r1
|
2013-12-02 18:18:37 +08:00
|
|
|
; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE: ldw r1, r1[0]
|
|
|
|
; LARGE: add r0, r0, r1
|
2013-12-02 18:18:37 +08:00
|
|
|
; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}]
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE: ldw r1, r1[0]
|
|
|
|
; LARGE: add r0, r0, r1
|
|
|
|
; LARGE: ldw r1, dp[s]
|
|
|
|
; LARGE: add r0, r0, r1
|
|
|
|
; LARGE: ldw r1, dp[s+36]
|
|
|
|
; LARGE: add r0, r0, r1
|
|
|
|
; LARGE: retsp 0
|
2013-12-02 18:18:24 +08:00
|
|
|
define i32 @f(i32* %i) {
|
|
|
|
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
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%0 = getelementptr inbounds i32, i32* %i, i32 16383
|
2015-02-28 05:17:42 +08:00
|
|
|
%1 = load i32, i32* %0
|
[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 i32, i32* %i, i32 16384
|
2015-02-28 05:17:42 +08:00
|
|
|
%3 = load i32, i32* %2
|
2013-12-02 18:18:24 +08:00
|
|
|
%4 = add nsw i32 %1, %3
|
2015-03-14 02:20:45 +08:00
|
|
|
%5 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 0)
|
2013-12-02 18:18:24 +08:00
|
|
|
%6 = add nsw i32 %4, %5
|
2015-03-14 02:20:45 +08:00
|
|
|
%7 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 1)
|
2013-12-02 18:18:24 +08:00
|
|
|
%8 = add nsw i32 %6, %7
|
2015-03-14 02:20:45 +08:00
|
|
|
%9 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 98)
|
2013-12-02 18:18:24 +08:00
|
|
|
%10 = add nsw i32 %8, %9
|
2015-03-14 02:20:45 +08:00
|
|
|
%11 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 99)
|
2013-12-02 18:18:24 +08:00
|
|
|
%12 = add nsw i32 %10, %11
|
2015-03-14 02:20:45 +08:00
|
|
|
%13 = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @s, i32 0, i32 0)
|
2013-12-02 18:18:24 +08:00
|
|
|
%14 = add nsw i32 %12, %13
|
2015-03-14 02:20:45 +08:00
|
|
|
%15 = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @s, i32 0, i32 9)
|
2013-12-02 18:18:24 +08:00
|
|
|
%16 = add nsw i32 %14, %15
|
|
|
|
ret i32 %16
|
|
|
|
}
|
|
|
|
|
2014-01-06 22:20:32 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: UnknownSize:
|
|
|
|
; CHECK: ldw r0, dp[NoSize+40]
|
|
|
|
; CHECK-NEXT: retsp 0
|
|
|
|
;
|
|
|
|
; LARGE: .section .cp.rodata,"ac",@progbits
|
|
|
|
; LARGE: .LCPI{{[0-9_]*}}
|
|
|
|
; LARGE-NEXT: .long NoSize
|
|
|
|
; LARGE-NEXT: .text
|
|
|
|
; LARGE-LABEL: UnknownSize:
|
|
|
|
; LARGE: ldw r0, cp[.LCPI{{[0-9_]*}}]
|
|
|
|
; LARGE-NEXT: ldw r0, r0[0]
|
|
|
|
; LARGE-NEXT: retsp 0
|
|
|
|
@NoSize = external global [0 x i32]
|
|
|
|
define i32 @UnknownSize() nounwind {
|
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%0 = load i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @NoSize, i32 0, i32 10)
|
2014-01-06 22:20:32 +08:00
|
|
|
ret i32 %0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
; CHECK-LABEL: UnknownStruct:
|
|
|
|
; CHECK: ldaw r0, dp[Unknown]
|
|
|
|
; CHECK-NEXT: retsp 0
|
|
|
|
;
|
|
|
|
; LARGE: .section .cp.rodata,"ac",@progbits
|
|
|
|
; LARGE: .LCPI{{[0-9_]*}}
|
|
|
|
; LARGE-NEXT: .long Unknown
|
|
|
|
; LARGE-NEXT: .text
|
|
|
|
; LARGE-LABEL: UnknownStruct:
|
|
|
|
; LARGE: ldw r0, cp[.LCPI{{[0-9_]*}}]
|
|
|
|
; LARGE-NEXT: retsp 0
|
|
|
|
%Struct = type opaque
|
|
|
|
@Unknown = external global %Struct
|
|
|
|
define %Struct* @UnknownStruct() nounwind {
|
|
|
|
entry:
|
|
|
|
ret %Struct* @Unknown
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-02 18:18:24 +08:00
|
|
|
; CHECK: .section .dp.bss,"awd",@nobits
|
|
|
|
; CHECK-LABEL: l:
|
|
|
|
; CHECK: .space 400
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE: .section .dp.bss.large,"awd",@nobits
|
|
|
|
; LARGE-LABEL: l:
|
|
|
|
; LARGE: .space 400
|
2013-12-02 18:18:24 +08:00
|
|
|
@l = global [100 x i32] zeroinitializer
|
|
|
|
|
|
|
|
; CHECK-LABEL: s:
|
|
|
|
; CHECK: .space 40
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE: .section .dp.bss,"awd",@nobits
|
|
|
|
; LARGE-LABEL: s:
|
|
|
|
; LARGE: .space 40
|
2013-12-02 18:18:24 +08:00
|
|
|
@s = global [10 x i32] zeroinitializer
|
|
|
|
|
2014-02-11 18:36:26 +08:00
|
|
|
; CHECK: .section .dp.rodata,"awd",@progbits
|
2013-12-02 18:18:24 +08:00
|
|
|
; CHECK-LABEL: cl:
|
|
|
|
; CHECK: .space 400
|
2014-02-11 18:36:26 +08:00
|
|
|
; LARGE: .section .dp.rodata.large,"awd",@progbits
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE-LABEL: cl:
|
|
|
|
; LARGE: .space 400
|
2013-12-02 18:18:24 +08:00
|
|
|
@cl = constant [100 x i32] zeroinitializer
|
|
|
|
|
|
|
|
; CHECK-LABEL: cs:
|
|
|
|
; CHECK: .space 40
|
2014-02-11 18:36:26 +08:00
|
|
|
; LARGE: .section .dp.rodata,"awd",@progbits
|
2013-12-02 18:18:31 +08:00
|
|
|
; LARGE-LABEL: cs:
|
|
|
|
; LARGE: .space 40
|
2013-12-02 18:18:24 +08:00
|
|
|
@cs = constant [10 x i32] zeroinitializer
|
2013-12-02 18:18:31 +08:00
|
|
|
|
2014-02-11 18:36:26 +08:00
|
|
|
; CHECK: .section .cp.rodata,"ac",@progbits
|
|
|
|
; CHECK-LABEL: icl:
|
|
|
|
; CHECK: .space 400
|
|
|
|
; LARGE: .section .cp.rodata.large,"ac",@progbits
|
|
|
|
; LARGE-LABEL: icl:
|
|
|
|
; LARGE: .space 400
|
|
|
|
@icl = internal constant [100 x i32] zeroinitializer
|
|
|
|
|
|
|
|
; CHECK-LABEL: cs:
|
|
|
|
; CHECK: .space 40
|
|
|
|
; LARGE: .section .cp.rodata,"ac",@progbits
|
|
|
|
; LARGE-LABEL: cs:
|
|
|
|
; LARGE: .space 40
|
|
|
|
@ics = internal constant [10 x i32] zeroinitializer
|
|
|
|
|
2013-12-02 18:18:31 +08:00
|
|
|
; CHECK: .section .cp.namedsection,"ac",@progbits
|
|
|
|
; CHECK-LABEL: cpsec:
|
|
|
|
; CHECK: .long 0
|
2014-02-11 18:36:26 +08:00
|
|
|
@cpsec = constant i32 0, section ".cp.namedsection"
|
2013-12-02 18:18:31 +08:00
|
|
|
|
|
|
|
; CHECK: .section .dp.namedsection,"awd",@progbits
|
|
|
|
; CHECK-LABEL: dpsec:
|
|
|
|
; CHECK: .long 0
|
|
|
|
@dpsec = global i32 0, section ".dp.namedsection"
|
2014-02-11 18:36:26 +08:00
|
|
|
|