1 |
The arch class structure ({alpha,amd64,mips,hppa,etc}.py files) are a |
2 |
lot of typing for the small number of attributes they synthesize. This |
3 |
makes them prone to typing errors. |
4 |
|
5 |
Consider mips.py. It supports big and little endian; mips 1, 3, 4, |
6 |
loongson, cobalt; o32, n32, n64, multilib ABIs. Almost every |
7 |
combination of these attributes exists as a hard-coded class, leaving |
8 |
us with 24 builder and 5 abstract base classes. |
9 |
|
10 |
Wouldn't it be simpler to pass in some information into an arch_mips |
11 |
class and let it generate the requested attributes. Something like |
12 |
this: |
13 |
|
14 |
class arch_mips(generic): |
15 |
"MIPS class" |
16 |
def __init__(self, Olevel, arch, additional_cflags, include_workarounds): |
17 |
generic.__init__(self) |
18 |
|
19 |
self.settings["CFLAGS"] = "-O" + Olevel |
20 |
self.settings["CFLAGS"] += " -march=" + arch |
21 |
if additional_cflags != "": |
22 |
self.settings["CFLAGS"] += " " + additional_cflags |
23 |
if include_workarounds: |
24 |
if arch == "mips3": |
25 |
self.settings["CFLAGS"] += " -mfix-r4000 -mfix-r4400" |
26 |
elif arch == "r4000" or arch == "r4k": |
27 |
self.settings["CFLAGS"] += " -mfix-r4000" |
28 |
elif arch == "r4300": |
29 |
self.settings["CFLAGS"] += " -mfix-r4300" |
30 |
elif arch == "r10000" or arch == "r10k": |
31 |
self.settings["CFLAGS"] += " -mfix-r10000" |
32 |
self.settings["CFLAGS"] += " -pipe" |
33 |
|
34 |
Clearly a simplistic and incomplete example, but it should be enough |
35 |
to understand the idea. |
36 |
|
37 |
Thanks, |
38 |
Matt |