Branch: Tag:

2002-11-05

2002-11-05 19:14:51 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Code cleanup.

Rev: src/code/sparc.c:1.14
Rev: src/code/sparc.h:1.16

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: sparc.c,v 1.13 2002/10/11 01:39:39 nilsson Exp $ + || $Id: sparc.c,v 1.14 2002/11/05 19:14:51 grubba Exp $   */      /*
13:      #include "operators.h"    + /* +  * Register definitions +  */ +  + #define SPARC_REG_G0 0 + #define SPARC_REG_G1 1 + #define SPARC_REG_G2 2 + #define SPARC_REG_G3 3 + #define SPARC_REG_G4 4 + #define SPARC_REG_G5 5 + #define SPARC_REG_G6 6 + #define SPARC_REG_G7 7 + #define SPARC_REG_O0 8 + #define SPARC_REG_O1 9 + #define SPARC_REG_O2 10 + #define SPARC_REG_O3 11 + #define SPARC_REG_O4 12 + #define SPARC_REG_O5 13 + #define SPARC_REG_O6 14 /* SP */ + #define SPARC_REG_O7 15 + #define SPARC_REG_L0 16 + #define SPARC_REG_L1 17 + #define SPARC_REG_L2 18 + #define SPARC_REG_L3 19 + #define SPARC_REG_L4 20 + #define SPARC_REG_L5 21 + #define SPARC_REG_L6 22 + #define SPARC_REG_L7 23 + #define SPARC_REG_I0 24 + #define SPARC_REG_I1 25 + #define SPARC_REG_I2 26 + #define SPARC_REG_I3 27 + #define SPARC_REG_I4 28 + #define SPARC_REG_I5 29 + #define SPARC_REG_I6 30 /* FP */ + #define SPARC_REG_I7 31 /* PC */ +  + /* +  * Logical operations. +  */ +  + #define SPARC_OP3_AND 0x01 + #define SPARC_OP3_ANDcc 0x11 + #define SPARC_OP3_ANDN 0x05 + #define SPARC_OP3_ANDNcc 0x15 + #define SPARC_OP3_OR 0x02 + #define SPARC_OP3_ORcc 0x12 + #define SPARC_OP3_ORN 0x06 + #define SPARC_OP3_ORNcc 0x16 + #define SPARC_OP3_XOR 0x03 + #define SPARC_OP3_XORcc 0x13 + #define SPARC_OP3_XNOR 0x07 + #define SPARC_OP3_XNORcc 0x17 + #define SPARC_OP3_SLL 0x25 + #define SPARC_OP3_SRL 0x26 + #define SPARC_OP3_SRA 0x27 +  + #define SPARC_LOG_OP(OP3, D, S1, S2, I) \ +  add_to_program(0x80000000|((D)<<25)|((OP3)<<19)|((S1)<<14)|((I)<<13)| \ +  ((S2)&((I)?0x1fff:0x1f))) +  + #define SPARC_OR(D,S1,S2,I) SPARC_LOG_OP(SPARC_OP3_OR, D, S1, S2, I) +  + #define SPARC_SRA(D,S1,S2,I) SPARC_LOG_OP(SPARC_OP3_SRA, D, S1, S2, I) +  + #define SPARC_SETHI(D, VAL) \ +  add_to_program(0x01000000|((D)<<25)|(((VAL)>>10)&0x3fffff)) +  + #define SET_REG(REG, X) do { \ +  INT32 val_ = X; \ +  INT32 reg_ = REG; \ +  if ((-4096 <= val_) && (val_ <= 4095)) { \ +  /* or %g0, val_, reg */ \ +  SPARC_OR(SPARC_REG_G0, reg_, val_, 1); \ +  } else { \ +  /* sethi %hi(val_), reg */ \ +  SPARC_SETHI(reg_, val_); \ +  if (val_ & 0x3ff) { \ +  /* or reg, %lo(val_), reg */ \ +  SPARC_OR(reg_, reg_, val_, 1); \ +  } \ +  if (val_ < 0) { \ +  /* Sign extend. */ \ +  /* sra reg, %g0, reg */ \ +  SPARC_SRA(reg_, reg_, SPARC_REG_G0, 0); \ +  } \ +  } \ +  } while(0) +    #define ADD_CALL(X, DELAY_OK) do { \    INT32 delta_; \    struct program *p_ = Pike_compiler->new_program; \
33:    add_to_program(delay_); \    } while(0)    + /* +  * Allocate a stack frame. +  * +  * Note that the prologue size must be constant. +  */ + void sparc_ins_entry(void) + { +  /* save %sp, -112, %sp */ +  add_to_program(0x81e02000|(SPARC_REG_O6<<25)| +  (SPARC_REG_O6<<14)|((-112)&0x1fff)); + } +  + void sparc_update_pc(void) + { +  /* call .+8 */ +  add_to_program(0x40000002); +  SET_REG(SPARC_REG_O3, ((INT32)(&Pike_interpreter.frame_pointer))); +  /* lduw [ %o3 ], %o3 */ +  add_to_program(0xc0000000|(SPARC_REG_O3<<25)|(SPARC_REG_O3<<14)); +  /* stw %o7, [ %o3 + pc ] */ +  add_to_program(0xc0202000|(SPARC_REG_O7<<25)|(SPARC_REG_O3<<14)| +  OFFSETOF(pike_frame, pc)); + } +  +  +    static void low_ins_f_byte(unsigned int b, int delay_ok)   {    void *addr;