summaryrefslogtreecommitdiff
path: root/src/third_party/unwind/dist/tests/ia64-test-stack-asm.S
blob: 0aea33a441345fc1db58225c29c3899b01c99787 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* libunwind - a platform-independent unwind library
   Copyright (C) 2003 Hewlett-Packard Co
	Contributed by David Mosberger-Tang <davidm@hpl.hp.com>

This file is part of libunwind.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */

#include "ia64-test-stack.h"

	.common stackmem, NSTACKS*STACK_SIZE, 16

	.global do_unwind_tests

	.text

#define SAVED_SP_OFF		 0
#define SAVED_RP_OFF		 8
#define SAVED_PFS_OFF		16
#define SAVED_RNAT_OFF		24
#define SAVED_BSP_OFF		32
#define SAVED_BSPSTORE_OFF	40
#define FRAME_SIZE		48

	.proc stack_it
stack_it:
	.prologue
	alloc r18 = ar.pfs, 0, 0, 0, 0		// read ar.pfs
	// first, calculate address of new stack:
	addl r2 = @ltoff(stackmem), gp
	shl r3 = r8, STACK_SIZE_SHIFT
	;;
	ld8 r2 = [r2]				// r2 = &stackmem
	;;
	add r2 = r2, r3				// r2 = stackmem[iteration]
	;;
	addl r3 = STACK_SIZE-FRAME_SIZE, r2	// r3 = &stackframe
	;;
	st8 [r3] = sp
	.vframesp SAVED_SP_OFF+16
	adds sp = -16, r3			// switch the memory stack
	;;
	adds r3 = (SAVED_RP_OFF - SAVED_SP_OFF), r3
	mov r16 = rp
	;;
	.savesp rp, SAVED_RP_OFF+16
	st8 [r3] = r16, (SAVED_PFS_OFF - SAVED_RP_OFF)
	;;
	.savesp ar.pfs, SAVED_PFS_OFF+16
	st8 [r3] = r18, (SAVED_BSP_OFF - SAVED_PFS_OFF)

	mov r16 = ar.bsp
	mov r17 = ar.bspstore
	mov r18 = ar.rnat
	;;
	.savesp ar.bsp, SAVED_BSP_OFF+16
	st8 [r3] = r16, (SAVED_BSPSTORE_OFF - SAVED_BSP_OFF)
	;;
	.savesp ar.bspstore, SAVED_BSPSTORE_OFF+16
	st8 [r3] = r17, (SAVED_RNAT_OFF - SAVED_BSPSTORE_OFF)
	;;
	.savesp ar.rnat, SAVED_RNAT_OFF+16
	st8 [r3] = r18
	;;
	mov ar.bspstore = r2			// switch the backing store

	.body

	// for even iterations, allocate a local variable:
	tbit.nz p6, p0 = r8, 0
(p6)	br.cond.sptk.few .skip
	;;
	alloc r2 = ar.pfs, 0, 1, 0, 0
	mov loc0 = r8
	;;
.skip:	cmp.ne p6, p7 = 0, r8
	;;
{	.mbb
(p6)	adds r8 = -1, r8
(p6)	br.call.sptk.many rp = stack_it		// next iteration
(p7)	br.call.sptk.many rp = do_unwind_tests	// time for introspection...
}
	// switch back to stack:

	adds r3 = SAVED_SP_OFF+16, sp
	;;
	ld8 r16 = [r3], (SAVED_RP_OFF-SAVED_SP_OFF);;		// saved sp
	ld8 r17 = [r3], (SAVED_PFS_OFF-SAVED_RP_OFF);;		// saved rp
	ld8 r18 = [r3], (SAVED_RNAT_OFF-SAVED_PFS_OFF);;	// saved pfs
	ld8 r19 = [r3], (SAVED_BSP_OFF-SAVED_RNAT_OFF);;	// saved rnat
	ld8 r20 = [r3], (SAVED_BSPSTORE_OFF-SAVED_BSP_OFF);;	// saved bsp
	ld8 r21 = [r3];;				// saved bspstore

	mov rp = r17
	mov ar.pfs = r18
	mov ar.bspstore = r21	// this also restores ar.bsp
	;;
	mov ar.rnat = r19

	.restore sp
	mov sp = r16
	br.ret.sptk.many rp
	.endp stack_it


#define SET_LOC(n)	add loc##n = n, r8
#define SET_NAT(n)	ld8.s loc##n = [r0]

	.global touch_all
	.proc touch_all
touch_all:
	.prologue
	.save ar.pfs, r34
	alloc loc1 = ar.pfs, 1, 94, 1, 0
	.save rp, loc0
	mov loc0 = rp
	.body

	mov ar.rsc = 0		// put RSE into enforced lazy mode
	shl r8 = in0, 32	// store iteration # in top 32 bits
	add out0 = -1, in0
	cmp.eq p6, p7 = 1, in0
	;;
	SET_LOC( 2); SET_LOC( 3)
	SET_LOC( 4); SET_LOC( 5); SET_LOC( 6); SET_LOC( 7)
	SET_LOC( 8); SET_LOC( 9); SET_LOC(10); SET_LOC(11)
	SET_LOC(12); SET_LOC(13); SET_LOC(14); SET_LOC(15)
	SET_LOC(16); SET_LOC(17); SET_LOC(18); SET_LOC(19)
	SET_LOC(20); SET_LOC(21); SET_LOC(22); SET_LOC(23)
	SET_LOC(24); SET_LOC(25); SET_LOC(26); SET_LOC(27)
	SET_LOC(28); SET_LOC(29); SET_LOC(30); SET_LOC(31)
	SET_LOC(32); SET_LOC(33); SET_LOC(34); SET_LOC(35)
	SET_LOC(36); SET_LOC(37); SET_LOC(38); SET_LOC(39)
	SET_LOC(40); SET_LOC(41); SET_LOC(42); SET_LOC(43)
	SET_LOC(44); SET_LOC(45); SET_LOC(46); SET_LOC(47)
	SET_LOC(48); SET_LOC(49); SET_LOC(50); SET_LOC(51)
	SET_LOC(52); SET_LOC(53); SET_LOC(54); SET_LOC(55)
	SET_LOC(56); SET_LOC(57); SET_LOC(58); SET_LOC(59)
	SET_LOC(60); SET_LOC(61); SET_LOC(62); SET_LOC(63)
	SET_LOC(64); SET_LOC(65); SET_LOC(66); SET_LOC(67)
	SET_LOC(68); SET_LOC(69); SET_LOC(70); SET_LOC(71)
	SET_LOC(72); SET_LOC(73); SET_LOC(74); SET_LOC(75)
	SET_LOC(76); SET_LOC(77); SET_LOC(78); SET_LOC(79)
	SET_LOC(80); SET_LOC(81); SET_LOC(82); SET_LOC(83)
	SET_LOC(84); SET_LOC(85); SET_LOC(86); SET_LOC(87)
	SET_LOC(88); SET_LOC(89); SET_LOC(90); SET_LOC(91)
	SET_LOC(92); SET_LOC(93)
	;;
	SET_NAT(2);  SET_NAT(31); SET_NAT(73); SET_NAT(93)
	;;
{	.mbb
	mov r8=NSTACKS-1
(p6)	br.call.sptk.many rp = stack_it
(p7)	br.call.sptk.many rp = touch_all
}
	;;

	mov rp = loc0
	mov ar.pfs = loc1
	br.ret.sptk.many rp
	.endp touch_all

#ifdef __linux__
        /* We do not need executable stack.  */
        .section        .note.GNU-stack,"",@progbits
#endif