575c386f9a5d7acf807d29e38f10dc7c3dcad8da
[dragonfly.git] / share / mk / bsd.cpu.gcc47.mk
1 # Set default CPU compile flags and baseline CPUTYPE for each arch.  The
2 # compile flags must support the minimum CPU type for each architecture but
3 # may tune support for more advanced processors.
4
5 .if !defined(CPUTYPE) || empty(CPUTYPE) || ${CPUTYPE} == "native"
6
7 . if defined(CPUTYPE) && !empty(CPUTYPE) && ${CPUTYPE} == "native"
8 _CPUCFLAGS = -march=native
9 . else
10 _CPUCFLAGS =
11 . endif
12
13 .else
14
15 _CPUCFLAGS_FIXUP =
16
17 # Old CPUTYPE compat shim
18 . if ${CPUTYPE} == "i586" \
19   || ${CPUTYPE} == "k5"
20 CPUTYPE = pentium
21 . elif ${CPUTYPE} == "i586/mmx"
22 CPUTYPE = pentium-mmx
23 . elif ${CPUTYPE} == "p2"
24 CPUTYPE = pentium2
25 . elif ${CPUTYPE} == "pentium3m" \
26     || ${CPUTYPE} == "p3m" \
27     || ${CPUTYPE} == "p3" \
28     || ${CPUTYPE} == "c3-2"
29 CPUTYPE = pentium3
30 . elif ${CPUTYPE} == "pentium4m" \
31     || ${CPUTYPE} == "pentium-m" \
32     || ${CPUTYPE} == "p-m" \
33     || ${CPUTYPE} == "p4"\
34     || ${CPUTYPE} == "p4m"
35 CPUTYPE = pentium4
36 . elif ${CPUTYPE} == "crusoe"
37 CPUTYPE = pentiumpro
38 _CPUCFLAGS_FIXUP = -falign-functions=0 -falign-jumps=0 -falign-loops=0
39 . elif ${CPUTYPE} == "i686"
40 CPUTYPE = pentiumpro
41 . elif ${CPUTYPE} == "k6-2"
42 CPUTYPE = k6-3
43 . elif ${CPUTYPE} == "k7" \
44     || ${CPUTYPE} == "athlon-tbird"
45 CPUTYPE = athlon
46 . elif ${CPUTYPE} == "athlon-mp" \
47     || ${CPUTYPE} == "athlon-4"
48 CPUTYPE = athlon-xp
49 . elif ${CPUTYPE} == "k8" \
50     || ${CPUTYPE} == "opteron" \
51     || ${CPUTYPE} == "athlon-fx"
52 CPUTYPE = athlon64
53 . elif ${CPUTYPE} == "k8-sse3" \
54     || ${CPUTYPE} == "opteron-sse3"
55 CPUTYPE = athlon64-sse3
56 . elif ${CPUTYPE} == "amdfam10"
57 CPUTYPE = barcelona
58 . elif ${CPUTYPE} == "c3"
59 CPUTYPE = winchip2
60 . elif ${CPUTYPE} == "core"
61 CPUTYPE = nocona
62 . elif ${CPUTYPE} == "corei7-avx" \
63     || ${CPUTYPE} == "corei7-avx-i" \
64     || ${CPUTYPE} == "corei7-avx2"
65 CPUTYPE = corei7
66 . elif ${CPUTYPE} == "atom"
67 CPUTYPE = core2
68 . elif ${CPUTYPE} == "bdver2"
69 CPUTYPE = bdver1
70 . elif ${CPUTYPE} == "btver1"
71 CPUTYPE = barcelona
72 . endif
73
74 ###############################################################################
75 # Logic to set up correct gcc optimization flag.  This must be included
76 # after /etc/make.conf so it can react to the local value of CPUTYPE
77 # defined therein.  Consult:
78 #       http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86-64-Options.html
79
80 _CPUCFLAGS = -march=${CPUTYPE} ${_CPUCFLAGS_FIXUP}
81
82 # Set up the list of CPU features based on the CPU type.  This is an
83 # unordered list to make it easy for client makefiles to test for the
84 # presence of a CPU feature.
85
86 . if ${MACHINE_ARCH} == "i386"
87 .  if ${CPUTYPE} == "bdver1"
88 MACHINE_CPU = abm 3dnow mmx sse4.2 sse4.1 sse3 sse2 sse \
89         athlon-xp athlon k7 k6 k5 i586
90 .  elif ${CPUTYPE} == "barcelona"
91 MACHINE_CPU = abm 3dnow mmx sse4a sse3 sse2 sse \
92         athlon-xp athlon k7 k6 k5 i586
93 .  elif ${CPUTYPE} == "athlon64-sse3"
94 MACHINE_CPU = 3dnow mmx sse3 sse2 sse athlon-xp athlon k7 k6 k5 i586
95 .  elif ${CPUTYPE} == "athlon64"
96 MACHINE_CPU = 3dnow mmx sse2 sse athlon-xp athlon k7 k6 k5 i586
97 .  elif ${CPUTYPE} == "athlon-xp"
98 MACHINE_CPU = 3dnow mmx sse athlon-xp athlon k7 k6 k5 i586
99 .  elif ${CPUTYPE} == "athlon"
100 MACHINE_CPU = 3dnow mmx athlon k7 k6 k5 i586
101 .  elif ${CPUTYPE} == "k6-3"
102 MACHINE_CPU = 3dnow mmx k6 k5 i586
103 .  elif ${CPUTYPE} == "k6"
104 MACHINE_CPU = mmx k6 k5 i586
105 .  elif ${CPUTYPE} == "geode"
106 MACHINE_CPU = 3dnow mmx i686 i586
107 .  elif ${CPUTYPE} == "corei7"
108 MACHINE_CPU = sse4.2 sse4.1 ssse3 sse3 sse2 sse mmx i686 i586
109 .  elif ${CPUTYPE} == "core2"
110 MACHINE_CPU = ssse3 sse3 sse2 sse mmx i686 i586
111 .  elif ${CPUTYPE} == "nocona"
112 MACHINE_CPU = sse3 sse2 sse mmx i686 i586
113 .  elif ${CPUTYPE} == "prescott"
114 MACHINE_CPU = sse3 sse2 sse mmx i686 i586
115 .  elif ${CPUTYPE} == "pentium4"
116 MACHINE_CPU = sse2 sse mmx i686 i586
117 .  elif ${CPUTYPE} == "pentium3"
118 MACHINE_CPU = sse mmx i686 i586
119 .  elif ${CPUTYPE} == "pentium2"
120 MACHINE_CPU = mmx i686 i586
121 .  elif ${CPUTYPE} == "pentiumpro"
122 MACHINE_CPU = i686 i586
123 .  elif ${CPUTYPE} == "winchip2"
124 MACHINE_CPU = 3dnow mmx
125 .  elif ${CPUTYPE} == "winchip-c6"
126 MACHINE_CPU = mmx
127 .  elif ${CPUTYPE} == "pentium-mmx"
128 MACHINE_CPU = mmx i586
129 .  elif ${CPUTYPE} == "pentium"
130 MACHINE_CPU = i586
131 .  endif
132 MACHINE_CPU += i386 i486
133 . elif ${MACHINE_ARCH} == "x86_64"
134 .  if ${CPUTYPE} == "bdver1"
135 MACHINE_CPU = k8 abm 3dnow sse4.2 sse4.1 sse3
136 .  elif ${CPUTYPE} == "barcelona"
137 MACHINE_CPU = k8 abm 3dnow sse4a sse3
138 .  elif ${CPUTYPE} == "athlon64-sse3"
139 MACHINE_CPU = k8 3dnow sse3
140 .  elif ${CPUTYPE} == "athlon64"
141 MACHINE_CPU = k8 3dnow
142 .  elif ${CPUTYPE} == "corei7"
143 MACHINE_CPU = sse4.2 sse4.1 ssse3 sse3
144 .  elif ${CPUTYPE} == "core2"
145 MACHINE_CPU = ssse3 sse3
146 .  elif ${CPUTYPE} == "nocona"
147 MACHINE_CPU = sse3
148 .  endif
149 MACHINE_CPU += sse2 sse mmx x86_64
150 . endif
151
152 .endif