xref: /dragonfly/share/mk/bsd.cpu.gcc47.mk (revision 77b0c609)
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"
20CPUTYPE = pentium
21. elif ${CPUTYPE} == "i586/mmx"
22CPUTYPE = pentium-mmx
23. elif ${CPUTYPE} == "p2"
24CPUTYPE = pentium2
25. elif ${CPUTYPE} == "pentium3m" \
26    || ${CPUTYPE} == "p3m" \
27    || ${CPUTYPE} == "p3" \
28    || ${CPUTYPE} == "c3-2"
29CPUTYPE = pentium3
30. elif ${CPUTYPE} == "pentium4m" \
31    || ${CPUTYPE} == "pentium-m" \
32    || ${CPUTYPE} == "p-m" \
33    || ${CPUTYPE} == "p4"\
34    || ${CPUTYPE} == "p4m"
35CPUTYPE = pentium4
36. elif ${CPUTYPE} == "crusoe"
37CPUTYPE = pentiumpro
38_CPUCFLAGS_FIXUP = -falign-functions=0 -falign-jumps=0 -falign-loops=0
39. elif ${CPUTYPE} == "i686"
40CPUTYPE = pentiumpro
41. elif ${CPUTYPE} == "k6-2"
42CPUTYPE = k6-3
43. elif ${CPUTYPE} == "k7" \
44    || ${CPUTYPE} == "athlon-tbird"
45CPUTYPE = athlon
46. elif ${CPUTYPE} == "athlon-mp" \
47    || ${CPUTYPE} == "athlon-4"
48CPUTYPE = athlon-xp
49. elif ${CPUTYPE} == "k8" \
50    || ${CPUTYPE} == "opteron" \
51    || ${CPUTYPE} == "athlon-fx"
52CPUTYPE = athlon64
53. elif ${CPUTYPE} == "k8-sse3" \
54    || ${CPUTYPE} == "opteron-sse3"
55CPUTYPE = athlon64-sse3
56. elif ${CPUTYPE} == "amdfam10"
57CPUTYPE = barcelona
58. elif ${CPUTYPE} == "c3"
59CPUTYPE = winchip2
60. elif ${CPUTYPE} == "core"
61CPUTYPE = nocona
62. elif ${CPUTYPE} == "corei7-avx" \
63    || ${CPUTYPE} == "corei7-avx-i" \
64    || ${CPUTYPE} == "corei7-avx2"
65CPUTYPE = corei7
66. elif ${CPUTYPE} == "atom"
67CPUTYPE = core2
68. elif ${CPUTYPE} == "bdver2"
69CPUTYPE = bdver1
70. elif ${CPUTYPE} == "btver1"
71CPUTYPE = 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"
88MACHINE_CPU = abm 3dnow mmx sse4.2 sse4.1 sse3 sse2 sse \
89	athlon-xp athlon k7 k6 k5 i586
90.  elif ${CPUTYPE} == "barcelona"
91MACHINE_CPU = abm 3dnow mmx sse4a sse3 sse2 sse \
92	athlon-xp athlon k7 k6 k5 i586
93.  elif ${CPUTYPE} == "athlon64-sse3"
94MACHINE_CPU = 3dnow mmx sse3 sse2 sse athlon-xp athlon k7 k6 k5 i586
95.  elif ${CPUTYPE} == "athlon64"
96MACHINE_CPU = 3dnow mmx sse2 sse athlon-xp athlon k7 k6 k5 i586
97.  elif ${CPUTYPE} == "athlon-xp"
98MACHINE_CPU = 3dnow mmx sse athlon-xp athlon k7 k6 k5 i586
99.  elif ${CPUTYPE} == "athlon"
100MACHINE_CPU = 3dnow mmx athlon k7 k6 k5 i586
101.  elif ${CPUTYPE} == "k6-3"
102MACHINE_CPU = 3dnow mmx k6 k5 i586
103.  elif ${CPUTYPE} == "k6"
104MACHINE_CPU = mmx k6 k5 i586
105.  elif ${CPUTYPE} == "geode"
106MACHINE_CPU = 3dnow mmx i686 i586
107.  elif ${CPUTYPE} == "corei7"
108MACHINE_CPU = sse4.2 sse4.1 ssse3 sse3 sse2 sse mmx i686 i586
109.  elif ${CPUTYPE} == "core2"
110MACHINE_CPU = ssse3 sse3 sse2 sse mmx i686 i586
111.  elif ${CPUTYPE} == "nocona"
112MACHINE_CPU = sse3 sse2 sse mmx i686 i586
113.  elif ${CPUTYPE} == "prescott"
114MACHINE_CPU = sse3 sse2 sse mmx i686 i586
115.  elif ${CPUTYPE} == "pentium4"
116MACHINE_CPU = sse2 sse mmx i686 i586
117.  elif ${CPUTYPE} == "pentium3"
118MACHINE_CPU = sse mmx i686 i586
119.  elif ${CPUTYPE} == "pentium2"
120MACHINE_CPU = mmx i686 i586
121.  elif ${CPUTYPE} == "pentiumpro"
122MACHINE_CPU = i686 i586
123.  elif ${CPUTYPE} == "winchip2"
124MACHINE_CPU = 3dnow mmx
125.  elif ${CPUTYPE} == "winchip-c6"
126MACHINE_CPU = mmx
127.  elif ${CPUTYPE} == "pentium-mmx"
128MACHINE_CPU = mmx i586
129.  elif ${CPUTYPE} == "pentium"
130MACHINE_CPU = i586
131.  endif
132MACHINE_CPU += i386 i486
133. elif ${MACHINE_ARCH} == "x86_64"
134.  if ${CPUTYPE} == "bdver1"
135MACHINE_CPU = k8 abm 3dnow sse4.2 sse4.1 sse3
136.  elif ${CPUTYPE} == "barcelona"
137MACHINE_CPU = k8 abm 3dnow sse4a sse3
138.  elif ${CPUTYPE} == "athlon64-sse3"
139MACHINE_CPU = k8 3dnow sse3
140.  elif ${CPUTYPE} == "athlon64"
141MACHINE_CPU = k8 3dnow
142.  elif ${CPUTYPE} == "corei7"
143MACHINE_CPU = sse4.2 sse4.1 ssse3 sse3
144.  elif ${CPUTYPE} == "core2"
145MACHINE_CPU = ssse3 sse3
146.  elif ${CPUTYPE} == "nocona"
147MACHINE_CPU = sse3
148.  endif
149MACHINE_CPU += sse2 sse mmx x86_64
150. endif
151
152.endif
153