Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/rs6000/tramp.asm @ 0:a06113de4d67
first commit
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2009 14:47:48 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a06113de4d67 |
---|---|
1 /* Special support for trampolines | |
2 * | |
3 * Copyright (C) 1996, 1997, 2000, 2007, 2008, 2009 Free Software Foundation, Inc. | |
4 * Written By Michael Meissner | |
5 * | |
6 * This file is free software; you can redistribute it and/or modify it | |
7 * under the terms of the GNU General Public License as published by the | |
8 * Free Software Foundation; either version 3, or (at your option) any | |
9 * later version. | |
10 * | |
11 * This file is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * Under Section 7 of GPL version 3, you are granted additional | |
17 * permissions described in the GCC Runtime Library Exception, version | |
18 * 3.1, as published by the Free Software Foundation. | |
19 * | |
20 * You should have received a copy of the GNU General Public License and | |
21 * a copy of the GCC Runtime Library Exception along with this program; | |
22 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 * <http://www.gnu.org/licenses/>. | |
24 */ | |
25 | |
26 /* Set up trampolines. */ | |
27 | |
28 .section ".text" | |
29 #include "ppc-asm.h" | |
30 #include "config.h" | |
31 | |
32 #ifndef __powerpc64__ | |
33 .type trampoline_initial,@object | |
34 .align 2 | |
35 trampoline_initial: | |
36 mflr r0 | |
37 bcl 20,31,1f | |
38 .Lfunc = .-trampoline_initial | |
39 .long 0 /* will be replaced with function address */ | |
40 .Lchain = .-trampoline_initial | |
41 .long 0 /* will be replaced with static chain */ | |
42 1: mflr r11 | |
43 mtlr r0 | |
44 lwz r0,0(r11) /* function address */ | |
45 lwz r11,4(r11) /* static chain */ | |
46 mtctr r0 | |
47 bctr | |
48 | |
49 trampoline_size = .-trampoline_initial | |
50 .size trampoline_initial,trampoline_size | |
51 | |
52 | |
53 /* R3 = stack address to store trampoline */ | |
54 /* R4 = length of trampoline area */ | |
55 /* R5 = function address */ | |
56 /* R6 = static chain */ | |
57 | |
58 FUNC_START(__trampoline_setup) | |
59 mflr r0 /* save return address */ | |
60 bcl 20,31,.LCF0 /* load up __trampoline_initial into r7 */ | |
61 .LCF0: | |
62 mflr r11 | |
63 addi r7,r11,trampoline_initial-4-.LCF0 /* trampoline address -4 */ | |
64 | |
65 li r8,trampoline_size /* verify that the trampoline is big enough */ | |
66 cmpw cr1,r8,r4 | |
67 srwi r4,r4,2 /* # words to move */ | |
68 addi r9,r3,-4 /* adjust pointer for lwzu */ | |
69 mtctr r4 | |
70 blt cr1,.Labort | |
71 | |
72 mtlr r0 | |
73 | |
74 /* Copy the instructions to the stack */ | |
75 .Lmove: | |
76 lwzu r10,4(r7) | |
77 stwu r10,4(r9) | |
78 bdnz .Lmove | |
79 | |
80 /* Store correct function and static chain */ | |
81 stw r5,.Lfunc(r3) | |
82 stw r6,.Lchain(r3) | |
83 | |
84 /* Now flush both caches */ | |
85 mtctr r4 | |
86 .Lcache: | |
87 icbi 0,r3 | |
88 dcbf 0,r3 | |
89 addi r3,r3,4 | |
90 bdnz .Lcache | |
91 | |
92 /* Finally synchronize things & return */ | |
93 sync | |
94 isync | |
95 blr | |
96 | |
97 .Labort: | |
98 #if (defined __PIC__ || defined __pic__) && defined HAVE_AS_REL16 | |
99 bcl 20,31,1f | |
100 1: mflr r30 | |
101 addis r30,r30,_GLOBAL_OFFSET_TABLE_-1b@ha | |
102 addi r30,r30,_GLOBAL_OFFSET_TABLE_-1b@l | |
103 #endif | |
104 bl JUMP_TARGET(abort) | |
105 FUNC_END(__trampoline_setup) | |
106 | |
107 #endif |