brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · c7e4c1b Raw
87 lines · c
1// REQUIRES: x86-registered-target2// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -Wno-strict-prototypes -fasm-blocks -emit-llvm -o - | FileCheck %s3 4void t1(void) {5  int var = 10;6  __asm mov rax, offset var ; rax = address of myvar7// CHECK: t18// CHECK: call void asm sideeffect inteldialect9// CHECK-SAME: mov rax, $010// CHECK-SAME: "r,~{rax},~{dirflag},~{fpsr},~{flags}"(ptr %{{.*}})11}12 13void t2(void) {14  int var = 10;15  __asm mov qword ptr [eax], offset var16// CHECK: t217// CHECK: call void asm sideeffect inteldialect18// CHECK-SAME: mov qword ptr [eax], $019// CHECK-SAME: "r,~{dirflag},~{fpsr},~{flags}"(ptr %{{.*}})20}21 22struct t3_type { int a, b; };23 24int t3(void) {25  struct t3_type foo;26  foo.a = 1;27  foo.b = 2;28  __asm {29     lea ebx, foo30     mov eax, [ebx].031     mov [ebx].4, ecx32  }33  return foo.b;34// CHECK: t335// CHECK: call void asm sideeffect inteldialect36// CHECK-SAME: lea ebx, $037// CHECK-SAME: mov eax, [ebx]38// CHECK-SAME: mov [ebx + $$4], ecx39// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(%struct.t3_type) %{{.*}})40}41 42int t4(void) {43  struct t3_type foo;44  foo.a = 1;45  foo.b = 2;46  __asm {47     lea ebx, foo48     {49       mov eax, [ebx].foo.a50     }51     mov [ebx].foo.b, ecx52  }53  return foo.b;54// CHECK: t455// CHECK: call void asm sideeffect inteldialect56// CHECK-SAME: lea ebx, $057// CHECK-SAME: mov eax, [ebx]58// CHECK-SAME: mov [ebx + $$4], ecx59// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(%struct.t3_type) %{{.*}})60}61 62void bar() {}63static void (*fptr)();64 65void t5(void) {66  __asm {67    call bar68    jmp bar69    call fptr70    jmp fptr71  }72  // CHECK: t573  // CHECK: call void asm sideeffect inteldialect74  // CHECK-SAME: call ${0:P}75  // CHECK-SAME: jmp ${1:P}76  // CHECK-SAME: call $277  // CHECK-SAME: jmp $378  // CHECK-SAME: "*m,*m,*m,*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(void (...)) @bar, ptr elementtype(void (...)) @bar, ptr elementtype(ptr) @fptr, ptr elementtype(ptr) @fptr)79}80 81void t47(void) {82  // CHECK-LABEL: define{{.*}} void @t4783  int arr[1000];84  __asm movdir64b rax, zmmword ptr [arr]85  // CHECK: call void asm sideeffect inteldialect "movdir64b rax, zmmword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype([1000 x i32]) %arr)86}87