]> begriffs open source - cmsis/blob - CMSIS/Core/Test/lit.cfg.py
Core: correct type ENDIANNESS
[cmsis] / CMSIS / Core / Test / lit.cfg.py
1 # -*- Python -*-
2
3 import os
4
5 import lit.formats
6 import lit.util
7
8 DEVICES = {
9     'CM0': {
10         'arch': 'thumbv6m',
11         'triple': 'thumbv6m',
12         'abi': 'eabi',
13         'mcpu': 'cortex-m0',
14         'mfpu': 'none',
15         'mpu': False,
16         'features': ['thumbv6m'],
17         'header': 'core_cm0.h',
18         'defines': {
19             '__CM0_REV': '0x0000U',
20             '__NVIC_PRIO_BITS': '2U',
21             '__Vendor_SysTickConfig': '0U'
22         }
23     },
24     'CM0plus': {
25         'arch': 'thumbv6m',
26         'triple': 'thumbv6m',
27         'abi': 'eabi',
28         'mcpu': 'cortex-m0plus',
29         'mfpu': 'none',
30         'mpu': True,
31         'features': ['thumbv6m'],
32         'header': 'core_cm0plus.h',
33         'defines': {
34             '__CM0PLUS_REV': '0x0000U',
35             '__MPU_PRESENT': '1U',
36             '__VTOR_PRESENT': '1U',
37             '__NVIC_PRIO_BITS': '2U',
38             '__Vendor_SysTickConfig': '0U'
39         }
40     },
41     'CM3': {
42         'arch': 'thumbv7m',
43         'triple': 'thumbv7-m',
44         'abi': 'eabi',
45         'mcpu': 'cortex-m3',
46         'mfpu': 'none',
47         'mpu': True,
48         'features': ['thumbv6m', 'thumbv7m', 'thumb-2', 'sat', 'ldrex', 'clz'],
49         'header': 'core_cm3.h',
50         'defines': {
51             '__CM3_REV': '0x0000U',
52             '__MPU_PRESENT': '1U',
53             '__VTOR_PRESENT': '1U',
54             '__NVIC_PRIO_BITS': '3U',
55             '__Vendor_SysTickConfig': '0U'
56         }
57     },
58     'CM4': {
59         'arch': 'thumbv7em',
60         'triple': 'thumbv7-em',
61         'abi': 'eabi',
62         'mcpu': 'cortex-m4',
63         'mfpu': 'none',
64         'mpu': True,
65         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumb-2', 'sat', 'ldrex', 'clz'],
66         'header': 'core_cm4.h',
67         'defines': {
68             '__CM4_REV': '0x0000U',
69             '__FPU_PRESENT': '0U',
70             '__MPU_PRESENT': '1U',
71             '__VTOR_PRESENT': '1U',
72             '__NVIC_PRIO_BITS': '3U',
73             '__Vendor_SysTickConfig': '0U'
74         }
75     },
76     'CM4FP': {
77         'arch': 'thumbv7em',
78         'triple': 'thumbv7-em',
79         'abi': 'eabihf',
80         'mcpu': 'cortex-m4',
81         'mfpu': 'fpv4-sp-d16',
82         'mpu': True,
83         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumb-2', 'sat', 'ldrex', 'clz'],
84         'header': 'core_cm4.h',
85         'defines': {
86             '__CM4_REV': '0x0000U',
87             '__FPU_PRESENT': '1U',
88             '__MPU_PRESENT': '1U',
89             '__VTOR_PRESENT': '1U',
90             '__NVIC_PRIO_BITS': '3U',
91             '__Vendor_SysTickConfig': '0U'
92         }
93     },
94     'CM7': {
95         'arch': 'thumbv7em',
96         'triple': 'thumbv7-em',
97         'abi': 'eabi',
98         'mcpu': 'cortex-m7',
99         'mfpu': 'none',
100         'mpu': True,
101         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumb-2', 'sat', 'ldrex', 'clz'],
102         'header': 'core_cm7.h',
103         'defines': {
104             '__CM7_REV': '0x0000U',
105             '__FPU_PRESENT': '0U',
106             '__MPU_PRESENT': '1U',
107             '__ICACHE_PRESENT': '1U',
108             '__DCACHE_PRESENT': '1U',
109             '__DTCM_PRESENT': '1U',
110             '__VTOR_PRESENT': '1U',
111             '__NVIC_PRIO_BITS': '3U',
112             '__Vendor_SysTickConfig': '0U'
113         }
114     },
115     'CM7SP': {
116         'arch': 'thumbv7em',
117         'triple': 'thumbv7-em',
118         'abi': 'eabi',
119         'mcpu': 'cortex-m7',
120         'mfpu': 'fpv4-sp-d16',
121         'mpu': True,
122         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumb-2', 'sat', 'ldrex', 'clz'],
123         'header': 'core_cm7.h',
124         'defines': {
125             '__CM7_REV': '0x0000U',
126             '__FPU_PRESENT': '1U',
127             '__MPU_PRESENT': '1U',
128             '__ICACHE_PRESENT': '1U',
129             '__DCACHE_PRESENT': '1U',
130             '__DTCM_PRESENT': '1U',
131             '__VTOR_PRESENT': '1U',
132             '__NVIC_PRIO_BITS': '3U',
133             '__Vendor_SysTickConfig': '0U'
134         }
135     },
136     'CM7DP': {
137         'arch': 'thumbv7em',
138         'triple': 'thumbv7-em',
139         'abi': 'eabihf',
140         'mcpu': 'cortex-m7',
141         'mfpu': 'fpv5-d16',
142         'mpu': True,
143         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumb-2', 'sat', 'ldrex', 'clz'],
144         'header': 'core_cm7.h',
145         'defines': {
146             '__CM7_REV': '0x0000U',
147             '__FPU_PRESENT': '1U',
148             '__MPU_PRESENT': '1U',
149             '__ICACHE_PRESENT': '1U',
150             '__DCACHE_PRESENT': '1U',
151             '__DTCM_PRESENT': '1U',
152             '__VTOR_PRESENT': '1U',
153             '__NVIC_PRIO_BITS': '3U',
154             '__Vendor_SysTickConfig': '0U'
155         }
156     },
157     'CM23': {
158         'arch': 'thumbv8m.base',
159         'triple': 'thumbv8m',
160         'abi': 'eabi',
161         'mcpu': 'cortex-m23',
162         'mfpu': 'none',
163         'mpu': True,
164         'features': ['thumbv6m', 'thumbv7m', 'thumbv8m.base', 'ldrex'],
165         'header': 'core_cm23.h',
166         'defines': {
167             '__CM23_REV': '0x0000U',
168             '__FPU_PRESENT': '0U',
169             '__MPU_PRESENT': '1U',
170             '__SAUREGION_PRESENT': '8U',
171             '__VTOR_PRESENT': '1U',
172             '__NVIC_PRIO_BITS': '3U',
173             '__Vendor_SysTickConfig': '0U'
174         }
175     },
176     'CM23S': {
177         'arch': 'thumbv8m.base',
178         'triple': 'thumbv8m',
179         'abi': 'eabi',
180         'mcpu': 'cortex-m23',
181         'mfpu': 'none',
182         'mpu': True,
183         'features': ['thumbv6m', 'thumbv7m', 'thumbv8m.base', 'ldrex'],
184         'header': 'core_cm23.h',
185         'defines': {
186             '__CM23_REV': '0x0000U',
187             '__FPU_PRESENT': '0U',
188             '__MPU_PRESENT': '1U',
189             '__SAUREGION_PRESENT': '8U',
190             '__VTOR_PRESENT': '1U',
191             '__NVIC_PRIO_BITS': '3U',
192             '__Vendor_SysTickConfig': '0U'
193         }
194     },
195     'CM23NS': {
196         'arch': 'thumbv8m.base',
197         'triple': 'thumbv8m',
198         'abi': 'eabi',
199         'mcpu': 'cortex-m23',
200         'mfpu': 'none',
201         'mpu': True,
202         'features': ['thumbv6m', 'thumbv7m', 'thumbv8m.base', 'ldrex'],
203         'header': 'core_cm23.h',
204         'defines': {
205             '__CM23_REV': '0x0000U',
206             '__FPU_PRESENT': '0U',
207             '__MPU_PRESENT': '1U',
208             '__SAUREGION_PRESENT': '8U',
209             '__VTOR_PRESENT': '1U',
210             '__NVIC_PRIO_BITS': '3U',
211             '__Vendor_SysTickConfig': '0U'
212         }
213     },
214     'CM33': {
215         'arch': 'thumbv8m.main',
216         'triple': 'thumbv8m',
217         'abi': 'eabihf',
218         'mcpu': 'cortex-m33',
219         'mfpu': 'fpv5-d16',
220         'mpu': True,
221         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
222         'header': 'core_cm33.h',
223         'defines': {
224             '__CM33_REV': '0x0000U',
225             '__FPU_PRESENT': '1U',
226             '__MPU_PRESENT': '1U',
227             '__SAUREGION_PRESENT': '8U',
228             '__VTOR_PRESENT': '1U',
229             '__NVIC_PRIO_BITS': '3U',
230             '__Vendor_SysTickConfig': '0U'
231         }
232     },
233     'CM33S': {
234         'arch': 'thumbv8m.main',
235         'triple': 'thumbv8m',
236         'abi': 'eabihf',
237         'mcpu': 'cortex-m33',
238         'mfpu': 'fpv5-d16',
239         'mpu': True,
240         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
241         'header': 'core_cm33.h',
242         'defines': {
243             '__CM33_REV': '0x0000U',
244             '__FPU_PRESENT': '1U',
245             '__MPU_PRESENT': '1U',
246             '__SAUREGION_PRESENT': '8U',
247             '__VTOR_PRESENT': '1U',
248             '__NVIC_PRIO_BITS': '3U',
249             '__Vendor_SysTickConfig': '0U'
250         }
251     },
252     'CM33NS': {
253         'arch': 'thumbv8m.main',
254         'triple': 'thumbv8m',
255         'abi': 'eabihf',
256         'mcpu': 'cortex-m33',
257         'mfpu': 'fpv5-d16',
258         'mpu': True,
259         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
260         'header': 'core_cm33.h',
261         'defines': {
262             '__CM33_REV': '0x0000U',
263             '__FPU_PRESENT': '1U',
264             '__MPU_PRESENT': '1U',
265             '__SAUREGION_PRESENT': '8U',
266             '__VTOR_PRESENT': '1U',
267             '__NVIC_PRIO_BITS': '3U',
268             '__Vendor_SysTickConfig': '0U'
269         }
270     },
271     'CM35P': {
272         'arch': 'thumbv8m.main',
273         'triple': 'thumbv8m',
274         'abi': 'eabihf',
275         'mcpu': 'cortex-m35p',
276         'mfpu': 'fpv5-d16',
277         'mpu': True,
278         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
279         'header': 'core_cm35p.h',
280         'defines': {
281             '__CM35P_REV': '0x0000U',
282             '__FPU_PRESENT': '1U',
283             '__MPU_PRESENT': '1U',
284             '__SAUREGION_PRESENT': '8U',
285             '__VTOR_PRESENT': '1U',
286             '__NVIC_PRIO_BITS': '3U',
287             '__Vendor_SysTickConfig': '0U'
288         }
289     },
290     'CM35PS': {
291         'arch': 'thumbv8m.main',
292         'triple': 'thumbv8m',
293         'abi': 'eabihf',
294         'mcpu': 'cortex-m35p',
295         'mfpu': 'fpv5-d16',
296         'mpu': True,
297         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
298         'header': 'core_cm35p.h',
299         'defines': {
300             '__CM35P_REV': '0x0000U',
301             '__FPU_PRESENT': '1U',
302             '__MPU_PRESENT': '1U',
303             '__SAUREGION_PRESENT': '8U',
304             '__VTOR_PRESENT': '1U',
305             '__NVIC_PRIO_BITS': '3U',
306             '__Vendor_SysTickConfig': '0U'
307         }
308     },
309     'CM35PNS': {
310         'arch': 'thumbv8m.main',
311         'triple': 'thumbv8m',
312         'abi': 'eabihf',
313         'mcpu': 'cortex-m35p',
314         'mfpu': 'fpv5-d16',
315         'mpu': True,
316         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
317         'header': 'core_cm35p.h',
318         'defines': {
319             '__CM35P_REV': '0x0000U',
320             '__FPU_PRESENT': '1U',
321             '__MPU_PRESENT': '1U',
322             '__SAUREGION_PRESENT': '8U',
323             '__VTOR_PRESENT': '1U',
324             '__NVIC_PRIO_BITS': '3U',
325             '__Vendor_SysTickConfig': '0U'
326         }
327     },
328     'CM55': {
329         'arch': 'thumbv8.1m.main',
330         'triple': 'thumbv8m',
331         'abi': 'eabihf',
332         'mcpu': 'cortex-m55',
333         'mfpu': 'fpv5-d16',
334         'mpu': True,
335         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumbv8.1m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
336         'header': 'core_cm55.h',
337         'defines': {
338             '__CM55_REV': '0x0000U',
339             '__FPU_PRESENT': '1U',
340             '__FPU_DP': '1U',
341             '__MPU_PRESENT': '1U',
342             '__ICACHE_PRESENT': '1U',
343             '__DCACHE_PRESENT': '1U',
344             '__SAUREGION_PRESENT': '8U',
345             '__DSP_PRESENT': '1U',
346             '__VTOR_PRESENT': '1U',
347             '__PMU_PRESENT': '1U',
348             '__PMU_NUM_EVENTCNT': '8U',
349             '__NVIC_PRIO_BITS': '3U',
350             '__Vendor_SysTickConfig': '0U'
351         }
352     },
353     'CM55S': {
354         'arch': 'thumbv8.1m.main',
355         'triple': 'thumbv8m',
356         'abi': 'eabihf',
357         'mcpu': 'cortex-m55',
358         'mfpu': 'fpv5-d16',
359         'mpu': True,
360         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumbv8.1m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
361         'header': 'core_cm55.h',
362         'defines': {
363             '__CM55_REV': '0x0000U',
364             '__FPU_PRESENT': '1U',
365             '__FPU_DP': '1U',
366             '__MPU_PRESENT': '1U',
367             '__ICACHE_PRESENT': '1U',
368             '__DCACHE_PRESENT': '1U',
369             '__SAUREGION_PRESENT': '8U',
370             '__DSP_PRESENT': '1U',
371             '__VTOR_PRESENT': '1U',
372             '__PMU_PRESENT': '1U',
373             '__PMU_NUM_EVENTCNT': '8U',
374             '__NVIC_PRIO_BITS': '3U',
375             '__Vendor_SysTickConfig': '0U'
376         }
377     },
378     'CM55NS': {
379         'arch': 'thumbv8.1m.main',
380         'triple': 'thumbv8m',
381         'abi': 'eabihf',
382         'mcpu': 'cortex-m55',
383         'mfpu': 'fpv5-d16',
384         'mpu': True,
385         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumbv8.1m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
386         'header': 'core_cm55.h',
387         'defines': {
388             '__CM55_REV': '0x0000U',
389             '__FPU_PRESENT': '1U',
390             '__FPU_DP': '1U',
391             '__MPU_PRESENT': '1U',
392             '__ICACHE_PRESENT': '1U',
393             '__DCACHE_PRESENT': '1U',
394             '__SAUREGION_PRESENT': '8U',
395             '__DSP_PRESENT': '1U',
396             '__VTOR_PRESENT': '1U',
397             '__PMU_PRESENT': '1U',
398             '__PMU_NUM_EVENTCNT': '8U',
399             '__NVIC_PRIO_BITS': '3U',
400             '__Vendor_SysTickConfig': '0U'
401         }
402     },
403     'CM85': {
404         'arch': 'thumbv8.1m.main',
405         'triple': 'thumbv8m',
406         'abi': 'eabihf',
407         'mcpu': 'cortex-m85',
408         'mfpu': 'fpv5-d16',
409         'mpu': True,
410         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumbv8.1m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
411         'header': 'core_cm85.h',
412         'defines': {
413             '__CM85_REV': '0x0000U',
414             '__FPU_PRESENT': '1U',
415             '__FPU_DP': '1U',
416             '__MPU_PRESENT': '1U',
417             '__ICACHE_PRESENT': '1U',
418             '__DCACHE_PRESENT': '1U',
419             '__SAUREGION_PRESENT': '8U',
420             '__DSP_PRESENT': '1U',
421             '__VTOR_PRESENT': '1U',
422             '__PMU_PRESENT': '1U',
423             '__PMU_NUM_EVENTCNT': '8U',
424             '__NVIC_PRIO_BITS': '3U',
425             '__Vendor_SysTickConfig': '0U'
426         }
427     },
428     'CM85S': {
429         'arch': 'thumbv8.1m.main',
430         'triple': 'thumbv8m',
431         'abi': 'eabihf',
432         'mcpu': 'cortex-m85',
433         'mfpu': 'fpv5-d16',
434         'mpu': True,
435         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumbv8.1m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
436         'header': 'core_cm85.h',
437         'defines': {
438             '__CM85_REV': '0x0000U',
439             '__FPU_PRESENT': '1U',
440             '__FPU_DP': '1U',
441             '__MPU_PRESENT': '1U',
442             '__ICACHE_PRESENT': '1U',
443             '__DCACHE_PRESENT': '1U',
444             '__SAUREGION_PRESENT': '8U',
445             '__DSP_PRESENT': '1U',
446             '__VTOR_PRESENT': '1U',
447             '__PMU_PRESENT': '1U',
448             '__PMU_NUM_EVENTCNT': '8U',
449             '__NVIC_PRIO_BITS': '3U',
450             '__Vendor_SysTickConfig': '0U'
451         }
452     },
453     'CM85NS': {
454         'arch': 'thumbv8.1m.main',
455         'triple': 'thumbv8m',
456         'abi': 'eabihf',
457         'mcpu': 'cortex-m85',
458         'mfpu': 'fpv5-d16',
459         'mpu': True,
460         'features': ['thumbv6m', 'thumbv7m', 'dsp', 'thumbv8m.base', 'thumbv8m.main', 'thumbv8.1m.main', 'thumb-2', 'sat', 'ldrex', 'clz'],
461         'header': 'core_cm85.h',
462         'defines': {
463             '__CM85_REV': '0x0000U',
464             '__FPU_PRESENT': '1U',
465             '__FPU_DP': '1U',
466             '__MPU_PRESENT': '1U',
467             '__ICACHE_PRESENT': '1U',
468             '__DCACHE_PRESENT': '1U',
469             '__SAUREGION_PRESENT': '8U',
470             '__DSP_PRESENT': '1U',
471             '__VTOR_PRESENT': '1U',
472             '__PMU_PRESENT': '1U',
473             '__PMU_NUM_EVENTCNT': '8U',
474             '__NVIC_PRIO_BITS': '3U',
475             '__Vendor_SysTickConfig': '0U'
476         }
477     },
478     'CA5': {
479         'arch': 'armv7a',
480         'triple': 'armv7-a',
481         'abi': 'eabi',
482         'mcpu': 'cortex-a5',
483         'mfpu': 'none',
484         'mpu': True,
485         'features': ['armv7a', 'thumb-2', 'sat', 'clz'],
486         'header': 'core_ca.h',
487         'defines': {
488             '__CORTEX_A': '7',
489             '__CA_REV': '0x0000U',
490             '__FPU_PRESENT': '0U',
491             '__GIC_PRESENT': '1U',
492             '__TIM_PRESENT': '1U',
493             '__L2C_PRESENT': '1U',
494             'GIC_DISTRIBUTOR_BASE': '0x2C001000UL',
495             'GIC_INTERFACE_BASE': '0x2C000100UL',
496             'TIMER_BASE': '0x2C000600UL',
497             'L2C_310_BASE': '0x2C0F0000UL',
498             'IRQn_Type': 'int'
499         }
500     },
501     'CA5neon': {
502         'arch': 'armv7a',
503         'triple': 'armv7-a',
504         'abi': 'eabihf',
505         'mcpu': 'cortex-a5',
506         'mfpu': 'neon-vfpv4',
507         'mpu': True,
508         'features': ['armv7a', 'thumb-2', 'sat', 'dsp', 'clz'],
509         'header': 'core_ca.h',
510         'defines': {
511             '__CORTEX_A': '7',
512             '__CA_REV': '0x0000U',
513             '__FPU_PRESENT': '1U',
514             '__GIC_PRESENT': '1U',
515             '__TIM_PRESENT': '1U',
516             '__L2C_PRESENT': '1U',
517             'GIC_DISTRIBUTOR_BASE': '0x2C001000UL',
518             'GIC_INTERFACE_BASE': '0x2C000100UL',
519             'TIMER_BASE': '0x2C000600UL',
520             'L2C_310_BASE': '0x2C0F0000UL',
521             'IRQn_Type': 'int'
522         }
523     },
524     'CA7': {
525         'arch': 'armv7a',
526         'triple': 'armv7-a',
527         'abi': 'eabi',
528         'mcpu': 'cortex-a7',
529         'mfpu': 'none',
530         'mpu': True,
531         'features': ['armv7a', 'thumb-2', 'sat', 'clz'],
532         'header': 'core_ca.h',
533         'defines': {
534             '__CORTEX_A': '7',
535             '__CA_REV': '0x0000U',
536             '__FPU_PRESENT': '0U',
537             '__GIC_PRESENT': '1U',
538             '__TIM_PRESENT': '1U',
539             '__L2C_PRESENT': '1U',
540             'GIC_DISTRIBUTOR_BASE': '0x2C001000UL',
541             'GIC_INTERFACE_BASE': '0x2C000100UL',
542             'TIMER_BASE': '0x2C000600UL',
543             'L2C_310_BASE': '0x2C0F0000UL',
544             'IRQn_Type': 'int'
545         }
546     },
547     'CA7neon': {
548         'arch': 'armv7a',
549         'triple': 'armv7-a',
550         'abi': 'eabihf',
551         'mcpu': 'cortex-a7',
552         'mfpu': 'neon-vfpv4',
553         'mpu': True,
554         'features': ['armv7a', 'thumb-2', 'sat', 'dsp', 'clz'],
555         'header': 'core_ca.h',
556         'defines': {
557             '__CORTEX_A': '7',
558             '__CA_REV': '0x0000U',
559             '__FPU_PRESENT': '1U',
560             '__GIC_PRESENT': '1U',
561             '__TIM_PRESENT': '1U',
562             '__L2C_PRESENT': '1U',
563             'GIC_DISTRIBUTOR_BASE': '0x2C001000UL',
564             'GIC_INTERFACE_BASE': '0x2C000100UL',
565             'TIMER_BASE': '0x2C000600UL',
566             'L2C_310_BASE': '0x2C0F0000UL',
567             'IRQn_Type': 'int'
568         }
569     },
570     'CA9': {
571         'arch': 'armv7a',
572         'triple': 'armv7-a',
573         'abi': 'eabi',
574         'mcpu': 'cortex-a9',
575         'mfpu': 'none',
576         'mpu': True,
577         'features': ['armv7a', 'thumb-2', 'sat', 'clz'],
578         'header': 'core_ca.h',
579         'defines': {
580             '__CORTEX_A': '7',
581             '__CA_REV': '0x0000U',
582             '__FPU_PRESENT': '0U',
583             '__GIC_PRESENT': '1U',
584             '__TIM_PRESENT': '1U',
585             '__L2C_PRESENT': '1U',
586             'GIC_DISTRIBUTOR_BASE': '0x2C001000UL',
587             'GIC_INTERFACE_BASE': '0x2C000100UL',
588             'TIMER_BASE': '0x2C000600UL',
589             'L2C_310_BASE': '0x2C0F0000UL',
590             'IRQn_Type': 'int'
591         }
592     },
593     'CA9neon': {
594         'arch': 'armv7a',
595         'triple': 'armv7-a',
596         'abi': 'eabihf',
597         'mcpu': 'cortex-a9',
598         'mfpu': 'neon-vfpv3',
599         'mpu': True,
600         'features': ['armv7a', 'thumb-2', 'sat', 'dsp', 'ldrex', 'clz'],
601         'header': 'core_ca.h',
602         'defines': {
603             '__CORTEX_A': '7',
604             '__CA_REV': '0x0000U',
605             '__FPU_PRESENT': '1U',
606             '__GIC_PRESENT': '1U',
607             '__TIM_PRESENT': '1U',
608             '__L2C_PRESENT': '1U',
609             'GIC_DISTRIBUTOR_BASE': '0x2C001000UL',
610             'GIC_INTERFACE_BASE': '0x2C000100UL',
611             'TIMER_BASE': '0x2C000600UL',
612             'L2C_310_BASE': '0x2C0F0000UL',
613             'IRQn_Type': 'int'
614         }
615     }
616 }
617
618 # Configuration file for the 'lit' test runner.
619
620 # name: The name of this test suite.
621 config.name = "CMSIS-Core"
622
623 # testFormat: The test format to use to interpret tests.
624 #
625 # For now we require '&&' between commands, until they get globally killed and
626 # the test runner updated.
627 config.test_format = lit.formats.ShTest()
628
629 # suffixes: A list of file extensions to treat as test files.
630 config.suffixes = [
631     ".c"
632 ]
633
634 # test_source_root: The root path where tests are located.
635 config.test_source_root = os.path.dirname(__file__)
636
637
638 # clang_path = get_toolchain_from_env('CLANG')
639
640 toolchain = lit_config.params.get("toolchain", "AC6")
641 device = lit_config.params.get("device", "ARMCM3")
642 optimize = lit_config.params.get("optimize", "none")
643
644 class Toolchain:
645     def __init__(self, toolchain, device, optimize):
646         self._toolchain = toolchain
647         self.device = device
648         self.optimize = optimize
649
650     def get_root_from_env(self):
651         keys = sorted((k for k in os.environ.keys() if k.startswith(f'{self._toolchain}_TOOLCHAIN_')), reverse=True)
652         if not keys:
653             print(f"Toolchain '{self._toolchain}' not registered!")
654             return None
655         return os.environ.get(keys[0])
656
657     def get_root(self):
658         return self.get_root_from_env()
659
660
661 class Toolchain_AC6(Toolchain):
662     OPTIMIZE = {
663         'none': '-O1',
664         'balanced': '-O3',
665         'speed': '-Os',
666         'size': '-Oz'
667     }
668
669     def __init__(self, **args):
670         super().__init__('AC6', **args)
671
672     def get_cc(self):
673         return os.path.join(self.get_root(), 'armclang')
674
675     def get_ccflags(self):
676         ccflags = [
677             '--target=arm-arm-none-eabi', f'-mcpu={DEVICES[self.device]["mcpu"]}', f'-mfpu={DEVICES[self.device]["mfpu"]}', 
678             self.OPTIMIZE[self.optimize], '-I', os.path.abspath('../Include'), '-c', '-D', f'CORE_HEADER="{DEVICES[device]["header"]}"']
679         if device.endswith('S') and not device.endswith('NS'):
680             ccflags += ["-mcmse"]
681         ccflags += list(sum([('-D', f'{define}={value}') for (define, value) in DEVICES[self.device]['defines'].items()], ()))
682         return ccflags
683
684
685 class Toolchain_GCC(Toolchain):
686     OPTIMIZE = {
687         'none': '-O1',
688         'balanced': '-O3',
689         'speed': '-Os',
690         'size': '-Oz'
691     }
692
693     def __init__(self, **args):
694         super().__init__('GCC', **args)
695
696     def get_cc(self):
697         return os.path.join(self.get_root(), 'arm-none-eabi-gcc')
698
699     def get_ccflags(self):
700         floatabi='soft'
701         if DEVICES[self.device]["mfpu"] != 'none':
702             floatabi='hard'
703         ccflags = [
704             f'-mcpu={DEVICES[self.device]["mcpu"]}', f'-mfloat-abi={floatabi}', 
705             self.OPTIMIZE[self.optimize], '-I', os.path.abspath('../Include'), 
706             '-D', f'CORE_HEADER="{DEVICES[device]["header"]}"', '-c']
707         if DEVICES[self.device]["mfpu"] != "none":
708             ccflags += [f'-mfpu={DEVICES[self.device]["mfpu"]}']
709         if device.endswith('S') and not device.endswith('NS'):
710             ccflags += ["-mcmse"]
711         ccflags += list(sum([('-D', f'{define}={value}') for (define, value) in DEVICES[self.device]['defines'].items()], ()))
712         return ccflags
713
714 class Toolchain_Clang(Toolchain):
715     TARGET = {
716         'CM0': 'thumbv6m-none-unknown-eabi',
717         'CM0plus': 'thumbv6m-none-unknown-eabi',
718         'CM3': 'thumbv7m-none-unknown-eabi',
719         'CM4': 'thumbv7em-none-unknown-eabi',
720         'CM4FP': 'thumbv7em-none-unknown-eabihf',
721         'CM7': 'thumbv7em-none-unknown-eabi',
722         'CM7SP': 'thumbv7em-none-unknown-eabihf',
723         'CM7DP': 'thumbv7em-none-unknown-eabihf',
724         'CM23': 'thumbv8m.base-none-unknown-eabi',
725         'CM23S': 'thumbv8m.base-none-unknown-eabi',
726         'CM23NS': 'thumbv8m.base-none-unknown-eabi',
727         'CM33': 'thumbv8m.main-none-unknown-eabihf',
728         'CM33S': 'thumbv8m.main-none-unknown-eabihf',
729         'CM33NS': 'thumbv8m.main-none-unknown-eabihf',
730         'CM35P': 'thumbv8m.main-none-unknown-eabihf',
731         'CM35PS': 'thumbv8m.main-none-unknown-eabihf',
732         'CM35PNS': 'thumbv8m.main-none-unknown-eabihf',
733         'CM55': 'thumbv8.1m.main-none-unknown-eabihf',
734         'CM55S': 'thumbv8.1m.main-none-unknown-eabihf',
735         'CM55NS': 'thumbv8.1m.main-none-unknown-eabihf',
736         'CM85': 'thumbv8.1m.main-none-unknown-eabihf',
737         'CM85S': 'thumbv8.1m.main-none-unknown-eabihf',
738         'CM85NS': 'thumbv8.1m.main-none-unknown-eabihf',
739         'CA5': 'armv7-none-unknown-eabi',
740         'CA5neon': 'armv7-none-unknown-eabihf',
741         'CA7': 'armv7-none-unknown-eabi',
742         'CA7neon': 'armv7-none-unknown-eabihf',
743         'CA9': 'armv7-none-unknown-eabi',
744         'CA9neon': 'armv7-none-unknown-eabihf'
745     }
746     OPTIMIZE = {
747         'none': '-O1',
748         'balanced': '-O3',
749         'speed': '-Os',
750         'size': '-Oz'
751     }
752     def __init__(self, **args):
753         super().__init__('CLANG', **args)
754
755     def get_cc(self):
756         return os.path.join(self.get_root(), 'clang')
757
758     def get_ccflags(self):
759         ccflags = [
760             f'--target={self.TARGET[self.device]}', self.OPTIMIZE[self.optimize], 
761             f'-mcpu={DEVICES[self.device]["mcpu"]}', f'-mfpu={DEVICES[self.device]["mfpu"]}', 
762             '-I', os.path.abspath('../Include'), '-c', '-D', f'CORE_HEADER="{DEVICES[device]["header"]}"']
763         if device.endswith('S') and not device.endswith('NS'):
764             ccflags += ["-mcmse"]
765         ccflags += list(sum([('-D', f'{define}={value}') for (define, value) in DEVICES[self.device]['defines'].items()], ()))
766
767         return ccflags
768     
769 tc = None
770 if toolchain == 'AC6':
771     tc = Toolchain_AC6(device=device, optimize=optimize)
772 elif toolchain == 'GCC':
773     tc = Toolchain_GCC(device=device, optimize=optimize)
774 elif toolchain == 'Clang':
775     tc = Toolchain_Clang(device=device, optimize=optimize)
776
777 prefixes = ['CHECK']
778 if device.endswith('NS'):
779     prefixes += ['CHECK-NS']
780 elif device.endswith('S'):
781     prefixes += ['CHECK-S']
782 if DEVICES[device]['arch'].startswith('thumb'):
783     prefixes += ['CHECK-THUMB']       
784 elif DEVICES[device]['arch'].startswith('arm'):
785     prefixes += ['CHECK-ARM']
786
787 if DEVICES[device]["mfpu"] != 'none':
788     config.available_features.add('fpu')
789 for feature in DEVICES[device]['features']:
790     config.available_features.add(feature)
791
792 objdump = os.path.join(Toolchain("CLANG", "none", "none").get_root(), 'llvm-objdump')
793 config.substitutions.append(("llvm-objdump", objdump))
794
795 config.substitutions.append(("%ccout%", "-o"))
796 config.substitutions.append(("%cc%", tc.get_cc()))
797 config.substitutions.append(("%ccflags%", ' '.join(tc.get_ccflags())))
798 config.substitutions.append(("%prefixes%", ','.join(prefixes)))
799 config.substitutions.append(("%triple%", DEVICES[device]['triple']))
800 config.substitutions.append(("%mcpu%", DEVICES[device]['mcpu']))