1 /* 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * and/or other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #include "pcc_prefix.s" 19 20 #define BLANK 21 #define BANNER(str) BLANK .VERSION str 22 #define ENTRY(Name) BLANK M_ENTRY (Name,PROF_/**/Name) 23 #define ENTRYC(Name) BLANK M_ENTRYC(Name,PROF_/**/Name) 24 #define EXIT(Name) BLANK M_EXIT (Name,PROF_/**/Name) 25 #define EXITC(Name) BLANK M_EXITC (Name,PROF_/**/Name) 26 27 #if 0 28 #define TEXT_SEGMENT \ 29 .SPACE $TEXT$ !\ 30 .SUBSPA $CODE$ 31 #define RO_SEGMENT \ 32 .SPACE $TEXT$ !\ 33 .SUBSPA $lit$ 34 #define DATA_SEGMENT \ 35 .SPACE $PRIVATE$ !\ 36 .SUBSPA $data$ 37 #define BSS_SEGMENT \ 38 .SPACE $PRIVATE$ !\ 39 .SUBSPA $bss$ 40 #else 41 #define TEXT_SEGMENT .text 42 #define RO_SEGMENT .rodata 43 #define DATA_SEGMENT .data 44 #define BSS_SEGMENT .bss 45 #endif 46 47 48 49 50 #ifdef PROF 51 52 ; 53 ; All four argument registers are saved into caller save registers 54 ; and restored after the call to _mcount. This is possible because 55 ; the mcount routine does not modify them, so we can. Mcount takes 56 ; 3 arguments; the first argument is the incoming 'rp', the second 57 ; is the starting address of the profiled routine, and the third is 58 ; the address of the PROF label (which is where mcount stores the 59 ; profile data). 60 ; 61 #define M_ENTRY(name,prof) \ 62 TEXT_SEGMENT !\ 63 .label name !\ 64 .PROC !\ 65 .CALLINFO CALLER,SAVE_RP !\ 66 .ENTRY !\ 67 stw rp,-20(sp) !\ 68 ldo 48(sp),sp !\ 69 or arg0,r0,r19 !\ 70 or arg1,r0,r20 !\ 71 or arg2,r0,r21 !\ 72 or arg3,r0,r22 !\ 73 or rp,r0,arg0 !\ 74 ldil L%name,r1 !\ 75 ldo R%name(r1),arg1 !\ 76 addil L%prof-$global$,dp !\ 77 bl _mcount,rp !\ 78 ldo R%prof-$global$(r1),arg2 !\ 79 ldw -68(sp),rp !\ 80 ldo -48(sp),sp !\ 81 or r19,r0,arg0 !\ 82 or r20,r0,arg1 !\ 83 or r21,r0,arg2 !\ 84 or r22,r0,arg3 !\ 85 86 87 #define M_ENTRYC(name,prof) \ 88 TEXT_SEGMENT !\ 89 .label name !\ 90 .PROC !\ 91 .CALLINFO CALLER,SAVE_RP !\ 92 .ENTRY !\ 93 stw rp,-20(sp) !\ 94 ldo 128(sp),sp !\ 95 or arg0,r0,r19 !\ 96 or arg1,r0,r20 !\ 97 or arg2,r0,r21 !\ 98 or arg3,r0,r22 !\ 99 or rp,r0,arg0 !\ 100 ldil L%name,r1 !\ 101 ldo R%name(r1),arg1 !\ 102 addil L%prof-$global$,dp !\ 103 bl _mcount,rp !\ 104 ldo R%prof-$global$(r1),arg2 !\ 105 ldw -148(sp),rp !\ 106 or r19,r0,arg0 !\ 107 or r20,r0,arg1 !\ 108 or r21,r0,arg2 !\ 109 or r22,r0,arg3 !\ 110 111 ; 112 ; The HPUX profiler uses a word for each entrypoint to store the profiling 113 ; information. The setup code passes the address to the _mcount routine. 114 ; The EXIT macro defines a label (PROF_foo), and a word of storage. 115 ; 116 #define M_EXIT(name,prof) \ 117 bv,n r0(rp) !\ 118 .EXIT !\ 119 .PROCEND !\ 120 .EXPORT name,ENTRY !\ 121 DATA_SEGMENT !\ 122 .label prof !\ 123 .WORD 0 !\ 124 .IMPORT $global$,DATA !\ 125 .IMPORT _mcount,CODE 126 127 #define M_EXITC(name,prof) \ 128 bv r0(rp) !\ 129 ldo -128(sp),sp !\ 130 .EXIT !\ 131 .PROCEND !\ 132 .EXPORT name,ENTRY !\ 133 DATA_SEGMENT !\ 134 .label prof !\ 135 .WORD 0 !\ 136 .IMPORT $global$,DATA !\ 137 .IMPORT _mcount,CODE 138 139 #else /* NOT profiling */ 140 141 #define M_ENTRY(name,prof) \ 142 TEXT_SEGMENT !\ 143 .label name !\ 144 .PROC !\ 145 .CALLINFO !\ 146 .ENTRY 147 148 #define M_ENTRYC(name,prof) \ 149 TEXT_SEGMENT !\ 150 .label name !\ 151 .PROC !\ 152 .CALLINFO CALLER,SAVE_RP !\ 153 .ENTRY !\ 154 stw rp,-20(sp) !\ 155 ldo 128(sp),sp 156 157 #define M_EXIT(name,prof) \ 158 bv,n r0(rp) !\ 159 .EXIT !\ 160 .PROCEND !\ 161 .EXPORT name,ENTRY 162 163 #define M_EXITC(name,prof) \ 164 ldw -148(sp),rp !\ 165 bv r0(rp) !\ 166 ldo -128(sp),sp !\ 167 .EXIT !\ 168 .PROCEND !\ 169 .EXPORT name,ENTRY 170 171 #define ENTRY(Name) BLANK M_ENTRY (Name,PROF_/**/Name) 172 #define ENTRYC(Name) BLANK M_ENTRYC(Name,PROF_/**/Name) 173 #define EXIT(Name) BLANK M_EXIT (Name,PROF_/**/Name) 174 #define EXITC(Name) BLANK M_EXITC (Name,PROF_/**/Name) 175 176 177 #endif 178 179