Skip to content

Commit 7e60448

Browse files
committed
[test] Improve x86 inline asm tests
Reorganize *asm-modifier* and make other cleanups.
1 parent a5dc3f6 commit 7e60448

10 files changed

+99
-95
lines changed

llvm/test/CodeGen/X86/2007-10-28-inlineasm-q-modifier.ll

Lines changed: 0 additions & 11 deletions
This file was deleted.

llvm/test/CodeGen/X86/asm-modifier-error.ll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ entry:
77
ret void
88
}
99

10+
;CHECK: error: invalid operand in inline asm: 'vmovd ${1:k}, $0'
11+
define i32 @foo() {
12+
entry:
13+
%0 = tail call i32 asm sideeffect "vmovd ${1:k}, $0", "=r,x,~{dirflag},~{fpsr},~{flags}"(<2 x i64> <i64 240518168632, i64 240518168632>)
14+
ret i32 %0
15+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
; RUN: llc < %s | FileCheck %s
2+
; ModuleID = 'asm.c'
3+
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
4+
target triple = "i386-apple-darwin9.6"
5+
6+
define i32 @test1() nounwind {
7+
entry:
8+
; CHECK-LABEL: test1:
9+
; CHECK: movw %gs:6, %ax
10+
%asmtmp.i = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 6) nounwind ; <i16> [#uses=1]
11+
%0 = zext i16 %asmtmp.i to i32 ; <i32> [#uses=1]
12+
ret i32 %0
13+
}
14+
15+
define zeroext i16 @test2(i32 %address) nounwind {
16+
entry:
17+
; CHECK-LABEL: test2:
18+
; CHECK: movw %gs:(%eax), %ax
19+
%asmtmp = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 %address) nounwind ; <i16> [#uses=1]
20+
ret i16 %asmtmp
21+
}
22+
23+
@n = global i32 42 ; <ptr> [#uses=3]
24+
@y = common global i32 0 ; <ptr> [#uses=3]
25+
26+
define void @test3() nounwind {
27+
entry:
28+
; CHECK-LABEL: test3:
29+
; CHECK: movl _n, %eax
30+
call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @n) nounwind
31+
ret void
32+
}
33+
34+
define void @test4() nounwind {
35+
entry:
36+
; CHECK-LABEL: test4:
37+
; CHECK: movl L_y$non_lazy_ptr, %ecx
38+
; CHECK: movl (%ecx), %eax
39+
call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @y) nounwind
40+
ret void
41+
}

llvm/test/CodeGen/X86/asm-modifier.ll

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,64 @@
1-
; RUN: llc < %s | FileCheck %s
2-
; ModuleID = 'asm.c'
3-
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
4-
target triple = "i386-apple-darwin9.6"
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc -mtriple=i686 < %s | FileCheck %s --check-prefixes=CHECK,32
3+
; RUN: llc -mtriple=x86_64 < %s | FileCheck %s --check-prefixes=CHECK,64
54

6-
define i32 @test1() nounwind {
7-
entry:
8-
; CHECK-LABEL: test1:
9-
; CHECK: movw %gs:6, %ax
10-
%asmtmp.i = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 6) nounwind ; <i16> [#uses=1]
11-
%0 = zext i16 %asmtmp.i to i32 ; <i32> [#uses=1]
12-
ret i32 %0
13-
}
5+
@var = internal global i32 0, align 4
146

15-
define zeroext i16 @test2(i32 %address) nounwind {
16-
entry:
17-
; CHECK-LABEL: test2:
18-
; CHECK: movw %gs:(%eax), %ax
19-
%asmtmp = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 %address) nounwind ; <i16> [#uses=1]
20-
ret i16 %asmtmp
7+
define dso_local void @test_c() nounwind {
8+
; CHECK-LABEL: test_c:
9+
; CHECK: # %bb.0:
10+
; CHECK-NEXT: #APP
11+
; CHECK-NEXT: #TEST 42
12+
; CHECK-NEXT: #NO_APP
13+
; CHECK-NEXT: #APP
14+
; CHECK-NEXT: #TEST var
15+
; CHECK-NEXT: #NO_APP
16+
; CHECK-NEXT: ret{{[l|q]}}
17+
tail call void asm sideeffect "#TEST ${0:c}", "i"(i32 42)
18+
tail call void asm sideeffect "#TEST ${0:c}", "i"(ptr nonnull @var)
19+
ret void
2120
}
2221

23-
@n = global i32 42 ; <ptr> [#uses=3]
24-
@y = common global i32 0 ; <ptr> [#uses=3]
22+
define dso_local void @test_n() nounwind {
23+
; CHECK-LABEL: test_n:
24+
; CHECK: # %bb.0:
25+
; CHECK-NEXT: #APP
26+
; CHECK-NEXT: #TEST 37
27+
; CHECK-NEXT: #NO_APP
28+
; CHECK-NEXT: ret{{[l|q]}}
29+
tail call void asm sideeffect "#TEST ${0:n}", "i"(i32 -37)
30+
ret void
31+
}
2532

26-
define void @test3() nounwind {
33+
define void @test_q() {
34+
; CHECK-LABEL: test_q:
35+
; CHECK: # %bb.0: # %entry
36+
; CHECK-NEXT: #APP
37+
; CHECK-NEXT: #TEST 0
38+
; CHECK-NEXT: #NO_APP
39+
; CHECK-NEXT: ret{{[l|q]}}
2740
entry:
28-
; CHECK-LABEL: test3:
29-
; CHECK: movl _n, %eax
30-
call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @n) nounwind
41+
call void asm sideeffect "#TEST ${0:q}", "=*imr"( ptr elementtype( i64) null )
3142
ret void
3243
}
3344

34-
define void @test4() nounwind {
45+
define void @test_V(ptr %p) {
46+
; 32-LABEL: test_V:
47+
; 32: # %bb.0: # %entry
48+
; 32-NEXT: movl {{[0-9]+}}(%esp), %eax
49+
; 32-NEXT: #APP
50+
; 32-NEXT: calll __x86_indirect_thunk_eax
51+
; 32-NEXT: #NO_APP
52+
; 32-NEXT: retl
53+
;
54+
; 64-LABEL: test_V:
55+
; 64: # %bb.0: # %entry
56+
; 64-NEXT: #APP
57+
; 64-NEXT: callq __x86_indirect_thunk_rdi
58+
; 64-NEXT: #NO_APP
59+
; 64-NEXT: retq
3560
entry:
36-
; CHECK-LABEL: test4:
37-
; CHECK: movl L_y$non_lazy_ptr, %ecx
38-
; CHECK: movl (%ecx), %eax
39-
call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @y) nounwind
61+
tail call void asm sideeffect "call __x86_indirect_thunk_${0:V}", "r,~{dirflag},~{fpsr},~{flags}"(ptr %p)
4062
ret void
4163
}
64+

llvm/test/CodeGen/X86/inline-asm-bad-modifier.ll

Lines changed: 0 additions & 8 deletions
This file was deleted.

llvm/test/CodeGen/X86/inline-asm-modifier-V.ll

Lines changed: 0 additions & 14 deletions
This file was deleted.

llvm/test/CodeGen/X86/inline-asm-modifier-c.ll

Lines changed: 0 additions & 18 deletions
This file was deleted.

llvm/test/CodeGen/X86/inline-asm-modifier-n.ll

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)