1 /* This file contains code to do profiling.
3 Copyright (C) 2007-2016 Free Software Foundation, Inc.
4 Contributor: Joern Rennecke <joern.rennecke@embecosm.com>
5 on behalf of Synopsys Inc.
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 3, or (at your option) any later
15 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 Under Section 7 of GPL version 3, you are granted additional
21 permissions described in the GCC Runtime Library Exception, version
22 3.1, as published by the Free Software Foundation.
24 You should have received a copy of the GNU General Public License and
25 a copy of the GCC Runtime Library Exception along with this program;
26 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
27 <http://www.gnu.org/licenses/>. */
31 /* This file contains code to do profiling. */
32 .weak __profile_timer_cycles
33 .global __profile_timer_cycles
34 .set __profile_timer_cycles, 200
37 .global __profil_offset
39 .type __profil_offset, @object
40 .size __profil_offset, 4
45 .global __dcache_linesz
48 #if !defined (__EM__) && !defined (__HS__)
55 breq_s r0,0,.Lstop_profiling
56 ; r0: buf r1: bufsiz r2: offset r3: scale
57 bxor.f r3,r3,15; scale must be 0x8000, i.e. 1/2; generate 0.
61 flag.ne 1 ; halt if wrong scale
63 st r0,[__profil_offset]
74 #else /* !__ARC700__ */
75 # FIX ME: set up loop according to cache line size
76 lr r12,[D_CACHE_BUILD]
89 #endif /* __ARC700__ */
90 2: b_s .Lcounters_cleared
93 lr r1,[INT_VECTOR_BASE] ; disable timer0 interrupts
96 0: ld_s r0,[pcl,1f-0b+((0b-.Lprofil) & 2)] ; 1f@GOTOFF
97 0: ld_s r12,[pcl,1f+4-0b+((0b-.Lprofil) & 2)] ; 1f@GOTOFF + 4
98 st_s r0,[r1,24]; timer0 uses vector3
99 st_s r12,[r1,24+4]; timer0 uses vector3
101 sr __profile_timer_cycles,[LIMIT0]
102 mov_s r12,3 ; enable timer interrupts; count only when not halted.
105 bset_s r12,r12,1 ; allow level 1 interrupts
116 #endif /* !__EM__ && !__HS__ */
120 .balign 4 ; make final jump unaligned to avoid delay penalty
121 .balign 32,0,12 ; make sure the code spans no more that two cache lines
124 #if !defined (__EM__) && !defined (__HS__)
126 ld r0,[__profil_offset]
136 nostore:ld.ab r2,[sp,8]
141 #endif /* !__EM__ && !__HS__ */
142 ENDFUNC(__profil_irq)
144 ; could save one cycle if the counters were allocated at link time and
145 ; the contents of __profil_offset were pre-computed at link time, like this:
147 ; __profil_offset needs to be PROVIDEd as __profile_base-text/4
148 .global __profil_offset
153 add1 r0,__profil_offset,r0