Hi,
I use the Hercules HDK /Cortex R5F / TMS570LC4357.
As i have Code generated for the TI compiler and for the GNU toolchain, set up two projects for the same task - performance measurement.
The code for the ti Compiler worked, but the same C-Code returned only zeros as measured time.
after comparing HL_sys_pmu.asm (TI) and HL_sys_pmu.s (GNU gas), the Assembler Code differs.
i.e. the function _pmuGetEventCount_ misses the "lsr r0, r0, #1 " part...
See Code created by HALCoGen:
/*-------------------------------------------------------------------------------*/
@ Get Event Counter Count Value
.weak _pmuGetEventCount_
.type _pmuGetEventCount_, %function
_pmuGetEventCount_:
mcr p15, #0, r0, c9, c12, #5 @ select counter
mrc p15, #0, r0, c9, c13, #2 @ read event counter
bx lr
After Modification:
/*-------------------------------------------------------------------------------*/
@ Get Event Counter Count Value
.weak _pmuGetEventCount_
.type _pmuGetEventCount_, %function
_pmuGetEventCount_:
lsr r0, r0, #1 @ missed - TODO: Bug Report
mcr p15, #0, r0, c9, c12, #5 @ select counter
mrc p15, #0, r0, c9, c13, #2 @ read event counter
bx lr
a complete diff is here (sorry - Code was cleaned up before by unusable trailing spaces and tabs...):
--- ../../BenchR5F-gcc/source/HL_sys_pmu.s 2016-08-03 16:36:00.000000000 +0200
+++ HL_sys_pmu.s 2016-08-03 17:02:08.000000000 +0200
@@ -2,8 +2,8 @@
HL_sys_pmu.s
Copyright (C) 2009-2016 Texas Instruments Incorporated - www.ti.com
-
-
+
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
@@ -44,11 +44,12 @@
@ Initialize Pmu
@ Note: It will reset all counters
- .weak _pmuInit_
- .type _pmuInit_, %function
+ .weak _pmuInit_
+ .type _pmuInit_, %function
_pmuInit_:
+ stmfd sp!, {r0}
@ set control register
mrc p15, #0, r0, c9, c12, #0
orr r0, r0, #(1 << 4) + 6 + 1
@@ -72,6 +73,7 @@
mcr p15, #0, r0, c9, c12, #5 @ select counter
mov r0, #0x11
mcr p15, #0, r0, c9, c13, #1 @ select event
+ ldmfd sp!, {r0}
bx lr
/*-------------------------------------------------------------------------------*/
@@ -80,12 +82,14 @@
.weak _pmuEnableCountersGlobal_
.type _pmuEnableCountersGlobal_, %function
-
+
_pmuEnableCountersGlobal_:
+ stmfd sp!, {r0}
mrc p15, #0, r0, c9, c12, #0
orr r0, r0, #7
mcr p15, #0, r0, c9, c12, #0
+ ldmfd sp!, {r0}
bx lr
/*-------------------------------------------------------------------------------*/
@@ -93,12 +97,14 @@
.weak _pmuDisableCountersGlobal_
.type _pmuDisableCountersGlobal_, %function
-
+
_pmuDisableCountersGlobal_:
+ stmfd sp!, {r0}
mrc p15, #0, r0, c9, c12, #0
bic r0, r0, #1
mcr p15, #0, r0, c9, c12, #0
+ ldmfd sp!, {r0}
bx lr
/*-------------------------------------------------------------------------------*/
@@ -106,12 +112,14 @@
.weak _pmuResetCycleCounter_
.type _pmuResetCycleCounter_, %function
-
+
_pmuResetCycleCounter_:
+ stmfd sp!, {r0}
mrc p15, #0, r0, c9, c12, #0
orr r0, r0, #4
mcr p15, #0, r0, c9, c12, #0
+ ldmfd sp!, {r0}
bx lr
/*-------------------------------------------------------------------------------*/
@@ -119,25 +127,29 @@
.weak _pmuResetEventCounters_
.type _pmuResetEventCounters_, %function
-
+
_pmuResetEventCounters_:
+ stmfd sp!, {r0}
mrc p15, #0, r0, c9, c12, #0
orr r0, r0, #2
mcr p15, #0, r0, c9, c12, #0
+ ldmfd sp!, {r0}
bx lr
/*-------------------------------------------------------------------------------*/
-@ Reset Cycle Counter abd Event Counters [0..2]
+@ Reset Cycle Counter and Event Counters [0..2]
- .weak _pmuResetCounters_
+ .weak _pmuResetCounters_
.type _pmuResetCounters_, %function
-
+
_pmuResetCounters_:
+ stmfd sp!, {r0}
mrc p15, #0, r0, c9, c12, #0
orr r0, r0, #6
mcr p15, #0, r0, c9, c12, #0
+ ldmfd sp!, {r0}
bx lr
/*-------------------------------------------------------------------------------*/
@@ -145,7 +157,7 @@
.weak _pmuStartCounters_
.type _pmuStartCounters_, %function
-
+
_pmuStartCounters_:
mcr p15, #0, r0, c9, c12, #1
@@ -156,7 +168,7 @@
.weak _pmuStopCounters_
.type _pmuStopCounters_, %function
-
+
_pmuStopCounters_:
mcr p15, #0, r0, c9, c12, #2
@@ -166,8 +178,8 @@
@ Set Count event
.weak _pmuSetCountEvent_
- .type _pmuSetCountEvent_, %function
-
+ .type _pmuSetCountEvent_, %function
+
_pmuSetCountEvent_:
mcr p15, #0, r0, c9, c12, #5 @ select counter
@@ -179,7 +191,7 @@
.weak _pmuGetCycleCount_
.type _pmuGetCycleCount_, %function
-
+
_pmuGetCycleCount_:
mrc p15, #0, r0, c9, c13, #0
@@ -190,9 +202,10 @@
.weak _pmuGetEventCount_
.type _pmuGetEventCount_, %function
-
+
_pmuGetEventCount_:
+ lsr r0, r0, #1
mcr p15, #0, r0, c9, c12, #5 @ select counter
mrc p15, #0, r0, c9, c13, #2 @ read event counter
bx lr
@@ -202,7 +215,7 @@
.weak _pmuGetOverflow_
.type _pmuGetOverflow_, %function
-
+
_pmuGetOverflow_:
mrc p15, #0, r0, c9, c12, #3 @ read overflow
