/[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 739 by zherczeg, Fri Oct 7 19:18:55 2011 UTC revision 740 by zherczeg, Mon Oct 31 06:10:14 2011 UTC
# Line 199  struct sljit_compiler { Line 199  struct sljit_compiler {
199    
200  #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)  #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
201          int mode32;          int mode32;
202    #ifdef _WIN64
203            int has_locals;
204    #endif
205  #endif  #endif
206    
207  #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)  #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
# Line 257  struct sljit_compiler { Line 260  struct sljit_compiler {
260    
261  /* Creates an sljit compiler.  /* Creates an sljit compiler.
262     Returns NULL if failed. */     Returns NULL if failed. */
263  struct sljit_compiler* sljit_create_compiler(void);  SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void);
264  /* Free everything except the codes. */  /* Free everything except the codes. */
265  void sljit_free_compiler(struct sljit_compiler *compiler);  SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler);
266    
267  static SLJIT_INLINE int sljit_get_compiler_error(struct sljit_compiler *compiler) { return compiler->error; }  static SLJIT_INLINE int sljit_get_compiler_error(struct sljit_compiler *compiler) { return compiler->error; }
268    
# Line 273  static SLJIT_INLINE int sljit_get_compil Line 276  static SLJIT_INLINE int sljit_get_compil
276     but this return value does not indicate that there is no more memory (does     but this return value does not indicate that there is no more memory (does
277     not set the compiler to out-of-memory status).     not set the compiler to out-of-memory status).
278  */  */
279  void* sljit_alloc_memory(struct sljit_compiler *compiler, int size);  SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, int size);
280    
281  #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)  #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
282  /* Passing NULL disables verbose. */  /* Passing NULL disables verbose. */
283  void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose);  SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose);
284  #endif  #endif
285    
286  void* sljit_generate_code(struct sljit_compiler *compiler);  SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler);
287  void sljit_free_code(void* code);  SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code);
288    
289  /* Instruction generation. Returns with error code. */  /* Instruction generation. Returns with error code. */
290    
# Line 302  void sljit_free_code(void* code); Line 305  void sljit_free_code(void* code);
305    
306  #define SLJIT_MAX_LOCAL_SIZE    65536  #define SLJIT_MAX_LOCAL_SIZE    65536
307    
308  int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size);
309    
310  /* Since sljit_emit_return (and many asserts) uses variables which are initialized  /* Since sljit_emit_return (and many asserts) uses variables which are initialized
311     by sljit_emit_enter, a simple return is not possible if these variables are not     by sljit_emit_enter, a simple return is not possible if these variables are not
# Line 311  int sljit_emit_enter(struct sljit_compil Line 314  int sljit_emit_enter(struct sljit_compil
314    
315  /* Note: multiple calls of this function overwrites the previous call. */  /* Note: multiple calls of this function overwrites the previous call. */
316    
317  void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size);  SLJIT_API_FUNC_ATTRIBUTE void sljit_fake_enter(struct sljit_compiler *compiler, int args, int temporaries, int generals, int local_size);
318    
319  /* Return from jit. See below the possible values for src and srcw. */  /* Return from jit. See below the possible values for src and srcw. */
320  int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw);
321    
322  /* Really fast calling method for utility functions inside sljit (see SLJIT_FAST_CALL).  /* Really fast calling method for utility functions inside sljit (see SLJIT_FAST_CALL).
323     All registers and even the stack frame is passed to the callee. The return address is     All registers and even the stack frame is passed to the callee. The return address is
# Line 331  int sljit_emit_return(struct sljit_compi Line 334  int sljit_emit_return(struct sljit_compi
334  /* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested,  /* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested,
335     since many architectures do clever branch prediction on call / return instruction pairs. */     since many architectures do clever branch prediction on call / return instruction pairs. */
336    
337  int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size);
338  int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw);
339    
340  /*  /*
341     Source and destination values for arithmetical instructions     Source and destination values for arithmetical instructions
# Line 427  int sljit_emit_fast_return(struct sljit_ Line 430  int sljit_emit_fast_return(struct sljit_
430           it can even decrease the runtime in a few cases. */           it can even decrease the runtime in a few cases. */
431  #define SLJIT_NOP                       1  #define SLJIT_NOP                       1
432    
433  int sljit_emit_op0(struct sljit_compiler *compiler, int op);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op0(struct sljit_compiler *compiler, int op);
434    
435  /* Notes for MOV instructions:  /* Notes for MOV instructions:
436     U = Mov with update (post form). If source or destination defined as SLJIT_MEM1(r1)     U = Mov with update (post form). If source or destination defined as SLJIT_MEM1(r1)
# Line 473  int sljit_emit_op0(struct sljit_compiler Line 476  int sljit_emit_op0(struct sljit_compiler
476     Flags: I | E | K */     Flags: I | E | K */
477  #define SLJIT_CLZ                       18  #define SLJIT_CLZ                       18
478    
479  int sljit_emit_op1(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op1(struct sljit_compiler *compiler, int op,
480          int dst, sljit_w dstw,          int dst, sljit_w dstw,
481          int src, sljit_w srcw);          int src, sljit_w srcw);
482    
# Line 501  int sljit_emit_op1(struct sljit_compiler Line 504  int sljit_emit_op1(struct sljit_compiler
504  /* Flags: I | E | K */  /* Flags: I | E | K */
505  #define SLJIT_ASHR                      29  #define SLJIT_ASHR                      29
506    
507  int sljit_emit_op2(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_op2(struct sljit_compiler *compiler, int op,
508          int dst, sljit_w dstw,          int dst, sljit_w dstw,
509          int src1, sljit_w src1w,          int src1, sljit_w src1w,
510          int src2, sljit_w src2w);          int src2, sljit_w src2w);
511    
512  int sljit_is_fpu_available(void);  SLJIT_API_FUNC_ATTRIBUTE int sljit_is_fpu_available(void);
513    
514  /* 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.
515     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,
# Line 520  int sljit_is_fpu_available(void); Line 523  int sljit_is_fpu_available(void);
523  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
524  #define SLJIT_FABS                      33  #define SLJIT_FABS                      33
525    
526  int sljit_emit_fop1(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop1(struct sljit_compiler *compiler, int op,
527          int dst, sljit_w dstw,          int dst, sljit_w dstw,
528          int src, sljit_w srcw);          int src, sljit_w srcw);
529    
# Line 533  int sljit_emit_fop1(struct sljit_compile Line 536  int sljit_emit_fop1(struct sljit_compile
536  /* Flags: - (never set any flags) */  /* Flags: - (never set any flags) */
537  #define SLJIT_FDIV                      37  #define SLJIT_FDIV                      37
538    
539  int sljit_emit_fop2(struct sljit_compiler *compiler, int op,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fop2(struct sljit_compiler *compiler, int op,
540          int dst, sljit_w dstw,          int dst, sljit_w dstw,
541          int src1, sljit_w src1w,          int src1, sljit_w src1w,
542          int src2, sljit_w src2w);          int src2, sljit_w src2w);
543    
544  /* Label and jump instructions. */  /* Label and jump instructions. */
545    
546  struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler);  SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler);
547    
548  /* Invert conditional instruction: xor (^) with 0x1 */  /* Invert conditional instruction: xor (^) with 0x1 */
549  #define SLJIT_C_EQUAL                   0  #define SLJIT_C_EQUAL                   0
# Line 589  struct sljit_label* sljit_emit_label(str Line 592  struct sljit_label* sljit_emit_label(str
592      type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP      type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP
593     Flags: - (never set any flags) for both conditional and unconditional jumps.     Flags: - (never set any flags) for both conditional and unconditional jumps.
594     Flags: destroy all flags for calls. */     Flags: destroy all flags for calls. */
595  struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type);  SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, int type);
596    
597  /* Basic arithmetic comparison. In most architectures it is equal to  /* Basic arithmetic comparison. In most architectures it is equal to
598     an SLJIT_SUB operation (with SLJIT_UNUSED destination) followed by a     an SLJIT_SUB operation (with SLJIT_UNUSED destination) followed by a
# Line 599  struct sljit_jump* sljit_emit_jump(struc Line 602  struct sljit_jump* sljit_emit_jump(struc
602      type must be between SLJIT_C_EQUAL and SLJIT_C_SIG_LESS_EQUAL      type must be between SLJIT_C_EQUAL and SLJIT_C_SIG_LESS_EQUAL
603      type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP or SLJIT_INT_OP      type can be combined (or'ed) with SLJIT_REWRITABLE_JUMP or SLJIT_INT_OP
604     Flags: destroy flags. */     Flags: destroy flags. */
605  struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type,  SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, int type,
606          int src1, sljit_w src1w,          int src1, sljit_w src1w,
607          int src2, sljit_w src2w);          int src2, sljit_w src2w);
608    
609  /* Set the destination of the jump to this label. */  /* Set the destination of the jump to this label. */
610  void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label);  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label);
611  /* Only for jumps defined with SLJIT_REWRITABLE_JUMP flag.  /* Only for jumps defined with SLJIT_REWRITABLE_JUMP flag.
612     Note: use sljit_emit_ijump for fixed jumps. */     Note: use sljit_emit_ijump for fixed jumps. */
613  void sljit_set_target(struct sljit_jump *jump, sljit_uw target);  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target);
614    
615  /* Call function or jump anywhere. Both direct and indirect form  /* Call function or jump anywhere. Both direct and indirect form
616      type must be between SLJIT_JUMP and SLJIT_CALL3      type must be between SLJIT_JUMP and SLJIT_CALL3
# Line 615  void sljit_set_target(struct sljit_jump Line 618  void sljit_set_target(struct sljit_jump
618      Indirect form: any other valid addressing mode      Indirect form: any other valid addressing mode
619     Flags: - (never set any flags) for unconditional jumps.     Flags: - (never set any flags) for unconditional jumps.
620     Flags: destroy all flags for calls. */     Flags: destroy all flags for calls. */
621  int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ijump(struct sljit_compiler *compiler, int type, int src, sljit_w srcw);
622    
623  /* If op == SLJIT_MOV:  /* If op == SLJIT_MOV:
624       Set dst to 1 if condition is fulfilled, 0 otherwise       Set dst to 1 if condition is fulfilled, 0 otherwise
# Line 626  int sljit_emit_ijump(struct sljit_compil Line 629  int sljit_emit_ijump(struct sljit_compil
629       the condition is fulfilled. Otherwise it does nothing.       the condition is fulfilled. Otherwise it does nothing.
630       Flags: E | K       Flags: E | K
631     Note: sljit_emit_cond_value does nothing, if dst is SLJIT_UNUSED (regardless of op). */     Note: sljit_emit_cond_value does nothing, if dst is SLJIT_UNUSED (regardless of op). */
632  int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_cond_value(struct sljit_compiler *compiler, int op, int dst, sljit_w dstw, int type);
633    
634  /* The constant can be changed runtime (see: sljit_set_const)  /* The constant can be changed runtime (see: sljit_set_const)
635     Flags: - (never set any flags) */     Flags: - (never set any flags) */
636  struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value);  SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, int dst, sljit_w dstw, sljit_w init_value);
637    
638  /* After the code generation the address for label, jump and const instructions  /* After the code generation the address for label, jump and const instructions
639     are computed. Since these structures are freed sljit_free_compiler, the     are computed. Since these structures are freed sljit_free_compiler, the
# Line 640  static SLJIT_INLINE sljit_uw sljit_get_j Line 643  static SLJIT_INLINE sljit_uw sljit_get_j
643  static SLJIT_INLINE sljit_uw sljit_get_const_addr(struct sljit_const *const_) { return const_->addr; }  static SLJIT_INLINE sljit_uw sljit_get_const_addr(struct sljit_const *const_) { return const_->addr; }
644    
645  /* Only the address is required to rewrite the code. */  /* Only the address is required to rewrite the code. */
646  void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr);  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr);
647  void sljit_set_const(sljit_uw addr, sljit_w new_constant);  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_w new_constant);
648    
649  /* --------------------------------------------------------------------- */  /* --------------------------------------------------------------------- */
650  /*  Miscellaneous utility functions                                      */  /*  Miscellaneous utility functions                                      */
# Line 653  void sljit_set_const(sljit_uw addr, slji Line 656  void sljit_set_const(sljit_uw addr, slji
656  /* Get the human readable name of the platfrom.  /* Get the human readable name of the platfrom.
657     Can be useful for debugging on platforms like ARM, where ARM and     Can be useful for debugging on platforms like ARM, where ARM and
658     Thumb2 functions can be mixed. */     Thumb2 functions can be mixed. */
659  SLJIT_CONST char* sljit_get_platform_name(void);  SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void);
660    
661  /* Portble helper function to get an offset of a member. */  /* Portble helper function to get an offset of a member. */
662  #define SLJIT_OFFSETOF(base, member)    ((sljit_w)(&((base*)0x10)->member) - 0x10)  #define SLJIT_OFFSETOF(base, member)    ((sljit_w)(&((base*)0x10)->member) - 0x10)
663    
664  #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)  #if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
665  /* This global lock is useful to compile common functions. */  /* This global lock is useful to compile common functions. */
666  void SLJIT_CALL sljit_grab_lock(void);  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void);
667  void SLJIT_CALL sljit_release_lock(void);  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void);
668  #endif  #endif
669    
670  #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)  #if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
# Line 696  struct sljit_stack { Line 699  struct sljit_stack {
699  /* Returns NULL if unsuccessful.  /* Returns NULL if unsuccessful.
700     Note: limit and max_limit contains the size for stack allocation     Note: limit and max_limit contains the size for stack allocation
701     Note: the top field is initialized to base. */     Note: the top field is initialized to base. */
702  struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_w limit, sljit_w max_limit);  SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit);
703  void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack);  SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack);
704    
705  /* Can be used to increase (allocate) or decrease (free) the memory area.  /* Can be used to increase (allocate) or decrease (free) the memory area.
706     Returns with a non-zero value if unsuccessful. If new_limit is greater than     Returns with a non-zero value if unsuccessful. If new_limit is greater than
# Line 705  void SLJIT_CALL sljit_free_stack(struct Line 708  void SLJIT_CALL sljit_free_stack(struct
708     since the growth ratio can be added to the current limit, and sljit_stack_resize     since the growth ratio can be added to the current limit, and sljit_stack_resize
709     will do all the necessary checks. The fields of the stack are not changed if     will do all the necessary checks. The fields of the stack are not changed if
710     sljit_stack_resize fails. */     sljit_stack_resize fails. */
711  sljit_w SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit);  SLJIT_API_FUNC_ATTRIBUTE sljit_w SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit);
712    
713  #endif /* (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) */  #endif /* (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) */
714    
# Line 730  struct sljit_function_context { Line 733  struct sljit_function_context {
733  /* Fill the context arguments using the addr and the function.  /* Fill the context arguments using the addr and the function.
734     If func_ptr is NULL, it will not be set to the address of context     If func_ptr is NULL, it will not be set to the address of context
735     If addr is NULL, the function address also comes from the func pointer. */     If addr is NULL, the function address also comes from the func pointer. */
736  void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_w addr, void* func);  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_w addr, void* func);
737    
738  #endif /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */  #endif /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */
739    

Legend:
Removed from v.739  
changed lines
  Added in v.740

  ViewVC Help
Powered by ViewVC 1.1.5