Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGen/inline-asm-intel.c
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

85 lines
3.6 KiB
C

// REQUIRES: x86-registered-target
/// Accept intel inline asm but write it out as att:
// RUN: %clang_cc1 -triple i386-unknown-linux -mllvm -x86-asm-syntax=att -inline-asm=intel -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -O0 -S %s -o - | FileCheck --check-prefix=ATT %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux -mllvm -x86-asm-syntax=att -inline-asm=intel -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -O0 -S %s -o - | FileCheck --check-prefix=ATT %s
/// Accept intel inline asm and write it out as intel:
// RUN: %clang_cc1 -triple i386-unknown-linux -mllvm -x86-asm-syntax=intel -inline-asm=intel -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -O0 -S %s -o - | FileCheck --check-prefix=INTEL %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux -mllvm -x86-asm-syntax=intel -inline-asm=intel -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -O0 -S %s -o - | FileCheck --check-prefix=INTEL %s
/// Check MS compat mode (_MSC_VER defined). The driver always picks intel
/// output in that mode, so test only that.
// RUN: %clang_cc1 -triple i386-pc-win32 -mllvm -x86-asm-syntax=intel -inline-asm=intel -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -O0 -S %s -o - -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 | FileCheck --check-prefix=INTEL %s
// RUN: %clang_cc1 -triple x86_64-pc-win32 -mllvm -x86-asm-syntax=intel -inline-asm=intel -Werror -target-feature +hreset -target-feature +pconfig -target-feature +sgx -ffreestanding -O0 -S %s -o - -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 | FileCheck --check-prefix=INTEL %s
// Test that intrinsics headers still work with -masm=intel.
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <x86intrin.h>
#endif
void f(void) {
// Intrinsic headers contain macros and inline functions.
// Inline assembly in both are checked only when they are
// referenced, so reference a few intrinsics here.
__SSC_MARK(4);
int a;
_hreset(a);
_pconfig_u32(0, (void*)0);
_encls_u32(0, (void*)0);
_enclu_u32(0, (void*)0);
_enclv_u32(0, (void*)0);
#ifdef _MSC_VER
__movsb((void*)0, (void*)0, 0);
__movsd((void*)0, (void*)0, 0);
__movsw((void*)0, (void*)0, 0);
__stosb((void*)0, 0, 0);
__stosd((void*)0, 0, 0);
__stosw((void*)0, 0, 0);
#ifdef __x86_64__
__movsq((void*)0, (void*)0, 0);
__stosq((void*)0, 0, 0);
#endif
__cpuid((void*)0, 0);
__cpuidex((void*)0, 0, 0);
__halt();
__nop();
__readmsr(0);
__readcr3();
__writecr3(0);
_InterlockedExchange_HLEAcquire((void*)0, 0);
_InterlockedExchange_HLERelease((void*)0, 0);
_InterlockedCompareExchange_HLEAcquire((void*)0, 0, 0);
_InterlockedCompareExchange_HLERelease((void*)0, 0, 0);
#ifdef __x86_64__
_InterlockedExchange64_HLEAcquire((void*)0, 0);
_InterlockedExchange64_HLERelease((void*)0, 0);
_InterlockedCompareExchange64_HLEAcquire((void*)0, 0, 0);
_InterlockedCompareExchange64_HLERelease((void*)0, 0, 0);
#endif
#endif
__asm__("mov eax, ebx");
// ATT: movl %ebx, %eax
// INTEL: mov eax, ebx
// Explicitly overriding asm style per block works:
__asm__(".att_syntax\nmovl %ebx, %eax");
// ATT: movl %ebx, %eax
// INTEL: mov eax, ebx
// The .att_syntax was only scoped to the previous statement.
// (This is different from gcc, where `.att_syntax` is in
// effect from that point on, so portable code would want an
// explicit `.intel_syntax noprefix\n` at the start of this string).
__asm__("mov eax, ebx");
// ATT: movl %ebx, %eax
// INTEL: mov eax, ebx
}