uwx_self_context.s revision 115013
1/* 2 * Copyright (c) 2002,2003 Hewlett-Packard Company 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * DEALINGS IN THE SOFTWARE. 21 */ 22 23#ifdef _LP64 24#define SWIZZLE add 25#define STPTR st8 26#else 27#define SWIZZLE addp4 28#define STPTR st4 29#endif 30 31rRP = r14 32rPFS = r15 33rUNAT = r16 34rRNAT = r17 35rENV0 = r18 36rENV1 = r19 37rENV2 = r20 38rNSLOT = r21 39rBSP = r22 40rPBSP = r23 41rRSC = r24 42rNATP = r25 43rBIAS = r26 44rRSC0 = r27 45rTMP1 = r28 46rTMP2 = r29 47rTMP3 = r30 48rTMP4 = r31 49rTMP5 = r8 50 51 .text 52 .proc uwx_self_init_context 53 .global uwx_self_init_context 54uwx_self_init_context: 55 .prologue 56 alloc rPFS = ar.pfs, 1, 0, 0, 0 57 mov rUNAT = ar.unat 58 .body 59 SWIZZLE rENV0 = r0, r32 // rENV0 = &env 60 ;; 61 flushrs 62 extr.u rNSLOT = rPFS, 7, 7 // nslots = pfs.sol 63 mov rRP = b0 64 ;; 65 mov rRSC = ar.rsc 66 add rENV1 = 120, rENV0 // rENV1 = &env->context.gr[0] 67 add rENV2 = 128, rENV0 // rENV2 = &env->context.gr[1] 68 ;; 69 and rRSC0 = -4, rRSC // clear ar.rsc.mode 70 adds rNATP = 0x1f8, r0 71 mov rTMP1 = b1 72 ;; 73 st8.spill [rENV1] = r4, 16 // env+120: r4 74 st8.spill [rENV2] = r5, 16 // env+128: r5 75 mov rTMP2 = b2 76 ;; 77 st8.spill [rENV1] = r6, 16 // env+136: r6 78 st8.spill [rENV2] = r7, 16 // env+144: r7 79 mov rTMP3 = b3 80 ;; 81 st8 [rENV1] = rTMP1, 16 // env+152: b1 82 st8 [rENV2] = rTMP2, 16 // env+160: b2 83 mov rTMP1 = b4 84 ;; 85 st8 [rENV1] = rTMP3, 16 // env+168: b3 86 st8 [rENV2] = rTMP1, 16 // env+176: b4 87 mov rTMP2 = b5 88 ;; 89 st8 [rENV1] = rTMP2 // env+184: b5 90 mov ar.rsc = rRSC0 // enforced lazy mode 91 add rENV1 = 8, rENV0 92 ;; 93 mov rRNAT = ar.rnat // get copy of ar.rnat 94 movl rTMP1 = 0x7fec8f00000000 // valid_regs: ip, sp, bsp, cfm, 95 // preds, rnat, unat, lc, grs, brs 96 ;; 97 mov ar.rsc = rRSC // restore ar.rsc 98 mov rBSP = ar.bsp 99 add rTMP3 = 120, rENV0 // spill_loc = &env->context.gr[0] 100 ;; 101 mov rTMP2 = ar.unat 102 nop 103 extr.u rTMP3 = rTMP3, 3, 6 // bitpos = spill_loc{8:3} 104 ;; 105 or rNATP = rBSP, rNATP // natp = bsp | 0x1f8 106 sub rTMP4 = 64, rTMP3 // (64 - bitpos) 107 shr rTMP5 = rTMP2, rTMP3 // (unat >> bitpos) 108 ;; 109 sub rBIAS = rNATP, rBSP // bias = (natp - bsp) ... 110 nop 111 shl rTMP2 = rTMP2, rTMP4 // (unat << (64 - bitpos)) 112 ;; 113 or rTMP2 = rTMP2, rTMP5 // rotate_right(unat, bitpos) 114 extr.u rBIAS = rBIAS, 3, 6 // ... div 8 115 mov rTMP4 = pr 116 ;; 117 st8 [rENV0] = rTMP1, 16 // env+0: valid_regs mask 118 st8 [rENV1] = rRP, 24 // env+8: ip (my rp) 119 add rBIAS = rNSLOT, rBIAS // bias += nslots 120 ;; 121 cmp.lt p6, p0 = 63, rBIAS // if (63 < bias) ... 122 cmp.lt p7, p0 = 126, rBIAS // if (126 < bias) ... 123 nop 124 ;; 125 st8 [rENV0] = r12, 48 // env+16: sp 126 st8 [rENV1] = rPFS, 40 // env+32: cfm (my pfs) 127(p6) add rNSLOT = 1, rNSLOT // ... nslots++ 128 ;; 129 st8 [rENV0] = rTMP4, 24 // env+64: preds 130 st8 [rENV1] = rTMP2, 24 // env+72: priunat 131(p7) add rNSLOT = 1, rNSLOT // ... nslots++ 132 ;; 133 st8 [rENV0] = rRNAT, -64 // env+88: rnat 134 st8 [rENV1] = rUNAT, 8 // env+96: unat 135 dep.z rTMP3 = rNSLOT, 3, 7 // (nslots << 3) 136 ;; 137 sub rPBSP = rBSP, rTMP3 // prev_bsp = bsp - (nslots << 3) 138 mov rTMP3 = ar.fpsr 139 mov rTMP1 = ar.lc 140 ;; 141 st8 [rENV0] = rPBSP // env+24: bsp (my prev bsp) 142 st8 [rENV1] = rTMP3, 8 // env+104: fpsr 143 add rENV2 = 320, rENV2 // rENV2 = &env->context.rstate 144 ;; 145 st8 [rENV1] = rTMP1 // env+112: lc 146 STPTR [rENV2] = r0 // env+512: env->rstate = 0 147 nop 148 ;; 149 mov ar.unat = rUNAT 150 mov ret0 = r0 // return UWX_OK 151 br.ret.sptk b0 152 .endp 153 154