Welcome to mirror list, hosted at ThFree Co, Russian Federation.

profile.h « machine « xscale « machine « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 90198ba699606a9b6315c8ea502c65ab9bcb9827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* profile.h

   Copyright (C) 2002 by  Red Hat, Incorporated. All rights reserved.
 
   Permission to use, copy, modify, and distribute this software
   is freely granted, provided that this notice is preserved.  */

#ifndef __XSCALE_PROFILE_H__
#define __XSCALE_PROFILE_H__

/* FIXME:
   We need to create a string version of the CPP predefined
   __USER_LABEL_PREFIX__ macro.  Ideally we would like to
   so do something like:

     #if  __USER_LABEL_PREFIX__ == _

   but this fails for arm-elf targets because although
   __USER_LABEL__PREFIX__ is defined, it is not defined to
   a specific value (even 0) and so the above test fails
   with:
   
      operator '==' has no left operand

  Instead we have to test the CPP predefined __ELF__ and
  rely upon the *assumption* that ELF targets will not use
  an underscore prefix and that COFF targets will.  */

#ifdef __ELF__
#define FOO ""
#else
#define FOO "_"
#endif

#define _MCOUNT_DECL(frompc, selfpc) \
void __attribute__ ((no_instrument_function)) \
mcount_internal (frompc, selfpc)

/* mcount_internal expects two arguments
   r0 frompc (return address for function that call function that calls mcount)
   r1 selfpc (return address for function that called mcount)

   The frompc is extracted from the stack frames. If the code does not
   generate stack frames, then mcount cannot extract this
   information. Thus, the -fomit-frame-pointer optimization cannot be
   used if a call graph information is required.

   Due to optimizations mcount doesn't set up a new fp. mcount has the fp
   of the calling function.

   r0 frompc is from the current frame
   r1 selfpc can be obtained directly from lr.  */

#ifdef __thumb__
#define MCOUNT					\
void __attribute__ ((naked))			\
     __attribute__ ((no_instrument_function))	\
mcount (void)					\
{						\
  __asm__("push {r0, r1, r2, r3, lr};"		\
	  "add r0, r7, #0;"			\
	  "beq 1f;"				\
	  "sub r0, r0, #4;"			\
	  "ldr r0, [r0];"			\
	  "1: mov r1, lr;"			\
	  "bl " FOO "mcount_internal ;"		\
	  "pop {r0, r1, r2, r3, pc};"		\
	);					\
}
#else
#define MCOUNT					\
void __attribute__ ((naked))			\
     __attribute__ ((no_instrument_function))	\
mcount (void)					\
{						\
  __asm__("stmdb sp!, {r0, r1, r2, r3, lr};"	\
	  "movs r0, fp;"			\
	  "ldrne r0, [r0, #-4];"		\
	  "mov r1, lr;"				\
	  "bl " FOO "mcount_internal ;" 	\
          "ldmia sp!, {r0, r1, r2, r3, pc};"	\
	);					\
}
#endif

#define FUNCTION_ALIGNMENT 2

#endif /* !__XSCALE_PROFILE_H__ */