blob: 45cc8aab7c79c2aa334f5f3b4b99f76cc43d16a8 [file] [log] [blame]
mostang.com!davidm3f0ebaa2003-01-23 10:04:09 +00001/* libunwind - a platform-independent unwind library
2 Copyright (C) 2003 Hewlett-Packard Co
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4
5This file is part of libunwind.
6
7Permission is hereby granted, free of charge, to any person obtaining
8a copy of this software and associated documentation files (the
9"Software"), to deal in the Software without restriction, including
10without limitation the rights to use, copy, modify, merge, publish,
11distribute, sublicense, and/or sell copies of the Software, and to
12permit persons to whom the Software is furnished to do so, subject to
13the following conditions:
14
15The above copyright notice and this permission notice shall be
16included in all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
25
mostang.com!davidme55b2e02003-01-23 18:47:51 +000026#include "ia64-test-stack.h"
mostang.com!davidm3f0ebaa2003-01-23 10:04:09 +000027
28 .common stackmem, NSTACKS*STACK_SIZE, 16
29
30 .text
31
32#define SAVED_SP_OFF 0
33#define SAVED_RP_OFF 8
34#define SAVED_PFS_OFF 16
35#define SAVED_RNAT_OFF 24
36#define SAVED_BSP_OFF 32
37#define SAVED_BSPSTORE_OFF 40
38#define FRAME_SIZE 48
39
40 .proc stack_it
41stack_it:
42 .prologue
43 alloc r18 = ar.pfs, 0, 0, 0, 0 // read ar.pfs
44 // first, calculate address of new stack:
45 addl r2 = @ltoff(stackmem), gp
46 shl r3 = r8, STACK_SIZE_SHIFT
47 ;;
48 ld8 r2 = [r2] // r2 = &stackmem
49 ;;
50 add r2 = r2, r3 // r2 = stackmem[iteration]
51 ;;
52 addl r3 = STACK_SIZE-FRAME_SIZE, r2 // r3 = &stackframe
53 ;;
54 st8 [r3] = sp
55 .vframesp SAVED_SP_OFF+16
56 adds sp = -16, r3 // switch the memory stack
57 ;;
58 adds r3 = (SAVED_RP_OFF - SAVED_SP_OFF), r3
59 mov r16 = rp
60 ;;
61 .savesp rp, SAVED_RP_OFF+16
62 st8 [r3] = r16, (SAVED_PFS_OFF - SAVED_RP_OFF)
63 ;;
64 .savesp ar.pfs, SAVED_PFS_OFF+16
65 st8 [r3] = r18, (SAVED_BSP_OFF - SAVED_PFS_OFF)
66
67 mov r16 = ar.bsp
68 mov r17 = ar.bspstore
69 mov r18 = ar.rnat
70 ;;
71 .savesp ar.bsp, SAVED_BSP_OFF+16
72 st8 [r3] = r16, (SAVED_BSPSTORE_OFF - SAVED_BSP_OFF)
73 ;;
74 .savesp ar.bspstore, SAVED_BSPSTORE_OFF+16
75 st8 [r3] = r17, (SAVED_RNAT_OFF - SAVED_BSPSTORE_OFF)
76 ;;
77 .savesp ar.rnat, SAVED_RNAT_OFF+16
78 st8 [r3] = r18
79 ;;
80 mov ar.bspstore = r2 // switch the backing store
81
82 .body
83
84 // for even iterations, allocate a local variable:
85 tbit.nz p6, p0 = r8, 0
86(p6) br.cond.sptk.few 1f
87 ;;
88 alloc r2 = ar.pfs, 0, 1, 0, 0
89 mov loc0 = r8
90 ;;
911: cmp.ne p6, p7 = 0, r8
92 ;;
93{ .mbb
94(p6) adds r8 = -1, r8
95(p6) br.call.sptk.many rp = stack_it // next iteration
96(p7) br.call.sptk.many rp = do_unwind_tests // time for introspection...
97}
98 // switch back to stack:
99
100 adds r3 = SAVED_SP_OFF+16, sp
101 ;;
102 ld8 r16 = [r3], (SAVED_RP_OFF-SAVED_SP_OFF);; // saved sp
103 ld8 r17 = [r3], (SAVED_PFS_OFF-SAVED_RP_OFF);; // saved rp
104 ld8 r18 = [r3], (SAVED_RNAT_OFF-SAVED_PFS_OFF);; // saved pfs
105 ld8 r19 = [r3], (SAVED_BSP_OFF-SAVED_RNAT_OFF);; // saved rnat
106 ld8 r20 = [r3], (SAVED_BSPSTORE_OFF-SAVED_BSP_OFF);; // saved bsp
107 ld8 r21 = [r3];; // saved bspstore
108
109 mov rp = r17
110 mov ar.pfs = r18
111 mov ar.bspstore = r21 // this also restores ar.bsp
112 ;;
113 mov ar.rnat = r19
114
115 .restore sp
116 mov sp = r16
117 br.ret.sptk.many rp
118 .endp stack_it
119
120
121#define SET_LOC(n) add loc##n = n, r8
122#define SET_NAT(n) ld8.s loc##n = [r0]
123
124 .global touch_all
125 .proc touch_all
126touch_all:
127 .prologue
128 .save ar.pfs, r34
129 alloc loc1 = ar.pfs, 1, 94, 1, 0
130 .save rp, loc0
131 mov loc0 = rp
132 .body
133
134 mov ar.rsc = 0 // put RSE into enforced lazy mode
135 shl r8 = in0, 32 // store iteration # in top 32 bits
136 add out0 = -1, in0
137 cmp.eq p6, p7 = 1, in0
138 ;;
139 SET_LOC( 2); SET_LOC( 3)
140 SET_LOC( 4); SET_LOC( 5); SET_LOC( 6); SET_LOC( 7)
141 SET_LOC( 8); SET_LOC( 9); SET_LOC(10); SET_LOC(11)
142 SET_LOC(12); SET_LOC(13); SET_LOC(14); SET_LOC(15)
143 SET_LOC(16); SET_LOC(17); SET_LOC(18); SET_LOC(19)
144 SET_LOC(20); SET_LOC(21); SET_LOC(22); SET_LOC(23)
145 SET_LOC(24); SET_LOC(25); SET_LOC(26); SET_LOC(27)
146 SET_LOC(28); SET_LOC(29); SET_LOC(30); SET_LOC(31)
147 SET_LOC(32); SET_LOC(33); SET_LOC(34); SET_LOC(35)
148 SET_LOC(36); SET_LOC(37); SET_LOC(38); SET_LOC(39)
149 SET_LOC(40); SET_LOC(41); SET_LOC(42); SET_LOC(43)
150 SET_LOC(44); SET_LOC(45); SET_LOC(46); SET_LOC(47)
151 SET_LOC(48); SET_LOC(49); SET_LOC(50); SET_LOC(51)
152 SET_LOC(52); SET_LOC(53); SET_LOC(54); SET_LOC(55)
153 SET_LOC(56); SET_LOC(57); SET_LOC(58); SET_LOC(59)
154 SET_LOC(60); SET_LOC(61); SET_LOC(62); SET_LOC(63)
155 SET_LOC(64); SET_LOC(65); SET_LOC(66); SET_LOC(67)
156 SET_LOC(68); SET_LOC(69); SET_LOC(70); SET_LOC(71)
157 SET_LOC(72); SET_LOC(73); SET_LOC(74); SET_LOC(75)
158 SET_LOC(76); SET_LOC(77); SET_LOC(78); SET_LOC(79)
159 SET_LOC(80); SET_LOC(81); SET_LOC(82); SET_LOC(83)
160 SET_LOC(84); SET_LOC(85); SET_LOC(86); SET_LOC(87)
161 SET_LOC(88); SET_LOC(89); SET_LOC(90); SET_LOC(91)
162 SET_LOC(92); SET_LOC(93)
163 ;;
164 SET_NAT(2); SET_NAT(31); SET_NAT(73); SET_NAT(93)
165 ;;
166{ .mbb
167 mov r8=NSTACKS-1
168(p6) br.call.sptk.many rp = stack_it
169(p7) br.call.sptk.many rp = touch_all
170}
171 ;;
172
173 mov rp = loc0
174 mov ar.pfs = loc1
175 br.ret.sptk.many rp
176 .endp touch_all