pike.git / src / peep.c

version» Context lines:

pike.git/src/peep.c:11:   #include "pike_memory.h"   #include "peep.h"   #include "dmalloc.h"   #include "stuff.h"   #include "bignum.h"   #include "opcodes.h"   #include "builtin_functions.h"   #include "constants.h"   #include "interpret.h"    - RCSID("$Id: peep.c,v 1.56 2001/07/17 08:33:23 hubbe Exp $"); + RCSID("$Id: peep.c,v 1.57 2001/07/17 17:50:39 grubba Exp $");      static void asm_opt(void);      dynamic_buffer instrbuf;      static int hasarg(int opcode)   {    return instrs[opcode-F_OFFSET].flags & I_HASARG;   }   
pike.git/src/peep.c:129: Inside #if defined(PIKE_DEBUG)
   if(instr > (long)instrbuf.s.len / (long)sizeof(p_instr) || instr < 0)    fatal("update_arg outside known space.\n");   #endif    p=(p_instr *)instrbuf.s.str;    p[instr].arg=arg;   }         /**** Bytecode Generator *****/    + #ifdef PIKE_USE_MACHINE_CODE   /* FIXME: Move this to pike_cpulib.h */ - #if defined(__i386__) && defined(__GNUC__) + #ifdef __GNUC__      #define PUSH_INT(X) ins_int((INT32)(X), add_to_program)   #define PUSH_ADDR(X) PUSH_INT((X))    -  + #ifdef __i386__ +    /* This is ugly, but since the code may be moved we cannot use    * relative addressing :(    */   #define CALL_ABSOLUTE(X) do{ \    add_to_program(0xb8); /* mov $xxx,%eax */ \    PUSH_INT(X); \    add_to_program(0xff); /* jsr *(%eax) */ \    add_to_program(0xd0); \   }while(0)   
