I am trying to migrate my source code compilation from armcc compiler v5.06 to armclang v6. And I see armclang errors out saying it can not recognize cp15 registers. It looks like there might be a change in armcc vs clang as how to declare the registers. However, I could not find anything on the migration docs or in compiler doc.
Here is the code snippet -
void reset_clock_count(void) { register uint32_t reg_cp15_pmcr __asm("cp15:0:c9:c12:0"); reg_cp15_pmcr |= RESET_CYCLE_COUNTER; }
And error snippet -
error: unknown register name 'cp15:0:c9:c12:0' in asm register uint32_t reg_cp15_pmcr __asm("cp15:0:c9:c12:0"); ^
I see same errors for other places for similarly declared register. Any pointer on what might have gone wrong will be helpful.
Hi Ronan,
I am using Cortex A5 and I do not use dev studio. However, I could not find such examples in ARM docs.
I saw some example in linux repo : https://github.com/torvalds/linux/blob/8808cf8cbc4da1ceef9307fba7e499563908c211/arch/arm/kernel/perf_event_v7.c
The way it is being accessed is
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (value));
I had tried this way but no luck -
reg_cp15_pmcr __asm("mcr cp15, 0, c9, c12, 0"); // experiment 1
reg_cp15_pmcr __asm("mcr cp15:0:c9:c12:0"); // experiment 2
All I see here in programmer's guide - https://www.macs.hw.ac.uk/~hwloidl/Courses/F28HS/Docu/DEN0013D_cortex_a_series_PG.pdf
There is no example for calling from c for clang.
I see cp15 is accessed as p15 in the doc.
For clang:
https://godbolt.org/z/YWsTe4
Thanks for the explanation and snippet. This is what I was looking for.