2017-08-02 08:28:10 +08:00
|
|
|
; RUN: llc < %s -mtriple=i686-- -mcpu=core2 -no-integrated-as | FileCheck %s
|
2012-09-11 05:10:49 +08:00
|
|
|
|
|
|
|
define i32 @t1() nounwind {
|
|
|
|
entry:
|
2012-09-12 00:33:10 +08:00
|
|
|
%0 = tail call i32 asm sideeffect inteldialect "mov eax, $1\0A\09mov $0, eax", "=r,r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32 1) nounwind
|
2012-09-11 05:10:49 +08:00
|
|
|
ret i32 %0
|
2012-09-11 05:31:43 +08:00
|
|
|
; CHECK: t1
|
2012-09-11 06:04:54 +08:00
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
2012-09-11 05:36:05 +08:00
|
|
|
; CHECK: .intel_syntax
|
2012-09-11 05:10:49 +08:00
|
|
|
; CHECK: mov eax, ecx
|
|
|
|
; CHECK: mov ecx, eax
|
2012-09-11 05:36:05 +08:00
|
|
|
; CHECK: .att_syntax
|
2012-09-11 06:04:54 +08:00
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
2012-09-11 05:10:49 +08:00
|
|
|
}
|
2012-09-12 03:09:56 +08:00
|
|
|
|
|
|
|
define void @t2() nounwind {
|
|
|
|
entry:
|
|
|
|
call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
|
|
|
|
ret void
|
|
|
|
; CHECK: t2
|
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
|
|
|
; CHECK: .intel_syntax
|
|
|
|
; CHECK: mov eax, 1
|
|
|
|
; CHECK: .att_syntax
|
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
|
|
|
}
|
2012-10-04 06:06:44 +08:00
|
|
|
|
|
|
|
define void @t3(i32 %V) nounwind {
|
|
|
|
entry:
|
|
|
|
%V.addr = alloca i32, align 4
|
|
|
|
store i32 %V, i32* %V.addr, align 4
|
|
|
|
call void asm sideeffect inteldialect "mov eax, DWORD PTR [$0]", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %V.addr) nounwind
|
|
|
|
ret void
|
|
|
|
; CHECK: t3
|
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
|
|
|
; CHECK: .intel_syntax
|
|
|
|
; CHECK: mov eax, DWORD PTR {{[[esp]}}
|
|
|
|
; CHECK: .att_syntax
|
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
|
|
|
}
|
2012-10-25 07:10:28 +08:00
|
|
|
|
|
|
|
%struct.t18_type = type { i32, i32 }
|
|
|
|
|
|
|
|
define i32 @t18() nounwind {
|
|
|
|
entry:
|
|
|
|
%foo = alloca %struct.t18_type, align 4
|
[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
|
|
|
%a = getelementptr inbounds %struct.t18_type, %struct.t18_type* %foo, i32 0, i32 0
|
2012-10-25 07:10:28 +08:00
|
|
|
store i32 1, i32* %a, align 4
|
[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
|
|
|
%b = getelementptr inbounds %struct.t18_type, %struct.t18_type* %foo, i32 0, i32 1
|
2012-10-25 07:10:28 +08:00
|
|
|
store i32 2, i32* %b, align 4
|
|
|
|
call void asm sideeffect inteldialect "lea ebx, foo\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
|
[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
|
|
|
%b1 = getelementptr inbounds %struct.t18_type, %struct.t18_type* %foo, i32 0, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32, i32* %b1, align 4
|
2012-10-25 07:10:28 +08:00
|
|
|
ret i32 %0
|
|
|
|
; CHECK: t18
|
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
|
|
|
; CHECK: .intel_syntax
|
|
|
|
; CHECK: lea ebx, foo
|
|
|
|
; CHECK: mov eax, [ebx].0
|
|
|
|
; CHECK: mov [ebx].4, ecx
|
|
|
|
; CHECK: .att_syntax
|
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
|
|
|
}
|
2013-01-11 06:10:27 +08:00
|
|
|
|
|
|
|
define void @t19_helper() nounwind {
|
|
|
|
entry:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @t19() nounwind {
|
|
|
|
entry:
|
|
|
|
call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(void ()* @t19_helper) nounwind
|
|
|
|
ret void
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: t19:
|
2013-01-11 07:02:48 +08:00
|
|
|
; CHECK: movl ${{_?}}t19_helper, %eax
|
2013-01-11 06:10:27 +08:00
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
|
|
|
; CHECK: .intel_syntax
|
|
|
|
; CHECK: call eax
|
|
|
|
; CHECK: .att_syntax
|
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
|
|
|
}
|
2013-02-14 05:33:44 +08:00
|
|
|
|
|
|
|
@results = global [2 x i32] [i32 3, i32 2], align 4
|
|
|
|
|
|
|
|
define i32* @t30() nounwind ssp {
|
|
|
|
entry:
|
|
|
|
%res = alloca i32*, align 4
|
|
|
|
call void asm sideeffect inteldialect "lea edi, dword ptr $0", "*m,~{edi},~{dirflag},~{fpsr},~{flags}"([2 x i32]* @results) nounwind
|
|
|
|
call void asm sideeffect inteldialect "mov dword ptr $0, edi", "=*m,~{dirflag},~{fpsr},~{flags}"(i32** %res) nounwind
|
2015-02-28 05:17:42 +08:00
|
|
|
%0 = load i32*, i32** %res, align 4
|
2013-02-14 05:33:44 +08:00
|
|
|
ret i32* %0
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: t30:
|
2013-02-14 05:33:44 +08:00
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
|
|
|
; CHECK: .intel_syntax
|
2019-12-31 03:33:56 +08:00
|
|
|
; CHECK: lea edi, dword ptr [offset {{_?}}results]
|
2013-02-14 05:33:44 +08:00
|
|
|
; CHECK: .att_syntax
|
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
|
|
|
; CHECK: .intel_syntax
|
2013-12-11 02:27:32 +08:00
|
|
|
; CHECK: mov dword ptr [esp], edi
|
|
|
|
; CHECK: .att_syntax
|
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
|
|
|
; CHECK: movl (%esp), %eax
|
|
|
|
}
|
|
|
|
|
|
|
|
; Stack realignment plus MS inline asm that does *not* adjust the stack is no
|
|
|
|
; longer an error.
|
|
|
|
|
|
|
|
define i32 @t31() {
|
|
|
|
entry:
|
|
|
|
%val = alloca i32, align 64
|
|
|
|
store i32 -1, i32* %val, align 64
|
2014-08-02 04:21:24 +08:00
|
|
|
call void asm sideeffect inteldialect "mov dword ptr $0, esp", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %val)
|
2015-02-28 05:17:42 +08:00
|
|
|
%sp = load i32, i32* %val, align 64
|
2013-12-11 02:27:32 +08:00
|
|
|
ret i32 %sp
|
|
|
|
; CHECK-LABEL: t31:
|
|
|
|
; CHECK: pushl %ebp
|
|
|
|
; CHECK: movl %esp, %ebp
|
|
|
|
; CHECK: andl $-64, %esp
|
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
|
|
|
; CHECK: .intel_syntax
|
|
|
|
; CHECK: mov dword ptr [esp], esp
|
2013-02-14 05:33:44 +08:00
|
|
|
; CHECK: .att_syntax
|
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
2013-12-11 02:27:32 +08:00
|
|
|
; CHECK: movl (%esp), %eax
|
|
|
|
; CHECK: ret
|
2013-02-14 05:33:44 +08:00
|
|
|
}
|
2014-08-02 04:21:24 +08:00
|
|
|
|
2016-11-29 08:29:27 +08:00
|
|
|
; Make sure ${:uid} works. Clang uses it for MS inline asm labels.
|
|
|
|
;
|
|
|
|
; C source:
|
|
|
|
; int uid() {
|
|
|
|
; int r;
|
|
|
|
; __asm {
|
|
|
|
; xor eax, eax
|
|
|
|
; wloop:
|
|
|
|
; inc eax
|
|
|
|
; cmp eax, 42
|
|
|
|
; jne wloop
|
|
|
|
; mov r, eax
|
|
|
|
; }
|
|
|
|
; return r;
|
|
|
|
; }
|
|
|
|
define i32 @uid() {
|
|
|
|
entry:
|
|
|
|
%r = alloca i32, align 4
|
|
|
|
%0 = bitcast i32* %r to i8*
|
|
|
|
call void asm sideeffect inteldialect "xor eax, eax\0A\09.L__MSASMLABEL_.${:uid}__wloop:\0A\09inc eax\0A\09cmp eax, $$42\0A\09jne .L__MSASMLABEL_.${:uid}__wloop\0A\09mov dword ptr $0, eax", "=*m,~{eax},~{flags},~{dirflag},~{fpsr},~{flags}"(i32* nonnull %r)
|
|
|
|
%1 = load i32, i32* %r, align 4
|
|
|
|
ret i32 %1
|
|
|
|
; CHECK-LABEL: uid:
|
|
|
|
; CHECK: {{## InlineAsm Start|#APP}}
|
|
|
|
; CHECK: .L__MSASMLABEL_.0__wloop:
|
|
|
|
; CHECK: jne .L__MSASMLABEL_.0__wloop
|
|
|
|
; CHECK: .att_syntax
|
|
|
|
; CHECK: {{## InlineAsm End|#NO_APP}}
|
|
|
|
; CHECK: ret
|
|
|
|
}
|
|
|
|
|
2014-08-02 05:54:37 +08:00
|
|
|
declare hidden void @other_func()
|
2014-08-02 04:21:24 +08:00
|
|
|
|
|
|
|
define void @naked() #0 {
|
|
|
|
call void asm sideeffect inteldialect "call dword ptr $0", "*m,~{eax},~{ebx},~{ecx},~{edx},~{edi},~{esi},~{esp},~{ebp},~{dirflag},~{fpsr},~{flags}"(void()* @other_func)
|
|
|
|
unreachable
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { naked }
|