Merge "Fix typos in arch_list and do variant validation"

This commit is contained in:
Treehugger Robot 2022-02-23 17:34:51 +00:00 committed by Gerrit Code Review
commit cda344f120
3 changed files with 55 additions and 30 deletions

View file

@ -864,6 +864,10 @@ func createArchPropTypeDesc(props reflect.Type) []archPropTypeDesc {
archVariant := variantReplacer.Replace(archVariant)
variants = append(variants, proptools.FieldNameForProperty(archVariant))
}
for _, cpuVariant := range cpuVariants[arch] {
cpuVariant := variantReplacer.Replace(cpuVariant)
variants = append(variants, proptools.FieldNameForProperty(cpuVariant))
}
for _, feature := range archFeatures[arch] {
feature := variantReplacer.Replace(feature)
variants = append(variants, proptools.FieldNameForProperty(feature))
@ -1741,6 +1745,18 @@ func decodeArch(os OsType, arch string, archVariant, cpuVariant *string, abi []s
a.CpuVariant = ""
}
if a.ArchVariant != "" {
if validArchVariants := archVariants[archType]; !InList(a.ArchVariant, validArchVariants) {
return Arch{}, fmt.Errorf("[%q] unknown arch variant %q, support variants: %q", archType, a.ArchVariant, validArchVariants)
}
}
if a.CpuVariant != "" {
if validCpuVariants := cpuVariants[archType]; !InList(a.CpuVariant, validCpuVariants) {
return Arch{}, fmt.Errorf("[%q] unknown cpu variant %q, support variants: %q", archType, a.CpuVariant, validCpuVariants)
}
}
// Filter empty ABIs out of the list.
for i := 0; i < len(a.Abi); i++ {
if a.Abi[i] == "" {

View file

@ -22,38 +22,12 @@ var archVariants = map[ArchType][]string{
"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_a_branchprot",
"armv8_2a",
"armv8-a",
"armv8-a-branchprot",
"armv8-2a",
"armv8-2a-dotprod",
"cortex-a53",
"cortex-a55",
"cortex-a72",
"cortex-a73",
"cortex-a75",
"cortex-a76",
"kryo",
"kryo385",
"exynos-m1",
"exynos-m2",
},
X86: {
"amberlake",
@ -87,6 +61,41 @@ var archVariants = map[ArchType][]string{
},
}
var cpuVariants = map[ArchType][]string{
Arm: {
"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: {
"cortex-a53",
"cortex-a55",
"cortex-a72",
"cortex-a73",
"cortex-a75",
"cortex-a76",
"kryo",
"kryo385",
"exynos-m1",
"exynos-m2",
},
X86: {},
X86_64: {},
}
var archFeatures = map[ArchType][]string{
Arm: {
"neon",

View file

@ -37,10 +37,10 @@ var (
"": []string{
"-march=x86-64",
},
"broadwell": []string{
"-march=broadwell",
},
"haswell": []string{
"-march=core-avx2",
},