1 /* Checks proper behavior of __morestack function - specifically, GPR
2 values surviving, stack parameters being copied, and vararg
3 pointer being correct. */
6 /* { dg-options "" } */
12 /* 1. Function "test" saves registers, makes a stack frame, puts known
13 * values in registers, and calls __morestack, telling it to jump to
14 * testinner, with return address pointing to "testret".
15 * 2. "testinner" checks that parameter registers match what has been
16 * passed from "test", stack parameters were copied properly to
17 * the new stack, and the argument pointer matches the calling
18 * function's stack pointer. It then leaves new values in volatile
19 * registers (including return value registers) and returns.
20 * 3. "testret" checks that return value registers contain the expected
21 * return value, callee-saved GPRs match the values from "test",
22 * and then returns to main. */
24 extern unsigned long testparams
[3];
31 ".type test, @function\n"
33 "stmg %r6, %r15, 0x30(%r15)\n"
34 /* Save original sp in a global. */
35 "larl %r1, orig_r15\n"
37 /* Make a stack frame. */
39 /* A stack parameter. */
41 "stg %r1, 160(%r15)\n"
56 /* Fake return address. */
57 "larl %r14, testret\n"
59 "larl %r1, testparams\n"
64 /* Check registers. */
77 /* Check stack param. */
78 "lg %r0, 0xa0(%r15)\n"
81 /* Check argument pointer. */
83 "larl %r2, orig_r15\n"
86 /* Modify volatile registers. */
98 /* Check return registers. */
101 /* Check callee-saved registers. */
110 "cghi %r10, 0x123a\n"
112 "cghi %r11, 0x123b\n"
114 "cghi %r12, 0x123c\n"
116 "cghi %r13, 0x123d\n"
119 "lmg %r6, %r15, 0xd8(%r15)\n"
122 /* Parameters block. */
128 ".quad testinner-testparams\n"
137 ".type test, @function\n"
138 /* Save registers. */
139 "stm %r6, %r15, 0x18(%r15)\n"
140 /* Save original sp in a global. */
141 "larl %r1, orig_r15\n"
143 /* Make a stack frame. */
145 /* A stack parameter. */
147 "st %r1, 0x60(%r15)\n"
149 "st %r1, 0x64(%r15)\n"
164 /* Fake return address. */
165 "larl %r14, testret\n"
166 /* Call morestack. */
167 "larl %r1, testparams\n"
172 /* Check registers. */
185 /* Check stack param. */
186 "l %r0, 0x60(%r15)\n"
189 "l %r0, 0x64(%r15)\n"
192 /* Check argument pointer. */
194 "larl %r2, orig_r15\n"
197 /* Modify volatile registers. */
209 /* Check return registers. */
214 /* Check callee-saved registers. */
232 "lm %r6, %r15, 0x80(%r15)\n"
235 /* Parameters block. */
241 ".long testinner-testparams\n"
247 _Noreturn
void testerr (void) {
251 extern void test (void);
255 /* Now try again, with huge stack frame requested - to exercise
256 both paths in __morestack (new allocation needed or not). */
257 testparams
[0] = 1000000;