aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/X86/asm-modifier-macho.ll
blob: b8da424bbaccade9ba8c052e287b3327f65fa8fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple=i386-apple-darwin9.6 < %s | FileCheck %s --check-prefixes=CHECK,X86
; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s --check-prefixes=CHECK,X64

define i32 @test1() nounwind {
; CHECK-LABEL: test1:
; CHECK:       ## %bb.0: ## %entry
; CHECK-NEXT:    ## InlineAsm Start
; CHECK-NEXT:    movw %gs:6, %ax
; CHECK-NEXT:    ## InlineAsm End
; CHECK-NEXT:    movzwl %ax, %eax
; CHECK-NEXT:    ret{{[l|q]}}
entry:
  %asmtmp.i = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 6) nounwind ; <i16> [#uses=1]
  %0 = zext i16 %asmtmp.i to i32                  ; <i32> [#uses=1]
  ret i32 %0
}

define zeroext i16 @test2(i32 %address) nounwind {
; X86-LABEL: test2:
; X86:       ## %bb.0: ## %entry
; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
; X86-NEXT:    ## InlineAsm Start
; X86-NEXT:    movw %gs:(%eax), %ax
; X86-NEXT:    ## InlineAsm End
; X86-NEXT:    movzwl %ax, %eax
; X86-NEXT:    retl
;
; X64-LABEL: test2:
; X64:       ## %bb.0: ## %entry
; X64-NEXT:    ## InlineAsm Start
; X64-NEXT:    movw %gs:(%edi), %ax
; X64-NEXT:    ## InlineAsm End
; X64-NEXT:    movzwl %ax, %eax
; X64-NEXT:    retq
entry:
  %asmtmp = tail call i16 asm "movw\09%gs:${1:a}, ${0:w}", "=r,ir,~{dirflag},~{fpsr},~{flags}"(i32 %address) nounwind ; <i16> [#uses=1]
  ret i16 %asmtmp
}

@n = global i32 42                                ; <ptr> [#uses=3]
@y = common global i32 0                          ; <ptr> [#uses=3]

define void @test3() nounwind {
; X86-LABEL: test3:
; X86:       ## %bb.0: ## %entry
; X86-NEXT:    ## InlineAsm Start
; X86-NEXT:    movl _n, %eax
; X86-NEXT:    ## InlineAsm End
; X86-NEXT:    retl
;
; X64-LABEL: test3:
; X64:       ## %bb.0: ## %entry
; X64-NEXT:    ## InlineAsm Start
; X64-NEXT:    movl _n(%rip), %eax
; X64-NEXT:    ## InlineAsm End
; X64-NEXT:    retq
entry:
  call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @n) nounwind
  ret void
}

define void @test4() nounwind {
; X86-LABEL: test4:
; X86:       ## %bb.0: ## %entry
; X86-NEXT:    movl L_y$non_lazy_ptr, %ecx
; X86-NEXT:    ## InlineAsm Start
; X86-NEXT:    movl (%ecx), %eax
; X86-NEXT:    ## InlineAsm End
; X86-NEXT:    retl
;
; X64-LABEL: test4:
; X64:       ## %bb.0: ## %entry
; X64-NEXT:    movq _y@GOTPCREL(%rip), %rcx
; X64-NEXT:    ## InlineAsm Start
; X64-NEXT:    movl (%rcx), %eax
; X64-NEXT:    ## InlineAsm End
; X64-NEXT:    retq
entry:
  call void asm sideeffect "movl ${0:a}, %eax", "ir,~{dirflag},~{fpsr},~{flags},~{eax}"(ptr @y) nounwind
  ret void
}