Skip to content

Commit febbeff

Browse files
author
deepikabhavnani
committed
Change if statements to lookup tables
1 parent f7d49fd commit febbeff

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tools/toolchains/gcc.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,18 @@ def __init__(self, target, notify=None, macros=None, build_profile=None,
6666
"-Wl,--out-implib=%s" % join(build_dir, "cmse_lib.o")
6767
])
6868

69-
if core == "Cortex-M0+":
70-
self.cpu = ["-mcpu=cortex-m0plus"]
71-
elif core.startswith("Cortex-M4"):
72-
self.cpu = ["-mcpu=cortex-m4"]
73-
elif core.startswith("Cortex-M7"):
74-
self.cpu = ["-mcpu=cortex-m7"]
75-
elif core == "Cortex-M33FE":
76-
self.cpu = ["-mcpu=cortex-m33"]
77-
elif core == "Cortex-M33F":
78-
self.cpu = ["-mcpu=cortex-m33+nodsp"]
79-
elif core == "Cortex-M33":
69+
cpu = {
70+
"Cortex-M0+": "cortex-m0plus",
71+
"Cortex-M4F": "cortex-m4",
72+
"Cortex-M7F": "cortex-m7",
73+
"Cortex-M7FD": "cortex-m7",
74+
"Cortex-M33F": "cortex-m33+no_dsp",
75+
"Cortex-M33FE": "cortex-m33"}.get(core, core)
76+
77+
if core == "Cortex-M33":
8078
self.cpu = ["-march=armv8-m.main"]
8179
else:
82-
self.cpu = ["-mcpu={}".format(core.lower())]
80+
self.cpu = ["-mcpu={}".format(cpu.lower())]
8381

8482
if target.core.startswith("Cortex-M"):
8583
self.cpu.append("-mthumb")

0 commit comments

Comments
 (0)