Index: lib/Basic/Targets.cpp =================================================================== --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -4549,6 +4549,7 @@ bool hasFeature(StringRef Feature) const override { return llvm::StringSwitch(Feature) .Case("arm", true) + .Case("aarch32", true) .Case("softfloat", SoftFloat) .Case("thumb", isThumb()) .Case("neon", (FPU & NeonFPU) && !SoftFloat) @@ -5196,6 +5197,7 @@ bool hasFeature(StringRef Feature) const override { return Feature == "aarch64" || Feature == "arm64" || + Feature == "arm" || (Feature == "neon" && FPU == NeonMode); } Index: test/Modules/Inputs/module.map =================================================================== --- test/Modules/Inputs/module.map +++ test/Modules/Inputs/module.map @@ -347,3 +347,16 @@ header "RequiresWithMissingHeader-Missing2.h" } } + +module TargetFeatures { + module arm { + requires arm + module aarch32 { requires aarch32 } + module aarch64 { requires aarch64 } + } + module x86 { + requires x86 + module x86_32 { requires x86_32 } + module x86_64 { requires x86_64 } + } +} Index: test/Modules/compiler_builtins_aarch64.m =================================================================== --- /dev/null +++ test/Modules/compiler_builtins_aarch64.m @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fsyntax-only -triple aarch64-unknown-unknown -target-feature +neon -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify %s +// expected-no-diagnostics +// REQUIRES: aarch64-registered-target +@import _Builtin_intrinsics.arm; +@import _Builtin_intrinsics.arm.neon; Index: test/Modules/target-features.m =================================================================== --- /dev/null +++ test/Modules/target-features.m @@ -0,0 +1,61 @@ +// REQUIRES: x86-registered-target +// REQUIRES: arm-registered-target +// REQUIRES: aarch64-registered-target + +// RUN: rm -rf %t + +// Sanity check one of the compilations. +// RUN: %clang_cc1 -triple aarch64-unknown-unknown -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs -fsyntax-only %s -verify -DSANITY_CHECK +// expected-no-diagnostics + +// Check all the targets: +// RUN: not %clang_cc1 -triple armv7-unknown-unknown -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs -fsyntax-only %s 2> %t.aarch32 +// RUN: FileCheck %s -check-prefix=AARCH32 < %t.aarch32 +// RUN: not %clang_cc1 -triple aarch64-unknown-unknown -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs -fsyntax-only %s 2> %t.aarch64 +// RUN: FileCheck %s -check-prefix=AARCH64 < %t.aarch64 +// RUN: not %clang_cc1 -triple i386-unknown-unknown -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs -fsyntax-only %s 2> %t.x86_32 +// RUN: FileCheck %s -check-prefix=X86_32 < %t.x86_32 +// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs -fsyntax-only %s 2> %t.x86_64 +// RUN: FileCheck %s -check-prefix=X86_64 < %t.x86_64 + +#ifndef SANITY_CHECK +@import TargetFeatures; +// AARCH32-NOT: module 'TargetFeatures' requires +// AARCH64-NOT: module 'TargetFeatures' requires +// X86_32-NOT: module 'TargetFeatures' requires +// X86_64-NOT: module 'TargetFeatures' requires +@import TargetFeatures.arm; +// AARCH32-NOT: module 'TargetFeatures.arm' requires +// AARCH64-NOT: module 'TargetFeatures.arm' requires +// X86_32: module 'TargetFeatures.arm' requires feature 'arm' +// X86_64: module 'TargetFeatures.arm' requires feature 'arm' +@import TargetFeatures.arm.aarch32; +// AARCH32-NOT: module 'TargetFeatures.arm.aarch32' requires +// AARCH64: module 'TargetFeatures.arm.aarch32' requires feature 'aarch32' +// X86_32: module 'TargetFeatures.arm.aarch32' requires feature +// X86_64: module 'TargetFeatures.arm.aarch32' requires feature +#endif + +@import TargetFeatures.arm.aarch64; +// AARCH32: module 'TargetFeatures.arm.aarch64' requires feature 'aarch64' +// AARCH64-NOT: module 'TargetFeatures.arm.aarch64' requires +// X86_32: module 'TargetFeatures.arm.aarch64' requires feature +// X86_64: module 'TargetFeatures.arm.aarch64' requires feature + +#ifndef SANITY_CHECK +@import TargetFeatures.x86; +// AARCH32: module 'TargetFeatures.x86' requires feature 'x86' +// AARCH64: module 'TargetFeatures.x86' requires feature 'x86' +// X86_32-NOT: module 'TargetFeatures.x86' requires +// X86_64-NOT: module 'TargetFeatures.x86' requires +@import TargetFeatures.x86.x86_32; +// AARCH32: module 'TargetFeatures.x86.x86_32' requires feature +// AARCH64: module 'TargetFeatures.x86.x86_32' requires feature +// X86_32-NOT: module 'TargetFeatures.x86.x86_32' requires +// X86_64: module 'TargetFeatures.x86.x86_32' requires feature 'x86_32' +@import TargetFeatures.x86.x86_64; +// AARCH32: module 'TargetFeatures.x86.x86_64' requires feature +// AARCH64: module 'TargetFeatures.x86.x86_64' requires feature +// X86_32: module 'TargetFeatures.x86.x86_64' requires feature 'x86_64' +// X86_64-NOT: module 'TargetFeatures.x86.x86_64' requires +#endif