asmacros.h (90e35b0a987f8e61ea5682b951c771b6f9dd5b63) | asmacros.h (aa3ea612be3659881392251e91912682b038ce78) |
---|---|
1/* -*- mode: asm -*- */ 2/*- 3 * SPDX-License-Identifier: BSD-3-Clause 4 * 5 * Copyright (c) 1993 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * Copyright (c) 2018 The FreeBSD Foundation --- 41 unchanged lines hidden (view full) --- 50 * CNAME is used to manage the relationship between symbol names in C 51 * and the equivalent assembly language names. CNAME is given a name as 52 * it would be used in a C program. It expands to the equivalent assembly 53 * language name. 54 */ 55#define CNAME(csym) csym 56 57#define ALIGN_DATA .p2align 3 /* 8 byte alignment, zero filled */ | 1/* -*- mode: asm -*- */ 2/*- 3 * SPDX-License-Identifier: BSD-3-Clause 4 * 5 * Copyright (c) 1993 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * Copyright (c) 2018 The FreeBSD Foundation --- 41 unchanged lines hidden (view full) --- 50 * CNAME is used to manage the relationship between symbol names in C 51 * and the equivalent assembly language names. CNAME is given a name as 52 * it would be used in a C program. It expands to the equivalent assembly 53 * language name. 54 */ 55#define CNAME(csym) csym 56 57#define ALIGN_DATA .p2align 3 /* 8 byte alignment, zero filled */ |
58#ifdef GPROF | |
59#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ | 58#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ |
60#else 61#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ 62#endif | |
63#define SUPERALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ 64 65#define GEN_ENTRY(name) ALIGN_TEXT; .globl CNAME(name); \ 66 .type CNAME(name),@function; CNAME(name): | 59#define SUPERALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ 60 61#define GEN_ENTRY(name) ALIGN_TEXT; .globl CNAME(name); \ 62 .type CNAME(name),@function; CNAME(name): |
67#define NON_GPROF_ENTRY(name) GEN_ENTRY(name) 68#define NON_GPROF_RET .byte 0xc3 /* opcode for `ret' */ 69 | 63#define ENTRY(name) GEN_ENTRY(name) 64#define ALTENTRY(name) GEN_ENTRY(name) |
70#define END(name) .size name, . - name 71 | 65#define END(name) .size name, . - name 66 |
72#ifdef GPROF | |
73/* | 67/* |
74 * __mcount is like [.]mcount except that doesn't require its caller to set 75 * up a frame pointer. It must be called before pushing anything onto the 76 * stack. gcc should eventually generate code to call __mcount in most 77 * cases. This would make -pg in combination with -fomit-frame-pointer 78 * useful. gcc has a configuration variable PROFILE_BEFORE_PROLOGUE to 79 * allow profiling before setting up the frame pointer, but this is 80 * inadequate for good handling of special cases, e.g., -fpic works best 81 * with profiling after the prologue. 82 * 83 * [.]mexitcount is a new function to support non-statistical profiling if an 84 * accurate clock is available. For C sources, calls to it are generated 85 * by the FreeBSD extension `-mprofiler-epilogue' to gcc. It is best to 86 * call [.]mexitcount at the end of a function like the MEXITCOUNT macro does, 87 * but gcc currently generates calls to it at the start of the epilogue to 88 * avoid problems with -fpic. 89 * 90 * [.]mcount and __mcount may clobber the call-used registers and %ef. 91 * [.]mexitcount may clobber %ecx and %ef. 92 * 93 * Cross-jumping makes non-statistical profiling timing more complicated. 94 * It is handled in many cases by calling [.]mexitcount before jumping. It 95 * is handled for conditional jumps using CROSSJUMP() and CROSSJUMP_LABEL(). 96 * It is handled for some fault-handling jumps by not sharing the exit 97 * routine. 98 * 99 * ALTENTRY() must be before a corresponding ENTRY() so that it can jump to 100 * the main entry point. Note that alt entries are counted twice. They 101 * have to be counted as ordinary entries for gprof to get the call times 102 * right for the ordinary entries. 103 * 104 * High local labels are used in macros to avoid clashes with local labels 105 * in functions. 106 * 107 * Ordinary `ret' is used instead of a macro `RET' because there are a lot 108 * of `ret's. 0xc3 is the opcode for `ret' (`#define ret ... ret' can't 109 * be used because this file is sometimes preprocessed in traditional mode). 110 * `ret' clobbers eflags but this doesn't matter. 111 */ 112#define ALTENTRY(name) GEN_ENTRY(name) ; MCOUNT ; MEXITCOUNT ; jmp 9f 113#define CROSSJUMP(jtrue, label, jfalse) \ 114 jfalse 8f; MEXITCOUNT; jmp __CONCAT(to,label); 8: 115#define CROSSJUMPTARGET(label) \ 116 ALIGN_TEXT; __CONCAT(to,label): ; MCOUNT; jmp label 117#define ENTRY(name) GEN_ENTRY(name) ; 9: ; MCOUNT 118#define FAKE_MCOUNT(caller) pushq caller ; call __mcount ; popq %rcx 119#define MCOUNT call __mcount 120#define MCOUNT_LABEL(name) GEN_ENTRY(name) ; nop ; ALIGN_TEXT 121#ifdef GUPROF 122#define MEXITCOUNT call .mexitcount 123#define ret MEXITCOUNT ; NON_GPROF_RET 124#else 125#define MEXITCOUNT 126#endif 127 128#else /* !GPROF */ 129/* 130 * ALTENTRY() has to align because it is before a corresponding ENTRY(). 131 * ENTRY() has to align to because there may be no ALTENTRY() before it. 132 * If there is a previous ALTENTRY() then the alignment code for ENTRY() 133 * is empty. 134 */ 135#define ALTENTRY(name) GEN_ENTRY(name) 136#define CROSSJUMP(jtrue, label, jfalse) jtrue label 137#define CROSSJUMPTARGET(label) 138#define ENTRY(name) GEN_ENTRY(name) 139#define FAKE_MCOUNT(caller) 140#define MCOUNT 141#define MCOUNT_LABEL(name) 142#define MEXITCOUNT 143#endif /* GPROF */ 144 145/* | |
146 * Convenience for adding frame pointers to hand-coded ASM. Useful for 147 * DTrace, HWPMC, and KDB. 148 */ 149#define PUSH_FRAME_POINTER \ 150 pushq %rbp ; \ 151 movq %rsp, %rbp ; 152#define POP_FRAME_POINTER \ 153 popq %rbp --- 169 unchanged lines hidden --- | 68 * Convenience for adding frame pointers to hand-coded ASM. Useful for 69 * DTrace, HWPMC, and KDB. 70 */ 71#define PUSH_FRAME_POINTER \ 72 pushq %rbp ; \ 73 movq %rsp, %rbp ; 74#define POP_FRAME_POINTER \ 75 popq %rbp --- 169 unchanged lines hidden --- |