1 # Copyright (C) 2016-2018 Free Software Foundation, Inc.
3 # This file is part of GCC.
5 # GCC is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation; either version 3, or (at your option) any later
10 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # You should have received a copy of the GNU General Public License
16 # along with GCC; see the file COPYING3. If not see
17 # <http://www.gnu.org/licenses/>.
19 ##################################################################
21 # This file is using AVR's genmultilib.awk idea.
22 # Transform CPU Information from arc-cpu.def to a
23 # Representation that is understood by GCC's multilib Machinery.
25 # The Script works as a Filter from STDIN to STDOUT.
27 # FORMAT = "Makefile": Generate Makefile Snipet that sets some
28 # MULTILIB_* Variables as needed.
30 ##################################################################
39 ##################################################################
40 # Add some Comments to the generated Files and copy-paste
41 # Copyright Notice from above.
42 ##################################################################
46 else if (comment ==
1)
48 if (FORMAT ==
"Makefile")
50 print "# Auto-generated Makefile Snip"
51 print "# Generated by : ./gcc/config/arc/genmultilib.awk"
52 print "# Generated from : ./gcc/config/arc/arc-cpu.def"
53 print "# Used by : tmake_file from Makefile and genmultilib"
64 # The first empty line stops copy-pasting the GPL comments
65 # from this file to the generated file.
73 # gsub ("\"", "", name)
81 n =
split ($
4, cpu_flg
, "|")
84 for (i =
1; i
<= n
; i
++)
86 if (cpu_flg
[i
] ==
"FL_MPYOPT_0")
87 line = line
"/mmpy-option.0"
88 else if (cpu_flg
[i
] ==
"FL_MPYOPT_1")
89 line = line
"/mmpy-option.1"
90 else if (cpu_flg
[i
] ==
"FL_MPYOPT_2")
91 line = line
"/mmpy-option.2"
92 else if (cpu_flg
[i
] ==
"FL_MPYOPT_3")
93 line = line
"/mmpy-option.3"
94 else if (cpu_flg
[i
] ==
"FL_MPYOPT_4")
95 line = line
"/mmpy-option.4"
96 else if (cpu_flg
[i
] ==
"FL_MPYOPT_5")
97 line = line
"/mmpy-option.5"
98 else if (cpu_flg
[i
] ==
"FL_MPYOPT_6")
99 line = line
"/mmpy-option.6"
100 else if (cpu_flg
[i
] ==
"FL_MPYOPT_7")
101 line = line
"/mmpy-option.7"
102 else if (cpu_flg
[i
] ==
"FL_MPYOPT_8")
103 line = line
"/mmpy-option.8"
104 else if (cpu_flg
[i
] ==
"FL_MPYOPT_9")
105 line = line
"/mmpy-option.9"
106 else if (cpu_flg
[i
] ==
"FL_CD")
107 line = line
"/mcode-density"
108 else if (cpu_flg
[i
] ==
"FL_BS")
109 line = line
"/mbarrel-shifter"
110 else if (cpu_flg
[i
] ==
"FL_DIVREM")
111 line = line
"/mdiv-rem"
112 else if (cpu_flg
[i
] ==
"FL_NORM" \
113 || cpu_flg
[i
] ==
"FL_SWAP")
115 else if (cpu_flg
[i
] ==
"FL_FPU_FPUS")
116 line = line
"/mfpu.fpus"
117 else if (cpu_flg
[i
] ==
"FL_FPU_FPUDA")
118 line = line
"/mfpu.fpuda"
119 else if (cpu_flg
[i
] ==
"FL_FPU_FPUD_ALL")
120 line = line
"/mfpu.fpud_all"
121 else if (cpu_flg
[i
] ==
"FL_LL64")
123 else if (cpu_flg
[i
] ==
"FL_MUL64")
124 line = line
"/mmul64"
125 else if (cpu_flg
[i
] ==
"FL_MUL32x16")
126 line = line
"/mmul32x16"
127 else if (cpu_flg
[i
] ==
"FL_FPX_QUARK")
129 else if (cpu_flg
[i
] ==
"FL_SPFP")
131 else if (cpu_flg
[i
] ==
"FL_DPFP")
133 else if (cpu_flg
[i
] ==
"FL_RF16")
137 print "Don't know the flag " cpu_flg
[i
] > "/dev/stderr"
141 line =
"mcpu." name
"=" line
142 reuse
[n_reuse
] = line
147 cores
[n_cores
] = core
151 ##################################################################
153 # We gathered all the Information, now build/output the following:
155 # awk Variable target Variable FORMAT
156 # -----------------------------------------------------------
157 # m_options <-> MULTILIB_OPTIONS Makefile
158 # m_dirnames <-> MULTILIB_DIRNAMES "
160 ##################################################################
163 m_options =
"\nMULTILIB_OPTIONS = "
164 m_dirnames =
"\nMULTILIB_DIRNAMES ="
165 m_reuse =
"\nMULTILIB_REUSE ="
168 for (c =
0; c
< n_cores
; c
++)
170 m_options = m_options sep
"mcpu=" cores
[c
]
171 m_dirnames = m_dirnames
" " cores
[c
]
176 for (c =
0; c
< n_reuse
; c
++)
178 m_reuse = m_reuse sep reuse
[c
]
179 sep =
"\nMULTILIB_REUSE +="
181 ############################################################
183 ############################################################
185 if (FORMAT ==
"Makefile")
187 # Intended Target: ./gcc/config/arc/t-multilib
192 ############################################################
194 ############################################################
198 print "MULTILIB_MATCHES = mcpu?arc600=mcpu?ARC600"
199 print "MULTILIB_MATCHES += mcpu?arc600=mARC600"
200 print "MULTILIB_MATCHES += mcpu?arc600=mA6"
201 print "MULTILIB_MATCHES += mcpu?arc601=mcpu?ARC601"
202 print "MULTILIB_MATCHES += mcpu?arc700=mA7"
203 print "MULTILIB_MATCHES += mcpu?arc700=mARC700"