Merge "Move arch variants registering code to arch.go."

This commit is contained in:
Jaewoong Jung 2019-01-17 15:26:23 +00:00 committed by Gerrit Code Review
commit d4a393466a
7 changed files with 209 additions and 198 deletions

View file

@ -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

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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)

View file

@ -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",