From e46114c11b3baede6fc0b8ea04889373aa0f1131 Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Wed, 16 Jan 2019 14:33:13 -0800 Subject: [PATCH] Move arch variants registering code to arch.go. This enables using arch-dependent property values in modules defined in android/. Bug: 122332178 Test: Soong tests + TreeHugger Change-Id: I89869e395fabf0e69f505b77eab8a4221384124e --- android/arch.go | 240 ++++++++++++++++++++++++++++++++----- cc/config/arm64_device.go | 14 --- cc/config/arm_device.go | 29 ----- cc/config/mips64_device.go | 9 -- cc/config/mips_device.go | 16 --- cc/config/x86_64_device.go | 42 ------- cc/config/x86_device.go | 57 --------- 7 files changed, 209 insertions(+), 198 deletions(-) diff --git a/android/arch.go b/android/arch.go index e8d9c6eeb..0180b8715 100644 --- a/android/arch.go +++ b/android/arch.go @@ -103,21 +103,217 @@ module { } */ -var archVariants = map[ArchType][]string{} -var archFeatures = map[ArchType][]string{} -var archFeatureMap = map[ArchType]map[string][]string{} +var archVariants = map[ArchType][]string{ + Arm: { + "armv7-a", + "armv7-a-neon", + "armv8-a", + "armv8-2a", + "cortex-a7", + "cortex-a8", + "cortex-a9", + "cortex-a15", + "cortex-a53", + "cortex-a53-a57", + "cortex-a55", + "cortex-a72", + "cortex-a73", + "cortex-a75", + "cortex-a76", + "krait", + "kryo", + "kryo385", + "exynos-m1", + "exynos-m2", + }, + Arm64: { + "armv8_a", + "armv8_2a", + "cortex-a53", + "cortex-a55", + "cortex-a72", + "cortex-a73", + "cortex-a75", + "cortex-a76", + "kryo", + "kryo385", + "exynos-m1", + "exynos-m2", + }, + Mips: { + "mips32_fp", + "mips32r2_fp", + "mips32r2_fp_xburst", + "mips32r2dsp_fp", + "mips32r2dspr2_fp", + "mips32r6", + }, + Mips64: { + "mips64r2", + "mips64r6", + }, + X86: { + "atom", + "haswell", + "ivybridge", + "sandybridge", + "silvermont", + "x86_64", + }, + X86_64: { + "haswell", + "ivybridge", + "sandybridge", + "silvermont", + }, +} + +var archFeatures = map[ArchType][]string{ + Arm: { + "neon", + }, + Mips: { + "dspr2", + "rev6", + "msa", + }, + Mips64: { + "rev6", + "msa", + }, + X86: { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "aes_ni", + "avx", + "popcnt", + "movbe", + }, + X86_64: { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "aes_ni", + "avx", + "popcnt", + }, +} + +var archFeatureMap = map[ArchType]map[string][]string{ + Arm: { + "armv7-a-neon": { + "neon", + }, + "armv8-a": { + "neon", + }, + "armv8-2a": { + "neon", + }, + }, + Mips: { + "mips32r2dspr2_fp": { + "dspr2", + }, + "mips32r6": { + "rev6", + }, + }, + Mips64: { + "mips64r6": { + "rev6", + }, + }, + X86: { + "atom": { + "ssse3", + "movbe", + }, + "haswell": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "aes_ni", + "avx", + "popcnt", + "movbe", + }, + "ivybridge": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "aes_ni", + "avx", + "popcnt", + }, + "sandybridge": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "popcnt", + }, + "silvermont": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "aes_ni", + "popcnt", + "movbe", + }, + "x86_64": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "popcnt", + }, + }, + X86_64: { + "haswell": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "aes_ni", + "avx", + "popcnt", + }, + "ivybridge": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "aes_ni", + "avx", + "popcnt", + }, + "sandybridge": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "popcnt", + }, + "silvermont": { + "ssse3", + "sse4", + "sse4_1", + "sse4_2", + "aes_ni", + "popcnt", + }, + }, +} + var defaultArchFeatureMap = map[OsType]map[ArchType][]string{} -func RegisterArchVariants(arch ArchType, variants ...string) { - checkCalledFromInit() - archVariants[arch] = append(archVariants[arch], variants...) -} - -func RegisterArchFeatures(arch ArchType, features ...string) { - checkCalledFromInit() - archFeatures[arch] = append(archFeatures[arch], features...) -} - func RegisterDefaultArchVariantFeatures(os OsType, arch ArchType, features ...string) { checkCalledFromInit() @@ -133,24 +329,6 @@ func RegisterDefaultArchVariantFeatures(os OsType, arch ArchType, features ...st defaultArchFeatureMap[os][arch] = features } -func RegisterArchVariantFeatures(arch ArchType, variant string, features ...string) { - checkCalledFromInit() - if !InList(variant, archVariants[arch]) { - panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch)) - } - - for _, feature := range features { - if !InList(feature, archFeatures[arch]) { - panic(fmt.Errorf("Invalid feature %q for arch %q variant %q", feature, arch, variant)) - } - } - - if archFeatureMap[arch] == nil { - archFeatureMap[arch] = make(map[string][]string) - } - archFeatureMap[arch][variant] = features -} - // An Arch indicates a single CPU architecture. type Arch struct { ArchType ArchType diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index f98e1be91..1ca1656d0 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -86,20 +86,6 @@ const ( ) func init() { - android.RegisterArchVariants(android.Arm64, - "armv8_a", - "armv8_2a", - "cortex-a53", - "cortex-a55", - "cortex-a72", - "cortex-a73", - "cortex-a75", - "cortex-a76", - "kryo", - "kryo385", - "exynos-m1", - "exynos-m2") - pctx.StaticVariable("arm64GccVersion", arm64GccVersion) pctx.SourcePathVariable("Arm64GccRoot", diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go index 60bb91a05..cd7c4107e 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -168,35 +168,6 @@ const ( ) func init() { - android.RegisterArchFeatures(android.Arm, - "neon") - - android.RegisterArchVariants(android.Arm, - "armv7-a", - "armv7-a-neon", - "armv8-a", - "armv8-2a", - "cortex-a7", - "cortex-a8", - "cortex-a9", - "cortex-a15", - "cortex-a53", - "cortex-a53-a57", - "cortex-a55", - "cortex-a72", - "cortex-a73", - "cortex-a75", - "cortex-a76", - "krait", - "kryo", - "kryo385", - "exynos-m1", - "exynos-m2") - - android.RegisterArchVariantFeatures(android.Arm, "armv7-a-neon", "neon") - android.RegisterArchVariantFeatures(android.Arm, "armv8-a", "neon") - android.RegisterArchVariantFeatures(android.Arm, "armv8-2a", "neon") - pctx.StaticVariable("armGccVersion", armGccVersion) pctx.SourcePathVariable("ArmGccRoot", diff --git a/cc/config/mips64_device.go b/cc/config/mips64_device.go index 561d8d6c5..c2af95115 100644 --- a/cc/config/mips64_device.go +++ b/cc/config/mips64_device.go @@ -55,15 +55,6 @@ const ( ) func init() { - android.RegisterArchVariants(android.Mips64, - "mips64r2", - "mips64r6") - android.RegisterArchFeatures(android.Mips64, - "rev6", - "msa") - android.RegisterArchVariantFeatures(android.Mips64, "mips64r6", - "rev6") - pctx.StaticVariable("mips64GccVersion", mips64GccVersion) pctx.SourcePathVariable("Mips64GccRoot", diff --git a/cc/config/mips_device.go b/cc/config/mips_device.go index 8cd35b3ed..ddbc41b28 100644 --- a/cc/config/mips_device.go +++ b/cc/config/mips_device.go @@ -89,22 +89,6 @@ const ( ) func init() { - android.RegisterArchVariants(android.Mips, - "mips32_fp", - "mips32r2_fp", - "mips32r2_fp_xburst", - "mips32r2dsp_fp", - "mips32r2dspr2_fp", - "mips32r6") - android.RegisterArchFeatures(android.Mips, - "dspr2", - "rev6", - "msa") - android.RegisterArchVariantFeatures(android.Mips, "mips32r2dspr2_fp", - "dspr2") - android.RegisterArchVariantFeatures(android.Mips, "mips32r6", - "rev6") - pctx.StaticVariable("mipsGccVersion", mipsGccVersion) pctx.SourcePathVariable("MipsGccRoot", diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index 381f7e7d1..4264edaa4 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -68,54 +68,12 @@ const ( ) func init() { - android.RegisterArchVariants(android.X86_64, - "haswell", - "ivybridge", - "sandybridge", - "silvermont") - android.RegisterArchFeatures(android.X86_64, - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "aes_ni", - "avx", - "popcnt") android.RegisterDefaultArchVariantFeatures(android.Android, android.X86_64, "ssse3", "sse4", "sse4_1", "sse4_2", "popcnt") - android.RegisterArchVariantFeatures(android.X86_64, "haswell", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "aes_ni", - "avx", - "popcnt") - android.RegisterArchVariantFeatures(android.X86_64, "ivybridge", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "aes_ni", - "avx", - "popcnt") - android.RegisterArchVariantFeatures(android.X86_64, "sandybridge", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "popcnt") - android.RegisterArchVariantFeatures(android.X86_64, "silvermont", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "aes_ni", - "popcnt") pctx.StaticVariable("x86_64GccVersion", x86_64GccVersion) diff --git a/cc/config/x86_device.go b/cc/config/x86_device.go index fc0b1d8a8..34e7df896 100644 --- a/cc/config/x86_device.go +++ b/cc/config/x86_device.go @@ -84,63 +84,6 @@ const ( ) func init() { - android.RegisterArchVariants(android.X86, - "atom", - "haswell", - "ivybridge", - "sandybridge", - "silvermont", - "x86_64") - android.RegisterArchFeatures(android.X86, - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "aes_ni", - "avx", - "popcnt", - "movbe") - android.RegisterArchVariantFeatures(android.X86, "x86_64", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "popcnt") - android.RegisterArchVariantFeatures(android.X86, "atom", - "ssse3", - "movbe") - android.RegisterArchVariantFeatures(android.X86, "haswell", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "aes_ni", - "avx", - "popcnt", - "movbe") - android.RegisterArchVariantFeatures(android.X86, "ivybridge", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "aes_ni", - "avx", - "popcnt") - android.RegisterArchVariantFeatures(android.X86, "sandybridge", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "popcnt") - android.RegisterArchVariantFeatures(android.X86, "silvermont", - "ssse3", - "sse4", - "sse4_1", - "sse4_2", - "aes_ni", - "popcnt", - "movbe") - pctx.StaticVariable("x86GccVersion", x86GccVersion) pctx.SourcePathVariable("X86GccRoot",