/
moptppc.go
46 lines (39 loc) · 1.07 KB
/
moptppc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2020-2021 C4 Project
//
// This file is part of c4t.
// Licenced under the MIT licence; see `LICENSE`.
package gcc
import (
"fmt"
"github.com/c4-project/c4t/internal/id"
)
// ppcMOpts calculates the m-optimisation set for the PowerPC variant variant.
func ppcMOpts(variant string, subvar id.ID) (*mOptSet, error) {
switch variant {
case id.ArchVariantPPC64LE:
return ppc64LEMOpts(subvar)
default:
return nil, fmt.Errorf("%w: unknown variant: %s", ErrUnsupportedVariant, variant)
}
}
// ppc64LEMOpts calculates the m-optimisation set for the PowerPC64LE subvariant svar.
func ppc64LEMOpts(svar id.ID) (*mOptSet, error) {
var err error
set := newMOptSet(true)
switch svar.String() {
case id.ArchSubVariantPPCPOWER9:
set.AddCPU("power9")
fallthrough
case id.ArchSubVariantPPCPOWER8:
set.AddCPU("power8")
fallthrough
case id.ArchSubVariantPPCPOWER7:
set.AddCPU("power7")
fallthrough
case "":
set.AddCPU("powerpc64le", "native")
default:
return nil, fmt.Errorf("%w: unknown subvariant: %s", ErrUnsupportedVariant, svar)
}
return set, err
}