91 lines · c
1// This file tests the -mtp=<mode> functionality in Clang’s ARM driver.2// It verifies:3//4// 1. ARMv7 targets: explicit hardware modes, explicit soft mode, and auto mode.5// 2. M Profile variants: explicit hardware mode should fail and auto mode defaults to soft.6// 3. ARMv6 variants: explicit hardware modes on ARMv6K/KZ work, but auto mode falls back to soft when Thumb2 is missing.7// 4. ARMv5 variants: explicit hardware mode is rejected and auto mode defaults to soft.8// 5. Miscellaneous error cases (e.g. empty -mtp value).9//10//===----------------------------------------------------------------------===//11 12//===----------------------------------------------------------------------===//13// 1. ARMv7 Targets14//===----------------------------------------------------------------------===//15 16// Test explicit hardware mode using "tpidrprw" on an ARMv7 target.17// RUN: %clang --target=armv7-linux -mtp=tpidrprw -### -S %s 2>&1 | FileCheck -check-prefix=ARMv7_TPIDRPRW %s18// ARMv7_TPIDRPRW: "-target-feature" "+read-tp-tpidrprw"19 20// Test explicit hardware mode using "tpidrurw" on an ARMv7 target.21// RUN: %clang --target=armv7-linux -mtp=tpidrurw -### -S %s 2>&1 | FileCheck -check-prefix=ARMv7_TPIDRURW %s22// ARMv7_TPIDRURW: "-target-feature" "+read-tp-tpidrurw"23 24// Test explicit hardware mode using "tpidruro" on an ARMv7 target.25// RUN: %clang --target=armv7-linux -mtp=tpidruro -### -S %s 2>&1 | FileCheck -check-prefix=ARMv7_TPIDRURO %s26// ARMv7_TPIDRURO: "-target-feature" "+read-tp-tpidruro"27 28// Test explicit "soft" mode on an ARMv7 target (forces software mode).29// RUN: %clang --target=armv7-linux -mtp=soft -### -S %s 2>&1 | FileCheck -check-prefix=ARM_Soft %s30// ARM_Soft-NOT: "-target-feature" "+read-tp-"31 32// Test auto mode on an ARMv7 target (hardware support and Thumb2 yield HW mode).33// RUN: %clang --target=armv7-linux -mtp=auto -### -S %s 2>&1 | FileCheck -check-prefix=ARMv7_Auto %s34// Default mode is implicitly -mtp=auto35// RUN: %clang --target=armv7-linux -### -S %s 2>&1 | FileCheck -check-prefix=ARMv7_Auto %s36// ARMv7_Auto: "-target-feature" "+read-tp-tpidruro"37 38//===----------------------------------------------------------------------===//39// 2. M Profile Variants (e.g. thumbv6t2)40//===----------------------------------------------------------------------===//41 42// Test explicit hardware mode on a M Profile target: thumbv6t2 does not support CP15.43// RUN: not %clang --target=thumbv6t2-linux -mtp=cp15 -### -S %s 2>&1 | FileCheck -check-prefix=Thumbv6t2_Error %s44// Thumbv6t2_Error: error: hardware TLS register is not supported for the armv6t2 sub-architecture45 46// Test auto mode on a M Profile target: should default to soft mode.47// RUN: %clang --target=thumbv6t2-linux -mtp=auto -### -S %s 2>&1 | FileCheck -check-prefix=Thumbv6t2_Auto %s48// Thumbv6t2_Auto-NOT: "-target-feature" "+read-tp-"49 50 51//===----------------------------------------------------------------------===//52// 3. ARMv6 Variants53//===----------------------------------------------------------------------===//54 55// Test explicit hardware mode using "cp15" on an ARMv6K and ARMv6KZ targets.56// RUN: %clang --target=armv6k-linux -mtp=cp15 -### -S %s 2>&1 | FileCheck -check-prefix=ARMv6k_Cp15 %s57// RUN: %clang --target=armv6kz-linux -mtp=cp15 -### -S %s 2>&1 | FileCheck -check-prefix=ARMv6k_Cp15 %s58// ARMv6k_Cp15: "-target-feature" "+read-tp-tpidruro"59 60 61// Test auto mode on ARMv6K and ARMv6KZ targets: defaults to soft mode due to missing Thumb2 encoding.62// RUN: %clang --target=armv6k-linux -mtp=auto -### -S %s 2>&1 | FileCheck -check-prefix=ARMv6k_Auto %s63// RUN: %clang --target=armv6kz-linux -mtp=auto -### -S %s 2>&1 | FileCheck -check-prefix=ARMv6k_Auto %s64// ARMv6k_Auto-NOT: "-target-feature" "+read-tp-"65 66 67//===----------------------------------------------------------------------===//68// 4. ARMv5 Variants69//===----------------------------------------------------------------------===//70 71// Test explicit hardware mode on an ARMv5T target: hardware TP is not supported.72// RUN: not %clang --target=armv5t-linux -mtp=cp15 -### -S %s 2>&1 | FileCheck -check-prefix=ARMv5t_Error %s73// ARMv5t_Error: error: hardware TLS register is not supported for the armv5 sub-architecture74 75// Test auto mode on an ARMv5T target: should default to soft mode.76// RUN: %clang --target=armv5t-linux -mtp=auto -### -S %s 2>&1 | FileCheck -check-prefix=ARMv5t_Auto %s77// ARMv5t_Auto-NOT: "-target-feature" "+read-tp-"78 79//===----------------------------------------------------------------------===//80// 5. Miscellaneous Tests81//===----------------------------------------------------------------------===//82 83// Test empty -mtp value on an ARMv7 target: should produce a missing argument error.84// RUN: not %clang --target=armv7-linux -mtp= -### -S %s 2>&1 | FileCheck -check-prefix=Empty_MTP %s85// Empty_MTP: error: {{.*}}missing86 87// Test explicit hardware mode in assembler mode on an unsupporting target does not fail with error88// RUN: %clang --target=thumbv6t2-linux -mtp=cp15 -x assembler -### %s 2>&1 | FileCheck -check-prefix=Thumbv6t2_Asm %s89// Thumbv6t2_Asm-NOT: "-target-feature" "+read-tp-"90 91