Home | History | Annotate | Download | only in CodeGen
      1 // REQUIRES: x86-registered-target
      2 // RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s
      3 
      4 void t1() {
      5 // CHECK: @t1
      6 // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"()
      7 // CHECK: ret void
      8   __asm {}
      9 }
     10 
     11 void t2() {
     12 // CHECK: @t2
     13 // CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"()
     14 // CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"()
     15 // CHECK: call void asm sideeffect inteldialect "nop", "~{dirflag},~{fpsr},~{flags}"()
     16 // CHECK: ret void
     17   __asm nop
     18   __asm nop
     19   __asm nop
     20 }
     21 
     22 void t3() {
     23 // CHECK: @t3
     24 // CHECK: call void asm sideeffect inteldialect "nop\0A\09nop\0A\09nop", "~{dirflag},~{fpsr},~{flags}"()
     25 // CHECK: ret void
     26   __asm nop __asm nop __asm nop
     27 }
     28 
     29 void t4(void) {
     30 // CHECK: @t4
     31 // CHECK: call void asm sideeffect inteldialect "mov ebx, eax", "~{ebx},~{dirflag},~{fpsr},~{flags}"()
     32 // CHECK: call void asm sideeffect inteldialect "mov ecx, ebx", "~{ecx},~{dirflag},~{fpsr},~{flags}"()
     33 // CHECK: ret void
     34   __asm mov ebx, eax
     35   __asm mov ecx, ebx
     36 }
     37 
     38 void t5(void) {
     39 // CHECK: @t5
     40 // CHECK: call void asm sideeffect inteldialect "mov ebx, eax\0A\09mov ecx, ebx", "~{ebx},~{ecx},~{dirflag},~{fpsr},~{flags}"()
     41 // CHECK: ret void
     42   __asm mov ebx, eax __asm mov ecx, ebx
     43 }
     44 
     45 void t6(void) {
     46   __asm int 0x2c
     47 // CHECK: t6
     48 // CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"()
     49 }
     50 
     51 void t7() {
     52   __asm {
     53     int 0x2c ; } asm comments are fun! }{
     54   }
     55   __asm {
     56     {
     57       int 0x2c ; } asm comments are fun! }{
     58     }
     59   }
     60   __asm {}
     61 // CHECK: t7
     62 // CHECK: call void asm sideeffect inteldialect "int $$0x2c", "~{dirflag},~{fpsr},~{flags}"()
     63 // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"()
     64 }
     65 
     66 int t8() {
     67   __asm int 4 ; } comments for single-line asm
     68   __asm {}
     69   __asm int 4
     70   return 10;
     71 // CHECK: t8
     72 // CHECK: call void asm sideeffect inteldialect "int $$4", "~{dirflag},~{fpsr},~{flags}"()
     73 // CHECK: call void asm sideeffect inteldialect "", "~{dirflag},~{fpsr},~{flags}"()
     74 // CHECK: call void asm sideeffect inteldialect "int $$4", "~{dirflag},~{fpsr},~{flags}"()
     75 // CHECK: ret i32 10
     76 }
     77 
     78 void t9() {
     79   __asm {
     80     push ebx
     81     { mov ebx, 0x07 }
     82     __asm { pop ebx }
     83   }
     84 // CHECK: t9
     85 // CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
     86 }
     87 
     88 unsigned t10(void) {
     89   unsigned i = 1, j;
     90   __asm {
     91     mov eax, i
     92     mov j, eax
     93   }
     94   return j;
     95 // CHECK: t10
     96 // CHECK: [[I:%[a-zA-Z0-9]+]] = alloca i32, align 4
     97 // CHECK: [[J:%[a-zA-Z0-9]+]] = alloca i32, align 4
     98 // CHECK: store i32 1, i32* [[I]], align 4
     99 // 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* %{{.*}})
    100 // CHECK: [[RET:%[a-zA-Z0-9]+]] = load i32* [[J]], align 4
    101 // CHECK: ret i32 [[RET]]
    102 }
    103 
    104 void t11(void) {
    105   __asm mov eax, 1
    106 // CHECK: t11
    107 // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    108 }
    109 
    110 unsigned t12(void) {
    111   unsigned i = 1, j, l = 1, m;
    112   __asm {
    113     mov eax, i
    114     mov j, eax
    115     mov eax, l
    116     mov m, eax
    117   }
    118   return j + m;
    119 // CHECK: t12
    120 // 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* %{{.*}})
    121 }
    122 
    123 void t13() {
    124   char i = 1;
    125   short j = 2;
    126   __asm movzx eax, i
    127   __asm movzx eax, j
    128 // CHECK: t13
    129 // CHECK: call void asm sideeffect inteldialect "movzx eax, byte ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i8* %{{.*}})
    130 // CHECK: call void asm sideeffect inteldialect "movzx eax, word ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i16* %{{.*}})
    131 }
    132 
    133 void t14() {
    134   unsigned i = 1, j = 2;
    135   __asm {
    136     .if 1
    137     { mov eax, i }
    138     .else
    139     mov ebx, j
    140     .endif
    141   }
    142 // CHECK: t14
    143 // 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* %{{.*}})
    144 }
    145 
    146 int gvar = 10;
    147 void t15() {
    148   int lvar = 10;
    149   __asm mov eax, lvar        ; eax = 10
    150   __asm mov eax, offset lvar ; eax = address of lvar
    151   __asm mov eax, offset gvar ; eax = address of gvar
    152 // CHECK: t15
    153 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    154 // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    155 // CHECK: call void asm sideeffect inteldialect "mov eax, $0", "r,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* @{{.*}})
    156 }
    157 
    158 void t16() {
    159   int var = 10;
    160   __asm mov [eax], offset var
    161 // CHECK: t16
    162 // CHECK: call void asm sideeffect inteldialect "mov [eax], $0", "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    163 }
    164 
    165 void t17() {
    166   __asm _emit 0x4A
    167   __asm _emit 0x43
    168   __asm _emit 0x4B
    169   __asm _EMIT 0x4B
    170 // CHECK: t17
    171 // CHECK:  call void asm sideeffect inteldialect ".byte 0x4A", "~{dirflag},~{fpsr},~{flags}"()
    172 // CHECK:  call void asm sideeffect inteldialect ".byte 0x43", "~{dirflag},~{fpsr},~{flags}"()
    173 // CHECK:  call void asm sideeffect inteldialect ".byte 0x4B", "~{dirflag},~{fpsr},~{flags}"()
    174 // CHECK:  call void asm sideeffect inteldialect ".byte 0x4B", "~{dirflag},~{fpsr},~{flags}"()
    175 }
    176 
    177 void t20() {
    178   char bar;
    179   int foo;
    180   char _bar[2];
    181   int _foo[4];
    182 
    183   __asm mov eax, LENGTH foo
    184   __asm mov eax, LENGTH bar
    185   __asm mov eax, LENGTH _foo
    186   __asm mov eax, LENGTH _bar
    187 // CHECK: t20
    188 // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    189 // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    190 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    191 // CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    192 
    193   __asm mov eax, TYPE foo
    194   __asm mov eax, TYPE bar
    195   __asm mov eax, TYPE _foo
    196   __asm mov eax, TYPE _bar
    197 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    198 // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    199 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    200 // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    201 
    202   __asm mov eax, SIZE foo
    203   __asm mov eax, SIZE bar
    204   __asm mov eax, SIZE _foo
    205   __asm mov eax, SIZE _bar
    206 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    207 // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    208 // CHECK: call void asm sideeffect inteldialect "mov eax, $$16", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    209 // CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    210 }
    211 
    212 void t21() {
    213   __asm {
    214     __asm push ebx
    215     __asm mov ebx, 0x07
    216     __asm pop ebx
    217   }
    218 // CHECK: t21
    219 // CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, $$0x07\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
    220 }
    221 
    222 extern void t22_helper(int x);
    223 void t22() {
    224   int x = 0;
    225   __asm {
    226     __asm push ebx
    227     __asm mov ebx, esp
    228   }
    229   t22_helper(x);
    230   __asm {
    231     __asm mov esp, ebx
    232     __asm pop ebx
    233   }
    234 // CHECK: t22
    235 // CHECK: call void asm sideeffect inteldialect "push ebx\0A\09mov ebx, esp", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
    236 // CHECK: call void @t22_helper
    237 // CHECK: call void asm sideeffect inteldialect "mov esp, ebx\0A\09pop ebx", "~{ebx},~{esp},~{dirflag},~{fpsr},~{flags}"()
    238 }
    239 
    240 void t23() {
    241   __asm {
    242   the_label:
    243   }
    244 // CHECK: t23
    245 // CHECK: call void asm sideeffect inteldialect "the_label:", "~{dirflag},~{fpsr},~{flags}"()
    246 }
    247 
    248 void t24_helper(void) {}
    249 void t24() {
    250   __asm call t24_helper
    251 // CHECK: t24
    252 // CHECK: call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(void ()* @t24_helper)
    253 }
    254 
    255 void t25() {
    256   __asm mov eax, 0ffffffffh
    257   __asm mov eax, 0fh
    258   __asm mov eax, 0a2h
    259   __asm mov eax, 0xa2h
    260   __asm mov eax, 0xa2
    261 // CHECK: t25
    262 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4294967295", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    263 // CHECK: call void asm sideeffect inteldialect "mov eax, $$15", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    264 // CHECK: call void asm sideeffect inteldialect "mov eax, $$162", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    265 // CHECK: call void asm sideeffect inteldialect "mov eax, $$0xa2h", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    266 // CHECK: call void asm sideeffect inteldialect "mov eax, $$0xa2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    267 }
    268 
    269 void t26() {
    270   __asm pushad
    271   __asm mov eax, 0
    272   __asm __emit 0fh
    273   __asm __emit 0a2h
    274   __asm __EMIT 0a2h
    275   __asm popad
    276 // FIXME: These all need to be merged into the same asm blob.
    277 // CHECK: t26
    278 // CHECK: call void asm sideeffect inteldialect "pushad", "~{esp},~{dirflag},~{fpsr},~{flags}"()
    279 // CHECK: call void asm sideeffect inteldialect "mov eax, $$0", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    280 // CHECK: call void asm sideeffect inteldialect ".byte 0fh", "~{dirflag},~{fpsr},~{flags}"()
    281 // CHECK: call void asm sideeffect inteldialect ".byte 0a2h", "~{dirflag},~{fpsr},~{flags}"()
    282 // CHECK: call void asm sideeffect inteldialect ".byte 0a2h", "~{dirflag},~{fpsr},~{flags}"()
    283 // CHECK: call void asm sideeffect inteldialect "popad", "~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"()
    284 }
    285 
    286 void t27() {
    287   __asm mov eax, fs:[0h]
    288 // CHECK: t27
    289 // CHECK: call void asm sideeffect inteldialect "mov eax, fs:[$$0h]", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    290 }
    291 
    292 void t28() {
    293   __asm align 8
    294   __asm align 16;
    295   __asm align 128;
    296   __asm ALIGN 256;
    297 // CHECK: t28
    298 // CHECK: call void asm sideeffect inteldialect ".align 3", "~{dirflag},~{fpsr},~{flags}"()
    299 // CHECK: call void asm sideeffect inteldialect ".align 4", "~{dirflag},~{fpsr},~{flags}"()
    300 // CHECK: call void asm sideeffect inteldialect ".align 7", "~{dirflag},~{fpsr},~{flags}"()
    301 // CHECK: call void asm sideeffect inteldialect ".align 8", "~{dirflag},~{fpsr},~{flags}"()
    302 }
    303 
    304 void t29() {
    305   int arr[2] = {0, 0};
    306   int olen = 0, osize = 0, otype = 0;
    307   __asm mov olen, LENGTH arr
    308   __asm mov osize, SIZE arr
    309   __asm mov otype, TYPE arr
    310 // CHECK: t29
    311 // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$2", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    312 // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$8", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    313 // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, $$4", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    314 }
    315 
    316 int results[2] = {13, 37};
    317 int *t30()
    318 {
    319   int *res;
    320   __asm lea edi, results
    321   __asm mov res, edi
    322   return res;
    323 // CHECK: t30
    324 // CHECK: call void asm sideeffect inteldialect "lea edi, dword ptr $0", "*m,~{edi},~{dirflag},~{fpsr},~{flags}"([2 x i32]* @{{.*}})
    325 // CHECK: call void asm sideeffect inteldialect "mov dword ptr $0, edi", "=*m,~{dirflag},~{fpsr},~{flags}"(i32** %{{.*}})
    326 }
    327 
    328 void t31() {
    329   __asm pushad
    330   __asm popad
    331 // CHECK: t31
    332 // CHECK: call void asm sideeffect inteldialect "pushad", "~{esp},~{dirflag},~{fpsr},~{flags}"()
    333 // CHECK: call void asm sideeffect inteldialect "popad", "~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"()
    334 }
    335 
    336 void t32() {
    337   int i;
    338   __asm mov eax, i
    339   __asm mov eax, dword ptr i
    340   __asm mov ax, word ptr i
    341   __asm mov al, byte ptr i
    342 // CHECK: t32
    343 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    344 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    345 // CHECK: call void asm sideeffect inteldialect "mov ax, word ptr $0", "*m,~{ax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    346 // CHECK: call void asm sideeffect inteldialect "mov al, byte ptr $0", "*m,~{al},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    347 }
    348 
    349 void t33() {
    350   int i;
    351   __asm mov eax, [i]
    352   __asm mov eax, dword ptr [i]
    353   __asm mov ax, word ptr [i]
    354   __asm mov al, byte ptr [i]
    355 // CHECK: t33
    356 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    357 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    358 // CHECK: call void asm sideeffect inteldialect "mov ax, word ptr $0", "*m,~{ax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    359 // CHECK: call void asm sideeffect inteldialect "mov al, byte ptr $0", "*m,~{al},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
    360 }
    361 
    362 void t34() {
    363   __asm prefetchnta 64[eax]
    364   __asm mov eax, dword ptr 4[eax]
    365 // CHECK: t34
    366 // CHECK: call void asm sideeffect inteldialect "prefetchnta $$64[eax]", "~{dirflag},~{fpsr},~{flags}"()
    367 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4[eax]", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    368 }
    369 
    370 void t35() {
    371   __asm prefetchnta [eax + (200*64)]
    372   __asm mov eax, dword ptr [eax + (200*64)]
    373 // CHECK: t35
    374 // CHECK: call void asm sideeffect inteldialect "prefetchnta [eax + ($$200*$$64)]", "~{dirflag},~{fpsr},~{flags}"()
    375 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr [eax + ($$200*$$64)]", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    376 }
    377 
    378 void t36() {
    379   int arr[4];
    380   __asm mov eax, 4[arr]
    381   __asm mov eax, 4[arr + 4]
    382   __asm mov eax, 8[arr + 4 + 32*2 - 4]
    383   __asm mov eax, 12[4 + arr]
    384   __asm mov eax, 4[4 + arr + 4]
    385   __asm mov eax, 4[64 + arr + (2*32)]
    386   __asm mov eax, 4[64 + arr - 2*32]
    387   __asm mov eax, [arr + 4]
    388   __asm mov eax, [arr + 4 + 32*2 - 4]
    389   __asm mov eax, [4 + arr]
    390   __asm mov eax, [4 + arr + 4]
    391   __asm mov eax, [64 + arr + (2*32)]
    392   __asm mov eax, [64 + arr - 2*32]
    393 // CHECK: t36
    394 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    395 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    396 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    397 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    398 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    399 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    400 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    401 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    402 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$64$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    403 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    404 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    405 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$128$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    406 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    407 }
    408 
    409 void t37() {
    410   __asm mov eax, 4 + 8
    411   __asm mov eax, 4 + 8 * 16
    412   __asm mov eax, -4 + 8 * 16
    413   __asm mov eax, (4 + 4) * 16
    414   __asm mov eax, 4 + 8 * -16
    415   __asm mov eax, 4 + 16 / -8
    416   __asm mov eax, (16 + 16) / -8
    417   __asm mov eax, ~15
    418 // CHECK: t37
    419 // CHECK: call void asm sideeffect inteldialect "mov eax, $$12", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    420 // CHECK: call void asm sideeffect inteldialect "mov eax, $$132", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    421 // CHECK: call void asm sideeffect inteldialect "mov eax, $$124", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    422 // CHECK: call void asm sideeffect inteldialect "mov eax, $$128", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    423 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4294967172", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    424 // CHECK: call void asm sideeffect inteldialect "mov eax, $$2", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    425 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4294967292", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    426 // CHECK: call void asm sideeffect inteldialect "mov eax, $$4294967280", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    427 }
    428 
    429 void t38() {
    430   int arr[4];
    431   __asm mov eax, 4+4[arr]
    432   __asm mov eax, (4+4)[arr + 4]
    433   __asm mov eax, 8*2[arr + 4 + 32*2 - 4]
    434   __asm mov eax, 12+20[4 + arr]
    435   __asm mov eax, 4*16+4[4 + arr + 4]
    436   __asm mov eax, 4*4[64 + arr + (2*32)]
    437   __asm mov eax, 4*(4-2)[64 + arr - 2*32]
    438   __asm mov eax, 32*(4-2)[arr - 2*32]
    439 // CHECK: t38
    440 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    441 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    442 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$80$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    443 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$36$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    444 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$76$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    445 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$144$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    446 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    447 // CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$0$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"([4 x i32]* %{{.*}})
    448 }
    449 
    450 void cpuid() {
    451   __asm cpuid
    452 // CHECK-LABEL: define void @cpuid
    453 // CHECK: call void asm sideeffect inteldialect "cpuid", "~{eax},~{ebx},~{ecx},~{edx},~{dirflag},~{fpsr},~{flags}"()
    454 }
    455 
    456 typedef struct {
    457   int a;
    458   int b;
    459 } A;
    460 
    461 void t39() {
    462   __asm mov eax, [eax].A.b
    463   __asm mov eax, [eax] A.b
    464   __asm mov eax, fs:[0] A.b
    465   // CHECK-LABEL: define void @t39
    466   // CHECK: call void asm sideeffect inteldialect "mov eax, [eax].4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    467   // CHECK: call void asm sideeffect inteldialect "mov eax, [eax] .4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    468   // CHECK: call void asm sideeffect inteldialect "mov eax, fs:[$$0] .4", "~{eax},~{dirflag},~{fpsr},~{flags}"()
    469 }
    470 
    471 void t40(float a) {
    472   int i;
    473   __asm fld a
    474   __asm fistp i
    475   // CHECK-LABEL: define void @t40
    476   // CHECK: call void asm sideeffect inteldialect "fld dword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(float* {{.*}})
    477   // CHECK: call void asm sideeffect inteldialect "fistp dword ptr $0", "=*m,~{dirflag},~{fpsr},~{flags}"(i32* {{.*}})
    478 }
    479