Branch: Tag:

2004-08-24

2004-08-24 14:15:21 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Fixed a few cases of negative arguments.
Added some optimizations for some ADD_INT* cases.
Added some more MARK_X rules.

Rev: src/peep.in:1.72

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: peep.in,v 1.71 2004/08/23 14:03:36 grubba Exp $ + // $Id: peep.in,v 1.72 2004/08/24 14:15:21 grubba Exp $      NOP :   POP_N_ELEMS (0) :
34:   NUMBER NEGATE : NEG_NUMBER($1a)   NEG_NUMBER NEGATE : NUMBER ($1a)   NUMBER [$1a < 0 && (-$1a)>0] : NEG_NUMBER (-$1a) - NEG_NUMBER [$1a < 0 && (-$1a)>0] : NUMBER (-$1a) + NEG_NUMBER [$1a <= 0 && (-$1a)>=0] : NUMBER (-$1a)   NEGATE NEGATE :   COMPL COMPL :   NEGATE CONST_1 ADD_INTS : COMPL
220:   CONST0 ADD_INTS: ADD_INT (0)   CONST1 ADD_INTS: ADD_INT (1)   CONST_1 ADD_INTS: ADD_NEG_INT (1) - NUMBER ADD_INTS : ADD_INT ($1a) - NEG_NUMBER ADD_INTS : ADD_NEG_INT ($1a) + NUMBER [$1a >= 0] ADD_INTS : ADD_INT ($1a) + NEG_NUMBER [$1a > 0] ADD_INTS : ADD_NEG_INT ($1a)      CONST0 ADD: ADD_INT (0)   CONST1 ADD: ADD_INT (1)   CONST_1 ADD: ADD_NEG_INT (1) - NUMBER ADD : ADD_INT ($1a) - NEG_NUMBER ADD : ADD_NEG_INT ($1a) + NUMBER [$1a >= 0] ADD : ADD_INT ($1a) + NEG_NUMBER [$1a > 0] ADD : ADD_NEG_INT ($1a)      CONST0 SUBTRACT: ADD_INT (0) - CONST1 SUBTRACT: ADD_NEG_INT (-1) + CONST1 SUBTRACT: ADD_NEG_INT (1)   CONST_1 SUBTRACT: ADD_INT (1) - NUMBER SUBTRACT : ADD_NEG_INT ($1a) - NEG_NUMBER SUBTRACT : ADD_INT ($1a) + NUMBER [$1a >= 0] SUBTRACT : ADD_NEG_INT ($1a) + NEG_NUMBER [$1a > 0] SUBTRACT : ADD_INT ($1a)      // This set of optimizations is broken. Consider the case:   // STRING ADD_INT ADD_INT
292:   NEG_NUMBER ADD_INT [ !INT_TYPE_ADD_OVERFLOW(-$1a, $2a) ]: NUMBER(-$1a+$2a)   NEG_NUMBER ADD_NEG_INT [ !INT_TYPE_SUB_OVERFLOW(-$1a, $2a) ]: NUMBER(-$1a-$2a)    + CONST0 ADD_INT : NUMBER($2a) + CONST0 ADD_NEG_INT : NEG_NUMBER($2a) + CONST1 ADD_INT [($2a+1) > 0] : NUMBER($2a+1) + CONST1 ADD_NEG_INT : NEG_NUMBER($2a-1) + CONST_1 ADD_INT : NUMBER($2a-1) + CONST_1 ADD_NEG_INT [($2a+1) > 0] : NEG_NUMBER($2a) + CONST0 LOCAL ADD_INTS : LOCAL($2a) + CONST0 LOCAL NEGATE ADD_INTS : LOCAL($2a) NEGATE + CONST0 GLOBAL ADD_INTS : GLOBAL($2a) + CONST0 GLOBAL NEGATE ADD_INTS : GLOBAL($2a) NEGATE +    LOCAL BRANCH_WHEN_NON_ZERO : BRANCH_IF_LOCAL($1a) POINTER($2a)   LOCAL BRANCH_WHEN_ZERO : BRANCH_IF_NOT_LOCAL($1a) POINTER($2a)   
325:   APPLY_ASSIGN_LOCAL_AND_POP LOCAL ($1b) : APPLY_ASSIGN_LOCAL($1a,$1b)   #endif    - DEC_LOCAL_AND_POP MARK_AND_LOCAL ($1a) : MARK DEC_LOCAL ($1a) - INC_LOCAL_AND_POP MARK_AND_LOCAL ($1a) : MARK INC_LOCAL ($1a) - ASSIGN_GLOBAL_AND_POP MARK GLOBAL($1a) : MARK_X(1) ASSIGN_GLOBAL($1a) - ASSIGN_LOCAL_AND_POP MARK_AND_LOCAL($1a) : MARK_X(1) ASSIGN_LOCAL($1a) + DEC_LOCAL_AND_POP MARK_AND_LOCAL ($1a) : DEC_LOCAL ($1a) MARK_X(1) + INC_LOCAL_AND_POP MARK_AND_LOCAL ($1a) : INC_LOCAL ($1a) MARK_X(1) + ASSIGN_GLOBAL_AND_POP MARK GLOBAL($1a) : ASSIGN_GLOBAL($1a) MARK_X(1) + ASSIGN_LOCAL_AND_POP MARK_AND_LOCAL($1a) : ASSIGN_LOCAL($1a) MARK_X(1)   #ifdef EAT_STACK   APPLY_ASSIGN_LOCAL_AND_POP MARK_AND_LOCAL ($1b) : APPLY_ASSIGN_LOCAL($1a,$1b) MARK_X(1)   #endif      ASSIGN_LOCAL ASSIGN_LOCAL($1a) : ASSIGN_LOCAL($1a)    -  + #if 0 + // The following set of rules attempt to push the mark toward the apply. + // The idea is to push it the entire way, to be able to have an apply + // opcode that contains the stack depth, and thus doesn't need the mark + // stack. +  + // MARK rules + MARK LOCAL : LOCAL($2a) MARK_X(1) + MARK STRING : STRING($2a) MARK_X(1) + MARK NUMBER : NUMBER($2a) MARK_X(1) + MARK CONST0 : CONST0 MARK_X(1) + MARK CONST1 : CONST1 MARK_X(1) + MARK CONST_1 : CONST_1 MARK_X(1) + MARK NEG_NUMBER : NEG_NUMBER($2a) MARK_X(1) + MARK GLOBAL : GLOBAL($2a) MARK_X(1) + MARK MARK_APPLY : MARK_APPLY($2a) MARK_X(1) + MARK CONSTANT : CONSTANT($2a) MARK_X(1) + //MARK FLOAT : FLOAT($2a) MARK_X(1) + MARK LFUN : LFUN($2a) MARK_X(1) + MARK LTOSVAL : LTOSVAL MARK_X(1) + MARK LOCAL_LVALUE : LOCAL_LVALUE($2a) MARK_X(2) + MARK 2_LOCALS : 2_LOCALS($2a,$2b) MARK_X(2) + MARK NEGATE : NEGATE MARK +    // MARK_X rules   MARK_X(0) : MARK -  + MARK_X LOCAL : LOCAL($2a) MARK_X($1a+1) + MARK_X STRING : STRING($2a) MARK_X($1a+1) + MARK_X NUMBER : NUMBER($2a) MARK_X($1a+1) + MARK_X CONST0 : CONST0 MARK_X($1a+1) + MARK_X CONST1 : CONST1 MARK_X($1a+1) + MARK_X CONST_1 : CONST_1 MARK_X($1a+1) + MARK_X NEG_NUMBER : NEG_NUMBER($2a) MARK_X($1a+1) + MARK_X GLOBAL : GLOBAL($2a) MARK_X($1a+1) + MARK_X MARK_APPLY : MARK_APPLY($2a) MARK_X($1a+1) + MARK_X CONSTANT : CONSTANT($2a) MARK_X($1a+1) + //MARK_X FLOAT : FLOAT($2a) MARK_X($1a+1) + MARK_X LFUN : LFUN($2a) MARK_X($1a+1) + MARK_X LTOSVAL : LTOSVAL MARK_X($1a+1) + MARK_X LOCAL_LVALUE : LOCAL_LVALUE($2a) MARK_X($1a+2) + MARK_X 2_LOCALS : 2_LOCALS($2a,$2b) MARK_X($1a+2) + MARK_X NEGATE : NEGATE MARK_X($1a) +  + #else /* !0 */ +  + // MARK_X rules + MARK_X(0) : MARK   LOCAL MARK_X [$2a>0] : MARK_X($2a-1) LOCAL($1a)   STRING MARK_X [$2a>0] : MARK_X($2a-1) STRING($1a)   NUMBER MARK_X [$2a>0] : MARK_X($2a-1) NUMBER($1a)
353:   LOCAL_LVALUE MARK_X [$2a>1] : MARK_X($2a-2) LOCAL_LVALUE($1a)   2_LOCALS MARK_X [$2a>0] : LOCAL($1a) MARK_X($2a-1) LOCAL($1b)    + CONST_1 ASSIGN_LOCAL MARK_X [$3a>0] : MARK_X($3a-1) CONST_1 ASSIGN_LOCAL($2a) + CONST1 ASSIGN_LOCAL MARK_X [$3a>0] : MARK_X($3a-1) CONST1 ASSIGN_LOCAL($2a) + NUMBER ASSIGN_LOCAL MARK_X [$3a>0] : MARK_X($3a-1) NUMBER($1a) ASSIGN_LOCAL($2a) + NEG_NUMBER ASSIGN_LOCAL MARK_X [$3a>0] : MARK_X($3a-1) NEG_NUMBER($1a) ASSIGN_LOCAL($2a) +  + #endif /* 0 */ +  + MARK_X [$1a>0] POP_VALUE : POP_VALUE MARK_X($1a-1) + MARK_X POP_N_ELEMS [$1a >= $2a] : POP_N_ELEMS($2a) MARK_X($1a-$2a) +    #define BasicBranch2(Branch,Oper,Pre,Post,Variable) \    Variable Branch Pre Variable ($1a) : Variable ($1a) Oper ($2a) Post ; \    ASSIGN_##Variable Branch Pre Variable ($1a) : ASSIGN_##Variable($1a) Oper ($2a) Post ;
470:   MARK NUMBER ASSIGN_GLOBAL_AND_POP: NUMBER($2a) ASSIGN_GLOBAL_AND_POP($3a) MARK   MARK NEG_NUMBER ASSIGN_LOCAL_AND_POP: NEG_NUMBER($2a) ASSIGN_LOCAL_AND_POP($3a) MARK   MARK NEG_NUMBER ASSIGN_GLOBAL_AND_POP: NEG_NUMBER($2a) ASSIGN_GLOBAL_AND_POP($3a) MARK - MARK CONST1 ASSIGN_LOCAL_AND_POP: CONST1 ASSIGN_LOCAL_AND_POP($3a) MARK - MARK CONST1 ASSIGN_GLOBAL_AND_POP: CONST1 ASSIGN_GLOBAL_AND_POP($3a) MARK + MARK_AND_CONST1 ASSIGN_LOCAL_AND_POP: CONST1 ASSIGN_LOCAL_AND_POP($3a) MARK + MARK_AND_CONST1 ASSIGN_GLOBAL_AND_POP: CONST1 ASSIGN_GLOBAL_AND_POP($3a) MARK   MARK CONST_1 ASSIGN_LOCAL_AND_POP: CONST_1 ASSIGN_LOCAL_AND_POP($3a) MARK   MARK CONST_1 ASSIGN_GLOBAL_AND_POP: CONST_1 ASSIGN_GLOBAL_AND_POP($3a) MARK