Alien-LibJIT
view release on metacpan or search on metacpan
libjit/attic/jit-apply-alpha.c view on Meta::CPAN
/*
* jit-apply-alpha.c - Apply support routines for alpha.
*
* Copyright (C) 2006 Southern Storm Software, Pty Ltd.
*
* This file is part of the libjit library.
*
* The libjit library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 2.1 of
* the License, or (at your option) any later version.
*
* The libjit library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "jit-internal.h"
#if defined(__alpha) || defined(__alpha__)
#include "jit-gen-alpha.h"
void _jit_create_closure(unsigned char *buf, void *func, void *closure, void *_type) {
alpha_inst inst = (alpha_inst) buf;
/* Compute and load the global pointer (2 instructions) */
alpha_ldah(inst,ALPHA_GP,ALPHA_PV,0);
alpha_lda( inst,ALPHA_GP,ALPHA_GP,0);
/* Allocate space for a new stack frame. (1 instruction) */
alpha_lda(inst,ALPHA_SP,ALPHA_SP,-(13*8));
/* Save the return address. (1 instruction) */
alpha_stq(inst,ALPHA_RA,ALPHA_SP,0*8);
/* Save integer register arguments as local variables (6 instructions) */
alpha_stq(inst,ALPHA_A0,ALPHA_SP,1*8);
alpha_stq(inst,ALPHA_A1,ALPHA_SP,2*8);
alpha_stq(inst,ALPHA_A2,ALPHA_SP,3*8);
alpha_stq(inst,ALPHA_A3,ALPHA_SP,4*8);
alpha_stq(inst,ALPHA_A4,ALPHA_SP,5*8);
alpha_stq(inst,ALPHA_A5,ALPHA_SP,6*8);
/* Save floating-point register arguments as local variables (8 instructions) */
alpha_stt(inst,ALPHA_FA0,ALPHA_SP, 7*8);
alpha_stt(inst,ALPHA_FA1,ALPHA_SP, 8*8);
alpha_stt(inst,ALPHA_FA2,ALPHA_SP, 9*8);
alpha_stt(inst,ALPHA_FA3,ALPHA_SP,10*8);
alpha_stt(inst,ALPHA_FA4,ALPHA_SP,11*8);
alpha_stt(inst,ALPHA_FA5,ALPHA_SP,12*8);
/* Call the closure handling function (1 instruction) */
alpha_call(inst,func);
/* Restore the return address (1 instruction) */
alpha_ldq(inst,ALPHA_RA,ALPHA_SP,0*8);
/* Restore integer register arguments (6 instructions) */
alpha_ldq(inst,ALPHA_A0,ALPHA_SP,1*8);
alpha_ldq(inst,ALPHA_A1,ALPHA_SP,2*8);
alpha_ldq(inst,ALPHA_A2,ALPHA_SP,3*8);
alpha_ldq(inst,ALPHA_A3,ALPHA_SP,4*8);
alpha_ldq(inst,ALPHA_A4,ALPHA_SP,5*8);
alpha_ldq(inst,ALPHA_A5,ALPHA_SP,6*8);
/* Restore floating-point register arguments (8 instructions) */
alpha_ldt(inst,ALPHA_FA0,ALPHA_SP, 7*8);
alpha_ldt(inst,ALPHA_FA1,ALPHA_SP, 8*8);
alpha_ldt(inst,ALPHA_FA2,ALPHA_SP, 9*8);
alpha_ldt(inst,ALPHA_FA3,ALPHA_SP,10*8);
alpha_ldt(inst,ALPHA_FA4,ALPHA_SP,11*8);
alpha_ldt(inst,ALPHA_FA5,ALPHA_SP,12*8);
/* restore the stack pointer (1 instruction) */
( run in 2.012 seconds using v1.01-cache-2.11-cpan-df04353d9ac )