NAKAMURA Takumi | cc59e91 | 2012-09-27 14:55:08 +0000 | [diff] [blame] | 1 | // REQUIRES: x86-64-registered-target |
Chad Rosier | b2e2157 | 2013-01-22 19:38:32 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 %s -triple i386-apple-darwin10 -O0 -fasm-blocks -emit-llvm -o - | FileCheck %s |
Chad Rosier | 25bc47e | 2012-10-19 20:38:09 +0000 | [diff] [blame] | 3 | |
Chad Rosier | b64f310 | 2012-08-08 20:37:31 +0000 | [diff] [blame] | 4 | void t1() { |
| 5 | // CHECK: @t1 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 6 | // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() [[NUW:#[0-9]+]] |
Chad Rosier | b64f310 | 2012-08-08 20:37:31 +0000 | [diff] [blame] | 7 | // CHECK: ret void |
| 8 | __asm {} |
| 9 | } |
Chad Rosier | 265f538 | 2012-08-13 20:32:07 +0000 | [diff] [blame] | 10 | |
| 11 | void t2() { |
| 12 | // CHECK: @t2 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 13 | // CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 14 | // CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 15 | // CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 265f538 | 2012-08-13 20:32:07 +0000 | [diff] [blame] | 16 | // CHECK: ret void |
| 17 | __asm nop |
| 18 | __asm nop |
| 19 | __asm nop |
| 20 | } |
| 21 | |
| 22 | void t3() { |
| 23 | // CHECK: @t3 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 24 | // CHECK: call void asm sideeffect inteldialect "nop\0A\09nop\0A\09nop", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 265f538 | 2012-08-13 20:32:07 +0000 | [diff] [blame] | 25 | // CHECK: ret void |
| 26 | __asm nop __asm nop __asm nop |
| 27 | } |
| 28 | |
| 29 | void t4(void) { |
| 30 | // CHECK: @t4 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 31 | // CHECK: call void asm sideeffect inteldialect "mov ebx, eax", "~{ebx},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 32 | // CHECK: call void asm sideeffect inteldialect "mov ecx, ebx", "~{ecx},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 265f538 | 2012-08-13 20:32:07 +0000 | [diff] [blame] | 33 | // CHECK: ret void |
| 34 | __asm mov ebx, eax |
| 35 | __asm mov ecx, ebx |
| 36 | } |
| 37 | |
| 38 | void t5(void) { |
| 39 | // CHECK: @t5 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 40 | // CHECK: call void asm sideeffect inteldialect "mov ebx, eax\0A\09mov ecx, ebx", "~{ebx},~{ecx},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 265f538 | 2012-08-13 20:32:07 +0000 | [diff] [blame] | 41 | // CHECK: ret void |
| 42 | __asm mov ebx, eax __asm mov ecx, ebx |
| 43 | } |
Chad Rosier | 27ef16b | 2012-08-14 23:48:41 +0000 | [diff] [blame] | 44 | |
| 45 | void t6(void) { |
| 46 | __asm int 0x2c |
| 47 | // CHECK: t6 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 48 | // CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 27ef16b | 2012-08-14 23:48:41 +0000 | [diff] [blame] | 49 | } |
| 50 | |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 51 | void t7() { |
Chad Rosier | 27ef16b | 2012-08-14 23:48:41 +0000 | [diff] [blame] | 52 | __asm { |
| 53 | int 0x2c ; } asm comments are fun! }{ |
| 54 | } |
| 55 | __asm {} |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 56 | // CHECK: t7 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 57 | // CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 58 | // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 27ef16b | 2012-08-14 23:48:41 +0000 | [diff] [blame] | 59 | } |
Chad Rosier | ac9289d | 2012-10-02 20:55:30 +0000 | [diff] [blame] | 60 | |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 61 | int t8() { |
Chad Rosier | d9b56ed | 2012-10-15 19:56:10 +0000 | [diff] [blame] | 62 | __asm int 4 ; } comments for single-line asm |
Chad Rosier | 27ef16b | 2012-08-14 23:48:41 +0000 | [diff] [blame] | 63 | __asm {} |
| 64 | __asm int 4 |
| 65 | return 10; |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 66 | // CHECK: t8 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 67 | // CHECK: call void asm sideeffect inteldialect "int $$4", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 68 | // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 69 | // CHECK: call void asm sideeffect inteldialect "int $$4", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 27ef16b | 2012-08-14 23:48:41 +0000 | [diff] [blame] | 70 | // CHECK: ret i32 10 |
| 71 | } |
Chad Rosier | ac9289d | 2012-10-02 20:55:30 +0000 | [diff] [blame] | 72 | |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 73 | void t9() { |
Chad Rosier | 27ef16b | 2012-08-14 23:48:41 +0000 | [diff] [blame] | 74 | __asm { |
| 75 | push ebx |
| 76 | mov ebx, 0x07 |
| 77 | pop ebx |
| 78 | } |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 79 | // CHECK: t9 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 80 | // CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx", "~{ebx},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 27ef16b | 2012-08-14 23:48:41 +0000 | [diff] [blame] | 81 | } |
Chad Rosier | f64c118 | 2012-08-16 17:10:59 +0000 | [diff] [blame] | 82 | |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 83 | unsigned t10(void) { |
Chad Rosier | f64c118 | 2012-08-16 17:10:59 +0000 | [diff] [blame] | 84 | unsigned i = 1, j; |
| 85 | __asm { |
| 86 | mov eax, i |
| 87 | mov j, eax |
| 88 | } |
| 89 | return j; |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 90 | // CHECK: t10 |
Chad Rosier | f64c118 | 2012-08-16 17:10:59 +0000 | [diff] [blame] | 91 | // CHECK: [[I:%[a-zA-Z0-9]+]] = alloca i32, align 4 |
| 92 | // CHECK: [[J:%[a-zA-Z0-9]+]] = alloca i32, align 4 |
| 93 | // CHECK: store i32 1, i32* [[I]], align 4 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 94 | // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $1\0A\09mov dword ptr $0, eax", "=*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}) [[NUW]] |
Chad Rosier | f64c118 | 2012-08-16 17:10:59 +0000 | [diff] [blame] | 95 | // CHECK: [[RET:%[a-zA-Z0-9]+]] = load i32* [[J]], align 4 |
| 96 | // CHECK: ret i32 [[RET]] |
| 97 | } |
Chad Rosier | 700ce64 | 2012-08-16 22:25:38 +0000 | [diff] [blame] | 98 | |
Chad Rosier | 7fcde17 | 2012-08-21 17:01:26 +0000 | [diff] [blame] | 99 | void t11(void) { |
Chad Rosier | 4de9716 | 2012-09-11 00:51:28 +0000 | [diff] [blame] | 100 | __asm mov eax, 1 |
Chad Rosier | fba3fb9 | 2012-10-12 21:37:00 +0000 | [diff] [blame] | 101 | // CHECK: t11 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 102 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 4de9716 | 2012-09-11 00:51:28 +0000 | [diff] [blame] | 103 | } |
Chad Rosier | 7f9678b | 2012-09-12 18:14:25 +0000 | [diff] [blame] | 104 | |
Chad Rosier | fba3fb9 | 2012-10-12 21:37:00 +0000 | [diff] [blame] | 105 | unsigned t12(void) { |
Chad Rosier | b55e602 | 2012-09-13 00:06:55 +0000 | [diff] [blame] | 106 | unsigned i = 1, j, l = 1, m; |
| 107 | __asm { |
| 108 | mov eax, i |
| 109 | mov j, eax |
| 110 | mov eax, l |
| 111 | mov m, eax |
| 112 | } |
| 113 | return j + m; |
Chad Rosier | fba3fb9 | 2012-10-12 21:37:00 +0000 | [diff] [blame] | 114 | // CHECK: t12 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 115 | // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $2\0A\09mov dword ptr $0, eax\0A\09mov eax, dword ptr $3\0A\09mov dword ptr $1, eax", "=*m,=*m,*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}) [[NUW]] |
Chad Rosier | 362b18c | 2012-10-19 20:57:37 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | void t13() { |
| 119 | char i = 1; |
| 120 | short j = 2; |
| 121 | __asm movzx eax, i |
| 122 | __asm movzx eax, j |
| 123 | // CHECK: t13 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 124 | // CHECK: call void asm sideeffect inteldialect "movzx eax, byte ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i8* %{{.*}}) [[NUW]] |
| 125 | // CHECK: call void asm sideeffect inteldialect "movzx eax, word ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i16* %{{.*}}) [[NUW]] |
Chad Rosier | b55e602 | 2012-09-13 00:06:55 +0000 | [diff] [blame] | 126 | } |
Chad Rosier | b0850b3 | 2012-10-19 23:16:17 +0000 | [diff] [blame] | 127 | |
| 128 | void t14() { |
| 129 | unsigned i = 1, j = 2; |
| 130 | __asm { |
| 131 | .if 1 |
| 132 | mov eax, i |
| 133 | .else |
| 134 | mov ebx, j |
| 135 | .endif |
| 136 | } |
| 137 | // CHECK: t14 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 138 | // CHECK: call void asm sideeffect inteldialect ".if 1\0A\09mov eax, dword ptr $0\0A\09.else\0A\09mov ebx, j\0A\09.endif", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) [[NUW]] |
Chad Rosier | b0850b3 | 2012-10-19 23:16:17 +0000 | [diff] [blame] | 139 | } |
Chad Rosier | 5a12aca | 2012-10-22 19:43:17 +0000 | [diff] [blame] | 140 | |
Chad Rosier | 6949ab1 | 2013-01-08 23:51:48 +0000 | [diff] [blame] | 141 | int gvar = 10; |
Chad Rosier | 5a12aca | 2012-10-22 19:43:17 +0000 | [diff] [blame] | 142 | void t15() { |
Chad Rosier | 6949ab1 | 2013-01-08 23:51:48 +0000 | [diff] [blame] | 143 | int lvar = 10; |
| 144 | __asm mov eax, lvar ; eax = 10 |
| 145 | __asm mov eax, offset lvar ; eax = address of lvar |
| 146 | __asm mov eax, offset gvar ; eax = address of gvar |
Chad Rosier | 5a12aca | 2012-10-22 19:43:17 +0000 | [diff] [blame] | 147 | // CHECK: t15 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 148 | // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) [[NUW]] |
| 149 | // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) [[NUW]] |
| 150 | // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* @{{.*}}) [[NUW]] |
Chad Rosier | 5a12aca | 2012-10-22 19:43:17 +0000 | [diff] [blame] | 151 | } |
Chad Rosier | 4224255 | 2012-10-24 17:23:06 +0000 | [diff] [blame] | 152 | |
| 153 | void t16() { |
| 154 | int var = 10; |
| 155 | __asm mov [eax], offset var |
| 156 | // CHECK: t16 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 157 | // CHECK: call void asm sideeffect inteldialect "mov [eax], $0", "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) [[NUW]] |
Chad Rosier | 4224255 | 2012-10-24 17:23:06 +0000 | [diff] [blame] | 158 | } |
Chad Rosier | 1bed9b7 | 2012-10-24 17:48:01 +0000 | [diff] [blame] | 159 | |
| 160 | void t17() { |
| 161 | __asm _emit 0x4A |
| 162 | __asm _emit 0x43 |
| 163 | __asm _emit 0x4B |
Chad Rosier | 7243b0f | 2013-02-12 21:34:14 +0000 | [diff] [blame] | 164 | __asm _EMIT 0x4B |
Chad Rosier | 1bed9b7 | 2012-10-24 17:48:01 +0000 | [diff] [blame] | 165 | // CHECK: t17 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 166 | // CHECK: call void asm sideeffect inteldialect ".byte 0x4A", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 167 | // CHECK: call void asm sideeffect inteldialect ".byte 0x43", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 168 | // CHECK: call void asm sideeffect inteldialect ".byte 0x4B", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 169 | // CHECK: call void asm sideeffect inteldialect ".byte 0x4B", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 1bed9b7 | 2012-10-24 17:48:01 +0000 | [diff] [blame] | 170 | } |
Chad Rosier | f742727 | 2012-10-24 22:22:12 +0000 | [diff] [blame] | 171 | |
| 172 | struct t18_type { int a, b; }; |
| 173 | |
| 174 | int t18() { |
| 175 | struct t18_type foo; |
| 176 | foo.a = 1; |
| 177 | foo.b = 2; |
| 178 | __asm { |
| 179 | lea ebx, foo |
| 180 | mov eax, [ebx].0 |
| 181 | mov [ebx].4, ecx |
| 182 | } |
| 183 | return foo.b; |
| 184 | // CHECK: t18 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 185 | // CHECK: call void asm sideeffect inteldialect "lea ebx, foo\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | f742727 | 2012-10-24 22:22:12 +0000 | [diff] [blame] | 186 | } |
Chad Rosier | d2e7d20 | 2012-10-25 21:52:03 +0000 | [diff] [blame] | 187 | |
| 188 | int t19() { |
| 189 | struct t18_type foo; |
| 190 | foo.a = 1; |
| 191 | foo.b = 2; |
| 192 | __asm { |
| 193 | lea ebx, foo |
| 194 | mov eax, [ebx].foo.a |
| 195 | mov [ebx].foo.b, ecx |
| 196 | } |
| 197 | return foo.b; |
| 198 | // CHECK: t19 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 199 | // CHECK: call void asm sideeffect inteldialect "lea ebx, foo\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | d2e7d20 | 2012-10-25 21:52:03 +0000 | [diff] [blame] | 200 | } |
Chad Rosier | da5c3b7 | 2012-10-26 18:04:45 +0000 | [diff] [blame] | 201 | |
| 202 | void t20() { |
Chad Rosier | 205ecf0 | 2013-01-17 19:22:48 +0000 | [diff] [blame] | 203 | char bar; |
Chad Rosier | da5c3b7 | 2012-10-26 18:04:45 +0000 | [diff] [blame] | 204 | int foo; |
Chad Rosier | 205ecf0 | 2013-01-17 19:22:48 +0000 | [diff] [blame] | 205 | char _bar[2]; |
| 206 | int _foo[4]; |
| 207 | |
| 208 | __asm mov eax, LENGTH foo |
| 209 | __asm mov eax, LENGTH bar |
| 210 | __asm mov eax, LENGTH _foo |
| 211 | __asm mov eax, LENGTH _bar |
Chad Rosier | da5c3b7 | 2012-10-26 18:04:45 +0000 | [diff] [blame] | 212 | // CHECK: t20 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 213 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 214 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 215 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 216 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 205ecf0 | 2013-01-17 19:22:48 +0000 | [diff] [blame] | 217 | |
| 218 | __asm mov eax, TYPE foo |
| 219 | __asm mov eax, TYPE bar |
| 220 | __asm mov eax, TYPE _foo |
| 221 | __asm mov eax, TYPE _bar |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 222 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 223 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 224 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 225 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 205ecf0 | 2013-01-17 19:22:48 +0000 | [diff] [blame] | 226 | |
| 227 | __asm mov eax, SIZE foo |
| 228 | __asm mov eax, SIZE bar |
| 229 | __asm mov eax, SIZE _foo |
| 230 | __asm mov eax, SIZE _bar |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 231 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 232 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 233 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$16", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 234 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | da5c3b7 | 2012-10-26 18:04:45 +0000 | [diff] [blame] | 235 | } |
Chad Rosier | e0c0196 | 2012-12-05 19:52:05 +0000 | [diff] [blame] | 236 | |
Chad Rosier | e0c0196 | 2012-12-05 19:52:05 +0000 | [diff] [blame] | 237 | void t21() { |
| 238 | __asm { |
| 239 | __asm push ebx |
| 240 | __asm mov ebx, 0x07 |
| 241 | __asm pop ebx |
| 242 | } |
| 243 | // CHECK: t21 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 244 | // CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx", "~{ebx},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | e0c0196 | 2012-12-05 19:52:05 +0000 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | extern void t22_helper(int x); |
| 248 | void t22() { |
| 249 | int x = 0; |
| 250 | __asm { |
| 251 | __asm push ebx |
| 252 | __asm mov ebx, esp |
| 253 | } |
| 254 | t22_helper(x); |
| 255 | __asm { |
| 256 | __asm mov esp, ebx |
| 257 | __asm pop ebx |
| 258 | } |
| 259 | // CHECK: t22 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 260 | // CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, esp", "~{ebx},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | e0c0196 | 2012-12-05 19:52:05 +0000 | [diff] [blame] | 261 | // CHECK: call void @t22_helper |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 262 | // CHECK: call void asm sideeffect inteldialect "mov esp, ebx\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | e0c0196 | 2012-12-05 19:52:05 +0000 | [diff] [blame] | 263 | } |
Chad Rosier | 7520fca | 2013-01-07 20:34:40 +0000 | [diff] [blame] | 264 | |
| 265 | void t23() { |
| 266 | __asm { |
| 267 | the_label: |
| 268 | } |
| 269 | // CHECK: t23 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 270 | // CHECK: call void asm sideeffect inteldialect "the_label:", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 7520fca | 2013-01-07 20:34:40 +0000 | [diff] [blame] | 271 | } |
Chad Rosier | 3731a41 | 2013-01-10 22:11:28 +0000 | [diff] [blame] | 272 | |
| 273 | void t24_helper(void) {} |
| 274 | void t24() { |
| 275 | __asm call t24_helper |
| 276 | // CHECK: t24 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 277 | // CHECK: call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(void ()* @t24_helper) [[NUW]] |
Chad Rosier | 3731a41 | 2013-01-10 22:11:28 +0000 | [diff] [blame] | 278 | } |
Chad Rosier | 8e70b00 | 2013-02-12 18:45:21 +0000 | [diff] [blame] | 279 | |
| 280 | void t25() { |
| 281 | __asm mov eax, 0ffffffffh |
| 282 | __asm mov eax, 0fh |
| 283 | __asm mov eax, 0a2h |
| 284 | __asm mov eax, 0xa2h |
| 285 | __asm mov eax, 0xa2 |
| 286 | // CHECK: t25 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 287 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$0ffffffffh", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 288 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$0fh", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 289 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$0a2h", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 290 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$0xa2h", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 291 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$0xa2", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 8e70b00 | 2013-02-12 18:45:21 +0000 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | void t26() { |
| 295 | __asm pushad |
| 296 | __asm mov eax, 0 |
| 297 | __asm __emit 0fh |
| 298 | __asm __emit 0a2h |
Chad Rosier | 7243b0f | 2013-02-12 21:34:14 +0000 | [diff] [blame] | 299 | __asm __EMIT 0a2h |
Chad Rosier | 8e70b00 | 2013-02-12 18:45:21 +0000 | [diff] [blame] | 300 | __asm popad |
| 301 | // CHECK: t26 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 302 | // CHECK: call void asm sideeffect inteldialect "pushad", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 303 | // CHECK: call void asm sideeffect inteldialect "mov eax, $$0", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 304 | // CHECK: call void asm sideeffect inteldialect ".byte 0fh", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 305 | // CHECK: call void asm sideeffect inteldialect ".byte 0a2h", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 306 | // CHECK: call void asm sideeffect inteldialect ".byte 0a2h", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 307 | // CHECK: call void asm sideeffect inteldialect "popad", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 8e70b00 | 2013-02-12 18:45:21 +0000 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | void t27() { |
| 311 | __asm mov eax, fs:[0h] |
| 312 | // CHECK: t27 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 313 | // CHECK: call void asm sideeffect inteldialect "mov eax, fs:[0h]", "~{eax},~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 8e70b00 | 2013-02-12 18:45:21 +0000 | [diff] [blame] | 314 | } |
Chad Rosier | 7243b0f | 2013-02-12 21:34:14 +0000 | [diff] [blame] | 315 | |
| 316 | void t28() { |
| 317 | __asm align 8 |
| 318 | __asm align 16; |
| 319 | __asm align 128; |
| 320 | __asm ALIGN 256; |
| 321 | // CHECK: t28 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 322 | // CHECK: call void asm sideeffect inteldialect ".align 3", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 323 | // CHECK: call void asm sideeffect inteldialect ".align 4", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 324 | // CHECK: call void asm sideeffect inteldialect ".align 7", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 325 | // CHECK: call void asm sideeffect inteldialect ".align 8", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
Chad Rosier | 7243b0f | 2013-02-12 21:34:14 +0000 | [diff] [blame] | 326 | } |
Chad Rosier | 74992c4 | 2013-02-13 01:06:08 +0000 | [diff] [blame] | 327 | |
| 328 | void t29() { |
| 329 | int arr[2] = {0, 0}; |
| 330 | int olen = 0, osize = 0, otype = 0; |
| 331 | __asm mov olen, LENGTH arr |
| 332 | __asm mov osize, SIZE arr |
| 333 | __asm mov otype, TYPE arr |
| 334 | // CHECK: t29 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 335 | // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$2", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) [[NUW]] |
| 336 | // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$8", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) [[NUW]] |
| 337 | // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$4", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) [[NUW]] |
Chad Rosier | 74992c4 | 2013-02-13 01:06:08 +0000 | [diff] [blame] | 338 | } |
Chad Rosier | d8d7f5f | 2013-02-13 21:34:54 +0000 | [diff] [blame] | 339 | |
| 340 | int results[2] = {13, 37}; |
| 341 | int *t30() |
| 342 | { |
| 343 | int *res; |
| 344 | __asm lea edi, results |
| 345 | __asm mov res, edi |
| 346 | return res; |
| 347 | // CHECK: t30 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 348 | // CHECK: call void asm sideeffect inteldialect "lea edi, dword ptr $0", "*m,~{edi},~{dirflag},~{fpsr},~{flags}"([2 x i32]* @{{.*}}) [[NUW]] |
| 349 | // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, edi", "=*m,~{dirflag},~{fpsr},~{flags}"(i32** %{{.*}}) [[NUW]] |
Chad Rosier | d8d7f5f | 2013-02-13 21:34:54 +0000 | [diff] [blame] | 350 | } |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 351 | |
Chad Rosier | 59c9003 | 2013-02-25 19:13:23 +0000 | [diff] [blame^] | 352 | void t31() { |
| 353 | __asm pushad |
| 354 | __asm popad |
| 355 | // CHECK: t31 |
| 356 | // CHECK: call void asm sideeffect inteldialect "pushad", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 357 | // CHECK: call void asm sideeffect inteldialect "popad", "~{dirflag},~{fpsr},~{flags}"() [[NUW]] |
| 358 | } |
| 359 | |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 360 | // CHECK: attributes [[NUW]] = { nounwind } |