/[pcre]/code/trunk/sljit/sljitLir.h
ViewVC logotype

Diff of /code/trunk/sljit/sljitLir.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 777 by zherczeg, Thu Dec 1 15:15:31 2011 UTC revision 847 by zherczeg, Tue Jan 3 17:49:03 2012 UTC
# Line 1  Line 1 
1  /*  /*
2   *    Stack-less Just-In-Time compiler   *    Stack-less Just-In-Time compiler
3   *   *
4   *    Copyright 2009-2010 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.   *    Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
5   *   *
6   * Redistribution and use in source and binary forms, with or without modification, are   * Redistribution and use in source and binary forms, with or without modification, are
7   * permitted provided that the following conditions are met:   * permitted provided that the following conditions are met:
# Line 64  Line 64 
64  #if !(defined SLJIT_NO_DEFAULT_CONFIG && SLJIT_NO_DEFAULT_CONFIG)  #if !(defined SLJIT_NO_DEFAULT_CONFIG && SLJIT_NO_DEFAULT_CONFIG)
65  #include "sljitConfig.h"  #include "sljitConfig.h"
66  #endif  #endif
67    
68    /* The following header file defines useful macros for fine tuning
69    sljit based code generators. They are listed in the begining
70    of sljitConfigInternal.h */
71    
72  #include "sljitConfigInternal.h"  #include "sljitConfigInternal.h"
73    
74  /* --------------------------------------------------------------------- */  /* --------------------------------------------------------------------- */
# Line 122  Line 127 
127    
128  #define SLJIT_RETURN_REG        SLJIT_TEMPORARY_REG1  #define SLJIT_RETURN_REG        SLJIT_TEMPORARY_REG1
129    
130  /* x86 prefers temporary registers for special purposes. If other  /* x86 prefers specific registers for special purposes. In case of shift
131     registers are used such purpose, it costs a little performance     by register it supports only SLJIT_TEMPORARY_REG3 for shift argument
132     drawback. It doesn't matter for other archs. */     (which is the src2 argument of sljit_emit_op2). If another register is
133       used, sljit must exchange data between registers which cause a minor
134       slowdown. Other architectures has no such limitation. */
135    
136  #define SLJIT_PREF_SHIFT_REG    SLJIT_TEMPORARY_REG3  #define SLJIT_PREF_SHIFT_REG    SLJIT_TEMPORARY_REG3
137    
# Line 365  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 372  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
372  */  */
373    
374  /*  /*
375     IMPORATNT NOTE: memory access MUST be naturally aligned.     IMPORATNT NOTE: memory access MUST be naturally aligned except
376                       SLJIT_UNALIGNED macro is defined and its value is 1.
377    
378       length | alignment       length | alignment
379     ---------+-----------     ---------+-----------
380       byte   | 1 byte (not aligned)       byte   | 1 byte (not aligned)
381       half   | 2 byte (real_address & 0x1 == 0)       half   | 2 byte (real_address & 0x1 == 0)
382       int    | 4 byte (real_address & 0x3 == 0)       int    | 4 byte (real_address & 0x3 == 0)
383      sljit_w | 4 byte if SLJIT_32BIT_ARCHITECTURE defined      sljit_w | 4 byte if SLJIT_32BIT_ARCHITECTURE is defined and its value is 1
384              | 8 byte if SLJIT_64BIT_ARCHITECTURE defined              | 8 byte if SLJIT_64BIT_ARCHITECTURE is defined and its value is 1
    (This is a strict requirement for embedded systems.)  
385    
386     Note: different architectures have different addressing limitations     Note: different architectures have different addressing limitations
387           Thus sljit may generate several instructions for other addressing modes           Thus sljit may generate several instructions for other addressing modes
# Line 445  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 453  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
453     Note: may or may not cause an extra cycle wait     Note: may or may not cause an extra cycle wait
454           it can even decrease the runtime in a few cases. */           it can even decrease the runtime in a few cases. */
455  #define SLJIT_NOP                       1  #define SLJIT_NOP                       1
456    /* Flags: may destroy flags
457       Unsigned multiplication of SLJIT_TEMPORARY_REG1 and SLJIT_TEMPORARY_REG2.
458       Result goes to SLJIT_TEMPORARY_REG2:SLJIT_TEMPORARY_REG1 (high:low) word */
459    #define SLJIT_UMUL                      2
460    /* Flags: may destroy flags
461       Signed multiplication of SLJIT_TEMPORARY_REG1 and SLJIT_TEMPORARY_REG2.
462       Result goes to SLJIT_TEMPORARY_REG2:SLJIT_TEMPORARY_REG1 (high:low) word */
463    #define SLJIT_SMUL                      3
464    /* Flags: I | may destroy flags
465       Unsigned divide the value in SLJIT_TEMPORARY_REG1 by SLJIT_TEMPORARY_REG2.
466       Result goes to SLJIT_TEMPORARY_REG1 and remainder goes to SLJIT_TEMPORARY_REG2.
467       Note: if SLJIT_TEMPORARY_REG2 is equal to 0, the behaviour is undefined. */
468    #define SLJIT_UDIV                      4
469    /* Flags: I | may destroy flags
470       Signed divide the value in SLJIT_TEMPORARY_REG1 by SLJIT_TEMPORARY_REG2.
471       Result goes to SLJIT_TEMPORARY_REG1 and remainder goes to SLJIT_TEMPORARY_REG2.
472       Note: if SLJIT_TEMPORARY_REG2 is equal to 0, the behaviour is undefined. */
473    #define SLJIT_SDIV                      5
474    
475  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op);
476    
# Line 457  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 483  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
483     SH = unsgined half (16 bit) */     SH = unsgined half (16 bit) */
484    
485  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
486  #define SLJIT_MOV                       2  #define SLJIT_MOV                       6
487  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
488  #define SLJIT_MOV_UB                    3  #define SLJIT_MOV_UB                    7
489  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
490  #define SLJIT_MOV_SB                    4  #define SLJIT_MOV_SB                    8
491  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
492  #define SLJIT_MOV_UH                    5  #define SLJIT_MOV_UH                    9
493  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
494  #define SLJIT_MOV_SH                    6  #define SLJIT_MOV_SH                    10
495  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
496  #define SLJIT_MOV_UI                    7  #define SLJIT_MOV_UI                    11
497  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
498  #define SLJIT_MOV_SI                    8  #define SLJIT_MOV_SI                    12
499  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
500  #define SLJIT_MOVU                      9  #define SLJIT_MOVU                      13
501  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
502  #define SLJIT_MOVU_UB                   10  #define SLJIT_MOVU_UB                   14
503  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
504  #define SLJIT_MOVU_SB                   11  #define SLJIT_MOVU_SB                   15
505  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
506  #define SLJIT_MOVU_UH                   12  #define SLJIT_MOVU_UH                   16
507  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
508  #define SLJIT_MOVU_SH                   13  #define SLJIT_MOVU_SH                   17
509  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
510  #define SLJIT_MOVU_UI                   14  #define SLJIT_MOVU_UI                   18
511  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
512  #define SLJIT_MOVU_SI                   15  #define SLJIT_MOVU_SI                   19
513  /* Flags: I | E | K */  /* Flags: I | E | K */
514  #define SLJIT_NOT                       16  #define SLJIT_NOT                       20
515  /* Flags: I | E | O | K */  /* Flags: I | E | O | K */
516  #define SLJIT_NEG                       17  #define SLJIT_NEG                       21
517  /* Count leading zeroes  /* Count leading zeroes
518     Flags: I | E | K */     Flags: I | E | K */
519  #define SLJIT_CLZ                       18  #define SLJIT_CLZ                       22
520    
521  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op,
522          int dst, sljit_w dstw,          int dst, sljit_w dstw,
523          int src, sljit_w srcw);          int src, sljit_w srcw);
524    
525  /* Flags: I | E | O | C | K */  /* Flags: I | E | O | C | K */
526  #define SLJIT_ADD                       19  #define SLJIT_ADD                       23
527  /* Flags: I | C | K */  /* Flags: I | C | K */
528  #define SLJIT_ADDC                      20  #define SLJIT_ADDC                      24
529  /* Flags: I | E | S | U | O | C | K */  /* Flags: I | E | S | U | O | C | K */
530  #define SLJIT_SUB                       21  #define SLJIT_SUB                       25
531  /* Flags: I | C | K */  /* Flags: I | C | K */
532  #define SLJIT_SUBC                      22  #define SLJIT_SUBC                      26
533  /* Note: integer mul */  /* Note: integer mul */
534  /* Flags: I | O (see SLJIT_C_MUL_*) | K */  /* Flags: I | O (see SLJIT_C_MUL_*) | K */
535  #define SLJIT_MUL                       23  #define SLJIT_MUL                       27
536  /* Flags: I | E | K */  /* Flags: I | E | K */
537  #define SLJIT_AND                       24  #define SLJIT_AND                       28
538  /* Flags: I | E | K */  /* Flags: I | E | K */
539  #define SLJIT_OR                        25  #define SLJIT_OR                        29
540  /* Flags: I | E | K */  /* Flags: I | E | K */
541  #define SLJIT_XOR                       26  #define SLJIT_XOR                       30
542  /* Flags: I | E | K */  /* Flags: I | E | K */
543  #define SLJIT_SHL                       27  #define SLJIT_SHL                       31
544  /* Flags: I | E | K */  /* Flags: I | E | K */
545  #define SLJIT_LSHR                      28  #define SLJIT_LSHR                      32
546  /* Flags: I | E | K */  /* Flags: I | E | K */
547  #define SLJIT_ASHR                      29  #define SLJIT_ASHR                      33
548    
549  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op,
550          int dst, sljit_w dstw,          int dst, sljit_w dstw,
551          int src1, sljit_w src1w,          int src1, sljit_w src1w,
552          int src2, sljit_w src2w);          int src2, sljit_w src2w);
553    
554    /* The following function is a helper function for sljit_emit_op_custom.
555       It returns with the real machine register index of any SLJIT_TEMPORARY
556       SLJIT_GENERAL or SLJIT_LOCALS register.
557       Note: it returns with -1 for virtual registers (all EREGs on x86-32).
558       Note: register returned by SLJIT_LOCALS_REG is not necessary the real
559             stack pointer register of the target architecture. */
560    
561    SLJIT_API_FUNC_ATTRIBUTE int sljit_get_register_index(int reg);
562    
563    /* Any instruction can be inserted into the instruction stream by
564       sljit_emit_op_custom. It has a similar purpose as inline assembly.
565       The size parameter must match to the instruction size of the target
566       architecture:
567    
568             x86: 0 < size <= 15. The instruction argument can be byte aligned.
569          Thumb2: if size == 2, the instruction argument must be 2 byte aligned.
570                  if size == 4, the instruction argument must be 4 byte aligned.
571       Otherwise: size must be 4 and instruction argument must be 4 byte aligned. */
572    
573    SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op_custom(struct sljit_compiler *compiler,
574            void *instruction, int size);
575    
576    /* Returns with non-zero if fpu is available. */
577    
578  SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void);  SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void);
579    
580  /* Note: dst is the left and src is the right operand for SLJIT_FCMP.  /* Note: dst is the left and src is the right operand for SLJIT_FCMP.
581     Note: NaN check is always performed. If SLJIT_C_FLOAT_NAN is set,     Note: NaN check is always performed. If SLJIT_C_FLOAT_NAN is set,
582           the comparison result is unpredictable.           the comparison result is unpredictable.
583     Flags: E | S (see SLJIT_C_FLOAT_*) */     Flags: E | S (see SLJIT_C_FLOAT_*) */
584  #define SLJIT_FCMP                      30  #define SLJIT_FCMP                      34
585  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
586  #define SLJIT_FMOV                      31  #define SLJIT_FMOV                      35
587  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
588  #define SLJIT_FNEG                      32  #define SLJIT_FNEG                      36
589  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
590  #define SLJIT_FABS                      33  #define SLJIT_FABS                      37
591    
592  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op,
593          int dst, sljit_w dstw,          int dst, sljit_w dstw,
594          int src, sljit_w srcw);          int src, sljit_w srcw);
595    
596  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
597  #define SLJIT_FADD                      34  #define SLJIT_FADD                      38
598  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
599  #define SLJIT_FSUB                      35  #define SLJIT_FSUB                      39
600  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
601  #define SLJIT_FMUL                      36  #define SLJIT_FMUL                      40
602  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
603  #define SLJIT_FDIV                      37  #define SLJIT_FDIV                      41
604    
605  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op,
606          int dst, sljit_w dstw,          int dst, sljit_w dstw,

Legend:
Removed from v.777  
changed lines
  Added in v.847

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12