1 // REQUIRES: x86-registered-target 2 3 /// Accept intel inline asm but write it out as att: 4 // RUN: %clang_cc1 -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -triple i386-unknown-unknown -mllvm -x86-asm-syntax=att -inline-asm=intel -O0 -S %s -o - | FileCheck --check-prefix=ATT %s 5 // RUN: %clang_cc1 -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -triple x86_64-unknown-unknown -mllvm -x86-asm-syntax=att -inline-asm=intel -O0 -S %s -o - | FileCheck --check-prefix=ATT %s 6 7 /// Accept intel inline asm and write it out as intel: 8 // RUN: %clang_cc1 -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -triple i386-unknown-unknown -mllvm -x86-asm-syntax=intel -inline-asm=intel -O0 -S %s -o - | FileCheck --check-prefix=INTEL %s 9 // RUN: %clang_cc1 -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -triple x86_64-unknown-unknown -mllvm -x86-asm-syntax=intel -inline-asm=intel -O0 -S %s -o - | FileCheck --check-prefix=INTEL %s 10 11 // RUN: %clang_cc1 -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -triple i386-pc-win32 -mllvm -x86-asm-syntax=intel -inline-asm=intel -O0 -S %s -o - -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 | FileCheck --check-prefix=INTEL %s 12 // RUN: %clang_cc1 -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -triple x86_64-pc-win32 -mllvm -x86-asm-syntax=intel -inline-asm=intel -O0 -S %s -o - -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 | FileCheck --check-prefix=INTEL %s 13 14 // Test that intrinsics headers still work with -masm=intel. 15 #ifdef _MSC_VER 16 #include <intrin.h> 17 #else 18 #include <x86intrin.h> 19 #endif 20 21 void f() { 22 // Intrinsic headers contain macros and inline functions. 23 // Inline assembly in both are checked only when they are 24 // referenced, so reference a few intrinsics here. 25 __SSC_MARK(4); 26 int a; 27 _hreset(a); 28 _pconfig_u32(0, (void*)0); 29 30 _encls_u32(0, (void*)0); 31 _enclu_u32(0, (void*)0); 32 _enclv_u32(0, (void*)0); 33 #ifdef _MSC_VER 34 __movsb((void*)0, (void*)0, 0); 35 __movsd((void*)0, (void*)0, 0); 36 __movsw((void*)0, (void*)0, 0); 37 __stosb((void*)0, 0, 0); 38 __stosd((void*)0, 0, 0); 39 __stosw((void*)0, 0, 0); 40 #ifdef __x86_64__ 41 __movsq((void*)0, (void*)0, 0); 42 __stosq((void*)0, 0, 0); 43 #endif 44 __cpuid((void*)0, 0); 45 __cpuidex((void*)0, 0, 0); 46 __halt(); 47 __nop(); 48 __readmsr(0); 49 __readcr3(); 50 __writecr3(0); 51 52 _InterlockedExchange_HLEAcquire((void*)0, 0); 53 _InterlockedExchange_HLERelease((void*)0, 0); 54 _InterlockedCompareExchange_HLEAcquire((void*)0, 0, 0); 55 _InterlockedCompareExchange_HLERelease((void*)0, 0, 0); 56 #ifdef __x86_64__ 57 _InterlockedExchange64_HLEAcquire((void*)0, 0); 58 _InterlockedExchange64_HLERelease((void*)0, 0); 59 _InterlockedCompareExchange64_HLEAcquire((void*)0, 0, 0); 60 _InterlockedCompareExchange64_HLERelease((void*)0, 0, 0); 61 #endif 62 #endif 63 64 65 __asm__("mov eax, ebx"); 66 // ATT: movl %ebx, %eax 67 // INTEL: mov eax, ebx 68 69 // Explicitly overriding asm style per block works: 70 __asm__(".att_syntax\nmovl %ebx, %eax"); 71 // ATT: movl %ebx, %eax 72 // INTEL: mov eax, ebx 73 74 // The .att_syntax was only scoped to the previous statement. 75 // (This is different from gcc, where `.att_syntax` is in 76 // effect from that point on, so portable code would want an 77 // explicit `.intel_syntax noprefix\n` at the start of this string). 78 __asm__("mov eax, ebx"); 79 // ATT: movl %ebx, %eax 80 // INTEL: mov eax, ebx 81 } 82 83