pike.git/src/peep.c:156:    INT32 tmp=PC; \    add_to_program(0xa1 /* mov $xxxxx, %eax */); \    ins_int((INT32)(&Pike_interpreter.frame_pointer), add_to_program); \    \    add_to_program(0xc7); /* movl $xxxxx, yy%(eax) */ \    add_to_program(0x40); \    add_to_program(OFFSETOF(pike_frame, pc)); \    ins_int((INT32)tmp, add_to_program); \   }while(0)    - #endif + #elif defined(sparc)    - #ifndef PIKE_USE_MACHINE_CODE + #define REG_O0 8 + #define REG_O1 9 + #define REG_O2 10 + #define REG_O3 11 + #define REG_O4 12 + #define REG_O5 13 + #define REG_O6 14 + #define REG_O7 15 +  + #define SET_REG(REG, X) do { \ +  INT32 val_ = X; \ +  INT32 reg_ = REG; \ +  if ((-4096 <= val_) && (val_ <= 4095)) { \ +  /* or %g0, val_, reg */ \ +  PUSH_INT(0x80102000|(reg_<<25)|(val_ & 0x1fff)); \ +  } else { \ +  /* sethi %hi(val_), reg */ \ +  PUSH_INT(0x01000000|(reg_<<25)|((val_ >> 10)&0x3fffff)); \ +  if (val_ & 0x3ff) { \ +  /* or reg, %lo(val_), reg */ \ +  PUSH_INT(0x80102000|(reg_<<25)|(reg_<<14)|(val_ & 0x0fff)); \ +  } \ +  if (val_ < 0) { \ +  /* sra reg, %g0, reg */ \ +  PUSH_INT(0x81380000|(reg_<<25)|(reg_<<14)); \ +  } \ +  } \ +  } while(0) +  + #define CALL_ABSOLUTE(X) do { \ +  SET_REG(REG_O2, (INT32)(X)); \ +  /* jmpl %o2, %o7 */ \ +  PUSH_INT(0x81c00000|(REG_O7<<24)|(REG_O2<<14)); \ +  /* noop */ \ +  PUSH_INT(0x01000000); \ +  } while(0) +  + #define UPDATE_PC() do { \ +  INT32 tmp = PC; \ +  SET_REG(REG_O3, ((INT32)(&Pike_interpreter.frame_pointer))); \ +  /* lduw %o3, %o3 */ \ +  PUSH_INT(0xc0000000|(REG_O3<<25)|(REG_O3<<14)); \ +  SET_REG(REG_O4, tmp); \ +  /* stw %o4, yy(%o3) */ \ +  PUSH_INT(0xc0202000|(REG_O4<<25)|(REG_O3<<14)|OFFSETOF(pike_frame, pc)); \ +  } while(0) + #endif /* __i386__ || sparc */ + #endif /* __GNUC__ */ +  + #else /* !PIKE_USE_MACHINE_CODE */   #undef UPDATE_PC   #define UPDATE_PC() - #endif + #endif /* PIKE_USE_MACHINE_CODE */      void ins_f_byte(unsigned int b)   {   #ifdef PIKE_DEBUG    if(store_linenumbers && b<F_MAX_OPCODE)    ADD_COMPILED(b);   #endif /* PIKE_DEBUG */       b-=F_OFFSET;   #ifdef PIKE_DEBUG
pike.git/src/peep.c:203: Inside #if defined(HAVE_COMPUTED_GOTO)
  #ifdef HAVE_COMPUTED_GOTO    add_to_program(fcode_to_opcode[b]);   #else /* !HAVE_COMPUTED_GOTO */    add_to_program((unsigned char)b);   #endif /* HAVE_COMPUTED_GOTO */   }      static void ins_f_byte_with_arg(unsigned int a,unsigned INT32 b)   {   #ifdef PIKE_USE_MACHINE_CODE - #if defined(__i386__) && defined(__GNUC__) + #ifdef __GNUC__ + #ifdef __i386__    add_to_program(0xc7); /* movl $xxxx, (%esp) */    add_to_program(0x04);    add_to_program(0x24);    PUSH_INT(b); -  + #elif defined(sparc) +  SET_REG(REG_O0, b); + #endif /* __i386__ || sparc */    ins_f_byte(a);    return; -  + #endif /* __GNUC__ */   #endif - #endif +       #ifndef HAVE_COMPUTED_GOTO    switch(b >> 8)    {    case 0 : break;    case 1 : ins_f_byte(F_PREFIX_256); break;    case 2 : ins_f_byte(F_PREFIX_512); break;    case 3 : ins_f_byte(F_PREFIX_768); break;    case 4 : ins_f_byte(F_PREFIX_1024); break;    default:
pike.git/src/peep.c:247:   #endif /* !HAVE_COMPUTED_GOTO */    ins_f_byte(a);    add_to_program((PIKE_OPCODE_T)b);   }      static void ins_f_byte_with_2_args(unsigned int a,    unsigned INT32 c,    unsigned INT32 b)   {   #ifdef PIKE_USE_MACHINE_CODE - #if defined(__i386__) && defined(__GNUC__) + #ifdef __GNUC__ + #ifdef __i386__    add_to_program(0xc7); /* movl $xxxx, (%esp) */    add_to_program(0x04);    add_to_program(0x24);    PUSH_INT(c);    add_to_program(0xc7); /* movl $xxxx, 4(%esp) */    add_to_program(0x44);    add_to_program(0x24);    add_to_program(0x04);    PUSH_INT(b); -  + #elif defined(sparc) +  SET_REG(REG_O0, c); +  SET_REG(REG_O1, b); + #endif /* __i386__ || sparc */    ins_f_byte(a);    return; -  + #endif /* __GNUC__ */   #endif - #endif +       #ifdef HAVE_COMPUTED_GOTO    switch(b >> 8)    {    case 0 : break;    case 1 : ins_f_byte(F_PREFIX2_256); break;    case 2 : ins_f_byte(F_PREFIX2_512); break;    case 3 : ins_f_byte(F_PREFIX2_768); break;    case 4 : ins_f_byte(F_PREFIX2_1024); break;    default: