summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornrootconauto <nrootconauto@gmail.com>2022-04-29 14:17:54 -0400
committernrootconauto <nrootconauto@gmail.com>2022-04-29 14:17:54 -0400
commitef63a875284f6e8f109469d0f90d6707265b1398 (patch)
tree2ab821def02ad3f38b75c9f2705caa423d20753c
parentc4c50b82c38bace6a12a40703075ca4fb621fd1f (diff)
Now uses templeOS abi,uses custom CODEGEN.HC.v0.1.00
-rw-r--r--.gitignore2
-rwxr-xr-x3Days.nsi6
-rwxr-xr-x3d.h6
-rwxr-xr-xCODEGEN.HC7094
-rwxr-xr-xDebian_pkg.sh5
-rw-r--r--FFI_SYSV.yasm223
-rw-r--r--FFI_WIN64.yasm237
-rw-r--r--FULL_RUNTIME.HC2
-rwxr-xr-xFreeBSD_pkg.sh4
-rwxr-xr-xHCRT/ASM.HC205
-rwxr-xr-xHCRT/BITS.HC3
-rwxr-xr-xHCRT/CHAR.HC9
-rwxr-xr-xHCRT/HASH.HC3
-rwxr-xr-xHCRT/HCRT.HC4
-rwxr-xr-xHCRT/HCRT.HH187
-rw-r--r--HCRT/HCRT_TOS.BINbin0 -> 1470143 bytes
-rwxr-xr-xHCRT/LEXER.HC13
-rwxr-xr-xHCRT/PRINT.HC6
-rwxr-xr-xHolyEd/EDITOR.HC16
-rwxr-xr-xHolyEd/ROPE.HC4
-rwxr-xr-xPARSER2.HC (renamed from PARSER.HC)4616
-rwxr-xr-xREADME.MD21
-rw-r--r--REPL.VBINbin1024006 -> 0 bytes
-rw-r--r--REPL.WBINbin1053132 -> 0 bytes
-rw-r--r--TOSJMP.yasm51
-rwxr-xr-xVECTOR.HC18
-rwxr-xr-xaot.c15
-rw-r--r--asmtest.hc114
-rwxr-xr-xdebuggerAsm.yasm92
-rwxr-xr-xexceptLin.yasm53
-rw-r--r--exceptTOS.yasm1
-rwxr-xr-xexceptWin.yasm65
-rwxr-xr-xext/myjit/LICENSE165
-rwxr-xr-xext/myjit/Makefile35
-rwxr-xr-xext/myjit/README1
-rwxr-xr-xext/myjit/demo1bin323900 -> 0 bytes
-rwxr-xr-xext/myjit/demo1.c47
-rwxr-xr-xext/myjit/demo2bin324494 -> 0 bytes
-rwxr-xr-xext/myjit/demo2.c63
-rwxr-xr-xext/myjit/demo3bin328581 -> 0 bytes
-rwxr-xr-xext/myjit/demo3.c97
-rwxr-xr-xext/myjit/disasm/Makefile20
-rwxr-xr-xext/myjit/disasm/io.c136
-rwxr-xr-xext/myjit/disasm/io.h35
-rwxr-xr-xext/myjit/disasm/myjit-disasmbin427295 -> 0 bytes
-rwxr-xr-xext/myjit/disasm/myjit-disasm.c182
-rwxr-xr-xext/myjit/disasm/sparc/Makefile9
-rwxr-xr-xext/myjit/disasm/sparc/sparc-dis.c568
-rwxr-xr-xext/myjit/disasm/sparc/sparc-dis.h35
-rwxr-xr-xext/myjit/disasm/udis86/Makefile24
-rwxr-xr-xext/myjit/disasm/udis86/decode.c1266
-rwxr-xr-xext/myjit/disasm/udis86/decode.h197
-rwxr-xr-xext/myjit/disasm/udis86/extern.h113
-rwxr-xr-xext/myjit/disasm/udis86/itab.c5946
-rwxr-xr-xext/myjit/disasm/udis86/itab.h939
-rwxr-xr-xext/myjit/disasm/udis86/syn-att.c228
-rwxr-xr-xext/myjit/disasm/udis86/syn-intel.c224
-rwxr-xr-xext/myjit/disasm/udis86/syn.c212
-rwxr-xr-xext/myjit/disasm/udis86/syn.h53
-rwxr-xr-xext/myjit/disasm/udis86/types.h260
-rwxr-xr-xext/myjit/disasm/udis86/udint.h99
-rwxr-xr-xext/myjit/disasm/udis86/udis86.c458
-rwxr-xr-xext/myjit/disasm/udis86/udis86.h33
-rwxr-xr-xext/myjit/doc/ChangeLog128
-rwxr-xr-xext/myjit/doc/README644
-rwxr-xr-xext/myjit/doc/TODO45
-rwxr-xr-xext/myjit/doc/build/Makefile34
-rwxr-xr-xext/myjit/doc/build/assets/code-style.css62
-rwxr-xr-xext/myjit/doc/build/assets/ga.htm9
-rwxr-xr-xext/myjit/doc/build/assets/main.css71
-rwxr-xr-xext/myjit/doc/build/assets/sflogo.htm1
-rwxr-xr-xext/myjit/doc/build/assets/template.htm40
-rwxr-xr-xext/myjit/doc/build/assets/web-main.css124
-rwxr-xr-xext/myjit/doc/build/assets/xetex-template.tex92
-rwxr-xr-xext/myjit/doc/build/src/01-About15
-rwxr-xr-xext/myjit/doc/build/src/02-Download26
-rwxr-xr-xext/myjit/doc/build/src/03-Instruction-set372
-rwxr-xr-xext/myjit/doc/build/src/04-Getting-started73
-rwxr-xr-xext/myjit/doc/build/src/05-Debugging114
-rwxr-xr-xext/myjit/doc/build/src/06-Optimizations26
-rwxr-xr-xext/myjit/doc/build/src/07-Notes18
-rwxr-xr-xext/myjit/doc/readme.htm717
-rwxr-xr-xext/myjit/doc/readme.pdfbin114431 -> 0 bytes
-rwxr-xr-xext/myjit/extras/myjit-unique.sh58
-rwxr-xr-xext/myjit/junk/Makefile2
-rwxr-xr-xext/myjit/junk/opcodes-debugger.c121
-rwxr-xr-xext/myjit/junk/sse-test.c91
-rwxr-xr-xext/myjit/myjit-disasmbin427295 -> 0 bytes
-rwxr-xr-xext/myjit/myjit/amd64-codegen.h1686
-rwxr-xr-xext/myjit/myjit/amd64-specific.h644
-rwxr-xr-xext/myjit/myjit/code-check.c307
-rwxr-xr-xext/myjit/myjit/common86-codegen.h174
-rwxr-xr-xext/myjit/myjit/common86-specific.h989
-rwxr-xr-xext/myjit/myjit/cpu-detect.h99
-rwxr-xr-xext/myjit/myjit/flow-analysis.h475
-rwxr-xr-xext/myjit/myjit/graphcoloring.h237
-rwxr-xr-xext/myjit/myjit/jitlib-core.c601
-rwxr-xr-xext/myjit/myjit/jitlib-core.h370
-rwxr-xr-xext/myjit/myjit/jitlib-debug.c694
-rwxr-xr-xext/myjit/myjit/jitlib.h712
-rwxr-xr-xext/myjit/myjit/llrb.c275
-rwxr-xr-xext/myjit/myjit/reg-allocator.h680
-rwxr-xr-xext/myjit/myjit/rmap.h249
-rwxr-xr-xext/myjit/myjit/set.h96
-rwxr-xr-xext/myjit/myjit/sparc-codegen.h983
-rwxr-xr-xext/myjit/myjit/sparc-specific.h1074
-rwxr-xr-xext/myjit/myjit/sse2-specific.h377
-rwxr-xr-xext/myjit/myjit/x86-codegen.h2424
-rwxr-xr-xext/myjit/myjit/x86-common-stuff.c303
-rwxr-xr-xext/myjit/myjit/x86-specific.h262
-rwxr-xr-xext/myjit/test/Makefile151
-rwxr-xr-xext/myjit/test/run-tests.sh25
-rwxr-xr-xext/myjit/test/simple-buffer.c20
-rwxr-xr-xext/myjit/test/t001-basics.c246
-rwxr-xr-xext/myjit/test/t002-arithmetic.c341
-rwxr-xr-xext/myjit/test/t003-conditions.c193
-rwxr-xr-xext/myjit/test/t004-branches.c327
-rwxr-xr-xext/myjit/test/t005-functions.c353
-rwxr-xr-xext/myjit/test/t006-misc.c178
-rwxr-xr-xext/myjit/test/t007-args.c69
-rwxr-xr-xext/myjit/test/t008-pushargs.c137
-rwxr-xr-xext/myjit/test/t009-allocaireg.c98
-rwxr-xr-xext/myjit/test/t010-debug.c169
-rwxr-xr-xext/myjit/test/t101-fp-basics.c240
-rwxr-xr-xext/myjit/test/t102-fp-arithmetic.c194
-rwxr-xr-xext/myjit/test/t103-fp-rounding.c37
-rwxr-xr-xext/myjit/test/t104-fp-branches.c128
-rwxr-xr-xext/myjit/test/t105-fp-functions.c354
-rwxr-xr-xext/myjit/test/t107-fp-args.c128
-rwxr-xr-xext/myjit/test/t108-fp-pushargs.c272
-rwxr-xr-xext/myjit/test/t109-fp-allocaireg.c100
-rwxr-xr-xext/myjit/test/t200-callr.c44
-rwxr-xr-xext/myjit/test/t201-functions.c165
-rwxr-xr-xext/myjit/test/t202-highmem.c54
-rwxr-xr-xext/myjit/test/t301-optim-adds.c165
-rwxr-xr-xext/myjit/test/t302-optim-stores.c60
-rwxr-xr-xext/myjit/test/t401-data-in-code.c306
-rwxr-xr-xext/myjit/test/tests.h165
-rwxr-xr-xfilelist.tcsh15
-rwxr-xr-xfilelistWIN.tcsh17
-rwxr-xr-xmain.c10
-rwxr-xr-xmake.tcsh47
-rw-r--r--makeBSD.tcsh43
-rwxr-xr-xmakeWIN.tcsh4
-rwxr-xr-xpoopalloc.c25
-rwxr-xr-xpoopalloc.h2
-rwxr-xr-xrl.c4
-rwxr-xr-xruntime.c1729
148 files changed, 10340 insertions, 37389 deletions
diff --git a/.gitignore b/.gitignore
index 0b12e60..9e19501 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,8 +57,6 @@ epm
*~
!ext/wineditline-2.206/lib64/*
!SDL2.dll
-*.BIN
-!HCRT/HCRT.BIN
3d_loader
chroot/*
proot
diff --git a/3Days.nsi b/3Days.nsi
index c29086b..5848ca5 100755
--- a/3Days.nsi
+++ b/3Days.nsi
@@ -6,7 +6,7 @@
!define APP_NAME "3Days"
!define COMP_NAME "nrootconauto@gmail.com"
-!define VERSION "00.00.99.00"
+!define VERSION "00.01.00.00"
!define COPYRIGHT "None"
!define DESCRIPTION "A HolyC Compiler"
!define INSTALLER_NAME "3d_setup.exe"
@@ -85,7 +85,7 @@ SetOutPath "$INSTDIR"
File "3d_loader.exe"
File "SDL2.dll"
SetOutPath "$INSTDIR\HCRT"
-File "HCRT\HCRT.BIN"
+File "HCRT\HCRT_TOS.BIN"
SectionEnd
######################################################################
@@ -138,7 +138,7 @@ Section Uninstall
${INSTALL_TYPE}
Delete "$INSTDIR\SDL2.dll"
Delete "$INSTDIR\${MAIN_APP_EXE}"
-Delete "$INSTDIR\HCRT\HCRT.BIN"
+Delete "$INSTDIR\HCRT\HCRT_TOS.BIN"
RmDir "$INSTDIR\HCRT"
Delete "$INSTDIR\uninstall.exe"
diff --git a/3d.h b/3d.h
index e36d680..55a8e76 100755
--- a/3d.h
+++ b/3d.h
@@ -7,7 +7,6 @@
typedef int8_t ExceptBuf[216];
#include "ext/map/src/map.h"
#include "ext/vec/src/vec.h"
-#include "ext/myjit/myjit/jitlib.h"
#include "rl.h"
#define AOT_NO_IMPORT_SYMS (1<<0)
#define AOT_MALLOCED_SYM (1<<1)
@@ -74,3 +73,8 @@ void InitRL();
void RegisterRuntimeClasses(void *gt,void *ctf,void *add_mem,void *c_arr_t);
void RegisterMacrosAndREPL(char *includes,int flags,char *body_code) ;
void RegisterMacrosAndCompile(char *includes,char *to_file,char *embed_header);
+int64_t FFI_CALL_TOS_0(void *fptr);
+int64_t FFI_CALL_TOS_1(void *fptr,int64_t);
+int64_t FFI_CALL_TOS_2(void *fptr,int64_t, int64_t);
+int64_t FFI_CALL_TOS_3(void *fptr,int64_t, int64_t,int64_t);
+int64_t FFI_CALL_TOS_4(void *fptr,int64_t, int64_t,int64_t,int64_t);
diff --git a/CODEGEN.HC b/CODEGEN.HC
new file mode 100755
index 0000000..01ab4b5
--- /dev/null
+++ b/CODEGEN.HC
@@ -0,0 +1,7094 @@
+#include "VECTOR.HC"
+CReg *IRegCodeToReg(I64 c) {
+ switch(c) {
+ case 0: return Str2Reg("RAX");
+ case 1: return Str2Reg("RCX");
+ case 2: return Str2Reg("RDX");
+ case 3: return Str2Reg("RBX");
+ case 4: return Str2Reg("RSP");
+ case 5: return Str2Reg("RBP");
+ case 6: return Str2Reg("RSI");
+ case 7: return Str2Reg("RDI");
+ case 8: return Str2Reg("R8");
+ case 9: return Str2Reg("R9");
+ case 10: return Str2Reg("R10");
+ case 11: return Str2Reg("R11");
+ case 12: return Str2Reg("R12");
+ case 13: return Str2Reg("R13");
+ case 14: return Str2Reg("R14");
+ case 15: return Str2Reg("R15");
+ }
+}
+//#define JIT_DBG 1
+I64 union CRPN_Code {
+ class {
+ U8 is_signed;
+ U8 is_flt;
+ #define OP_ADD 1
+ #define OP_SUB 2
+
+ #define OP_MUL 3
+ #define OP_DIV 4
+ #define OP_MOD 5
+
+ #define OP_SHL 6
+ #define OP_SHR 7
+
+ #define OP_AND 9
+ #define OP_OR 10
+ #define OP_XOR 11
+
+ #define OP_POS 12
+ #define OP_NEG 13
+
+ #define OP_GT 14
+ #define OP_LT 15
+ #define OP_GE 16
+ #define OP_LE 17
+
+ #define OP_LXOR 18
+ #define OP_LOR 19
+ #define OP_LAND 20
+
+ #define OP_POST_INC 21 //For interget version of operation,operands[1] is an I64 which is the amount to increment/decrement by
+ #define OP_POST_DEC 22 //Ditto
+ #define OP_PRE_INC 23 //Ditto
+ #define OP_PRE_DEC 24 //Ditto
+
+ #define OP_LITERAL 25 //See is_flt
+ #define OP_DEREF 26 //operands[1] is an I64 which is offset,operands[2] is size
+
+ #define OP_IF 27 //if cond el,else
+ #define OP_JMP 28 //Jumps to CRPN at operands[0]
+ #define OP_BODY 30 //See body_length
+
+ #define OP_VARIABLE 31 //See my_avalue
+
+ #define OP_ASSIGN 32
+
+ #define OP_CALL 33 //Return stuffed in my_avalue,last item is function to be called,arguments are put in reverse order
+ #define OP_GETARG 34
+ #define OP_RETURN 35
+
+ #define OP_NOT 36
+ #define OP_EQ 37
+ #define OP_NE 38
+
+ #define OP_REF_DATA 39
+ #define OP_DU8 40
+ #define OP_DU16 41
+ #define OP_DU32 42
+ #define OP_DU64 43
+ #define OP_ALIGN 44 //operands[0] is an I64 which is align,and simularly operands[1] is the fill
+ #define OP_ALLOCAI 45 //operands[0] is an I64 which is the size
+ #define OP_RELOCATION 46 //operands[0] is a U0** whihc will be filled in later
+ #define OP_ASSIGN_ADD 47
+ #define OP_ASSIGN_SUB 48
+ #define OP_ASSIGN_MUL 49
+ #define OP_ASSIGN_DIV 50
+ #define OP_ASSIGN_MOD 51
+ #define OP_ASSIGN_SHL 52
+ #define OP_ASSIGN_SHR 53
+ #define OP_ASSIGN_AND 54
+ #define OP_ASSIGN_XOR 55
+ #define OP_ASSIGN_OR 56
+
+ #define OP_COMMA 57
+ //This is a weird one,it pushes my_avalue to the stack,this is usefull for changing OP_LITERAL/OP_VARIABLE to a push for function calls
+ #define OP_INPLACE_PUSH 58
+ #define OP_DUMP_PTR 59
+
+ #define OP_TYPECAST_BIT4BIT 60
+
+ #define OP_BREAKPOINT 61
+
+ //Does not include bounds check,starts at 0,body_length tells how many items
+ //See RPN.jmp_table
+ #define OP_JMP_TABLE 62
+ U8 code;
+ U16 body_length;
+ U16 vargs_base;
+ };
+};
+CRPN_Code RPN_CodeNew(U8 code,U8 is_flt=FALSE,U8 is_signed=TRUE) {
+ CRPN_Code ret;
+ ret.code=code;
+ ret.is_signed=is_signed;
+ ret.is_flt=is_flt;
+ return ret;
+}
+class CAsmValue;
+class CAsmValue {
+ #define AV_UNOCC 0
+ #define AV_IREG 1
+ #define AV_FREG 2
+ #define AV_GLOBAL_PTR 3
+ #define AV_IREG_SHADOW 4
+ #define AV_FREG_SHADOW 5
+ #define AV_INT 6
+ #define AV_FLT 7
+ #define AV_VIREG 8
+ #define AV_VFREG 9
+ #define AV_IINDIR 10
+ #define AV_FINDIR 11
+ #define AV_IFRAME 12
+ #define AV_FFRAME 13
+ #define AV_IVINDIR 14
+ #define AV_FVINDIR 15
+ #define AV_PUSH 16 //This pushes to the stack,used for func calls
+ I64 type;
+ I64 vreg;
+ union {
+ CReg *reg;
+ U8 *global_name;
+ I64 int;
+ F64 flt;
+ };
+ I64 size,fpu_depth;
+ union {
+ I64 offset,f_offset;
+ };
+};
+Bool AsmValueEqual(CAsmValue *a,CAsmValue *b) {
+ if(a->type!=b->type) return FALSE;
+ switch(a->type) {
+ case AV_IREG:
+ return a->reg==b->reg;
+ case AV_IVINDIR:
+ case AV_FVINDIR:
+ return a->vreg==b->vreg&&a->offset==b->offset;
+ case AV_IREG_SHADOW:
+ case AV_FREG_SHADOW:
+ case AV_VIREG:
+ return a->vreg==b->vreg;
+ case AV_INT:
+ return a->int==b->int;
+ case AV_FLT:
+ return a->flt==b->flt;
+ case AV_IINDIR:
+ case AV_FINDIR:
+ return a->reg==b->reg&&a->f_offset==b->f_offset;
+ break;
+ case AV_IFRAME:
+ case AV_FFRAME:
+ return a->f_offset==b->f_offset;
+ }
+ return TRUE;
+}
+class CRPN {
+ CRPN_Code type;
+ CRPN *prev,*next,*consumer;
+ CAsmValue my_avalue;
+ CRPN *__end;
+ CAsmValue *operands[4];
+ CVector *successors;
+ I64 *live_in,*live_out;
+ I64 *flive_in,*flive_out;
+ Bool visited;
+ //Has from [ireg,physical_reg_code]
+ CVector *in_r_map,*r_map,*unspills,*spills,*__live_preds;
+ CRPN **jmp_table;
+ //Used for register adjustment
+ //Has form [CRPN *dst,I64 patch_addr]
+ CVector *jmp_table_trampolines;
+ //These represent the stack depth of the temp regs at the point of the CRPN
+ I64 live_tistack_depth;
+ I64 live_tfstack_depth;
+ I64 bin_off,patch_addr;
+ #define RPN_F_MERGED_ASSIGN (1)
+ //Default order is spill then unspill
+ #define RPN_F_UNSPILL_THEN_SPILL (1<<1)
+ //Dont emit the operation in CompilerOps
+ #define RPN_F_IMPLICIT_OPERATION (1<<2)
+ #define RPN_F_DONT_TOUCH (1<<3)
+ #define RPN_F_BIG_MOVE (1<<4)
+ #define RPN_F_LIVE_SHADOW (1<<5)
+ #define RPN_F_LIVE_CHANGED (1<<6)
+ //This marks a label as jumped to from assembler block,so its incoming registers may be tainted,so unspill all incoming
+ #define RPN_F_ASM_TAINTED (1<<7)
+ #define RPN_F_SPILL_ALL (1<<8)
+ #define RPN_F_NO_TYPECAST (1<<9)
+ I64 flags;
+};
+U0 RPNFree(CRPN *r) {
+ if(r->prev)
+ r->prev->next=r->next;
+ if(r->next)
+ r->next->prev=r->prev;
+ if(r->successors)
+ VectorFree(r->successors);
+ VectorFree(r->spills);
+ Free(r->jmp_table);
+ if(r->jmp_table_trampolines)
+ VectorFree(r->jmp_table_trampolines);
+ VectorFree(r->r_map);
+ VectorFree(r->unspills);
+ Free(r->flive_out);
+ Free(r->flive_in);
+ Free(r->live_out);
+ Free(r->live_in);
+ Free(r);
+}
+U8 *UniqLabelName() {
+ static I64 i;
+ return MStrPrint("__%x",++i);
+}
+class CMatrix;
+class JIT {
+ CRPN *cur_rpn_start;
+ I64 cur_tfreg;
+ I64 tireg_cnt,tfreg_cnt;
+ I64 vireg_cnt,vfreg_cnt;
+ I64 ireg_stk_depth,ireg_stk_start;
+ CMatrix *igraph,*fgraph;
+ U8 *buffer;
+ U8 *ip,*ret_label;
+ I64 buf_size,buf_cap,allocai_size;
+ //Shadows are for spilled items
+ I64 frame_offset,ireg_shadows,freg_shadows;
+ I64 fpu_stk_size,fpu_stk_offset;
+ CVector *tainted_caller_saved,*fpu_stk;
+ //We can skip out on liveness analysis on items before the RPNPushValue/RPNPopValue compute registers
+ //This is becuase items on the stack intefere with eachother if they are on the stack and hence dont need to be analyzised beyond the stack method
+ I64 live_icap;
+};
+CRPN *GetRPNEnterLabel(CRPN *item);
+U0 Push(JIT *jit,CRPN *op,U8 *op,CAsmValue *v);
+U0 __FMov(JIT *jit,CRPN *at,CAsmValue *dst,Bool pop=FALSE);
+CRPN *FirstRPN(CRPN *items) {
+ for(;items&&items->prev;items=items->prev);
+ return items;
+}
+U0 JIT_FREE(JIT *jit) {
+ CRPN *rpn,*next;
+ Free(jit->buffer);
+ Free(jit->ret_label);
+ VectorFree(jit->fpu_stk);
+ VectorFree(jit->tainted_caller_saved);
+ for(rpn=FirstRPN(jit->cur_rpn_start);rpn;rpn=next) {
+ next=rpn->next;
+ RPNFree(rpn);
+ }
+}
+Bool IsCallerSaved(CReg *reg) {
+ U8 *saved[]={
+ "RBP",
+ "RSI",
+ "RDI",
+ "R10",
+ "R11",
+ "R12",
+ "R13",
+ "R14",
+ "R15",
+ };
+ I64 idx;
+ for(idx=0;idx!=sizeof(saved)/sizeof(*saved);idx++)
+ if(Str2Reg(saved[idx])==reg)
+ return TRUE;
+ return FALSE;
+}
+/*
+ * Frame layout
+ * RETURN PTR
+ * RBP
+ * frame
+ * ...
+ * ireg_shadows
+ * ...
+ * freg_shadows
+ * ...
+ */
+U0 JIT_ExpandBufIfNeeded(JIT *jit) {
+ U8 *nbuf;
+ jit->buf_cap+=0xff,jit->buf_cap*=2;
+ nbuf=MAlloc(jit->buf_cap);
+ MemCpy(nbuf,jit->buffer,MSize(nbuf));
+ Free(jit->buffer),jit->buffer=nbuf;
+}
+JIT *jit_Init() {
+ JIT *ret=MAlloc(sizeof(JIT));
+ ret->tainted_caller_saved=VectorNew;
+ ret->ret_label=UniqLabelName;
+ ret->fpu_stk=VectorNew;
+ return ret;
+}
+CRPN *__jit_rpnNew(JIT *jit) {
+ CRPN *rpn=MAlloc(sizeof(CRPN));
+ rpn->successors=VectorNew;
+ rpn->r_map=VectorNew,rpn->in_r_map=VectorNew;
+ rpn->spills=VectorNew;
+ rpn->unspills=VectorNew;
+ if(!jit->cur_rpn_start) jit->cur_rpn_start=rpn;
+ else {
+ jit->cur_rpn_start->next=rpn;
+ rpn->prev=jit->cur_rpn_start;
+ jit->cur_rpn_start=rpn;
+ }
+ return rpn;
+}
+CRPN *jit_rpnNew(JIT *jit,I64 type) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ return rpn->type=RPN_CodeNew(type),rpn;
+}
+CRPN *jit_rpnNewU(JIT *jit,I64 type) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ rpn->type=RPN_CodeNew(type,,FALSE);
+ return rpn;
+}
+CRPN *jit_rpnInt(JIT *jit,I64 int) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ rpn->type=RPN_CodeNew(OP_LITERAL);
+ rpn->my_avalue.int=int;
+ rpn->my_avalue.type=AV_INT;
+ return rpn;
+}
+CRPN *jit_rpnFlt(JIT *jit,F64 flt) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ rpn->type=RPN_CodeNew(OP_LITERAL,TRUE);
+ rpn->my_avalue.flt=flt;
+ rpn->my_avalue.type=AV_FLT;
+ return rpn;
+}
+CRPN *jit_rpnNewF(JIT *jit,I64 type) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ rpn->type=RPN_CodeNew(type,TRUE);
+ return rpn;
+}
+CRPN *jit_rpnBodyStart(JIT *jit) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ rpn->type=RPN_CodeNew(OP_BODY);
+ return rpn;
+}
+CRPN *jit_rpnIf(JIT *jit) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ rpn->type=RPN_CodeNew(OP_IF);
+ return rpn;
+}
+CRPN *jit_rpnNewVreg(JIT *jit,I64 num) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ rpn->type=RPN_CodeNew(OP_VARIABLE);
+ rpn->my_avalue.type=AV_VIREG;
+ rpn->my_avalue.vreg=num;
+ if(jit->vireg_cnt<num)
+ jit->vireg_cnt=num;
+ return rpn;
+}
+CRPN *jit_rpnNewVFreg(JIT *jit,I64 num) {
+ CRPN *rpn=__jit_rpnNew(jit);
+ rpn->type=RPN_CodeNew(OP_VARIABLE,TRUE);
+ rpn->my_avalue.type=AV_VFREG;
+ rpn->my_avalue.vreg=num;
+ if(jit->vfreg_cnt<num)
+ jit->vfreg_cnt=num;
+ return rpn;
+}
+class CMatrix {
+ U8 **items;
+ I64 cnt;
+};
+CMatrix *NewMatrixNxN(I64 n) {
+ CMatrix *ret=MAlloc(sizeof(CMatrix));
+ I64 iter;
+ ret->items=MAlloc(sizeof(U8*)*n);
+ for(iter=0;iter!=n;iter++)
+ ret->items[iter]=MAlloc(n);
+ ret->cnt=n;
+ return ret;
+}
+U0 Interfere(CMatrix *mat,I64 a,I64 b) {
+ mat->items[a][b]=TRUE;
+ mat->items[b][a]=TRUE;
+}
+Bool IsRPNUnop(CRPN *node) {
+ switch(node->type.code) {
+ case OP_POST_INC:
+ case OP_POST_DEC:
+ case OP_PRE_INC:
+ case OP_PRE_DEC:
+ case OP_GETARG:
+ case OP_NEG:
+ case OP_POS:
+ case OP_NOT:
+ case OP_DEREF:
+ case OP_TYPECAST_BIT4BIT:
+ return TRUE;
+ }
+ return FALSE;
+
+}
+Bool IsRPNBinop(CRPN *node) {
+ switch(node->type.code) {
+ case OP_ADD:
+ case OP_SUB:
+ case OP_MUL:
+ case OP_DIV:
+ case OP_MOD:
+
+ case OP_SHL:
+ case OP_SHR:
+ case OP_POW:
+
+ case OP_AND:
+ case OP_OR:
+ case OP_XOR:
+ case OP_GT:
+ case OP_LT:
+ case OP_GE:
+ case OP_LE:
+
+ case OP_NE:
+ case OP_EQ:
+
+ case OP_LXOR:
+ case OP_LOR:
+ case OP_LAND:
+ case OP_ASSIGN:
+ case OP_ASSIGN_ADD:
+ case OP_ASSIGN_SUB:
+ case OP_ASSIGN_MUL:
+ case OP_ASSIGN_DIV:
+ case OP_ASSIGN_MOD:
+ case OP_ASSIGN_SHL:
+ case OP_ASSIGN_SHR:
+ case OP_ASSIGN_AND:
+ case OP_ASSIGN_XOR:
+ case OP_ASSIGN_OR:
+ case OP_COMMA:
+ return TRUE;
+ }
+ return FALSE;
+}
+CRPN *ComputeRPNSuccessor(CRPN *node) {
+ if(!node) return NULL;
+ if(node->__end) return node->__end;
+ CRPN *onode=node;
+ I64 idx;
+ if(node->type.code==OP_JMP_TABLE) {
+ idx=node->type.body_length;
+ return ComputeRPNSuccessor(node->next);
+ } else if(node.type.code==OP_JMP) {
+ return node->next;
+ } else if(node->type.code==OP_CALL) {
+ idx=node->type.body_length+1; //+1 for func call
+ node=node->next;
+ while(--idx>=0) node=ComputeRPNSuccessor(node);
+ return node;
+ } else if(IsRPNBinop(node)) {
+ node=ComputeRPNSuccessor(node->next);
+ return ComputeRPNSuccessor(node);
+ } else if(IsRPNUnop(node)||onode->type.code==OP_RETURN) {
+ return ComputeRPNSuccessor(node->next);
+ } else if(node->type.code==OP_LITERAL||node->type.code==OP_VARIABLE)
+ return node->next;
+ else if(node->type.code==OP_IF) {
+ //Condition
+ node=ComputeRPNSuccessor(node->next);
+ //body
+ node=ComputeRPNSuccessor(node);
+ //else
+ return ComputeRPNSuccessor(node);
+ } else if(node->type.code==OP_BODY) {
+ idx=node->type.body_length;
+ node=node->next;
+ while(--idx>=0) node=ComputeRPNSuccessor(node);
+ return node;
+ } else
+ return onode->next;
+}
+Bool UsesIntArg(CRPN *rpn) {
+ if(rpn->type.code==OP_CALL||rpn->type.code==OP_RELOCATION) return TRUE;
+ if(IsRPNBinop(rpn)) {
+ switch(ComputeRPNSuccessor(rpn->next)->my_avalue.type) {
+ case AV_IVINDIR:
+ case AV_VIREG:
+ return TRUE;
+ }
+ check_nxt:
+ switch(rpn->next->my_avalue.type) {
+ case AV_IVINDIR:
+ case AV_VIREG:
+ return TRUE;
+ }
+ } else if(IsRPNUnop(rpn)) {
+ goto check_nxt;
+ } else if(rpn->type.code==OP_IF||rpn->type.code==OP_RETURN||rpn->type.code==OP_JMP_TABLE)
+ goto check_nxt;
+ return FALSE;
+}
+U0 RPNPushValue(JIT *jit,CRPN *onode) {
+ I64 iter;
+ if(onode->type.code==OP_INPLACE_PUSH)
+ onode->live_tistack_depth=jit->ireg_stk_depth;
+ if(IsRPNBinop(onode)||IsRPNUnop(onode)||onode->type.code==OP_CALL||onode->type.code==OP_RELOCATION||onode->type.code==OP_REF_DATA) {
+ if(onode->type.is_flt)
+ jit->tfreg_cnt=MaxI64(jit->tfreg_cnt,++jit->cur_tfreg);
+ else goto i;
+ if(UsesIntArg(onode)) {
+ i:
+ onode->live_tistack_depth=++jit->ireg_stk_depth;
+ }
+ //Dont assign register to big/wierd sized deref
+ if(onode->type.code==OP_DEREF&&!onode->type.is_flt) {
+ switch(onode->operands[2](I64)) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ break;
+ default:
+ return;
+ }
+ }
+ if(onode->flags&RPN_F_DONT_TOUCH) return;
+ if(onode->my_avalue.type==AV_PUSH) return;
+ //Trust me,you want to "pretend" that the virtual register stack was changed even if we dont change the physical register
+ if(onode->type.is_flt) {
+ onode->my_avalue.type=AV_VFREG;
+ onode->my_avalue.vreg=jit->tfreg_cnt-1;
+ } else {
+ jit->tireg_cnt=MaxI64(jit->tireg_cnt,jit->ireg_stk_start+jit->ireg_stk_depth);
+ onode->my_avalue.type=AV_VIREG;
+ onode->my_avalue.vreg=jit->ireg_stk_start+jit->ireg_stk_depth-1;
+ }
+ }
+}
+U0 RPNPopValue(JIT *jit,CRPN *onode) {
+ if(IsRPNBinop(onode)||IsRPNUnop(onode)||onode->type.code==OP_CALL||onode->type.code==OP_RELOCATION||onode->type.code==OP_REF_DATA) {
+ if(onode->type.is_flt) --jit->cur_tfreg;
+ else {
+ i:
+ --jit->ireg_stk_depth;
+ return;
+ }
+ if(UsesIntArg(onode)) goto i;
+ }
+}
+Bool IsRPNAssign(CRPN *r) {
+ switch(r->type.code) {
+ case OP_ASSIGN_ADD:
+ case OP_ASSIGN_SUB:
+ case OP_ASSIGN_MUL:
+ case OP_ASSIGN_DIV:
+ case OP_ASSIGN_MOD:
+ case OP_ASSIGN_SHL:
+ case OP_ASSIGN_SHR:
+ case OP_ASSIGN_AND:
+ case OP_ASSIGN_XOR:
+ case OP_ASSIGN_OR:
+ case OP_ASSIGN:
+ case OP_POST_INC:
+ case OP_POST_DEC:
+ case OP_PRE_INC:
+ case OP_PRE_DEC:
+ return TRUE;
+ }
+ return FALSE;
+}
+CRPN *RPN_AssignOperandValues(JIT *jit,CRPN *node,CAsmValue **write_to=NULL,CRPN *consumer=NULL) {
+ if(!node) return NULL;
+ CRPN *onode=node,*prev,*buffer;
+ I64 iter;
+ onode->consumer=consumer;
+ if(write_to&&!*write_to) *write_to=&node->my_avalue;
+ else if(write_to&&*write_to) goto en;
+ if(IsRPNBinop(onode)) {
+ node=RPN_AssignOperandValues(jit,node->next,&onode->operands[0],onode);
+ RPNPushValue(jit,onode->next);
+ node=RPN_AssignOperandValues(jit,node,&onode->operands[1],onode);
+ RPNPushValue(jit,ComputeRPNSuccessor(onode->next));
+ RPNPopValue(jit,onode->next);
+ RPNPopValue(jit,ComputeRPNSuccessor(onode->next));
+ } else if(onode->type.code==OP_LITERAL) {
+ //Do nothing
+ } else if(IsRPNUnop(onode)||onode->type.code==OP_RETURN||onode->type.code==OP_JMP_TABLE) {
+ node=RPN_AssignOperandValues(jit,node->next,&onode->operands[0],onode);
+ RPNPushValue(jit,onode->next);
+ RPNPopValue(jit,onode->next);
+ // __
+ // | |
+ //\/(*__*)\/
+ // \( \/ )/ DONT MERGE ON FUNCTION PUSHES,we dont assign dude,we push
+ // (______)
+ // /\ /\
+ if(onode->consumer&&onode->consumer->type.code!=OP_CALL)
+ if(IsRPNAssign(onode->prev)||onode->consumer->type.is_signed==onode->type.is_signed)
+ if(onode->type.code==OP_DEREF&&!(RPN_F_DONT_TOUCH&onode->flags)) {
+ if(IsRPNAssign(onode->prev))
+ onode->prev->type.is_signed=onode->type.is_signed;
+ // ___
+ // ( )
+ // / * *| If we have compound OP_DEREFs be sure to store rightmost reref into a register to we can merge that register into a AV_IINDIR/AV_FINDIR
+ // <-- |>
+ // \ |>
+ // \ __|
+ // | |
+ // __| |___
+ // crowdude
+ dloop:
+ if(onode->prev->type.code!=OP_DEREF) {
+ if(onode->next->my_avalue.type==AV_VIREG) {
+ if(onode->type.is_flt)
+ onode->my_avalue.type=AV_FVINDIR;
+ else
+ onode->my_avalue.type=AV_IVINDIR;
+ //We "merged" the source into the destination,
+ onode->flags|=RPN_F_IMPLICIT_OPERATION|RPN_F_MERGED_ASSIGN|RPN_F_DONT_TOUCH;
+ onode->my_avalue.offset=onode->operands[1](I64);
+ onode->my_avalue.size=onode->operands[2](I64);
+ onode->my_avalue.vreg=onode->next->my_avalue.vreg;
+ goto en;
+ } else if(onode->next->my_avalue.type==AV_IREG) {
+ if(onode->type.is_flt)
+ onode->my_avalue.type=AV_FINDIR;
+ else
+ onode->my_avalue.type=AV_IINDIR;
+ //We "merged" the source into the destination,
+ onode->flags|=RPN_F_IMPLICIT_OPERATION|RPN_F_MERGED_ASSIGN|RPN_F_DONT_TOUCH;
+ onode->my_avalue.offset=onode->operands[1](I64);
+ onode->my_avalue.size=onode->operands[2](I64);
+ onode->my_avalue.reg=onode->next->my_avalue.reg;
+ goto en;
+ }
+ }
+ }
+ } else if(node->type.code==OP_IF) {
+ node=RPN_AssignOperandValues(jit,node->next,&onode->operands[0],onode);
+ RPNPushValue(jit,onode->next);
+ RPNPopValue(jit,onode->next);
+ prev=node;
+ node=RPN_AssignOperandValues(jit,node);
+ RPNPushValue(jit,prev);
+ RPNPopValue(jit,prev);
+ prev=node;
+ node=RPN_AssignOperandValues(jit,node);
+ RPNPushValue(jit,prev);
+ RPNPopValue(jit,prev);
+ } else if(node->type.code==OP_BODY) {
+ iter=node->type.body_length;
+ node=node->next;
+ while(--iter>=0) {
+ prev=node;
+ node=RPN_AssignOperandValues(jit,node);
+ RPNPushValue(jit,prev);
+ RPNPopValue(jit,prev);
+ }
+ } else if(onode->type.code==OP_CALL) {
+ iter=onode->type.body_length+1;
+ node=onode->next;
+ while(--iter>=0) {
+ prev=node;
+ node=RPN_AssignOperandValues(jit,node,,onode);
+ RPNPushValue(jit,prev);
+ RPNPopValue(jit,prev);
+ }
+ }
+ en:
+ return ComputeRPNSuccessor(onode);
+}
+U0 IsRPNData(CRPN *rpn) {
+ switch(rpn->type.code) {
+ case OP_DU8...OP_DU64:
+ return TRUE;
+ }
+ return FALSE;
+}
+//Heres the deal,
+//from contains the items from the previous operation on input,
+//and on exit it contains the outgoing items. This simplifies things alot
+U0 FlattenRPNTo(CRPN *rpn,CVector *to,CVector *from=NULL) {
+ I64 iter,iter2;
+ CRPN *cur,*next1,*next2,*old;
+ CVector *old_vec,*ul;
+ if(!from) {
+ old_vec=VectorNew;
+ FlattenRPNTo(rpn,to,old_vec);
+ VectorFree(old_vec);
+ return;
+ }
+ if(rpn->type.code==OP_JMP_TABLE) {
+ FlattenRPNTo(rpn->next,to,from);
+ VectorPush(to,rpn);
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn(I64));
+ }
+ }
+ for(iter2=0;iter2!=rpn->type.body_length;iter2++) {
+ VectorAdd(rpn->successors,GetRPNEnterLabel(rpn->jmp_table[iter2])(I64));
+ }
+ VectorPush(from,rpn);
+ return;
+ } else if(rpn->type.code==OP_INPLACE_PUSH||rpn->type.code==OP_RELOCATION||rpn->type.code==OP_REF_DATA) {
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn(I64));
+ }
+ }
+ VectorPush(to,rpn);
+ VectorPush(from,rpn);
+ } else if(IsRPNData(rpn)) {
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn(I64));
+ }
+ }
+ VectorPush(to,rpn);
+ VectorPush(from,rpn);
+ }else if(rpn->type.code==OP_REF_DATA) {
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn(I64));
+ }
+ }
+ VectorPush(to,rpn);
+ VectorPush(from,rpn);
+ } else if(rpn->type.code==OP_JMP) {
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn(I64));
+ }
+ }
+ next1=rpn->operands[0](CRPN*);
+ VectorAdd(rpn->successors,next1);
+ VectorPush(to,rpn);
+ VectorPush(from,rpn);
+ } else if(rpn->type.code==OP_CALL) {
+ for(cur=rpn->next,iter=0;iter!=rpn->type.body_length+1;iter++) {
+ FlattenRPNTo(cur,to,from);
+
+ cur=ComputeRPNSuccessor(cur);
+ }
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn);
+ }
+ }
+ VectorPush(to,rpn);
+ VectorPush(from,rpn);
+ } else if(IsRPNBinop(rpn)) {
+ FlattenRPNTo(rpn->next,to,from);
+ FlattenRPNTo(ComputeRPNSuccessor(rpn->next),to,from);
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn);
+ }
+ }
+ VectorPush(to,rpn);
+ VectorPush(from,rpn);
+ } else if(IsRPNUnop(rpn)) {
+ FlattenRPNTo(rpn->next,to,from);
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn);
+ }
+ }
+ VectorPush(from,rpn);
+ VectorPush(to,rpn);
+ } else if(rpn.type.code==OP_RETURN) {
+ FlattenRPNTo(rpn->next,to,from);
+ VectorPush(to,rpn);
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn);
+ }
+ }
+ VectorPush(from,rpn);
+ } else if(rpn->type.code==OP_BODY) {
+ VectorPush(to,rpn);
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn);
+ }
+ }
+ VectorPush(from,rpn);
+ cur=rpn->next;
+ old=rpn;
+ for(iter=0;iter!=rpn->type.body_length;iter++) {
+ FlattenRPNTo(cur,to,from);
+ if(cur->type.code==OP_RETURN||cur->type.code==OP_JMP)
+ from->size=0;
+ cur=ComputeRPNSuccessor(cur);
+ }
+ } else if(rpn->type.code==OP_IF) {
+ //Condtion
+ FlattenRPNTo(rpn->next,to,from);
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(VectorPop(from)(CRPN*)->successors,rpn);
+ }
+ }
+ VectorPush(to,rpn);
+ VectorPush(from,rpn);
+ //body and else
+ FlattenRPNTo(next1=ComputeRPNSuccessor(rpn->next),to,from);
+ //Keep the successors on the stack from later
+ old_vec=VectorNew;
+ if(from) {
+ iter2=from->size;
+ while(--iter2>=0) {
+ VectorAdd(old_vec,VectorPop(from));
+ }
+ }
+ VectorPush(from,rpn);
+ FlattenRPNTo(next2=ComputeRPNSuccessor(next1),to,from);
+ iter2=old_vec->size;
+ while(--iter2>=0) {
+ VectorAdd(from,VectorPop(old_vec));
+ }
+ VectorFree(old_vec);
+ } else
+ VectorPush(to,rpn);
+}
+U0 jit_rpnBodyEnd(JIT *jit,CRPN *strt) {
+ CRPN *rpn=strt;
+ I64 len=0;
+ for(strt=strt->next;strt;len++) {
+ if(!strt) break;
+ strt=ComputeRPNSuccessor(strt);
+ }
+ rpn->type.body_length=len;
+}
+U0 PrintLiveness(I64 *live) {
+ I64 max=MSize(live)*8;
+ while(--max>=0) {
+ if(Bt(live,max))
+ "%d,",max;
+ }
+}
+U0 DumpRPN(CRPN *rpn,I64 flags=0,I64 indent=0) {
+ if(!rpn) return;
+ I64 iter;
+ CRPN *cur;
+ if(indent) "%*c",4*indent,' ';
+ "[%p] ",rpn;
+ switch(rpn->type.code) {
+ start:
+ if(rpn->flags&RPN_F_IMPLICIT_OPERATION)
+ "IMPLCT:";
+ switch(rpn->my_avalue.type) {
+ case AV_VIREG:
+ "V(%d),",rpn->my_avalue.vreg;
+ break;
+ case AV_IVINDIR:
+ "IV(%d),",rpn->my_avalue.vreg;
+ break;
+ case AV_INT:
+ "INT(%p),",rpn->my_avalue.int;
+ break;
+ case AV_FREG:
+ "FR";
+ }
+ case OP_COMMA:
+ ",";
+ break;
+ case OP_NE:
+ "!=";
+ break;
+ case OP_EQ:
+ "==";
+ break;
+ case OP_TYPECAST_BIT4BIT:
+ "TC";
+ break;
+ case OP_RELOCATION:
+ "RELOC";
+ break;
+ case OP_INPLACE_PUSH:
+ "PUSH";
+ break;
+ case OP_JMP:
+ "JMP";
+ break;
+ case OP_RETURN:
+ "RETURN";
+ break;
+ case OP_GETARG:
+ "GETARG";
+ break;
+
+ case OP_NOT:
+ "~";
+ break;
+
+ case OP_ADD:
+ "+";
+ break;
+ case OP_SUB:
+ "-";
+ break;
+
+ case OP_MUL:
+ "*";
+ break;
+ case OP_DIV:
+ "/";
+ break;
+ case OP_MOD:
+ "%%";
+ break;
+ case OP_SHL:
+ "<<";
+ break;
+ case OP_SHR:
+ ">>";
+ break;
+ case OP_POW:
+ "`";
+ break;
+ case OP_AND:
+ "&";
+ break;
+ case OP_OR:
+ "|";
+ break;
+ case OP_XOR:
+ "^";
+ break;
+ case OP_ASSIGN:
+ "=";
+ break;
+ case OP_POS:
+ "+(unary)";
+ break;
+ case OP_NEG:
+ "-(unary)";
+ break;
+ case OP_GT:
+ ">";
+ break;
+ case OP_LT:
+ "<";
+ break;
+ case OP_GE:
+ ">=";
+ break;
+ case OP_LE:
+ "<=";
+ break;
+ case OP_LXOR:
+ "^^";
+ break;
+ case OP_LOR:
+ "||";
+ break;
+ case OP_LAND:
+ "&&";
+ break;
+ case OP_POST_INC:
+ "++";
+ break;
+ case OP_POST_DEC:
+ "--";
+ break;
+ case OP_PRE_INC:
+ "++";
+ break;
+ case OP_PRE_DEC:
+ "--";
+ break;
+ case OP_VARIABLE:
+ "VAR(%d)",rpn->my_avalue.vreg;
+ break;
+ case OP_LITERAL:
+ if(rpn->type.is_flt)
+ "%n",rpn->my_avalue.flt;
+ else
+ "%d",rpn->my_avalue.int;
+ break;
+ case OP_DEREF:
+ "DEREF(%d,%d)",rpn->operands[1],rpn->operands[2];
+ break;
+ case OP_IF:
+ "IF";
+
+ break;
+ case OP_BODY:
+ "BODY";
+ break;
+ case OP_CALL:
+ "CALL";
+ break;
+ case OP_ASSIGN_ADD:
+ "+=";
+ break;
+ case OP_ASSIGN_SUB:
+ "-=";
+ break;
+ case OP_ASSIGN_MUL:
+ "*=";
+ break;
+ case OP_ASSIGN_DIV:
+ "/=";
+ break;
+ case OP_ASSIGN_MOD:
+ "%=";
+ break;
+ case OP_ASSIGN_SHL:
+ "<<=";
+ break;
+ case OP_ASSIGN_SHR:
+ ">>=";
+ break;
+ case OP_ASSIGN_AND:
+ "&=";
+ break;
+ case OP_ASSIGN_XOR:
+ "^=";
+ break;
+ case OP_ASSIGN_OR:
+ "|=";
+ break;
+ case OP_JMP_TABLE:
+ "JTABLE";
+ end:
+ " <";
+ if(rpn->successors)
+ for(iter=0;iter!=rpn->successors->size;iter++) {
+ "%p,",rpn->successors->data[iter];
+ }
+ ">";
+ "(In:";
+ if(rpn->live_in)
+ PrintLiveness(rpn->live_in);
+ " Out:f";
+ if(rpn->live_out)
+ PrintLiveness(rpn->live_out);
+ ")";
+ "(Fin:";
+ if(rpn->flive_in)
+ PrintLiveness(rpn->flive_in);
+ " Fout:";
+ if(rpn->flive_out)
+ PrintLiveness(rpn->flive_out);
+ ");"
+ "IRMAP[";
+ if(rpn->in_r_map)
+ for(iter=0;iter!=rpn->in_r_map->size;iter+=2)
+ "%d,%s,",rpn->r_map->data[iter],IRegCodeToReg(rpn->in_r_map->data[iter+1])->str;
+ "]";
+ "RMAP[";
+ for(iter=0;iter!=rpn->r_map->size;iter+=2)
+ "%d,%s,",rpn->r_map->data[iter],IRegCodeToReg(rpn->r_map->data[iter+1])->str;
+ "]\n";
+ if(rpn->type.code==OP_JMP_TABLE) {
+ DumpRPN(rpn->next,flags,indent);
+ } else if(IsRPNBinop(rpn)) {
+ DumpRPN(rpn->next,flags,indent);
+ DumpRPN(ComputeRPNSuccessor(rpn->next),flags,indent);
+ } else if(IsRPNUnop(rpn)||rpn->type.code==OP_RETURN) {
+ DumpRPN(rpn->next,flags,indent);
+ } else if(rpn->type.code==OP_IF) {
+ DumpRPN(rpn->next,flags,indent);
+ DumpRPN(cur=ComputeRPNSuccessor(rpn->next),flags,indent+1);
+ "ELSE\n";
+ DumpRPN(ComputeRPNSuccessor(cur),flags,indent+1);
+ } else if(rpn->type.code==OP_BODY) {
+ cur=rpn->next;
+ for(iter=0;iter!=rpn->type.body_length;iter++) {
+ DumpRPN(cur,flags,indent+1);
+ cur=ComputeRPNSuccessor(cur);
+ }
+ } else if(rpn->type.code==OP_CALL) {
+ cur=rpn->next;
+ for(iter=0;iter!=rpn->type.body_length;iter++) {
+ DumpRPN(cur,flags,indent+1);
+ cur=ComputeRPNSuccessor(cur);
+ }
+ "FUNC:";
+ DumpRPN(cur,flags,indent);
+ } else if(rpn->type.code==OP_JMP) {
+ }
+ }
+}
+U0 InAdd(I64 cap,I64 *set,CAsmValue *value,Bool fp) {
+ switch(value.type) {
+ case AV_FVINDIR:
+ case AV_IVINDIR:
+ case AV_VIREG:
+ if(value->vreg<0) {
+ "%d\n",value->vreg;
+ throw('Toad');
+ }
+ if(value->vreg<=cap)
+ if(!fp) Bts(set,value->vreg);
+ break;
+ case AV_VFREG:
+ if(value->vreg<=cap)
+ if(fp) Bts(set,value->vreg);
+ break;
+ }
+}
+CRPN *GetCallFunction(CRPN *call) {
+ I64 iter=call->type.body_length;
+ call=call->next;
+ while(--iter>=0)
+ call=ComputeRPNSuccessor(call);
+ return call;
+}
+U0 AddLiveIncoming(I64 cap,I64 *set,CRPN *node,Bool fp) {
+ CAsmValue *v;
+ I64 idx=0,iter;
+ CRPN *cur;
+ if(node->type.code==OP_INPLACE_PUSH) {
+ InAdd(cap,set,&node->my_avalue,fp);
+ } else if(IsRPNBinop(node)) {
+ InAdd(cap,set,node->operands[1],fp);
+ InAdd(cap,set,node->operands[0],fp);
+ } else if(IsRPNUnop(node)) {
+ InAdd(cap,set,node->operands[0],fp);
+ } else if(node->type.code==OP_CALL) {
+ //Function
+ // Arguments are pushed to the stack so dont look for them for liveness
+ InAdd(cap,set,&GetCallFunction(node)->my_avalue,fp);
+ } else if(node->type.code==OP_RETURN||node->type.code==OP_JMP_TABLE) {
+ InAdd(cap,set,node->operands[0],fp);
+ } else if(node->type.code==OP_IF) {
+ InAdd(cap,set,&node->next->my_avalue,fp);
+ }
+}
+// __________________________________
+// / We Dont remove /
+// __________ / indirect values from the /
+// / O O \ _/ set as we dont "write" to them /
+// { \____/ } <__________________________________/
+// \__________/
+// ____/// \\\____
+// ___/// \\\___
+// ___/// \\\___
+//
+// Octopus
+U0 RemFromSet(I64 cap,I64 *set,CRPN *value,Bool fp) {
+ switch(value->my_avalue.type) {
+ //See the octopus
+ case AV_VIREG:
+ if(value->my_avalue->vreg<=cap)
+ if(!fp) Btr(set,value->my_avalue->vreg);
+ break;
+ case AV_VFREG:
+ if(value->my_avalue->vreg<=cap)
+ if(fp) Btr(set,value->my_avalue->vreg);
+ break;
+ }
+}
+Bool AnalyzeOp(JIT *jit,CRPN *op,I64 max_regs,Bool fp) {
+ I64 iter,iter2,qwords,cap=jit->live_icap;
+ CRPN *prepare,*cur;
+ Bool changed=FALSE;
+ //Optimize by checking only for items with shadow set
+ if(op->flags&RPN_F_LIVE_SHADOW) {
+ goto possible_change;
+ }
+ op->flags&=~RPN_F_LIVE_SHADOW;
+ if(IsRPNUnop(op)||op->type.code==OP_CALL||op->type.code==OP_IF||op->type.code==OP_RETURN||op->type.code==OP_JMP_TABLE)
+ if(op->next->flags&RPN_F_LIVE_CHANGED)
+ goto possible_change;
+ if(IsRPNBinop(op)) {
+ if(op->next->flags&RPN_F_LIVE_CHANGED)
+ goto possible_change;
+ if(ComputeRPNSuccessor(op->next)->flags&RPN_F_LIVE_CHANGED)
+ goto possible_change;
+ }
+ if(op->type.code==OP_CALL) {
+ if(GetCallFunction(op)->flags&RPN_F_LIVE_CHANGED)
+ goto possible_change;
+ }
+ for(iter=0;iter!=op->successors->size;iter++) {
+ cur=op->successors->data[iter];
+ if(cur->flags&RPN_F_LIVE_CHANGED)
+ goto possible_change;
+ }
+ return FALSE;
+ possible_change:
+ I64 *live_in=MAlloc(qwords=max_regs/8*8+8);
+ qwords/=8;
+ I64 *live_out=MAlloc(max_regs/8*8+8);
+ if(!fp)
+ MemCpy(live_in,op->live_out,MSize(live_in));
+ else
+ MemCpy(live_in,op->flive_out,MSize(live_in));
+ if(op->type.code==OP_RETURN||op->type.code==OP_JMP_TABLE) {
+ AddLiveIncoming(cap,live_in,op,fp);
+ } else if(op->type.code==OP_INPLACE_PUSH) {
+ AddLiveIncoming(cap,live_in,op,fp);
+ } else if(op->type.code==OP_CALL) {
+ RemFromSet(cap,live_in,op,fp);
+ AddLiveIncoming(cap,live_in,op,fp);
+ } else if(IsRPNBinop(op)&&!IsRPNAssign(op)) {
+ RemFromSet(cap,live_in,op,fp);
+ AddLiveIncoming(cap,live_in,op,fp);
+ } else if(IsRPNBinop(op)&&IsRPNAssign(op)) {
+ //2nd is gen
+ RemFromSet(cap,live_in,op,fp);
+ //kill
+ RemFromSet(cap,live_in,op->next,fp);
+ AddLiveIncoming(cap,live_in,op,fp);
+ } else if(IsRPNUnop(op)) {
+ RemFromSet(cap,live_in,op,fp);
+ AddLiveIncoming(cap,live_in,op,fp);
+ } else if(op->type.code==OP_IF) {
+ AddLiveIncoming(cap,live_in,op,fp);
+ }
+ skip:
+ //"C:%d\n",op->type.code;
+ for(iter=0;iter!=op->successors->size;iter++) {
+ iter2=qwords;
+ while(--iter2>=0) {
+ if(!fp)
+ live_out[iter2]|=op->successors->data[iter](CRPN*)->live_in[iter2];
+ else
+ live_out[iter2]|=op->successors->data[iter](CRPN*)->flive_in[iter2];
+ }
+ }
+ iter2=qwords;
+ while(--iter2>=0) {
+ if(!fp) {
+ changed|=op->live_in[iter2]!=live_in[iter2];
+ changed|=op->live_out[iter2]!=live_out[iter2];
+ } else {
+ changed|=op->flive_in[iter2]!=live_in[iter2];
+ changed|=op->flive_out[iter2]!=live_out[iter2];
+ }
+ if(changed) {
+ break;
+ }
+ }
+ if(!fp) {
+ Free(op->live_in),op->live_in=live_in;
+ Free(op->live_out),op->live_out=live_out;
+ } else {
+ Free(op->flive_in),op->flive_in=live_in;
+ Free(op->flive_out),op->flive_out=live_out;
+ }
+ if(changed) op->flags|=RPN_F_LIVE_SHADOW|RPN_F_LIVE_CHANGED;
+ else op->flags&=~(RPN_F_LIVE_SHADOW|RPN_F_LIVE_CHANGED);
+ return changed;
+}
+U0 ComputeRPNLiveness(JIT *jit,CRPN *first,Bool fp=FALSE) {
+ CVector *flat=VectorNew;
+ I64 iter,max_regs,iter2;
+ CRPN *rpn;
+ Bool changed;
+ FlattenRPNTo(first,flat); //This assigns the live_[ti]fstack_depth feild
+ for(iter=flat->size-1;iter>=0;iter--) {
+ rpn=flat->data[iter];
+ if(!fp)
+ max_regs=MaxI64(jit->vireg_cnt+1+rpn->live_tistack_depth,max_regs);
+ else
+ max_regs=MaxI64(jit->vfreg_cnt+1+rpn->live_tfstack_depth,max_regs);
+ }
+ for(iter=flat->size-1;iter>=0;iter--) {
+ rpn=flat->data[iter](CRPN*);
+ if(!fp) {
+ flat->data[iter](CRPN*)->live_out=MAlloc(max_regs/8*8 + 8);
+ flat->data[iter](CRPN*)->live_in=MAlloc(max_regs/8*8 + 8);
+ } else {
+ flat->data[iter](CRPN*)->flive_out=MAlloc(max_regs/8*8 + 8);
+ flat->data[iter](CRPN*)->flive_in=MAlloc(max_regs/8*8 + 8);
+ }
+ rpn->flags|=RPN_F_LIVE_SHADOW;
+ }
+ loop:
+ changed=FALSE;
+ for(iter=flat->size-1;iter>=0;iter--) {
+ changed|=AnalyzeOp(jit,flat->data[iter],max_regs,fp);
+ }
+ if(changed) goto loop;
+ for(iter=0;iter!=flat->size;iter++) {
+ rpn=flat->data[iter];
+ for(iter2=0;iter2!=rpn->live_tistack_depth;iter2++)
+ BEqu(rpn->live_out,iter2+jit->ireg_stk_start,TRUE);
+ if(IsRPNBinop(rpn)) {
+ for(iter2=0;iter2<rpn->live_tistack_depth+1;iter2++)
+ BEqu(rpn->live_in,iter2+jit->ireg_stk_start,TRUE);
+ } else {
+ for(iter2=0;iter2<rpn->live_tistack_depth;iter2++)
+ BEqu(rpn->live_in,iter2+jit->ireg_stk_start,TRUE);
+ }
+ }
+ VectorFree(flat);
+}
+U0 JIT_AppendAsmText(JIT *jit,U8 *buf,I64 len) {
+ U8 *str=buf,*old_buf;
+ if(jit->buf_cap<=jit->buf_size+len+1) {
+ jit->buf_cap+=len;
+ jit->buf_cap*=2;
+ old_buf=jit->buffer;
+ jit->buffer=MAlloc(jit->buf_cap+1);
+ MemCpy(jit->buffer,old_buf,jit->buf_size);
+ Free(old_buf);
+ }
+ MemCpy(jit->buffer+jit->buf_size,str,len);
+ jit->buf_size+=len;
+}
+
+
+I64 RMapGetPhysicalReg(CVector *map,I64 virt) {
+ I64 idx=0;
+ for(;idx<map->size;idx+=2)
+ if(map->data[idx]==virt)
+ return map->data[idx+1];
+ return -1;
+}
+I64 RMapGetVirtualReg(CVector *map,I64 physical) {
+ I64 idx=0;
+ for(;idx<map->size;idx+=2)
+ if(map->data[idx+1]==physical)
+ return map->data[idx];
+ return -1;
+}
+Bool RMapHasVirt(CVector *map,I64 virt) {
+ return -1!=RMapGetPhysicalReg(map,virt);
+}
+CReg *IRegCodeToReg16(I64 c) {
+ switch(c) {
+ case 0: return Str2Reg("AX");
+ case 1: return Str2Reg("CX");
+ case 2: return Str2Reg("DX");
+ case 3: return Str2Reg("BX");
+ case 4: return Str2Reg("SP");
+ case 5: return Str2Reg("BP");
+ case 6: return Str2Reg("SI");
+ case 7: return Str2Reg("DI");
+ case 8: return Str2Reg("R8u16");
+ case 9: return Str2Reg("R9u16");
+ case 10: return Str2Reg("R10u16");
+ case 11: return Str2Reg("R11u16");
+ case 12: return Str2Reg("R12u16");
+ case 13: return Str2Reg("R13u16");
+ case 14: return Str2Reg("R14u16");
+ case 15: return Str2Reg("R15u16");
+ }
+}
+CReg *IRegCodeToReg32(I64 c) {
+ switch(c) {
+ case 0: return Str2Reg("EAX");
+ case 1: return Str2Reg("ECX");
+ case 2: return Str2Reg("EDX");
+ case 3: return Str2Reg("EBX");
+ case 4: return Str2Reg("ESP");
+ case 5: return Str2Reg("EBP");
+ case 6: return Str2Reg("ESI");
+ case 7: return Str2Reg("EDI");
+ case 8: return Str2Reg("R8u32");
+ case 9: return Str2Reg("R9u32");
+ case 10: return Str2Reg("R10u32");
+ case 11: return Str2Reg("R11u32");
+ case 12: return Str2Reg("R12u32");
+ case 13: return Str2Reg("R13u32");
+ case 14: return Str2Reg("R14u32");
+ case 15: return Str2Reg("R15u32");
+ }
+}
+#define BASEREG_CODE 5
+CReg *FRegCodeToReg(I64 c) {
+ switch(c) {
+ case 0: return Str2Reg("ST0");
+ case 1: return Str2Reg("ST1");
+ case 2: return Str2Reg("ST2");
+ case 3: return Str2Reg("ST3");
+ case 4: return Str2Reg("ST4");
+ case 5: return Str2Reg("ST5");
+ case 6: return Str2Reg("ST6");
+ case 7: return Str2Reg("ST7");
+ }
+}
+U0 IPushR(JIT *jit,I64 push) {
+ U8 buffer[32],*end_ptr;
+ X64Mode *reg=X64ModeReg(IRegCodeToReg(push));
+ end_ptr=EncodeOpcode(buffer,"PUSH",NULL,NULL,NULL,NULL,reg);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(reg);
+}
+U0 IPopR(JIT *jit,I64 pop) {
+ U8 buffer[32],*end_ptr;
+ X64Mode *reg=X64ModeReg(IRegCodeToReg(pop));
+ end_ptr=EncodeOpcode(buffer,"POP",NULL,NULL,NULL,NULL,reg);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(reg);
+}
+U0 IMovRR(JIT *jit,I64 d,I64 s) {
+ U8 buffer[32],*end_ptr;
+ X64Mode *reg1=X64ModeReg(IRegCodeToReg(d)),*reg2=X64ModeReg(IRegCodeToReg(s));
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,NULL,NULL,reg1,reg2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(reg1),X64ModeFree(reg2);
+}
+U0 RemoveFromRMap(CVector *map,I64 v) {
+ I64 *data,size,idx;
+ if(-1==RMapGetPhysicalReg(map,v)) return;
+ if(map->size>2) {
+ data=map->data;
+ size=map->size;
+ for(idx=0;idx!=size;idx+=2) {
+ if(data[idx]==v) {
+ SwapI64(&data[size-2],&data[idx]);
+ SwapI64(&data[size-1],&data[idx+1]);
+ VectorPop(map),VectorPop(map);
+ break;
+ }
+ }
+ } else VectorPop(map),VectorPop(map);
+}
+U0 SpillIReg(JIT *jit,CRPN *at,I64 virt,Bool dry=FALSE) {
+ U8 buffer[32],*end_ptr;
+ X64Mode *frame,*reg;
+ I64 phy=RMapGetPhysicalReg(at->r_map,virt);
+ I64 size=at->r_map->size,idx,*data=at->r_map->data;
+ if(phy!=-1) {
+ if(!dry) {
+ frame=X64ModeMem(NULL,0,NULL,Str2Reg("RBP"),jit->ireg_shadows+8*virt,8);
+ reg=X64ModeReg(IRegCodeToReg(phy));
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,NULL,NULL,frame,reg);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(reg),X64ModeFree(frame);
+ } else {
+ RemoveFromRMap(at->r_map,virt);
+ if(Bt(at->live_in,virt)) {
+ VectorPush(at->spills,virt);
+ VectorPush(at->spills,phy);
+ }
+ }
+ } else
+ return;
+}
+CReg *__JIT_GetFreeIReg(JIT *jit,CRPN *at) {
+ U8 *cans[]={
+ "RBX",
+ "RCX",
+ "RDX",
+ "R8",
+ "R9",
+ "R10",
+ "R11",
+ "R12",
+ "R13",
+ "R14",
+ "R15",
+ //Save these for last as they are callee saved,we want to reduce stack spilling on the called functions end
+ "RSI",
+ "RDI",
+ };
+ I64 iter,v;
+ CReg *r;
+ for(iter=0;iter!=sizeof(cans)/sizeof(*cans);iter++) {
+ if(
+ -1!=(v=RMapGetVirtualReg(at->r_map,(r=Str2Reg(cans[iter]))->code))
+ ||-1!=(v=RMapGetVirtualReg(at->in_r_map,r->code))
+ )
+ ;
+ else {
+ if(IsCallerSaved(Str2Reg(cans[iter])))
+ VectorAdd(jit->tainted_caller_saved,r->code);
+ return r;
+ }
+ }
+ return NULL;
+}
+Bool PhyRegisterAtUseOnOperand(CRPN *at,CAsmValue *value,I64 phy) {
+ if(value->type==AV_IREG)
+ if(value->reg->code==phy)
+ return TRUE;
+ if(value->type==AV_VIREG)
+ return phy==RMapGetPhysicalReg(at->r_map,value->vreg);
+ return FALSE;
+}
+U0 UnspillIReg(JIT *jit,CRPN *at,I64 virt,Bool dry=FALSE) {
+ CRPN *spill;
+ I64 phy,idx,code,v,idx2,fspill_try=0,no_rdx=FALSE,no_rcx=FALSE,big_move=FALSE;
+ phy=RMapGetPhysicalReg(at->r_map,virt);
+ //See the Snailnelious
+ switch(at->type.code) {
+ case OP_MUL:
+ case OP_MOD:
+ case OP_DIV:
+ case OP_ASSIGN_MUL:
+ case OP_ASSIGN_MOD:
+ case OP_ASSIGN_DIV:
+ idx=RMapGetVirtualReg(at->r_map,Str2Reg("RDX")->code);
+ if(idx!=-1)
+ SpillIReg(jit,at,idx,dry);
+ no_rdx=TRUE;
+ if(Str2Reg("RDX")->code==phy) phy=-1;
+ break;
+ case OP_SHL:
+ case OP_ASSIGN_SHL:
+ case OP_SHR:
+ case OP_ASSIGN_SHR:
+ idx=RMapGetVirtualReg(at->r_map,Str2Reg("RCX")->code);
+ if(idx!=-1)
+ SpillIReg(jit,at,idx,dry);
+ no_rcx=TRUE;
+ if(Str2Reg("RCX")->code==phy) phy=-1;
+ break;
+ case OP_ASSIGN:
+ switch(at->operands[0]->type) {
+ case AV_IINDIR:
+ case AV_IVINDIR:
+ switch(at->operands[0]->size) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ break;
+ default:
+ at->flags|=RPN_F_BIG_MOVE;
+ big_move=TRUE;
+ }
+ }
+ }
+ if(phy!=-1)
+ return;
+ U8 *cans[]={
+ "RBX",
+ "RCX",
+ "RDX",
+ "R8",
+ "R9",
+ "R10",
+ "R11",
+ "R12",
+ "R13",
+ "R14",
+ "R15",
+ "RSI",
+ "RDI",
+ };
+ if(no_rdx)
+ for(idx=0;idx!=sizeof(cans)/sizeof(*cans);idx++)
+ if(!StrCmp(cans[idx],"RDX")) {
+ cans[idx]=NULL;
+ break;
+ }
+ if(no_rcx)
+ for(idx=0;idx!=sizeof(cans)/sizeof(*cans);idx++)
+ if(!StrCmp(cans[idx],"RCX")) {
+ cans[idx]=NULL;
+ break;
+ }
+ if(big_move)
+ for(idx=0;idx!=sizeof(cans)/sizeof(*cans);idx++) {
+ if(!StrCmp(cans[idx],"RDI")||!StrCmp(cans[idx],"RSI"))
+ cans[idx]=NULL;
+ }
+ for(idx=sizeof(cans)/sizeof(*cans)-1;idx>=0;idx--) {
+ if(!cans[idx]) goto can_next;
+ code=Str2Reg(cans[idx])->code;
+ if(PhyRegisterAtUseOnOperand(at,&at->my_avalue,code)) {
+ nospill:
+ cans[idx]=NULL;
+ goto can_next;
+ }
+ if(IsRPNUnop(at)&&PhyRegisterAtUseOnOperand(at,at->operands[0],code))
+ goto nospill;
+ if(IsRPNBinop(at)) {
+ if(PhyRegisterAtUseOnOperand(at,at->operands[0],code))
+ goto nospill;
+ if(PhyRegisterAtUseOnOperand(at,at->operands[1],code))
+ goto nospill;
+ }
+ if(at->type.code==OP_CALL)
+ if(PhyRegisterAtUseOnOperand(at,&GetCallFunction(at)->my_avalue,code))
+ goto nospill;
+ can_next:
+ }
+ loop:;
+ for(idx=0;idx!=sizeof(cans)/sizeof(*cans);idx++) {
+ if(!cans[idx]) goto next;
+ if(-1==(v=RMapGetVirtualReg(at->r_map,code=Str2Reg(cans[idx])->code))) {
+ unspill:
+ if(Bt(at->live_in,virt)) {
+ VectorPush(at->unspills,virt);
+ VectorPush(at->unspills,code);
+ }
+ if(IsCallerSaved(Str2Reg(cans[idx])))
+ VectorAdd(jit->tainted_caller_saved,Str2Reg(cans[idx])->code);
+ if(dry) {
+ RemoveFromRMap(at->r_map,virt);
+ VectorPush(at->r_map,virt);
+ VectorPush(at->r_map,code);
+ }
+ return;
+ } else if(!Bt(at->live_in,v)&&!Bt(at->live_out,v)) {
+ RemoveFromRMap(at->r_map,v);
+ goto unspill;
+ }
+ next:
+ }
+ v=-1;
+ while(v==-1) {
+ //v may be -1 if hit other unspilled cnaidate
+ if(cans[fspill_try])
+ v=RMapGetVirtualReg(at->r_map,Str2Reg(cans[fspill_try])->code);
+ fspill_try++;
+ }
+ SpillIReg(jit,at,v,dry);
+ goto loop;
+}
+U0 __CVT2Reg(JIT *jit,CRPN *rpn,CAsmValue *v,Bool dry) {
+ //Check AV_IREG/AV_IINDIR/AV_FINDIR for liveness of .vreg,if .vreg doesn not have the mapping as .reg,turn it back into a virtual register then reconvert to unspill into a new(or maybe same) register
+ //The reason for this is if we add to function calls,we invalidate the register mapping for that call maybe for argument a.
+ //So when it comes time to add,we have 2 register mappings for each of the operands(as the result register is part of each operand's mapping)
+ //This is why we do this.
+ // + //RCX+RCX? Nope ;)
+ // RCX=CALL(1,2,3) //RCX is not preserved so we map its free for the next operand
+ // RCX=CALL(4,5,6) //Oh no
+ //
+ CAsmValue virt=*v;
+ switch(virt.type) {
+ case AV_IREG:
+ case AV_IINDIR:
+ case AV_FINDIR:
+ if(virt->reg->code!=BASEREG_CODE&&RMapGetPhysicalReg(rpn->r_map,virt.vreg)!=virt.reg->code) {
+ SpillIReg(jit,rpn,virt.vreg,dry);
+ v=&virt;
+ }
+ }
+ if(v.type==AV_VIREG) {
+ UnspillIReg(jit,rpn,v.vreg,dry);
+ } else if(v.type==AV_IVINDIR) {
+ UnspillIReg(jit,rpn,v.vreg,dry);
+ } else if(v.type==AV_FVINDIR) {
+ UnspillIReg(jit,rpn,v.vreg,dry);
+ }
+}
+U0 BigMove(JIT *jit,CRPN *rpn,CAsmValue *dst,CAsmValue *src);
+U0 UnspillRPNRegs(JIT *jit,CRPN *rpn,Bool dry=TRUE) {
+ I64 idx2,idx;
+ CRPN *prev;
+ CReg *other_r;
+ //BigMove is used for moving big & wierd sized items,BigMove consumes RSI/RDI
+ if(rpn->type.code==OP_ASSIGN&&!rpn->type.is_flt) {
+ switch(rpn->operands[0]->type) {
+ case AV_IFRAME:
+ case AV_IINDIR:
+ case AV_IVINDIR:
+ switch(rpn->operands[0]->size) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ break;
+ default:
+ rpn->flags|=RPN_F_BIG_MOVE;
+ //Spilling doesnt invalidate the registers contents
+ if(-1!=(idx=RMapGetVirtualReg(rpn->r_map,Str2Reg("RDI")->code))) {
+ if(Bt(rpn->live_in,idx))
+ SpillIReg(jit,rpn,idx,TRUE);
+ }
+ if(-1!=(idx=RMapGetVirtualReg(rpn->r_map,Str2Reg("RSI")->code)))
+ if(Bt(rpn->live_in,idx))
+ SpillIReg(jit,rpn,idx,TRUE);
+ }
+ }
+ }
+ if(rpn->type.code==OP_RELOCATION||rpn->type.code==OP_REF_DATA) {
+ __CVT2Reg(jit,rpn,&rpn->my_avalue,dry);
+ } else if(IsRPNBinop(rpn)||IsRPNUnop(rpn)||IsRPNAssign(rpn)||rpn->type.code==OP_IF||rpn->type.code==OP_RETURN||rpn->type.code==OP_INPLACE_PUSH) {
+ __CVT2Reg(jit,rpn,&rpn->my_avalue,dry);
+ if(IsRPNBinop(rpn))
+ __CVT2Reg(jit,rpn,rpn->operands[0],dry),__CVT2Reg(jit,rpn,rpn->operands[1],dry);
+ if(IsRPNUnop(rpn)||rpn->type.code==OP_RETURN||rpn->type.code==OP_JMP_TABLE)
+ __CVT2Reg(jit,rpn,rpn->operands[0],dry);
+ if(rpn->type.code==OP_IF)
+ __CVT2Reg(jit,rpn,rpn->operands[0],dry);
+ }
+ if(rpn->type.code==OP_JMP_TABLE) {
+ //SPill all as we prepare to jump to a mystery location
+ __CVT2Reg(jit,rpn,&rpn->next->my_avalue,dry);
+ for(idx=0;idx!=16;idx++)
+ if(-1!=(idx2=RMapGetVirtualReg(rpn->r_map,idx)))
+ SpillIReg(jit,rpn,idx2,TRUE);
+ } else if(rpn->type.code==OP_CALL) {
+ prev=rpn->next;
+ //Spill Alive non-saved regs
+ for(idx=0;idx!=16;idx++)
+ if(-1!=(idx2=RMapGetVirtualReg(rpn->r_map,idx)))
+ if(!IsCallerSaved(IRegCodeToReg(idx)))
+ SpillIReg(jit,rpn,idx2,TRUE);
+ if(dry) jit->fpu_stk_size=0;
+ __CVT2Reg(jit,rpn,&GetCallFunction(rpn)->my_avalue,dry);
+ __CVT2Reg(jit,rpn,&rpn->my_avalue,dry);
+ }
+ if(rpn->my_avalue.type==AV_FREG&&rpn->type.code!=OP_VARIABLE) {
+ if(dry) jit->fpu_stk_size=MinI64(jit->fpu_stk_size+1,6);
+ }
+}
+U0 IMovRI(JIT *jit,I64 r,I64 imm) {
+ U8 buffer[32],*end_ptr;
+ X64Mode *ximm=X64ModeImm(imm),*reg=X64ModeReg(IRegCodeToReg(r));
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,NULL,NULL,reg,ximm);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(reg),X64ModeFree(ximm);
+}
+U0 IMovRInd(JIT *jit,I64 r,I64 in,I64 off=0,I64 sz=8,Bool unsigned) {
+ U8 buffer[32],*end_ptr;
+ X64Mode *ind,*reg;
+ switch(sz) {
+ case 1:
+ case 2:
+ ind=X64ModeMem(NULL,0,NULL,IRegCodeToReg(in),off,sz);
+ reg=X64ModeReg(IRegCodeToReg(r));
+ if(unsigned)
+ end_ptr=EncodeOpcode(buffer,"MOVZX",NULL,NULL,NULL,NULL,reg,ind);
+ else
+ end_ptr=EncodeOpcode(buffer,"MOVSX",NULL,NULL,NULL,NULL,reg,ind);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case 4:
+ case 8:
+ ind=X64ModeMem(NULL,0,NULL,IRegCodeToReg(in),off,sz);
+ reg=X64ModeReg(IRegCodeToReg(r));
+ if(sz==8)
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,NULL,NULL,reg,ind);
+ else if(sz==4&&!unsigned)
+ end_ptr=EncodeOpcode(buffer,"MOVSXD",NULL,NULL,NULL,NULL,reg,ind);
+ else {
+ X64ModeFree(reg);
+ reg=X64ModeReg(IRegCodeToReg32(r));
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,NULL,NULL,reg,ind);
+ }
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ }
+ X64ModeFree(reg),X64ModeFree(ind);
+}
+U0 IMovIndR(JIT *jit,I64 in,I64 off=0,I64 r,I64 sz=8) {
+ U8 buffer[32],*end_ptr;
+ X64Mode *ind,*reg;
+ switch(sz) {
+ start:
+ ind=X64ModeMem(NULL,0,NULL,IRegCodeToReg(in),off,sz);
+ case 1:
+ IMovRR(jit,0,r);
+ reg=X64ModeReg(Str2Reg("AL"));
+ break;
+ case 2:
+ reg=X64ModeReg(IRegCodeToReg16(r));
+ break;
+ case 4:
+ reg=X64ModeReg(IRegCodeToReg32(r));
+ break;
+ case 8:
+ reg=X64ModeReg(IRegCodeToReg(r));
+ end:
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,NULL,NULL,ind,reg);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ }
+ X64ModeFree(reg),X64ModeFree(ind);
+}
+
+U0 RMapSync(JIT *jit,CRPN *dst,CRPN *src) {
+ I64 idx,pr,desired,idx2,qwords=MSize(dst->live_in)/8,bit;
+ CVector *to_load=VectorNew,*to_unspill=VectorNew;
+ for(idx=0;idx!=src->r_map->size;idx+=2) {
+ if(-1==RMapGetPhysicalReg(dst->in_r_map,src->r_map->data[idx])) {
+ desired=src->r_map->data[idx+1];
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+8*src->r_map->data[idx],desired,8);
+ }
+ }
+ //Start with those loaded in dst's rmap
+ for(idx=0;idx!=dst->in_r_map->size;idx+=2) {
+ desired=dst->in_r_map->data[idx+1];
+ if(-1!=(pr=RMapGetPhysicalReg(src->r_map,dst->in_r_map->data[idx]))) {
+ if(pr==desired) goto ipass;
+ //If conflicts with existing in src,spill to stack then reaload later
+ if(-1!=RMapGetVirtualReg(src->r_map,desired)) {
+ VectorPush(to_load,dst->in_r_map->data[idx]);
+ IPushR(jit,pr);
+ goto ipass;
+ } else {
+ IMovRR(jit,desired,pr);
+ }
+ } else {
+ for(idx2=0;idx2!=dst->unspills->size;idx2+=2)
+ if(dst->unspills->data[idx2]==dst->in_r_map->data[idx])
+ goto ipass;
+ //Unspill desired reg
+ VectorPush(to_unspill,dst->in_r_map->data[idx]);
+ }
+ ipass:
+ }
+ //Load values expected to be spilled
+ for(idx=0;idx!=dst->spills->size;idx+=2)
+ if(-1==RMapGetPhysicalReg(dst->in_r_map,dst->spills->data[idx])) {
+ VectorAdd(to_unspill,dst->spills->data[idx]);
+ }
+ for(;to_load->size;) {
+ idx=VectorPop(to_load);
+ IPopR(jit,RMapGetPhysicalReg(dst->in_r_map,idx));
+ }
+ for(;to_unspill->size;) {
+ desired=RMapGetPhysicalReg(dst->in_r_map,idx=VectorPop(to_unspill));
+ IMovRInd(jit,desired,BASEREG_CODE,jit->ireg_shadows+8*idx,8,FALSE);
+ }
+ VectorFree(to_load),VectorFree(to_unspill);
+}
+U0 FISTP(JIT *jit,I64 in,I64 off=0) {
+ U8 buffer[32],*end_ptr;
+ X64Mode *ind=X64ModeMem(NULL,0,NULL,IRegCodeToReg(in),off,8);
+ end_ptr=EncodeOpcode(buffer,"FISTP",NULL,NULL,NULL,NULL,ind);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(ind);
+}
+U0 __X87Push(JIT *jit,CRPN *at,CAsmValue *src);
+U0 IMov(JIT *jit,CRPN *at,CAsmValue *dst,CAsmValue *src,Bool unsigned) {
+ if(AsmValueEqual(dst,src)) return;
+ I64 p,reg,old_buf_sz;
+ CAsmValue dummy;
+ #ifdef JIT_DBG
+ old_buf_sz=jit->buf_size;
+ #endif
+ switch(dst->type) {
+ case AV_PUSH:
+ switch(src->type) {
+ case AV_FREG_SHADOW:
+ case AV_FVINDIR:
+ case AV_FINDIR:
+ __X87Push(jit,at,src);
+ case AV_FREG:
+ //SUB RSP,8;
+ JIT_AppendAsmText(jit,"\x48\x83\xEC\x08",4);
+ FISTP(jit,Str2Reg("RSP")->code,0);
+ return;
+ }
+ Push(jit,at,"PUSH",src);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ if(reg==-1) throw('CodeGen');
+ goto r;
+ case AV_IREG:
+ reg=dst->reg->code;
+ r:
+ switch(src->type) {
+ case AV_IREG:
+ IMovRR(jit,reg,src->reg->code);
+ break;
+ case AV_VIREG:
+ if(RMapGetPhysicalReg(at->r_map,src->vreg)==-1) throw('CodeGen');
+ IMovRR(jit,reg,RMapGetPhysicalReg(at->r_map,src->vreg));
+ break;
+ case AV_INT:
+ IMovRI(jit,reg,src->int);
+ break;
+ case AV_FLT:
+ IMovRI(jit,reg,src->flt);
+ break;
+ case AV_IREG_SHADOW:
+ IMovRInd(jit,reg,BASEREG_CODE,jit->ireg_shadows+8*src->vreg,,unsigned);
+ break;
+ case AV_IFRAME:
+ IMovRInd(jit,reg,BASEREG_CODE,src->f_offset,,unsigned);
+ break;
+ case AV_FREG:
+ //SUB RSP,8,FISTP [RSP]
+ JIT_AppendAsmText(jit,"\x48\x83\xEC\x08\xDF\x3C\x24",4+3);
+ IPopR(jit,reg);
+ break;
+ case AV_FREG_SHADOW:
+ case AV_FINDIR:
+ case AV_FFRAME:
+ case AV_FVINDIR:
+ __X87Push(jit,at,src);
+ //SUB RSP,8,FISTP [RSP]
+ JIT_AppendAsmText(jit,"\x48\x83\xEC\x08\xDF\x3C\x24",4+3);
+ IPopR(jit,reg);
+ break;
+ case AV_IVINDIR:
+ IMovRInd(jit,reg,RMapGetPhysicalReg(at->r_map,src->vreg),src->offset,src->size,unsigned);
+ break;
+ case AV_IINDIR:
+ IMovRInd(jit,reg,src->reg->code,src->offset,src->size,unsigned);
+ break;
+ }
+ break;
+ case AV_IFRAME:
+ switch(src->type) {
+ case AV_IREG:
+ IMovIndR(jit,BASEREG_CODE,dst->f_offset,src->reg->code);
+ break;
+ case AV_VIREG:
+ IMovIndR(jit,BASEREG_CODE,dst->f_offset,RMapGetPhysicalReg(at->r_map,src->vreg));
+ break;
+ case AV_INT:
+ IMovRI(jit,Str2Reg("RAX")->code,src->int);
+ IMovIndR(jit,BASEREG_CODE,dst->f_offset,Str2Reg("RAX")->code);
+ break;
+ case AV_FLT:
+ IMovRI(jit,Str2Reg("RAX")->code,src->flt);
+ IMovIndR(jit,BASEREG_CODE,dst->f_offset,Str2Reg("RAX")->code);
+ break;
+ case AV_IREG_SHADOW:
+ IMovRInd(jit,Str2Reg("RAX")->code,BASEREG_CODE,jit->ireg_shadows+8*src->vreg,,unsigned);
+ IMovIndR(jit,BASEREG_CODE,dst->f_offset,Str2Reg("RAX")->code);
+ break;
+ case AV_FREG:
+ FISTP(jit,BASEREG_CODE,dst->f_offset);
+ break;
+ case AV_FINDIR:
+ case AV_FFRAME:
+ case AV_FREG_SHADOW:
+ __X87Push(jit,at,src);
+ FISTP(jit,BASEREG_CODE,dst->f_offset);
+ break;
+ case AV_IFRAME:
+ IMovRInd(jit,Str2Reg("RAX")->code,BASEREG_CODE,src->f_offset,src->size,unsigned);
+ IMovIndR(jit,BASEREG_CODE,dst->f_offset,Str2Reg("RAX")->code);
+ break;
+ case AV_IVINDIR:
+ IMovRInd(jit,Str2Reg("RAX")->code,RMapGetPhysicalReg(at->r_map,src->vreg),src->offset,src->size,unsigned);
+ IMovIndR(jit,BASEREG_CODE,dst->f_offset,Str2Reg("RAX")->code);
+ break;
+
+ case AV_IINDIR:
+ IMovRInd(jit,Str2Reg("RAX")->code,src->reg->code,src->offset,src->size,unsigned);
+ IMovIndR(jit,BASEREG_CODE,dst->f_offset,Str2Reg("RAX")->code);
+ break;
+ }
+ break;
+ case AV_IREG_SHADOW:
+ switch(src->type) {
+ case AV_IREG:
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg,src->reg->code,8);
+ break;
+ case AV_VIREG:
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg,RMapGetPhysicalReg(at->r_map,src->vreg),8);
+ break;
+ case AV_INT:
+ IMovRI(jit,Str2Reg("RAX")->code,src->int);
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg,Str2Reg("RAX")->code,8);
+ break;
+ case AV_FLT:
+ IMovRI(jit,Str2Reg("RAX")->code,src->flt);
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg,Str2Reg("RAX")->code,8);
+ break;
+ case AV_IREG_SHADOW:
+ IMovRInd(jit,Str2Reg("RAX")->code,BASEREG_CODE,jit->ireg_shadows+8*src->vreg,,unsigned);
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg,Str2Reg("RAX")->code,8);
+ break;
+ case AV_FREG:
+ FISTP(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg);
+ break;
+ case AV_FREG_SHADOW:
+ case AV_FINDIR:
+ case AV_FVINDIR:
+ case AV_FFRAME:
+ __X87Push(jit,at,src);
+ FISTP(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg);
+ break;
+ case AV_IVINDIR:
+ IMovRInd(jit,Str2Reg("RAX")->code,RMapGetPhysicalReg(at->r_map,src->vreg),src->offset,src->size,unsigned);
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg,Str2Reg("RAX")->code,8);
+ break;
+ case AV_IINDIR:
+ IMovRInd(jit,Str2Reg("RAX")->code,src->reg->code,src->offset,src->size,unsigned);
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg,Str2Reg("RAX")->code,8);
+ break;
+ }
+ break;
+ case AV_IINDIR:
+ reg=dst->reg->code;
+ ii:
+ switch(src->type) {
+ case AV_IREG:
+ IMovIndR(jit,reg,dst->offset,src->reg->code,dst->size);
+ break;
+ case AV_VIREG:
+ IMovIndR(jit,reg,dst->offset,RMapGetPhysicalReg(at->r_map,src->vreg),dst->size);
+ break;
+ case AV_INT:
+ IMovRI(jit,Str2Reg("RAX")->code,src->int);
+ IMovIndR(jit,reg,dst->offset,Str2Reg("RAX")->code,dst->size);
+ break;
+ case AV_FLT:
+ IMovRI(jit,Str2Reg("RAX")->code,src->flt);
+ IMovIndR(jit,reg,dst->offset,Str2Reg("RAX")->code,dst->size);
+ break;
+ case AV_IREG_SHADOW:
+ IMovRInd(jit,Str2Reg("RAX")->code,BASEREG_CODE,jit->ireg_shadows+8*src->vreg,,unsigned);
+ IMovIndR(jit,reg,dst->offset,Str2Reg("RAX")->code,8);
+ break;
+ case AV_IFRAME:
+ IMovRInd(jit,Str2Reg("RAX")->code,BASEREG_CODE,src->f_offset,src->size,unsigned);
+ IMovIndR(jit,reg,dst->offset,Str2Reg("RAX")->code,dst->size);
+ break;
+ case AV_FREG:
+ FISTP(jit,reg,dst->offset);
+ break;
+ case AV_FREG_SHADOW:
+ case AV_FINDIR:
+ case AV_FFRAME:
+ case AV_FVINDIR:
+ __X87Push(jit,at,src);
+ FISTP(jit,reg,dst->offset);
+ break;
+ case AV_IVINDIR:
+ IMovRInd(jit,Str2Reg("RAX")->code,RMapGetPhysicalReg(at->r_map,src->vreg),src->offset,src->size,unsigned);
+ IMovIndR(jit,reg,dst->offset,Str2Reg("RAX")->code,dst->size);
+ break;
+ case AV_IINDIR:
+ IMovRInd(jit,Str2Reg("RAX")->code,src->reg->code,src->offset,src->size,unsigned);
+ IMovIndR(jit,reg,dst->offset,Str2Reg("RAX")->code,dst->size);
+ break;
+ }
+ break;
+ case AV_IVINDIR:
+ reg=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ goto ii;
+ case AV_UNOCC:
+ if(src->type==AV_FREG)
+ //FSTP ST0;
+ JIT_AppendAsmText(jit,"\xDD\xD8",2);
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 IArithUnop(JIT *jit,CRPN *at,U8 *op,CAsmValue *dst,CAsmValue *src,Bool unsigned=FALSE) {
+ I64 reg,base,p,offset,old_buf_sz=jit->buf_size;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode;
+ CAsmValue dummy;
+ loop:
+ switch(dst->type) {
+ case AV_PUSH:
+ Push(jit,at,"PUSH",src);
+ dummy.reg=Str2Reg("RSP");
+ dummy.offset=0;
+ dummy.size=8;
+ dummy.type=AV_IINDIR;
+ dst=&dummy;
+ goto loop;
+ case AV_IREG:
+ reg=dst->reg->code;
+ r:
+ IMov(jit,at,dst,src,unsigned);
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode=X64ModeReg(IRegCodeToReg(reg)));
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ goto r;
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=dst->f_offset;
+ ind:
+ IMov(jit,at,dst,src,unsigned);
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,dst->size));
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*dst->vreg;
+ goto ind;
+ break;
+ case AV_IINDIR:
+ base=dst->reg->code;
+ offset=dst->offset;
+ goto ind;
+ case AV_IVINDIR:
+ offset=dst->offset;
+ base=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ goto ind;
+ }
+ X64ModeFree(mode);
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 IIncOp(JIT *jit,CRPN *at,U8 *op,CAsmValue *a,Bool unsigned) {
+ I64 reg,base,p,offset,p2,imm,old_buf_sz=jit->buf_size;
+ CAsmValue dummy;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode;
+ switch(a->type) {
+ case AV_PUSH:
+ Push(jit,at,"PUSH",a);
+ base=Str2Reg("RSP")->code;
+ offset=0;
+ goto i;
+ case AV_IREG:
+ reg=a->reg->code;
+ r:
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode=X64ModeReg(IRegCodeToReg(reg)));
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,a->vreg);
+ goto r;
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=a->f_offset;
+ i:
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,a->size));
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,a->vreg);
+ offset=a->offset;
+ goto i;
+ case AV_IINDIR:
+ base=a->reg->code;
+ offset=a->offset;
+ goto i;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*a->vreg;
+ goto i;
+ }
+ X64ModeFree(mode);
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 Push(JIT *jit,CRPN *at,U8 *op,CAsmValue *a) {
+ I64 imm,reg,p,base,offset,old_buf_sz=jit->buf_size;
+ CAsmValue dummy,dummy2;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode;
+ switch(a->type) {
+ case AV_INT:
+ imm=a->int;
+ pimm:
+ if(I32_MIN<=imm<=I32_MAX) {
+ end_ptr=EncodeOpcode(buffer,"REX",NULL,NULL,NULL,NULL);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ end_ptr=EncodeOpcode(buffer,"PUSH",NULL,NULL,NULL,NULL,mode=X64ModeImm(imm));
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ } else {
+ dummy2.type=AV_INT;
+ dummy2.int=imm;
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,&dummy,&dummy2,FALSE);
+ Push(jit,at,op,&dummy);
+ }
+ break;
+ case AV_FLT:
+ imm=a->flt(I64);
+ goto pimm;
+ case AV_IREG:
+ reg=a->reg->code;
+ r:
+ IPushR(jit,reg);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,a->vreg);
+ goto r;
+ break;
+ case AV_FREG:
+ fr:
+ //SUB RSP,8; FSTP F64 [RSP]
+ JIT_AppendAsmText(jit,"\x48\x83\xEC\x08\xDD\x1C\x24",4+3);
+ break;
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=a->f_offset;
+ i:
+ if(a->size==8) {
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,a->size);
+ end_ptr=EncodeOpcode(buffer,"PUSH",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ } else {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,&dummy,a,!at->type.is_signed);
+ Push(jit,at,op,&dummy);
+ }
+ break;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*a->vreg;
+ goto i;
+ case AV_FREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->freg_shadows+8*a->vreg;
+ goto i;
+ case AV_FINDIR:
+ case AV_IINDIR:
+ //FINDIR's are always 64-bit
+ base=a->reg->code;
+ offset=a->offset;
+ goto i;
+ case AV_FVINDIR:
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,a->vreg);
+ offset=a->offset;
+ goto i;
+ case AV_FFRAME:
+ base=BASEREG_CODE;
+ offset=a->f_offset;
+ goto i;
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+
+}
+U0 Pop(JIT *jit,CRPN *at,U8 *op,CAsmValue *a) {
+ I64 imm,reg,p,base,offset,old_buf_sz=jit->buf_size;
+ CAsmValue dummy,dummy2;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode;
+ switch(a->type) {
+ case AV_IREG:
+ reg=a->reg->code;
+ r:
+ IPopR(jit,reg);
+ break;
+ case AV_VIREG:
+ IPopR(jit,RMapGetPhysicalReg(at->r_map,a->vreg));
+ break;
+ case AV_FREG:
+ fr:
+ //FLD F64 [RSP];
+ //ADD RSP,8
+ JIT_AppendAsmText(jit,"\xDD\x04\x24\x48\x83\xC4\x08",3+4);
+ break;
+ case AV_FFRAME:
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=a->f_offset;
+ i:
+ if(a->size==8) {
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,a->size);
+ end_ptr=EncodeOpcode(buffer,"POP",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ } else {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ Pop(jit,at,op,&dummy);
+ IMov(jit,at,a,&dummy,!at->type.is_signed); //TODO Mov,not IMov
+ }
+ break;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*a->vreg;
+ goto i;
+ case AV_FREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->freg_shadows+8*a->vreg;
+ goto i;
+ case AV_FINDIR:
+ case AV_IINDIR:
+ //FINDIR's are always 64-bit
+ base=a->reg->code;
+ offset=a->offset;
+ goto i;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,a->vreg);
+ offset=a->offset;
+ goto i;
+ case AV_UNOCC:
+ //ADD RSP,8
+ JIT_AppendAsmText(jit,"\x48\x83\xC4\x08",4);
+ break;
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 __SetOnCondOp(JIT *jit,CRPN *at,U8 *op,CAsmValue *dst) {
+ I64 reg,base,offset,p,old_buf_sz=jit->buf_size;
+ U8 *br,*br2;
+ CAsmValue dummy,dummy2;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2,*mode3;
+ switch(dst->type) {
+ case AV_PUSH:
+ dummy.type=AV_INT;
+ dummy.int=0;
+ Push(jit,at,"PUSH",&dummy);
+ base=Str2Reg("RSP")->code;
+ offset=0;
+ dummy.size=8;
+ dummy.type=AV_IINDIR;
+ dummy.offset=0;
+ dummy.reg=Str2Reg("RSP");
+ dst=&dummy;
+ goto d_i;
+ case AV_IREG:
+ reg=dst->reg->code;
+ d_r:
+ mode=X64ModeReg(Str2Reg("AL"));
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ mode2=X64ModeReg(IRegCodeToReg(reg));
+ end_ptr=EncodeOpcode(buffer,"MOVZX",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ goto d_r;
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=dst->f_offset;
+ d_i:
+ mode=X64ModeReg(Str2Reg("AL"));
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ //
+ mode2=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,dst->size);
+ switch(dst->size) {
+ case 1:
+ mode=X64ModeReg(Str2Reg("AL"));
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ start:
+ //MOVZX RAX,AL
+ JIT_AppendAsmText(jit,"\x48\x0F\xB6\xC0",4);
+ case 2:
+ mode=X64ModeReg(Str2Reg("AX"));
+ break;
+ case 4:
+ mode=X64ModeReg(Str2Reg("EAX"));
+ break;
+ case 8:
+ mode=X64ModeReg(Str2Reg("RAX"));
+ end:
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ }
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ case AV_IINDIR:
+ base=dst->reg->code;
+ offset=dst->offset;
+ goto d_i;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ offset=dst->offset;
+ goto d_i;
+
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+dst->vreg*8;
+ goto d_i;
+ case AV_FREG:
+ case AV_FREG_SHADOW:
+ case AV_FFRAME:
+ case AV_FINDIR:
+ mode=X64ModeReg(Str2Reg("AL"));
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ /*
+ TEST al,al
+ JNZ t;
+ FLDZ;
+ JMP e;
+ t:
+ FLD1;
+ e:
+ */
+ JIT_AppendAsmText(jit,"\x84\xC0\x75\x04\xD9\xEE\xEB\x02\xD9\xE8",8+2);
+ if(dst->type!=AV_FREG)
+ __FMov(jit,at,dst,TRUE);
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+//Leave dst NULL for raw cmp,use SETcc
+U0 ICmpOp(JIT *jit,CRPN *at,U8 *op,CAsmValue *dst,CAsmValue *a,CAsmValue *b,Bool unsigned=FALSE) {
+ I64 reg,base,p,offset,p2,imm,old_buf_sz=jit->buf_size,stk_adj=0;
+ U8 *br,*br2;
+ CAsmValue dummy,ddummy;
+ CReg *spare;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2;
+ loop:
+ switch(a->type) {
+ case AV_IREG:
+ reg=a->reg->code;
+ r:
+ switch(b->type) {
+ case AV_INT:
+ imm=b->int;
+ try_imm:
+ if(I32_MIN<=imm<=I32_MAX) {
+ mode2=X64ModeReg(IRegCodeToReg(reg));
+ mode=X64ModeImm(imm);
+ end_ptr=EncodeOpcode(buffer,"CMP",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ } else {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,&dummy,b,unsigned);
+ ICmpOp(jit,at,op,dst,a,&dummy,unsigned);
+ return;
+ }
+ break;
+ case AV_FLT:
+ imm=ToI64(b->flt);
+ goto try_imm;
+ case AV_IREG:
+ mode2=X64ModeReg(IRegCodeToReg(reg));
+ mode=X64ModeReg(b->reg);
+ end_ptr=EncodeOpcode(buffer,"CMP",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ case AV_VIREG:
+ mode2=X64ModeReg(IRegCodeToReg(reg));
+ mode=X64ModeReg(IRegCodeToReg(RMapGetPhysicalReg(at->r_map,b->vreg)));
+ end_ptr=EncodeOpcode(buffer,"CMP",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=b->f_offset;
+ f1:
+ switch(b->size) {
+ case 1:
+ mode2=X64ModeReg(Str2Reg("AL"));
+ IMovRR(jit,0,reg);
+ break;
+ case 2:
+ mode2=X64ModeReg(IRegCodeToReg16(reg));
+ break;
+ case 4:
+ mode2=X64ModeReg(IRegCodeToReg32(reg));
+ break;
+ case 8:
+ mode2=X64ModeReg(IRegCodeToReg(reg));
+ }
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,b->size);
+ end_ptr=EncodeOpcode(buffer,"CMP",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ case AV_IINDIR:
+ base=b->reg->code;
+ offset=b->offset;
+ goto f1;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,b->vreg);
+ offset=b->offset;
+ goto f1;
+
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*b->vreg;
+ goto f1;
+ }
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,a->vreg);
+ goto r;
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=a->f_offset;
+ i:
+ switch(b->type) {
+ start:
+ case AV_INT:
+ imm=b->int;
+ break;
+ case AV_FLT:
+ imm=b->flt;
+ end:
+ if(I32_MIN<=imm<=I32_MAX) {
+ mode2=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,a->size);
+ mode=X64ModeImm(imm);
+ end_ptr=EncodeOpcode(buffer,"CMP",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ }
+ m2rax:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,&dummy,b,unsigned);
+ reg=Str2Reg("RAX")->code;
+ r2:
+ mode2=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,a->size);
+ switch(a->size) {
+ case 1:
+ mode=X64ModeReg(Str2Reg("AL"));
+ IMovRR(jit,0,reg);
+ break;
+ case 2:
+ mode=X64ModeReg(IRegCodeToReg16(reg));
+ break;
+ case 4:
+ mode=X64ModeReg(IRegCodeToReg32(reg));
+ break;
+ case 8:
+ mode=X64ModeReg(IRegCodeToReg(reg));
+ }
+ end_ptr=EncodeOpcode(buffer,"CMP",NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ case AV_IREG:
+ reg=b->reg->code;
+ goto r2;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,b->vreg);
+ goto r2;
+ case AV_IVINDIR:
+ case AV_IINDIR:
+ case AV_IREG_SHADOW:
+ goto m2rax;
+ }
+ break;
+ case AV_IINDIR:
+ base=a->reg->code;
+ offset=a->offset;
+ goto i;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,a->vreg);
+ offset=a->offset;
+ goto i;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows*8*a->vreg;
+ goto i;
+ break;
+ case AV_FLT:
+ case AV_INT:
+ if(spare=__JIT_GetFreeIReg(jit,at)) {
+ dummy.type=AV_IREG;
+ dummy.reg=spare;
+ IMov(jit,at,&dummy,a,unsigned);
+ reg=spare->code;
+ goto r;
+ } else {
+ Push(jit,at,"PUSH",a);
+ ddummy.reg=Str2Reg("RSP");
+ ddummy.offset=0;
+ ddummy.size=8;
+ ddummy.type=AV_IINDIR;
+ a=&ddummy;
+ stk_adj=8;
+ goto loop;
+ }
+ break;
+
+ }
+ if(stk_adj==8)
+ IPopR(jit,Str2Reg("RAX")->code);
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+ if(dst)
+ __SetOnCondOp(jit,at,op,dst);
+}
+Bool IsAsmIndirect(CAsmValue *v) {
+ switch(v->type) {
+ case AV_IINDIR:
+ case AV_FINDIR:
+ case AV_IVINDIR:
+ case AV_FVINDIR:
+ return TRUE;
+ }
+ return FALSE;
+}
+U0 IArithOp(JIT *jit,CRPN *at,U8 *name,CAsmValue *d,CAsmValue *a,CAsmValue *b,Bool unsigned=FALSE) {
+ I64 reg,base,offset,old_buf_sz=jit->buf_size,dreg;
+ CAsmValue dummy,dummy2,*orig_d=d;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2;
+ Bool use_treg=FALSE,pop=FALSE;
+ if(IsAsmIndirect(a)||IsAsmIndirect(b))
+ goto usetr;
+ if(!(AsmValueEqual(d,a)||AsmValueEqual(d,b))) {
+ IMov(jit,at,d,a,unsigned);
+ } else if(AsmValueEqual(d,a)) {
+ } else {
+ usetr:
+ dummy2.type=AV_IREG;
+ dummy2.reg=__JIT_GetFreeIReg(jit,at);
+ if(!dummy2.reg) {
+ dummy2.type=AV_IINDIR;
+ dummy2.reg=Str2Reg("RSP");
+ dummy2.size=8;
+ dummy2.offset=0;
+ Push(jit,at,"PUSH",a);
+ pop=TRUE;
+ } else {
+ use_treg=TRUE;
+ IMov(jit,at,&dummy2,a,unsigned);
+ }
+ d=&dummy2;
+ }
+ loop:
+ switch(d->type) {
+ case AV_PUSH:
+ Push(jit,at,"PUSH",d);
+ base=Str2Reg("RSP")->code;
+ offset=0;
+ dummy.size=8;
+ dummy.type=AV_IINDIR;
+ dummy.offset=0;
+ dummy.reg=Str2Reg("RSP");
+ d=&dummy;
+ goto loop;
+ case AV_IREG:
+ dreg=d->reg->code;
+ r:
+ switch(b->type) {
+ case AV_IREG:
+ reg=b->reg->code;
+ r2:
+ mode2=X64ModeReg(IRegCodeToReg(dreg));
+ mode=X64ModeReg(IRegCodeToReg(reg));
+ end_ptr=EncodeOpcode(buffer,name,NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,b->vreg);
+ goto r2;
+ break;
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=b->f_offset;
+ i2:
+ reg=dreg;
+ if(b->size==8) {
+ mode2=X64ModeReg(IRegCodeToReg(dreg));
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,8);
+ end_ptr=EncodeOpcode(buffer,name,NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ } else
+ goto mrax;
+ break;
+ case AV_IINDIR:
+ base=b->reg->code;
+ offset=b->offset;
+ goto i2;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,b->vreg);
+ offset=b->offset;
+ goto i2;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*b->vreg;
+ goto i2;
+ case AV_INT:
+ if(I32_MIN<=b->int<=I32_MAX) {
+ mode2=X64ModeReg(IRegCodeToReg(dreg));
+ mode=X64ModeImm(b->int);
+ end_ptr=EncodeOpcode(buffer,name,NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ }
+ default:
+ mrax:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ reg=dummy.reg->code;
+ IMov(jit,at,&dummy,b,unsigned);
+ b=&dummy;
+ goto r2;
+ break;
+ }
+ break;
+ case AV_VIREG:
+ dreg=RMapGetPhysicalReg(at->r_map,d->vreg);
+ goto r;
+ break;
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=d->f_offset;
+ i:
+ switch(b->type) {
+ case AV_IREG:
+ reg=b->reg->code;
+ r3:
+ mode2=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,d->size);
+ switch(d->size) {
+ case 1:
+ mode=X64ModeReg(Str2Reg("AL"));
+ IMovRR(jit,0,reg);
+ break;
+ case 2:
+ mode=X64ModeReg(IRegCodeToReg16(reg));
+ break;
+ case 4:
+ mode=X64ModeReg(IRegCodeToReg32(reg));
+ break;
+ case 8:
+ mode=X64ModeReg(IRegCodeToReg(reg));
+ break;
+ default:
+ "%d,%d,%d,%p,%p,%p\n",d->size,d->type,b->type,d,&dummy,&dummy2;
+ Debugger;
+ }
+ end_ptr=EncodeOpcode(buffer,name,NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,b->vreg);
+ goto r3;
+ case AV_INT:
+ if(I32_MIN<=b->int<=I32_MAX) {
+ mode2=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,d->size);
+ mode=X64ModeImm(b->int);
+ switch(d->size) {
+ case 1:
+ b->int&=0xff;
+ break;
+ case 2:
+ b->int&=0xffFF;
+ break;
+ case 4:
+ b->int&=0xffFFffFF;
+ break;
+ }
+ end_ptr=EncodeOpcode(buffer,name,NULL,NULL,NULL,NULL,mode2,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ break;
+ }
+ default:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,&dummy,b,unsigned);
+ b=&dummy;
+ goto i;
+ }
+ break;
+ case AV_IINDIR:
+ base=d->reg->code;
+ offset=d->offset;
+ goto i;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,d->vreg);
+ offset=d->offset;
+ goto i;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*d->vreg;
+ goto i;
+ }
+ if(use_treg)
+ IMov(jit,at,orig_d,&dummy2,unsigned);
+ else if(pop) {
+ Pop(jit,at,"POP",orig_d);
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+
+}
+Bool IRegIsAliveAfter(CRPN *at,CReg *reg) {
+ I64 p;
+ if(-1!=(p=RMapGetVirtualReg(at->r_map,reg->code))) {
+ if(Bt(at->live_out,p))
+ return TRUE;
+ }
+ return FALSE;
+}
+//
+// >..< Be sure not to pass RDX to this function
+// ww______
+// \______/
+//
+U0 __Div(JIT *jit,CRPN *at,U8 *op,CAsmValue *a,CAsmValue *b) {
+ CAsmValue dummy,cdummy;
+ I64 reg,p,base,offset,old_buf_sz=jit->buf_size;
+ Bool pop=FALSE,pop_rdx;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2;
+ cdummy.type=AV_IREG;
+ if(!(cdummy.reg=__JIT_GetFreeIReg(jit,at)))
+ goto push;
+ else if(cdummy.reg==Str2Reg("RDX"))
+ goto push;
+ loop:
+ switch(b->type) {
+ case AV_INT:
+ m2rcx:
+ if(!cdummy.reg) {
+ push:
+ pop=TRUE;
+ Push(jit,at,"PUSH",b);
+ cdummy.type=AV_IINDIR;
+ cdummy.reg=Str2Reg("RSP");
+ cdummy.offset=0;
+ cdummy.size=8;
+ b=&cdummy;
+ goto loop;
+ }
+ IMov(jit,at,&cdummy,b,FALSE);
+ b=&cdummy;
+ reg=b->reg->code;
+ goto reg;
+ case AV_FLT:
+ break;
+ case AV_IREG:
+ reg=b->reg->code;
+ reg:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,&dummy,a,FALSE);
+ //CQO
+ JIT_AppendAsmText(jit,"\x48\x99",2);
+ mode=X64ModeReg(IRegCodeToReg(reg));
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,b->vreg);
+ goto reg;
+ case AV_IFRAME:
+ base=BASEREG_CODE;
+ offset=b->f_offset;
+ i:
+ if(b->size==8) {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,&dummy,a,FALSE);
+ //CQO
+ JIT_AppendAsmText(jit,"\x48\x99",2);
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,8);
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ } else
+ goto m2rcx;
+ break;
+ case AV_IINDIR:
+ base=b->reg->code;
+ offset=b->offset;
+ goto i;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,b->vreg);
+ offset=b->offset;
+ goto i;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*b->vreg;
+ goto i;
+ }
+ if(pop)
+ JIT_AppendAsmText(jit,"\x48\x83\xC4\x08",4);
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U8 *StrPrintJoin2(U8 *dst,U8 *fmt,...) {
+ return StrPrintJoin(dst,fmt,argc,argv);
+}
+U0 __X87Push(JIT *jit,CRPN *at,CAsmValue *v) {
+ I64 p,old_buf_sz=jit->buf_size,base,offset;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode;
+ switch(v->type) {
+ start:
+ case AV_INT:
+ case AV_IREG:
+ case AV_VIREG:
+ case AV_IINDIR:
+ case AV_IVINDIR:
+ Push(jit,at,"PUSH",v);
+ end:
+ //FILD I64 [RSP];
+ //ADD RSP,8;
+ JIT_AppendAsmText(jit,"\xDF\x2C\x24\x48\x83\xC4\x08",3+4);
+ break;
+ case AV_FLT:
+ Push(jit,at,"PUSH",v);
+ //FLD I64 [RSP];
+ //ADD RSP,8;
+ JIT_AppendAsmText(jit,"\xDD\x04\x24\x48\x83\xC4\x08",3+4);
+ break;
+
+ case AV_IFRAME:
+ offset=v->offset;
+ base=BASEREG_CODE;
+ ii:
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,8);
+ end_ptr=EncodeOpcode(buffer,"FILD",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ break;
+ case AV_FFRAME:
+ offset=v->offset;
+ base=BASEREG_CODE;
+ goto fi;
+ break;
+ case AV_FVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,v->vreg);
+ offset=v->offset;
+ goto fi;
+ case AV_FINDIR:
+ base=v->reg->code;
+ offset=v->offset;
+ fi:
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,8);
+ end_ptr=EncodeOpcode(buffer,"FLD",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ break;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*v->vreg;
+ goto ii;
+ break;
+ case AV_FREG_SHADOW:
+ offset=jit->freg_shadows+8*v->vreg;
+ base=BASEREG_CODE;
+ goto fi;
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 __FMov(JIT *jit,CRPN *at,CAsmValue *dst,Bool pop) {
+ I64 reg,base,offset,reg2,old_buf_sz=jit->buf_size;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode;
+ switch(dst->type) {
+ case AV_PUSH:
+ //SUB RSP,8
+ JIT_AppendAsmText(jit,"\x48\x83\xEC\x08",4);
+ mode=X64ModeMem(NULL,0,NULL,Str2Reg("RSP"),0,8);
+ if(pop)
+ end_ptr=EncodeOpcode(buffer,"FSTP",NULL,NULL,NULL,NULL,mode);
+ else
+ end_ptr=EncodeOpcode(buffer,"FST",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ break;
+ case AV_FREG:
+ return;
+ start:
+ //SUB RSP,8
+ JIT_AppendAsmText(jit,"\x48\x83\xEC\x08",4);mode=X64ModeMem(NULL,0,NULL,Str2Reg("RSP"),0,8);
+ mode=X64ModeMem(NULL,0,NULL,Str2Reg("RSP"),0,8);
+ if(pop)
+ end_ptr=EncodeOpcode(buffer,"FSTP",NULL,NULL,NULL,NULL,mode);
+ else
+ end_ptr=EncodeOpcode(buffer,"FST",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ break;
+ case AV_IREG:
+ reg=dst->reg->code;
+ end:
+ IPopR(jit,reg);
+ return;
+ case AV_FFRAME:
+ base=BASEREG_CODE;
+ offset=dst->f_offset;
+ i:
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,8);
+ if(pop)
+ end_ptr=EncodeOpcode(buffer,"FSTP",NULL,NULL,NULL,NULL,mode);
+ else
+ end_ptr=EncodeOpcode(buffer,"FST",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ break;
+ case AV_FINDIR:
+ base=dst->reg->code;
+ offset=dst->offset;
+ goto i;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ offset=dst->offset;
+ goto ii;
+ case AV_IINDIR:
+ base=dst->reg->code;
+ offset=dst->offset;
+ ii:
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,8);
+ if(pop)
+ end_ptr=EncodeOpcode(buffer,"FISTP",NULL,NULL,NULL,NULL,mode);
+ else
+ end_ptr=EncodeOpcode(buffer,"FIST",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ break;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->ireg_shadows+8*dst->vreg;
+ goto ii;
+ case AV_FREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=jit->freg_shadows+8*dst->vreg;
+ goto i;
+ case AV_FVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,dst->vreg);
+ offset=dst->offset;
+ goto i;
+ case AV_UNOCC:
+ //FSTP ST0;
+ JIT_AppendAsmText(jit,"\xDD\xD8",2);
+ break;
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+//Use pop variant
+U0 FPUOp(JIT *jit,CRPN *at,U8 *op,CAsmValue *a,CAsmValue *b) {
+ I64 old_buf_sz=jit->buf_size;
+ I64 pop=0;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2;
+ if(a->type==AV_FREG&&b->type==AV_FREG) {
+ } else if(a->type==AV_FREG) {
+ __X87Push(jit,at,b);
+ } else if(b->type==AV_FREG) {
+ __X87Push(jit,at,a);
+ //FLD ST1
+ JIT_AppendAsmText(jit,"\xD9\xC1",2);
+ pop=1;
+ } else {
+ __X87Push(jit,at,a);
+ __X87Push(jit,at,b);
+ }
+ mode2=X64ModeReg(Str2Reg("ST0"));
+ mode=X64ModeReg(Str2Reg("ST1"));
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode,mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ while(--pop>=0)
+ JIT_AppendAsmText(jit,"\xDD\xD9",2); //FSTP ST1
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 FPRemOp(JIT *jit,CRPN *at,CAsmValue *a,CAsmValue *b) {
+ I64 old_buf_sz=jit->buf_size;
+ I64 pop=0;
+ if(a->type==AV_FREG&&b->type==AV_FREG) {
+ } else if(a->type==AV_FREG) {
+ __X87Push(jit,at,b);
+ } else if(b->type==AV_FREG) {
+ __X87Push(jit,at,a);
+ //FLD ST1
+ JIT_AppendAsmText(jit,"\xD9\xC1",2);
+ pop=2;
+ } else {
+ __X87Push(jit,at,a);
+ __X87Push(jit,at,b);
+ pop=1;
+ }
+ JIT_AppendAsmText(jit,"\xD9\xF8",2); //FPREM;
+ while(--pop>=0)
+ JIT_AppendAsmText(jit,"\xDD\xD9",2); //FSTP ST1
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+
+U0 FuncCall(JIT *jit,CRPN *at,CAsmValue *func,CAsmValue *ret,I64 argc,CRPN **argv) {
+ I64 idx,v,p,old_buf_sz=jit->buf_size,creg;
+ CAsmValue dummy;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2;
+ U8 *ikeep[]={
+ "RSI",
+ "RDI",
+ "R10",
+ "R11",
+ "R12",
+ "R13",
+ "R14",
+ "R15",
+ };
+ //We push the call address to the stack,and use RET to pop the stack and jump to its location
+ switch(func->type) {
+ default:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,&dummy,func,FALSE);
+ mode=X64ModeReg(Str2Reg("RAX"));
+ break;
+ case AV_VIREG:
+ creg=RMapGetPhysicalReg(at->r_map,func->vreg);
+ mode=X64ModeReg(IRegCodeToReg(creg));
+ break;
+ case AV_IREG:
+ mode=X64ModeReg(func->reg);
+ break;
+ case AV_IVINDIR:
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(RMapGetPhysicalReg(at->r_map,func->vreg)),func->offset,8);
+ break;
+ case AV_IINDIR:
+ mode=X64ModeMem(NULL,0,NULL,func->reg,func->offset,8);
+ }
+ end_ptr=EncodeOpcode(buffer,"CALL",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode);
+ if(argc>at->type.vargs_base) {
+ mode=X64ModeReg(Str2Reg("RSP"));
+ mode2=X64ModeImm((argc-at->type.vargs_base)*8);
+ end_ptr=EncodeOpcode(buffer,"ADD",NULL,NULL,NULL,NULL,mode,mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ }
+ //If we call using a non caller saved register,unspill it after we call the function as its value is discarded
+ switch(func->type) {
+ case AV_IVINDIR:
+ case AV_VIREG:
+ if(Bt(at->live_out,func->vreg)) {
+ creg=RMapGetPhysicalReg(at->r_map,func->vreg);
+ if(!IsCallerSaved(IRegCodeToReg(creg)))
+ IMovRInd(jit,creg,BASEREG_CODE,8*func->vreg+jit->ireg_shadows,8,FALSE);
+ }
+ }
+ switch(ret->type) {
+ case AV_FREG_SHADOW:
+ IMovIndR(jit,BASEREG_CODE,jit->freg_shadows+8*ret->vreg,0,8); //0 is RAX's code
+ break;
+ case AV_FREG:
+ rfr:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ Push(jit,at,"PUSH",&dummy);
+ dummy.type=AV_FINDIR;
+ dummy.offset=0;
+ dummy.size=8;
+ dummy.reg=Str2Reg("RSP");
+ __X87Push(jit,at,&dummy);
+ __FMov(jit,at,ret,FALSE);
+ //ADD RSP,8
+ JIT_AppendAsmText(jit,"\x48\x83\xC4\x08",4);
+ break;
+ default:;
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,at,ret,&dummy,FALSE);
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 FBinaryOp(JIT *jit,CRPN *at,U8 *op,CAsmValue *a,CAsmValue *b) {
+ CAsmValue dummy,dummy2;
+ I64 old_buf_sz=jit->buf_size;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2;
+ //AssignX87Regs will mark binop args as popped if both are regs,so pop
+ if(a->type==AV_FREG&&b->type==AV_FREG) {
+ //SUB RSP,16
+ //FSTP F64 [RSP+8]
+ //FSTP F64 [RSP]
+ JIT_AppendAsmText(jit,"\x48\x83\xEC\x10\xDD\x5C\x24\x08\xDD\x1C\x24",8+3);
+ } else {
+ switch(a->type) {
+ default:
+ Push(jit,at,"PUSH",a);
+ break;
+ case AV_INT:
+ case AV_VIREG:
+ case AV_IREG:
+ case AV_IFRAME:
+ case AV_IINDIR:
+ case AV_IVINDIR:
+ case AV_IREG_SHADOW:
+ __X87Push(jit,at,a);
+ dummy.type=AV_FREG;
+ Push(jit,at,"PUSH",&dummy);
+ }
+ switch(b->type) {
+ default:
+ Push(jit,at,"PUSH",b);
+ break;
+ case AV_INT:
+ case AV_IREG:
+ case AV_VIREG:
+ case AV_IFRAME:
+ case AV_IINDIR:
+ case AV_IVINDIR:
+ case AV_IREG_SHADOW:
+ __X87Push(jit,at,b);
+ dummy.type=AV_FREG;
+ Push(jit,at,"PUSH",&dummy);
+ }
+
+ }
+ //MOV RAX,I64[RSP+8]
+ JIT_AppendAsmText(jit,"\x48\x8B\x44\x24\x08",5);
+ mode=X64ModeMem(NULL,0,NULL,Str2Reg("RSP"),0,8);
+ mode2=X64ModeReg(Str2Reg("RAX"));
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ //FLD I64 [RSP];
+ //ADD RSP,16;
+ JIT_AppendAsmText(jit,"\xDD\x04\x24\x48\x83\xC4\x10",3+4);
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 ShiftOp(JIT *jit,CRPN *at,U8 *op,CAsmValue *dst,CAsmValue *src,CAsmValue *shift,Bool unsigned=FALSE) {
+ CAsmValue dummy,dst2,dummy2;
+ I64 reg,base,offset,p,bits,old_buf_sz=jit->buf_size;
+ CReg *tmp_reg;
+ Bool pop=FALSE;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2;
+ if(src->type==AV_FREG&&shift->type==AV_FREG) {
+ if(IRegIsAliveAfter(at,Str2Reg("RDX")))
+ IPushR(jit,Str2Reg("RDX")->code);
+ //SUB RSP,16
+ //FSTP QWORD PTR [RSP+8]
+ //FISTP QWORD PTR [RSP]
+ JIT_AppendAsmText(jit,"\x48\x83\xEC\x10\xDD\x5C\x24\x08\xDF\x3C\x24",8+3);
+ dummy.type=AV_IINDIR;
+ dummy.size=8;
+ dummy.reg=Str2Reg("RDX");
+ dummy.offset=8;
+ dummy2.type=AV_IINDIR;
+ dummy2.size=8;
+ dummy2.reg=Str2Reg("RDX");
+ dummy2.offset=0;
+ ShiftOp(jit,at,op,&dummy2,&dummy,&dummy2);
+ //FLD QWORD PTR [RSP]
+ //ADD RSP,16
+ JIT_AppendAsmText(jit,"\xDD\x04\x24\x48\x83\xC4\x10",3+4);
+ if(IRegIsAliveAfter(at,Str2Reg("RDX")))
+ IPopR(jit,Str2Reg("RDX")->code);
+ return;
+ }
+ switch(dst->type) {
+ case AV_FREG:
+ pop=TRUE;
+ case AV_PUSH:
+ push:
+ Push(jit,at,"PUSH",src);
+ dst2.type=AV_IINDIR;
+ dst2.offset=0;
+ dst2.reg=Str2Reg("RSP");
+ dst2.size=8;
+ break;
+ default:
+ if(AsmValueEqual(dst,shift)) {
+ pop=TRUE;
+ goto push;
+ }
+ IMov(jit,at,dst,src,unsigned);
+ dst2=*dst;
+ }
+ if(shift->type==AV_INT||shift->type==AV_FLT) {
+ if(shift->type==AV_INT) bits=shift->int;
+ else bits=shift->flt;
+ switch(dst2.type) {
+ case AV_IREG:
+ reg=dst2.reg->code;
+ r0:
+ mode=X64ModeReg(IRegCodeToReg(reg));
+ mode2=X64ModeImm(bits);
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,dst2.vreg);
+ goto r0;
+ case AV_IFRAME:
+ case AV_FFRAME:
+ base=BASEREG_CODE;
+ offset=dst2.f_offset;
+ i0:
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,dst2.size);
+ mode2=X64ModeImm(bits);
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,dst2.vreg);
+ offset=dst2.offset;
+ goto i0;
+ break;
+ case AV_IINDIR:
+ case AV_FINDIR:
+ base=dst2.reg->code;
+ offset=dst2.offset;
+ goto i0;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=dst2.f_offset;
+ goto i0;
+ case AV_FREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=dst2.f_offset;
+ goto i0;
+ }
+ } else {
+ switch(dst2.type) {
+ case AV_IREG:
+ reg=dst2.reg->code;
+ r:
+ if(reg==Str2Reg("RCX")->code) {
+ IPushR(jit,Str2Reg("RCX")->code);
+ pop=TRUE;
+ goto i;
+ }
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RCX");
+ IMov(jit,at,&dummy,shift,unsigned);
+ mode=X64ModeReg(IRegCodeToReg(reg));
+ mode2=X64ModeReg(Str2Reg("CL"));
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case AV_VIREG:
+ reg=RMapGetPhysicalReg(at->r_map,dst2.vreg);
+ goto r;
+ case AV_IFRAME:
+ case AV_FFRAME:
+ base=BASEREG_CODE;
+ offset=dst2.f_offset;
+ i:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RCX");
+ IMov(jit,at,&dummy,shift,unsigned);
+ mode=X64ModeMem(NULL,0,NULL,IRegCodeToReg(base),offset,dst2.size);
+ mode2=X64ModeReg(Str2Reg("CL"));
+ end_ptr=EncodeOpcode(buffer,op,NULL,NULL,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ break;
+ case AV_IVINDIR:
+ base=RMapGetPhysicalReg(at->r_map,dst2.vreg);
+ offset=dst2.offset;
+ goto i;
+ case AV_IINDIR:
+ case AV_FINDIR:
+ base=dst2.reg->code;
+ offset=dst2.offset;
+ goto i;
+ case AV_IREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=dst2.f_offset;
+ goto i;
+ case AV_FREG_SHADOW:
+ base=BASEREG_CODE;
+ offset=dst2.f_offset;
+ goto i;
+ }
+ }
+ if(pop) {
+ Pop(jit,at,"POP",dst);
+ }
+ #ifdef JIT_DBG
+ if(old_buf_sz==jit->buf_size) {
+ "NOTHING EMITED AT %d\n",at->type.code;
+ }
+ #endif
+}
+U0 Patch32(JIT *jit,I64 from,I64 to) {
+ (jit->buffer+from)(U32*)[0]=to-(from+4);
+}
+Bool IsControlNode(CRPN *item) {
+ return IsRPNUnop(item)
+ ||IsRPNBinop(item)
+ ||item->type.code==OP_CALL
+ ||item->type.code==OP_RELOCATION
+ ||item->type.code==OP_IF
+ ||item->type.code==OP_JMP
+ ||item->type.code==OP_RETURN
+ ||item->type.code==OP_JMP_TABLE;
+}
+//TODO document
+CRPN *GetRPNEnterLabel(CRPN *item) {
+ if(!item) return item;
+ I64 iter;
+ CRPN *last;
+ if(IsControlNode(item)) {
+ if(item->type.code==OP_CALL) {
+ last=item;
+ item=item->next;
+ for(iter=0;iter!=last->type.body_length+1;iter++) {
+ if(IsControlNode(item)||item->type.code==OP_INPLACE_PUSH) {
+ return GetRPNEnterLabel(item);
+ }
+ item=ComputeRPNSuccessor(item);
+ }
+ return last;
+ }
+ if((IsRPNBinop(item)||IsRPNUnop(item)||item->type.code==OP_IF||item->type.code==OP_RETURN)&&(IsControlNode(item->next)||item->next->type.code==OP_BODY))
+ return GetRPNEnterLabel(item->next);
+ if(IsRPNBinop(item)&&(IsControlNode(last=ComputeRPNSuccessor(item->next))||last->type.code==OP_BODY))
+ return GetRPNEnterLabel(last);
+ }
+ return item;
+}
+U0 JIT_DebuggerHit(U0 *,U0 *,U0 *);
+I64 JTabCmp(I64 a,I64 b) {
+ return a-b;
+}
+U0 CreateJmpTableTrampolines(JIT *jit,CRPN *j) {
+ CVector *unique=VectorNew;
+ U8 pad[8];
+ X64Mode *mode;
+ U8 buffer[32],*end_ptr;
+ CRPN **sorted=MAlloc(sizeof(CRPN*)*j->type.body_length),*prev;
+ I64 iter,table_start,dptr,iter2;
+ MemCpy(sorted,j->jmp_table,MSize(sorted));
+ QSortI64(sorted,j->type.body_length,&JTabCmp);
+ prev=NULL;
+ for(iter=0;iter!=j->type.body_length;iter++) {
+ if(prev!=sorted[iter]) {
+ prev=sorted[iter];
+ //CRPN *dst
+ VectorPush(unique,sorted[iter]);
+ //I64 patch_addr (fill later)
+ VectorPush(unique,0);
+ }
+ }
+ Free(sorted);
+ table_start=jit->buf_size;
+ for(iter=0;iter!=j->type.body_length;iter++) {
+ JIT_AppendAsmText(jit,pad,8);
+ }
+ mode=X64ModeLabel(NULL);
+ for(iter=0;iter!=unique->size;iter+=2) {
+ for(iter2=0;iter2!=j->type.body_length;iter2++) {
+ dptr=table_start+iter2*8;
+ if(j->jmp_table[iter2]==unique->data[iter](CRPN*))
+ (jit->buffer+dptr)(U64*)[0]=jit->buf_size-dptr;
+ }
+ RMapSync(jit,GetRPNEnterLabel(unique->data[iter](CRPN*)),j);
+ end_ptr=EncodeOpcode(buffer,"JMP",NULL,NULL,NULL,NULL,mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ JIT_AppendAsmText(jit,"\x44\x33\x22\x11",4);
+ unique->data[iter+1]=jit->buf_size-4; //The jmp address
+ }
+ X64ModeFree(mode);
+ j->jmp_table_trampolines=unique;
+}
+I64 CompileOps(JIT *jit,CVector *flat,I64 st=0,CRPN *stop_at=NULL) {
+ CAsmValue dummy,dummy2,*dummy_p;
+ Bool unsigned=FALSE;
+ CRPN *cur,*el,*exit,*prev,**args,*true,*jmp_to;
+ U8 *cond_op,*exit_lab,*jmp_lab,*pad;
+ I64 iter,iter2,lab_t_off,lab_f_off,lab_end_off,stack_adj,idx,idx2;
+ CReg *avail_reg;
+ U8 buffer[32],*end_ptr;
+ X64Mode *mode,*mode2;
+ Bool pop;
+ for(iter=st;iter!=flat->size&&flat->data[iter]!=stop_at;) {
+ cur=flat->data[iter];
+ cur->bin_off=jit->buf_size;
+ for(idx=0;idx!=cur->spills->size;idx+=2) {
+ IMovIndR(jit,BASEREG_CODE,jit->ireg_shadows+cur->spills->data[idx]*8,cur->spills->data[idx+1]);
+ }
+ for(idx=0;idx!=cur->unspills->size;idx+=2) {
+ idx2=cur->unspills->data[idx];
+ IMovRInd(jit,cur->unspills->data[idx+1],BASEREG_CODE,jit->ireg_shadows+idx2*8,,FALSE);
+ }
+ if(cur->flags&RPN_F_IMPLICIT_OPERATION) {
+ iter++;
+ goto next;
+ }
+ jit->fpu_stk_offset=0;
+ if(!cur->type.is_flt) {
+ unsigned=!cur->type.is_signed;
+ switch(cur->type.code) {
+ case OP_JMP_TABLE:
+ if(avail_reg=__JIT_GetFreeIReg(jit,cur)) {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,cur,&dummy,&cur->next->my_avalue,TRUE);
+ //SHL RAX,3(mul by 8)
+ JIT_AppendAsmText(jit,"\x48\xC1\xE0\x03",4);
+ mode=X64ModeReg(avail_reg);
+ mode2=X64ModeMem(NULL,0,NULL,Str2Reg("RIP"),0x11223344,8);
+ end_ptr=EncodeOpcode(buffer,"LEA",NULL,&cur->patch_addr,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ cur->patch_addr+=jit->buf_size-4; //-4 ignores sib size
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ mode=X64ModeReg(Str2Reg("RAX"));
+ mode2=X64ModeReg(avail_reg);
+ end_ptr=EncodeOpcode(buffer,"ADD",NULL,NULL,NULL,NULL,mode,mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ } else {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,cur,&dummy,&cur->next->my_avalue,TRUE);
+ //SHL RAX,3(mul by 8)
+ JIT_AppendAsmText(jit,"\x48\xC1\xE0\x03",4);
+ IPushR(jit,1);
+ mode=X64ModeReg(IRegCodeToReg(1));
+ mode2=X64ModeMem(NULL,0,NULL,Str2Reg("RIP"),0x11223344,8);
+ end_ptr=EncodeOpcode(buffer,"LEA",NULL,&cur->patch_addr,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ cur->patch_addr+=jit->buf_size-4; //-4 ignores sib size
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ mode=X64ModeReg(Str2Reg("RAX"));
+ mode2=X64ModeReg(IRegCodeToReg(1));
+ end_ptr=EncodeOpcode(buffer,"ADD",NULL,NULL,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ IPopR(jit,1);
+ }
+ //ADD RAX,[RAX]
+ //JMP RAX
+ JIT_AppendAsmText(jit,"\x48\x03\x00",3);
+ JIT_AppendAsmText(jit,"\xFF\xE0",2);
+ Patch32(jit,cur->patch_addr,jit->buf_size);
+ cur->patch_addr=jit->buf_size;
+ CreateJmpTableTrampolines(jit,cur);
+ break;
+ case OP_BREAKPOINT:
+ idx=Str2Reg("RAX")->code;
+ IMovRI(jit,idx,cur->operands[0](I64));
+ IPushR(jit,idx);
+ IMovRI(jit,idx,cur->operands[1](I64));
+ IPushR(jit,idx);
+ IMovRI(jit,idx,cur->operands[2](I64));
+ IPushR(jit,idx);
+ IMovRI(jit,idx,&JIT_DebuggerHit);
+ //CALL RAX
+ //ADD RSP,0x18
+ JIT_AppendAsmText(jit,"\xFF\xD0\x48\x83\xC4\x18",2+4);
+ break;
+ case OP_DEREF:
+ //
+ // // |\ //
+ // || || ||
+ // ___________
+ // (_ _)
+ // | O O |
+ // | . |
+ // | _____ |
+ // \ \___/ /
+ // \_____/
+ //
+ // I am frypot,dont let crowdude eat my fries
+ // Also know that OP_DEREF may be a implicit operation
+ if(cur->operands[0]->type==AV_IREG) {
+ dummy.type=AV_IINDIR;
+ dummy.reg=cur->operands[0]->reg;
+ dummy.offset=cur->operands[1](I64);
+ dummy.size=cur->operands[2](I64);
+ IMov(jit,cur,&cur->my_avalue,&dummy,!cur->type.is_signed);
+ } else if(cur->operands[0]->type==AV_VIREG) {
+ dummy.type=AV_IVINDIR;
+ dummy.vreg=cur->operands[0]->vreg;
+ dummy.offset=cur->operands[1](I64);
+ dummy.size=cur->operands[2](I64);
+ IMov(jit,cur,&cur->my_avalue,&dummy,!cur->type.is_signed);
+ } else {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,cur,&dummy,cur->operands[0],!cur->type.is_signed);
+ dummy.offset=0;
+ dummy.type=AV_IINDIR;
+ dummy.size=cur->operands[2](I64);
+ IMov(jit,cur,&cur->my_avalue,&dummy,!cur->type.is_signed);
+ }
+ break;
+ case OP_TYPECAST_BIT4BIT:
+ if(cur->next->type.is_flt) {
+ Push(jit,cur,"PUSH",cur->operands[0]);
+ if(cur->my_avalue.type!=AV_PUSH)
+ Pop(jit,cur,"POP",&cur->my_avalue);
+ } else
+ IMov(jit,cur,&cur->my_avalue,cur->operands[0],!cur->type.is_signed);
+ break;
+ case OP_VARIABLE:
+ break;
+ case OP_INPLACE_PUSH:
+ Push(jit,cur,"PUSH",&cur->my_avalue);
+ break;
+ case OP_BODY: //Accounted for with flattended
+ case OP_LITERAL:
+ break;
+ case OP_ALIGN:
+ //https://en.wikipedia.org/wiki/Data_structure_alignment
+ pad=MAlloc((jit->buf_size-(jit->buf_size%cur->operands[0]))%cur->operands[0]);
+ MemSet(pad,cur->operands[1],MSize(pad));
+ JIT_AppendAsmText(jit,pad,MSize(pad));
+ Free(pad);
+ break;
+ case OP_REF_DATA:
+ if(cur->my_avalue.type==AV_IREG) {
+ mode=X64ModeReg(cur->my_avalue.reg);
+ mode2=X64ModeMem(NULL,0,NULL,Str2Reg("RIP"),0x11223344,8);
+ end_ptr=EncodeOpcode(buffer,"LEA",NULL,&cur->patch_addr,NULL,NULL,mode,mode2);
+ cur->patch_addr+=jit->buf_size-4; //-4 ignores sib size
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ } else if(cur->my_avalue.type==AV_VIREG) {
+ mode=X64ModeReg(IRegCodeToReg(RMapGetPhysicalReg(cur->r_map,cur->my_avalue.vreg)));
+ mode2=X64ModeMem(NULL,0,NULL,Str2Reg("RIP"),0x11223344,8);
+ end_ptr=EncodeOpcode(buffer,"LEA",NULL,&cur->patch_addr,NULL,NULL,mode,mode2);
+ cur->patch_addr+=jit->buf_size-4; //-4 ignores sib size
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ } else {
+ mode=X64ModeReg(Str2Reg("RAX"));
+ mode2=X64ModeMem(NULL,0,NULL,Str2Reg("RIP"),0x11223344,8);
+ end_ptr=EncodeOpcode(buffer,"LEA",NULL,&cur->patch_addr,NULL,NULL,mode,mode2);
+ cur->patch_addr+=jit->buf_size-4; //-4 ignores sib size
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,cur,&cur->my_avalue,&dummy,!cur->type.is_signed);
+ }
+ break;
+ case OP_DU8:
+ JIT_AppendAsmText(jit,&cur->operands[0],1);
+ break;
+ case OP_DU16:
+ JIT_AppendAsmText(jit,&cur->operands[0],2);
+ break;
+ case OP_DU32:
+ JIT_AppendAsmText(jit,&cur->operands[0],4);
+ break;
+ case OP_DU64:
+ JIT_AppendAsmText(jit,&cur->operands[0],8);
+ break;
+ /*if(1) {
+ JIT_AppendAsmText(jit,"//INT: ");
+ for(iter2=0;iter2!=cur->r_map->size;iter2+=2) {
+ JIT_AppendAsmText(jit,"%d=%s,",cur->r_map->data[iter2],IRegCodeToStr(cur->r_map->data[iter2+1]));
+ }
+ JIT_AppendAsmText(jit,"\n");
+ }*/
+ case OP_RELOCATION:
+ //TODO fill in later
+ if(cur->my_avalue.type==AV_IREG)
+ mode=X64ModeReg(cur->my_avalue.reg);
+ else if(cur->my_avalue.type==AV_VIREG)
+ mode=X64ModeReg(IRegCodeToReg(RMapGetPhysicalReg(cur->r_map,cur->my_avalue.vreg)));
+ else
+ mode=X64ModeReg(Str2Reg("RAX"));
+ if(!mode->reg) {
+ "%p,%p,%p\n",&cur->r_map,cur->r_map->cap,cur->r_map->size;
+ }
+ mode2=X64ModeImm(0x1122334455);
+ end_ptr=EncodeOpcode(buffer,"MOV",NULL,NULL,&cur->patch_addr,NULL,mode,mode2);
+ cur->patch_addr+=jit->buf_size;
+ X64ModeFree(mode),X64ModeFree(mode2);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ if(cur->my_avalue.type!=AV_IREG&&cur->my_avalue.type!=AV_VIREG) {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,cur,&cur->my_avalue,&dummy,!cur->type.is_signed);
+ }
+ break;
+ start:
+ case OP_ASSIGN_ADD:
+ IArithOp(jit,cur,"ADD",cur->operands[0],cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_ASSIGN_SUB:
+ IArithOp(jit,cur,"SUB",cur->operands[0],cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_ASSIGN_SHL:
+ ShiftOp(jit,cur,"SHL",cur->operands[0],cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_SHR:
+ ShiftOp(jit,cur,"SHR",cur->operands[0],cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_AND:
+ IArithOp(jit,cur,"AND",cur->operands[0],cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_ASSIGN_XOR:
+ IArithOp(jit,cur,"XOR",cur->operands[0],cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_ASSIGN_OR:
+ IArithOp(jit,cur,"OR",cur->operands[0],cur->operands[0],cur->operands[1],unsigned);
+ end:
+ IMov(jit,cur,&cur->my_avalue,cur->operands[0],unsigned);
+ break;
+ case OP_CALL:
+ FuncCall(jit,cur,&GetCallFunction(cur)->my_avalue,&cur->my_avalue,cur->type.body_length,NULL);
+ break;
+ case OP_RETURN:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,cur,&dummy,cur->operands[0],!cur->type.is_signed);
+ mode=X64ModeLabel(NULL);
+ end_ptr=EncodeOpcode(buffer,"JMP",NULL,NULL,NULL,NULL,mode);
+ X64ModeFree(mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ cur->patch_addr=jit->buf_size;
+ JIT_AppendAsmText(jit,"\x00\x00\x00\x00",4);
+ break;
+ case OP_COMMA:
+ IMov(jit,cur,&cur->my_avalue,cur->operands[1],unsigned);
+ if(cur->operands[0]->type==AV_FREG) {
+ //FSTP ST0
+ JIT_AppendAsmText(jit,"\xDD\xD8",2);
+ }
+ break;
+ case OP_NE:
+ ICmpOp(jit,cur,"SETNE",&cur->my_avalue,cur->operands[0],cur->operands[1]);
+ break;
+ case OP_EQ:
+ ICmpOp(jit,cur,"SETE",&cur->my_avalue,cur->operands[0],cur->operands[1]);
+ break;
+ case OP_NOT:
+ IArithUnop(jit,cur,"NOT",&cur->my_avalue,cur->operands[0]);
+ break;
+ case OP_GETARG:
+ dummy.type=AV_IFRAME;
+ dummy.reg=Str2Reg("RBP");
+ //
+ // Stack
+ //
+ // ARGN
+ // ...
+ // ARG0
+ // RET_PTR
+ // OLD_RBP<--RBP
+ dummy.f_offset=2*8+8*cur->operands[0]->int;
+ IMov(jit,cur,&cur->my_avalue,&dummy,!cur->type.is_signed);
+ break;
+ case OP_IF:
+ //Assign to label to the else conditon
+ //Skip conditon then body
+ true=GetRPNEnterLabel(ComputeRPNSuccessor(cur->next));
+ el=GetRPNEnterLabel(ComputeRPNSuccessor(ComputeRPNSuccessor(cur->next)));
+ exit=GetRPNEnterLabel(ComputeRPNSuccessor(cur));
+ //Check for compare-style operand,use a sassy conditional-style jump
+ //SEE Potato Drop
+ cond_op=NULL;
+ switch(cur->next->type.code) {
+ case OP_EQ:
+ cond_op="JE";
+ break;
+ case OP_NE:
+ cond_op="JNE";
+ break;
+ case OP_GT:
+ // ____________
+ // / \ \ X87 items expect unsigned style compares
+ // |.__.| |
+ // | \/ | | - Mr. Noodles
+ // \__/_________/
+ if(!cur->next->type.is_signed||cur->next->type->is_flt)
+ cond_op="JA";
+ else
+ cond_op="JG";
+ break;
+ case OP_LT:
+ if(!cur->next->type.is_signed||cur->next->type->is_flt)
+ cond_op="JB";
+ else
+ cond_op="JL";
+ break;
+ case OP_GE:
+ if(!cur->next->type.is_signed||cur->next->type->is_flt)
+ cond_op="JAE";
+ else
+ cond_op="JGE";
+ break;
+ case OP_LE:
+ if(!cur->next->type.is_signed||cur->next->type->is_flt)
+ cond_op="JBE";
+ else
+ cond_op="JLE";
+ break;
+ default:
+ switch(cur->operands[0]->type) {
+ start:
+ case AV_FREG:
+ break;
+ case AV_FINDIR:
+ case AV_FFRAME:
+ case AV_FREG_SHADOW:
+ __X87Push(jit,cur,cur->operands[0]);
+ break;
+ end:
+ //FLDZ;
+ //FCOMIP ST0,ST1;
+ //FSTP ST0;
+ JIT_AppendAsmText(jit,"\xD9\xEE\xDF\xF1\xDD\xD8",6);
+ break;
+ default:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,cur,&dummy,cur->operands[0],!cur->type.is_signed);
+ //CMP RAX,0
+ JIT_AppendAsmText(jit,"\x48\x83\xF8\x00",4);
+ }
+ cond_op="JNZ";
+ }
+ //Jcc TRUE
+ mode=X64ModeLabel(NULL);
+ end_ptr=EncodeOpcode(buffer,cond_op,NULL,NULL,NULL,NULL,mode);
+ //Jump opcodes leave an area after to write our jmp offset
+ lab_t_off=jit->buf_size+end_ptr-buffer;
+ X64ModeFree(mode);
+ JIT_AppendAsmText(jit,buffer,4+end_ptr-buffer); //TempleOS uses 4 byte jumps always
+ //
+ //sync(false) & JMP FALSE
+ //
+ RMapSync(jit,el,cur);
+ mode=X64ModeLabel(NULL);
+ end_ptr=EncodeOpcode(buffer,"JMP",NULL,&lab_f_off,NULL,NULL,mode);
+ X64ModeFree(mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ lab_f_off=jit->buf_size;
+ JIT_AppendAsmText(jit,"\x00\x00\x00\x00",4);
+ //
+ //sync(true) & TRUE
+ //
+ Patch32(jit,lab_t_off,jit->buf_size);
+ RMapSync(jit,true,cur);
+ iter=CompileOps(jit,flat,iter+1,el);
+ //
+ //sync(exit) & Jump to end
+ //
+ if(exit)
+ RMapSync(jit,exit,flat->data[iter-1]);
+ mode=X64ModeLabel(NULL);
+ end_ptr=EncodeOpcode(buffer,"JMP",NULL,NULL,NULL,NULL,mode);
+ X64ModeFree(mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ lab_end_off=jit->buf_size;
+ JIT_AppendAsmText(jit,"\x00\x00\x00\x00",4);
+ //
+ //FALSE
+ //
+ Patch32(jit,lab_f_off,jit->buf_size);
+ iter=CompileOps(jit,flat,iter,exit);
+ if(flat->data[iter-1]&&exit)
+ RMapSync(jit,exit,flat->data[iter-1]);
+ Patch32(jit,lab_end_off,jit->buf_size);
+ goto next;
+ case OP_JMP:
+ mode=X64ModeLabel(NULL);
+ RMapSync(jit,GetRPNEnterLabel(cur->operands[0]),cur);
+ end_ptr=EncodeOpcode(buffer,"JMP",NULL,&cur->patch_addr,NULL,NULL,mode);
+ X64ModeFree(mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ cur->patch_addr=jit->buf_size;
+ JIT_AppendAsmText(jit,"\x00\x00\x00\x00",4);
+ break;
+ case OP_ADD:
+ IArithOp(jit,cur,"ADD",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_SUB:
+ IArithOp(jit,cur,"SUB",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ //These ones are special
+ start:
+ stack_adj=0;
+ // _ _ ____________________________________
+ // <*> <*> / \
+ // \\ // | SPILL RDX BEFOREHAND IN JitEmitCode |
+ // \\______// | See UnspillIReg |
+ // | _____ | | ____________________________________/
+ // / \___/ \ <==/
+ // /___________\
+ //
+ // Snailnelious
+ div:
+ case OP_DIV:
+ __Div(jit,cur,"IDIV",cur->operands[0],cur->operands[1]);
+ dummy2.type=AV_IREG;
+ dummy2.reg=Str2Reg("RAX");
+ IMov(jit,cur,&cur->my_avalue,&dummy2,unsigned);
+ break;
+ case OP_ASSIGN_DIV:
+ __Div(jit,cur,"IDIV",cur->operands[0],cur->operands[1]);
+ dummy2.type=AV_IREG;
+ dummy2.reg=Str2Reg("RAX");
+ IMov(jit,cur,cur->operands[0],&dummy2,unsigned);
+ break;
+ case OP_ASSIGN_MOD:
+ __Div(jit,cur,"IDIV",cur->operands[0],cur->operands[1]);
+ dummy2.type=AV_IREG;
+ dummy2.reg=Str2Reg("RDX");
+ IMov(jit,cur,cur->operands[0],&dummy2,unsigned);
+ break;
+ case OP_MOD:
+ __Div(jit,cur,"IDIV",cur->operands[0],cur->operands[1]);
+ dummy2.type=AV_IREG;
+ dummy2.reg=Str2Reg("RDX");
+ IMov(jit,cur,&cur->my_avalue,&dummy2,unsigned);
+ break;
+ case OP_ASSIGN_MUL:
+ __Div(jit,cur,"IMUL",cur->operands[0],cur->operands[1]);
+ dummy2.type=AV_IREG;
+ dummy2.reg=Str2Reg("RAX");
+ IMov(jit,cur,cur->operands[0],&dummy2,unsigned);
+ break;
+ case OP_MUL:
+ __Div(jit,cur,"IMUL",cur->operands[0],cur->operands[1]);
+ dummy2.type=AV_IREG;
+ dummy2.reg=Str2Reg("RAX");
+ end:
+ IMov(jit,cur,&cur->my_avalue,&dummy2,unsigned);
+ break;
+ case OP_SHL:
+ ShiftOp(jit,cur,"SHL",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_SHR:
+ if(unsigned)
+ ShiftOp(jit,cur,"SHR",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ else
+ ShiftOp(jit,cur,"SAR",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_AND:
+ IArithOp(jit,cur,"AND",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_OR:
+ IArithOp(jit,cur,"OR",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_XOR:
+ IArithOp(jit,cur,"XOR",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_POS:
+ pos:
+ IMov(jit,cur,&cur->my_avalue,cur->operands[0],unsigned);
+ break;
+ case OP_NEG:
+ IArithUnop(jit,cur,"NEG",&cur->my_avalue,cur->operands[0],unsigned);
+ break;
+
+ case OP_GT:
+ if(!unsigned)
+ ICmpOp(jit,cur,"SETG",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ else
+ ICmpOp(jit,cur,"SETA",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_LT:
+ if(!unsigned)
+ ICmpOp(jit,cur,"SETL",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ else
+ ICmpOp(jit,cur,"SETB",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_GE:
+ if(!unsigned)
+ ICmpOp(jit,cur,"SETGE",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ else
+ ICmpOp(jit,cur,"SETAE",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ case OP_LE:
+ if(!unsigned)
+ ICmpOp(jit,cur,"SETLE",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ else
+ ICmpOp(jit,cur,"SETBE",&cur->my_avalue,cur->operands[0],cur->operands[1],unsigned);
+ break;
+ start:
+ Push(jit,cur,"PUSH",cur->operands[0]);
+ case OP_POST_INC:
+ if(cur->operands[1](I64)==1)
+ IIncOp(jit, cur,"INC",cur->operands[0],unsigned);
+ else {
+ dummy2.type=AV_INT;
+ dummy2.int=cur->operands[1](I64);
+ IArithOp(jit,cur,"ADD",cur->operands[0],cur->operands[0],&dummy2,unsigned);
+ }
+ break;
+ case OP_POST_DEC:
+ if(cur->operands[1](I64)==1)
+ IIncOp(jit,cur,"DEC",cur->operands[0],unsigned);
+ else {
+ dummy2.type=AV_INT;
+ dummy2.int=cur->operands[1](I64);
+ IArithOp(jit,cur,"SUB",cur->operands[0],cur->operands[0],&dummy2,unsigned);
+ }
+ end:
+ Pop(jit,cur,"POP",&cur->my_avalue);
+ break;
+ case OP_PRE_INC:
+ if(cur->operands[1](I64)==1)
+ IIncOp(jit,cur,"INC",cur->operands[0],unsigned);
+ else {
+ dummy.type=AV_INT;
+ dummy.int=cur->operands[1](I64);
+ IArithOp(jit,cur,"ADD",cur->operands[0],cur->operands[0],&dummy,unsigned);
+ }
+ IMov(jit,cur,&cur->my_avalue,cur->operands[0],unsigned);
+ break;
+ case OP_PRE_DEC:
+ if(cur->operands[1](I64)==1)
+ IIncOp(jit,cur,"DEC",cur->operands[0],unsigned);
+ else {
+ dummy.type=AV_INT;
+ dummy.int=cur->operands[1](I64);
+ IArithOp(jit,cur,"SUB",cur->operands[0],cur->operands[0],&dummy,unsigned);
+ }
+ IMov(jit,cur,&cur->my_avalue,cur->operands[0],unsigned);
+ break;
+ case OP_ASSIGN:
+ if(cur->flags&RPN_F_BIG_MOVE) {
+ BigMove(jit,cur,cur->operands[0],cur->operands[1]);
+ if(cur->my_avalue.type!=AV_UNOCC)
+ BigMove(jit,cur,&cur->my_avalue,cur->operands[0]);
+ break;
+ }
+ IMov(jit,cur,cur->operands[0],cur->operands[1],unsigned);
+ if(cur->my_avalue.type!=AV_UNOCC)
+ IMov(jit,cur,&cur->my_avalue,cur->operands[0],unsigned);
+ case OP_DUMP_PTR:
+ break;
+ default:
+ "UNIMPI:%d\n",cur->type.code;
+ break;
+ }
+ } else if(cur->type.is_flt) {
+ switch(cur->type.code) {
+ case OP_DEREF:
+ //See frypot
+ //TODO non fpu pass if not directed to a x87 reg
+ if(cur->operands[0]->type==AV_VIREG) {
+ dummy.type=AV_FVINDIR;
+ dummy.vreg=cur->operands[0].vreg;
+ dummy.offset=cur->operands[1](I64);
+ __X87Push(jit,cur,&dummy);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ } else if(cur->operands[0]->type==AV_IREG) {
+ dummy.type=AV_FINDIR;
+ dummy.reg=cur->operands[0]->reg;
+ dummy.offset=cur->operands[1](I64);
+ __X87Push(jit,cur,&dummy);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ } else {
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ IMov(jit,cur,&dummy,cur->operands[0],!cur->type.is_signed);
+ dummy.offset=cur->operands[1](I64);
+ dummy.type=AV_FINDIR;
+ __X87Push(jit,cur,&dummy);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ }
+ break;
+ case OP_INPLACE_PUSH:
+ Push(jit,cur,"PUSH",&cur->my_avalue);
+ break;
+ case OP_REF_DATA:
+ //TODO test
+ mode=X64ModeReg(Str2Reg("RAX"));
+ mode2=X64ModeMem(NULL,0,NULL,Str2Reg("RIP"),0x11223344);
+ end_ptr=EncodeOpcode(buffer,"LEA",NULL,&cur->patch_addr,NULL,NULL,mode,mode2);
+ X64ModeFree(mode),X64ModeFree(mode2);
+ cur->patch_addr+=jit->buf_size-4; //-4 ignores sib size
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ IMov(jit,cur,&cur->my_avalue,&dummy,!cur->type.is_signed);
+ break;
+ case OP_LITERAL:
+ case OP_VARIABLE:
+ break;
+ start:
+ case OP_COMMA:
+ if(cur->operands[1]->type!=AV_FREG)
+ __X87Push(jit,cur,cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ if(cur->operands[0]->type==AV_FREG)
+ //FSTP ST0
+ JIT_AppendAsmText(jit,"\xDD\xD8",2);
+ break;
+ case OP_ASSIGN:
+ if(cur->my_avalue.type!=AV_UNOCC) {
+ // Optimization in AssignX87Regs that will pop if operand is register
+ if(cur->operands[1]->type==AV_FREG) {
+ __FMov(jit,cur,cur->operands[0],FALSE);
+ } else {
+ __X87Push(jit,cur,cur->operands[1]);
+ __FMov(jit,cur,cur->operands[0],FALSE);
+ }
+ if(cur->my_avalue.type!=AV_FREG);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ } else {
+ // Optimization in AssignX87Regs that will pop if operand is register
+ if(cur->operands[1]->type==AV_FREG) {
+ __FMov(jit,cur,cur->operands[0],TRUE);
+ } else {
+ __X87Push(jit,cur,cur->operands[1]);
+ __FMov(jit,cur,cur->operands[0],TRUE);
+ }
+ }
+ break;
+ case OP_RETURN:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RAX");
+ if(cur->operands[0]->type!=AV_FREG)
+ __X87Push(jit,cur,cur->operands[0]);
+ __FMov(jit,cur,&dummy,TRUE);
+ mode=X64ModeLabel(NULL);
+ end_ptr=EncodeOpcode(buffer,"JMP",NULL,&cur->patch_addr,NULL,NULL,mode);
+ X64ModeFree(mode);
+ JIT_AppendAsmText(jit,buffer,end_ptr-buffer);
+ cur->patch_addr=jit->buf_size;
+ JIT_AppendAsmText(jit,"\x00\x00\x00\x00",4);
+ break;
+ case OP_BODY:
+ break;
+ break;
+
+ case OP_GETARG:
+ dummy.type=AV_FFRAME;
+ dummy.reg=Str2Reg("RBP");
+ dummy.size=8;
+ //
+ // Stack
+ //
+ // ARGN
+ // ...
+ // ARG0
+ // RET_PTR
+ // OLD_RBP<--RBP
+ dummy.f_offset=2*8+8*cur->operands[0]->int;
+ __X87Push(jit,cur,&dummy);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+
+ case OP_ADD:
+ FPUOp(jit,cur,"FADDP",cur->operands[0],cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ case OP_SUB:
+ FPUOp(jit,cur,"FSUBP",cur->operands[0],cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ case OP_MUL:
+ FPUOp(jit,cur,"FMULP",cur->operands[0],cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ case OP_DIV:
+ FPUOp(jit,cur,"FDIVP",cur->operands[0],cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ case OP_MOD:
+ //Doesnt pop
+ FPRemOp(jit,cur,cur->operands[0],cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+
+ case OP_SHL:
+ ShiftOp(jit,cur,"SHL",&cur->my_avalue,cur->operands[0],cur->operands[1]);
+ break;
+ case OP_SHR:
+ ShiftOp(jit,cur,"SHR",&cur->my_avalue,cur->operands[0],cur->operands[1]);
+ break;
+ case OP_AND:
+ FBinaryOp(jit,cur,"AND",cur->operands[0],cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ case OP_OR:
+ FBinaryOp(jit,cur,"OR",cur->operands[0],cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ case OP_XOR:
+ FBinaryOp(jit,cur,"XOR",cur->operands[0],cur->operands[1]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ start:
+ case OP_ASSIGN_ADD:
+ FPUOp(jit,cur,"FADDP",cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_SUB:
+ FPUOp(jit,cur,"FSUBP",cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_MUL:
+ FPUOp(jit,cur,"FMULP",cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_DIV:
+ FPUOp(jit,cur,"FDIVP",cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_MOD:
+ FPUOp(jit,cur,"FPREM;\nFSTP ST1",cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_SHL:
+ ShiftOp(jit,cur,"SHL",&cur->operands[0],cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_SHR:
+ ShiftOp(jit,cur,"SAR",&cur->operands[0],cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_AND:
+ FBinaryOp(jit,cur,"ADD",cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_XOR:
+ FBinaryOp(jit,cur,"XOR",cur->operands[0],cur->operands[1]);
+ break;
+ case OP_ASSIGN_OR:
+ FBinaryOp(jit,cur,"OR",cur->operands[0],cur->operands[1]);
+ break;
+ end:
+ if(cur->my_avalue.type==AV_UNOCC) {
+ if(cur->operands[0]->type!=AV_FREG)
+ __FMov(jit,cur,cur->operands[0],TRUE);
+ else
+ //FSTP ST0
+ JIT_AppendAsmText(jit,"\xDD\xD8",2);
+ } else {
+ if(cur->operands[0]->type!=AV_FREG)
+ __FMov(jit,cur,cur->operands[0],FALSE);
+ if(cur->my_avalue.type!=AV_FREG);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ }
+ break;
+ case OP_TYPECAST_BIT4BIT:
+ if(!cur->next->type.is_flt) {
+ Push(jit,cur,"PUSH",cur->operands[0]);
+ if(cur->my_avalue.type!=AV_PUSH)
+ Pop(jit,cur,"POP",&cur->my_avalue);
+ } else {
+ __X87Push(jit,cur,cur->operands[0]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ }
+ break;
+
+ case OP_POS:
+ //See AssignX87Regs as it opitmizes out a push here for unops
+ if(cur->operands[0]->type!=AV_FREG)
+ __X87Push(jit,cur,cur->operands[0]);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ case OP_NOT:
+ if(cur->operands[0]->type!=AV_FREG)
+ __X87Push(jit,cur,cur->operands[0]);
+ dummy.type=AV_FREG;
+ Push(jit,cur,"PUSH",&dummy);
+ //NOT I64 [RSP]
+ JIT_AppendAsmText(jit,"\x48\xF7\x14\x24",4);
+ Pop(jit,cur,"POP",&cur->my_avalue);
+ break;
+
+ case OP_NEG:
+ //See above
+ if(cur->operands[0]->type!=AV_FREG)
+ __X87Push(jit,cur,cur->operands[0]);
+ //FCHS
+ JIT_AppendAsmText(jit,"\xD9\xE0",2);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ start:
+ if(cur->operands[0]->type==AV_FREG&&cur->operands[1]->type==AV_FREG) {
+ //FXCH ST1
+ JIT_AppendAsmText(jit,"\xD9\xC9",2);
+ } else if(cur->operands[0]->type==AV_FREG) {
+ __X87Push(jit,cur,cur->operands[1]);
+ //FXCH ST1
+ JIT_AppendAsmText(jit,"\xD9\xC9",2);
+ } else if(cur->operands[1]->type==AV_FREG) {
+ __X87Push(jit,cur,cur->operands[0]);
+ } else {
+ __X87Push(jit,cur,cur->operands[1]);
+ __X87Push(jit,cur,cur->operands[0]);
+ }
+ //FCOMIP ST,ST1;
+ JIT_AppendAsmText(jit,"\xDF\xF1",2);
+ //FSTP ST0
+ JIT_AppendAsmText(jit,"\xDD\xD8",2);
+ case OP_GT:
+ __SetOnCondOp(jit,cur,"SETA",&cur->my_avalue);
+ break;
+ case OP_LT:
+ __SetOnCondOp(jit,cur,"SETB",&cur->my_avalue);
+ break;
+ case OP_GE:
+ __SetOnCondOp(jit,cur,"SETAE",&cur->my_avalue);
+ break;
+ case OP_LE:
+ __SetOnCondOp(jit,cur,"SETBE",&cur->my_avalue);
+ break;
+ case OP_NE:
+ __SetOnCondOp(jit,cur,"SETNE",&cur->my_avalue);
+ break;
+ case OP_EQ:
+ __SetOnCondOp(jit,cur,"SETE",&cur->my_avalue);
+ break;
+ end:
+ break;
+ start:
+ Push(jit,cur,"PUSH",cur->operands[0]);
+ __X87Push(jit,cur,cur->operands[0]);
+ case OP_POST_INC:
+ //FLD1
+ //FADDP ST1,ST0
+ JIT_AppendAsmText(jit,"\xD9\xE8\xDE\xC1",4);
+ __FMov(jit,cur,cur->operands[0],TRUE);
+ break;
+ case OP_POST_DEC:
+ //FLD1
+ //FSUBP ST1,ST0
+ JIT_AppendAsmText(jit,"\xD9\xE8\xDE\xE9",4);
+ __FMov(jit,cur,cur->operands[0],TRUE);
+ break;
+ end:
+ Pop(jit,cur,"POP",&cur->my_avalue);
+ break;
+ case OP_PRE_INC:
+ __X87Push(jit,cur,cur->operands[0]);
+ //FLD1
+ //FADDP ST1,ST0
+ JIT_AppendAsmText(jit,"\xD9\xE8\xDE\xC1",4);
+ __FMov(jit,cur,cur->operands[0],FALSE);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ break;
+ case OP_PRE_DEC:
+ __X87Push(jit,cur,cur->operands[0]);
+ //FLD1
+ //FSUBP ST1,ST0
+ JIT_AppendAsmText(jit,"\xD9\xE8\xDE\xE9",4);
+ __FMov(jit,cur,cur->operands[0],FALSE);
+ __FMov(jit,cur,&cur->my_avalue,TRUE);
+ end:
+ break;
+ case OP_CALL:
+ FuncCall(jit,cur,&GetCallFunction(cur)->my_avalue,&cur->my_avalue,cur->type.body_length,NULL);
+ break;
+ default:
+ "UNIMPF:%d\n",cur->type.code;
+ break;
+ }
+ }
+ iter++;
+ next:;
+ }
+ return iter;
+}
+//
+// SPECIAL CASE!!!
+// If our previous op is a OP_IF,then discard the result for using special Jcc style jumps
+// |\ ______ /|
+// | \ /* * \ / |
+// | \| |/ |
+// | /| ==== |\ |
+// | / | WW | \ |
+// |/ \______/ \|
+//
+// Potato Drop
+//
+U0 NullifyUselessDests(JIT *jit,CVector *flat) {
+ I64 idx;
+ CRPN *rpn;
+ for(idx=0;idx!=flat->size;idx++) {
+ rpn=flat->data[idx];
+ if(!(rpn->flags&RPN_F_MERGED_ASSIGN)) {
+ switch(rpn->type.code) {
+ case OP_LT:
+ case OP_GT:
+ case OP_LE:
+ case OP_GE:
+ case OP_NE:
+ case OP_EQ:
+ if(rpn->prev&&rpn->prev->type.code==OP_IF)
+ rpn->my_avalue.type=AV_UNOCC;
+ }
+ if(IsRPNUnop(rpn)||IsRPNBinop(rpn)) {
+ if(!rpn->consumer)
+ rpn->my_avalue.type=AV_UNOCC;
+ }
+ }
+ }
+}
+U0 JIT_PropigateAssigns(JIT *jit,CRPN *rpn=NULL,CRPN *stop_at=NULL) {
+ /*
+ CRPN *from,*next2;
+ if(!rpn)
+ rpn=FirstRPN(jit->cur_rpn_start);
+ loop:
+ for(;rpn!=stop_at;rpn=rpn->next) {
+ if(rpn->type.code==OP_CALL) {
+ //Dont propigate assigns in calls as we we may inplace push their values
+ for(next2=ComputeRPNSuccessor(rpn),rpn=rpn->next;rpn!=next2;) {
+ if(IsRPNAssign(rpn)) {
+ //Skip past the assign and do the assign's operands
+ JIT_PropigateAssigns(jit,rpn->next,ComputeRPNSuccessor(rpn));
+ } else
+ JIT_PropigateAssigns(jit,rpn,ComputeRPNSuccessor(rpn));
+ rpn=ComputeRPNSuccessor(rpn);
+ }
+ goto loop;
+ } else if(rpn->type.code==OP_FUNC_CALL) {
+
+ } else if(rpn->type.code==OP_ASSIGN) {
+ if(rpn->next->type.code==OP_VARIABLE) {
+ from=ComputeRPNSuccessor(rpn->next);
+ if(rpn->type.is_flt!=from->type.is_flt) goto next;
+ switch(from->type.code) {
+ case OP_VARIABLE:
+ case OP_LITERAL:
+ case OP_RELOCATION:
+ break;
+ default:
+ if(!(from->flags&(RPN_F_DONT_TOUCH|RPN_F_IMPLICIT_OPERATION))) {
+ from->flags|=RPN_F_MERGED_ASSIGN|RPN_F_DONT_TOUCH;
+ from->my_avalue=rpn->next->my_avalue;
+ next2=rpn->next->next;
+ RPNFree(rpn->next),RPNFree(rpn);
+ rpn=next2;
+ goto loop;
+ }
+ }
+ }
+ }
+ next:;
+ }*/
+}
+U0 AssignX87Regs(JIT *jit,CVector *flat) {
+ I64 idx,stk_regs=0,idx2;
+ CRPN *rpn,*dst;
+ CAsmValue *value;
+ for(idx=0;idx!=flat->size;idx++) {
+ rpn=flat->data[idx];
+ rpn->my_avalue.fpu_depth=jit->fpu_stk->size;
+ if(rpn->type.code==OP_CALL) {
+ while(jit->fpu_stk->size) {
+ value=VectorPop(jit->fpu_stk);
+ value->type=AV_FREG_SHADOW;
+ value->size=8;
+ }
+ stk_regs=jit->fpu_stk_size=0;
+ } else if(IsRPNUnop(rpn)||rpn->type.code==OP_RETURN||rpn->type.code==OP_IF||rpn->type.code==OP_JMP_TABLE) {
+ if(rpn->operands[0]->type==AV_VFREG) {
+ VectorPop(jit->fpu_stk),stk_regs--;
+ }
+ } else if(IsRPNAssign(rpn)&&rpn->operands[1]->type==AV_VFREG) {
+ VectorPop(jit->fpu_stk),stk_regs--;
+ } else if(IsRPNBinop(rpn)) {
+ if(rpn->operands[0]->type==AV_VFREG)
+ VectorPop(jit->fpu_stk),stk_regs--;
+ if(rpn->operands[1]->type==AV_VFREG)
+ VectorPop(jit->fpu_stk),stk_regs--;
+ }
+ //Check if result is "consumed" by successor
+ if(!rpn->consumer) {
+ rpn->my_avalue.type=AV_UNOCC;
+ goto next;
+ }
+ if(rpn->my_avalue.type==AV_VFREG) {
+ jit->vfreg_cnt=MaxI64((rpn->my_avalue.vreg=stk_regs)+1,jit->vfreg_cnt);
+ VectorPush(jit->fpu_stk,&rpn->my_avalue);
+ if(++stk_regs>=6) {
+ for(idx2=0;idx2!=jit->fpu_stk->size;idx2++) {
+ value=jit->fpu_stk->data[idx2];
+ if(value->type==AV_VFREG) {
+ value->type=AV_FREG_SHADOW;
+ value->size=8;
+ stk_regs--;
+ break;
+ }
+ }
+ }
+ }
+ next:
+ }
+ jit->fpu_stk_offset=0;
+ for(idx=0;idx!=flat->size;idx++) {
+ rpn=flat->data[idx];
+ if(rpn->my_avalue.type==AV_VFREG)
+ rpn->my_avalue.type=AV_FREG;
+ }
+}
+Bool IsConst(CRPN *const) {
+ return const->type.code==OP_LITERAL&&(const->my_avalue.type==AV_INT||const->my_avalue.type==AV_FLT);
+}
+F64 ConstF64(CRPN *const) {
+ if(const->type.is_flt) return const->my_avalue.flt;
+ return const->my_avalue.int;
+}
+I64 ConstI64(CRPN *const) {
+ if(const->type.is_flt) return const->my_avalue.flt;
+ return const->my_avalue.int;
+}
+//
+// Run this after the RPN is finalized,dont run if you intend on modifing the RPN
+//
+//
+U0 CacheRPNSuccessors(JIT *jit) {
+ CRPN *r=FirstRPN(jit->cur_rpn_start);
+ for(;r->next;r=r->next);
+ for(;r;r=r->prev)
+ r->__end=ComputeRPNSuccessor(r);
+}
+I64 ShiftifyAmt(I64 v) {
+ if(BCnt(v)==1)
+ return Bsf(v)-1;
+ return -1;
+}
+CRPN *FoldConstants(JIT *jit) {
+ I64 idx,mul;
+ CRPN *next,*rpn,*const1,*const2,*first=FirstRPN(jit->cur_rpn_start),*new;
+ loop1:
+ //Phase 1,Constant folding
+ for(rpn=first;rpn->next;rpn=rpn->next);
+ for(;rpn;rpn=rpn->prev) {
+ rpn->__end=NULL;
+ if(IsRPNUnop(rpn)&&IsConst(const1=rpn->next)) {
+ switch(rpn->type.code) {
+ start:
+ rpn->type.code=OP_LITERAL;
+ case OP_POS:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1);
+ }
+ break;
+ //case OP_NOT:
+ //if(rpn->type.is_flt) {
+ // rpn->my_avalue.type=AV_FLT;
+ // rpn->my_avalue.flt=~ConstF64(const1);
+ //} else {
+ // rpn->my_avalue.type=AV_INT;
+ // rpn->my_avalue.int=~ConstI64(const1);
+ //}
+ break;
+ case OP_NEG:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=-ConstF64(const1);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=-ConstI64(const1);
+ }
+ break;
+ end:
+ RPNFree(const1);
+ }
+ goto next1;
+ }
+ if(!IsRPNBinop(rpn)) goto next1;
+ if(IsConst(const1=rpn->next)&&IsConst(const2=ComputeRPNSuccessor(rpn->next))) {
+ switch(rpn->type.code) {
+ start:
+ rpn->type.code=OP_LITERAL;
+ case OP_ADD:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)+ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)+ConstI64(const2);
+ }
+ break;
+ case OP_SUB:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)-ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)-ConstI64(const2);
+ }
+ break;
+ case OP_MUL:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)*ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)*ConstI64(const2);
+ }
+ break;
+ case OP_DIV:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)/ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)/ConstI64(const2);
+ }
+ break;
+ case OP_MOD:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)%ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)%ConstI64(const2);
+ }
+ break;
+
+ case OP_SHL:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)<<ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)<<ConstI64(const2);
+ }
+ break;
+ case OP_SHR:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)>>ConstF64(const2);
+ } else if(rpn->type.is_signed) {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)>>ConstI64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)(U64)>>(ConstI64(const2)(U64));
+ }
+ break;
+
+ case OP_AND:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)&ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)&ConstI64(const2);
+ }
+ break;
+ case OP_OR:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)|ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)|ConstI64(const2);
+ }
+ break;
+ case OP_XOR:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_FLT;
+ rpn->my_avalue.flt=ConstF64(const1)^ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)^ConstI64(const2);
+ }
+ break;
+
+
+ case OP_GT:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstF64(const1)>ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)>ConstI64(const2);
+ }
+ break;
+ case OP_LT:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstF64(const1)<ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)<ConstI64(const2);
+ }
+ break;
+ case OP_GE:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstF64(const1)>=ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)>=ConstI64(const2);
+ }
+ break;
+ case OP_LE:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstF64(const1)<=ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)<=ConstI64(const2);
+ }
+ break;
+ case OP_EQ:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstF64(const1)==ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)==ConstI64(const2);
+ }
+ break;
+ case OP_NE:
+ if(rpn->type.is_flt) {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstF64(const1)!=ConstF64(const2);
+ } else {
+ rpn->my_avalue.type=AV_INT;
+ rpn->my_avalue.int=ConstI64(const1)!=ConstI64(const2);
+ }
+ break;
+ end:
+ RPNFree(const2);
+ RPNFree(const1);
+ break;
+ }
+ }
+ next1:
+ }
+ //Phase 2,communitive values
+ rpn=jit->cur_rpn_start;
+ loop2:
+ for(rpn=first;rpn;rpn=rpn->next) {
+ rpn->__end=NULL;
+ if(!IsRPNBinop(rpn)) goto next2;
+ const1=ComputeRPNSuccessor(rpn->next);
+ if(IsConst(const1)) {
+ switch(rpn->type.code) {
+ case OP_ADD:
+ if(rpn->next->type.code==OP_ADD) {
+ const2=ComputeRPNSuccessor(rpn->next->next);;
+ if(IsConst(const2)) {
+ if(rpn->next->type.is_flt) {
+ const2->my_avalue.flt=ConstF64(const2)+ConstF64(const1);
+ } else
+ const2->my_avalue.int=ConstI64(const2)+ConstI64(const1);
+ next=rpn->next;
+ RPNFree(const1),RPNFree(rpn);
+ rpn=next;
+ goto loop2;
+ }
+ }
+ break;
+ case OP_SUB:
+ if(rpn->next->type.code==OP_SUB) {
+ const2=ComputeRPNSuccessor(rpn->next->next);;
+ if(IsConst(const2)) {
+ if(rpn->next->type.is_flt) {
+ const2->my_avalue.flt=ConstF64(const1)+ConstF64(const2);
+ } else
+ const2->my_avalue.int=ConstI64(const1)+ConstI64(const2);
+ next=rpn->next;
+ RPNFree(const1),RPNFree(rpn);
+ rpn=next;
+ goto loop2;
+ }
+ }
+ break;
+ case OP_MUL:
+ if(rpn->next->type.code==OP_MUL) {
+ const2=ComputeRPNSuccessor(rpn->next->next);;
+ if(IsConst(const2)) {
+ if(rpn->next->type.is_flt) {
+ const2->my_avalue.flt=ConstF64(const2)*ConstF64(const1);
+ } else
+ const2->my_avalue.int=ConstI64(const2)*ConstI64(const1);
+ next=rpn->next;
+ RPNFree(const1),RPNFree(rpn);
+ rpn=next;
+ goto loop2;
+ }
+ }
+ break;
+ }
+ }
+ next2:
+ }
+ //Phase 3 OP_MUL/OP_DIV shiftifys/remove 1's
+ for(rpn=first;rpn;){
+ loop3:
+ if((rpn->type.code==OP_MUL)&&!rpn->type.is_flt) {
+ if(IsConst(const1=rpn->next)) {
+ if(ConstI64(const1)==1) {
+ next=ComputeRPNSuccessor(const1);
+ RPNFree(const1),RPNFree(rpn);
+ rpn=next;
+ goto loop3;
+ } else if(-1!=(mul=ShiftifyAmt(ConstI64(const1)))) {
+ next=ComputeRPNSuccessor(ComputeRPNSuccessor(const1));
+ if(next) {
+ RPNFree(const1);
+ new=MAlloc(sizeof(CRPN));
+ new->type.code=OP_LITERAL;
+ new->my_avalue.type=AV_INT;
+ new->my_avalue.int=mul;
+ new->next=next;
+ new->prev=next->prev;
+ new->next->prev=new;
+ new->prev->next=new;
+ new->successors=VectorNew;
+ new->r_map=VectorNew,new->in_r_map=VectorNew;
+ new->spills=VectorNew;
+ new->unspills=VectorNew;
+ rpn->type.code=OP_SHL;
+ }
+ }
+ } else if(IsConst(const2=ComputeRPNSuccessor(rpn->next))) {
+ if(ConstI64(const2)==1) {
+ next=rpn->next;
+ RPNFree(const2),RPNFree(rpn);
+ rpn=next;
+ goto loop3;
+ } else if(-1!=ShiftifyAmt(ConstI64(const2))) {
+ const2->my_avalue.int=ShiftifyAmt(ConstI64(const2));
+ const2->my_avalue.type=AV_INT;
+ rpn->type.code=OP_SHL;
+ }
+ }
+ } else if((rpn->type.code==OP_DIV||rpn->type.code==OP_ASSIGN_DIV)&&!rpn->type.is_flt) {
+ if(IsConst(const2=ComputeRPNSuccessor(rpn->next))) {
+ if(ConstI64(const2)==1) {
+ next=rpn->next;
+ RPNFree(const2),RPNFree(rpn);
+ rpn=next;
+ goto loop3;
+ } else if(-1!=ShiftifyAmt(ConstI64(const2))) {
+ const2->my_avalue.int=ShiftifyAmt(ConstI64(const2));
+ const2->my_avalue.type=AV_INT;
+ if(rpn->type.code==OP_DIV)
+ rpn->type.code=OP_SHR;
+ else
+ rpn->type.code=OP_ASSIGN_SHR;
+ }
+ }
+ }
+ rpn=rpn->next;
+ }
+ //Phase 4 OP_DEREF offsets
+ for(rpn=first;rpn;){
+ loop4:
+ if(rpn->type.code==OP_DEREF) {
+ if(rpn->next->type.code==OP_ADD) {
+ mul=1;
+ deref_merge:
+ if(IsConst(const1=rpn->next->next)) {
+ rpn->operands[1](I64)+=mul*ConstI64(const1);
+ RPNFree(const1),RPNFree(rpn->next);
+ goto loop4;
+ } else if(IsConst(const2=ComputeRPNSuccessor(rpn->next->next))) {
+ rpn->operands[1](I64)+=mul*ConstI64(const2);
+ RPNFree(const2),RPNFree(rpn->next);
+ goto loop4;
+ }
+ } else if(rpn->next->type.code==OP_SUB) {
+ mul=-1;
+ goto deref_merge;
+ }
+ }
+ rpn=rpn->next;
+ }
+ for(rpn=first;rpn->next;rpn=rpn->next);
+ jit->cur_rpn_start=rpn;
+}
+U0 TellArgumentsToBePushed(JIT *jit) {
+ I64 idx,idx2;
+ CRPN *rpn,*arg;
+ for(rpn=FirstRPN(jit->cur_rpn_start);rpn;rpn=rpn->next) {
+ if(rpn->type.code==OP_CALL) {
+ arg=rpn->next;
+ for(idx2=0;idx2!=rpn->type.body_length;idx2++) {
+ switch(arg->type.code) {
+ case OP_VARIABLE:
+ case OP_LITERAL:
+ arg->type.code=OP_INPLACE_PUSH;
+ break;
+ default:
+ arg->my_avalue.type=AV_PUSH;
+ }
+ arg=ComputeRPNSuccessor(arg);
+ }
+ }
+ }
+}
+//Pass indirects to me
+U0 BigMove(JIT *jit,CRPN *rpn,CAsmValue *dst,CAsmValue *src) {
+ VectorAdd(jit->tainted_caller_saved,Str2Reg("RDI")->code);
+ VectorAdd(jit->tainted_caller_saved,Str2Reg("RSI")->code);
+ I64 len=MinI64(dst->size,src->size),r;
+ CReg *rcx;
+ Bool pop=FALSE;
+ CAsmValue dummy,dummy2,dummy3;
+ dummy.type=AV_IREG;
+ //RDI/RSI were spilled before this operation,so they are not alive here so we are free to poo poo them
+ switch(dst->type) {
+ start:
+ dummy2.type=AV_IREG;
+ case AV_IVINDIR:
+ case AV_FVINDIR:
+ dummy2.reg=IRegCodeToReg(r=RMapGetPhysicalReg(rpn->r_map,dst->vreg));
+ if(r==-1) {
+ dummy2.reg=Str2Reg("RDI");
+ IMovRInd(jit,dummy2.reg->code,BASEREG_CODE,jit->ireg_shadows+8*dst->vreg,8,FALSE);
+ }
+ break;
+ case AV_IINDIR:
+ case AV_FINDIR:
+ dummy2.reg=dst->reg;
+ break;
+ case AV_IFRAME:
+ case AV_FFRAME:
+ dummy2.reg=Str2Reg("RSP");
+ end:
+ switch(src->type) {
+ start:
+ dummy3.type=AV_IREG;
+ case AV_IVINDIR:
+ case AV_FVINDIR:
+ dummy3.reg=IRegCodeToReg(r=RMapGetPhysicalReg(rpn->r_map,src->vreg));
+ if(r==-1) {
+ dummy3.reg=Str2Reg("RSI");
+ IMovRInd(jit,dummy3.reg->code,BASEREG_CODE,jit->ireg_shadows+8*src->vreg,8,FALSE);
+ }
+ break;
+ case AV_IINDIR:
+ case AV_FINDIR:
+ dummy3.reg=src->reg;
+ break;
+ case AV_FFRAME:
+ case AV_IFRAME:
+ dummy3.reg=Str2Reg("RSP");
+ end:
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RSI");
+ IMov(jit,rpn,&dummy,&dummy3,FALSE);
+ if(src->offset) {
+ //ADD RSI,xxxxxxxx
+ JIT_AppendAsmText(jit,"\x48\x81\xC6",3);
+ JIT_AppendAsmText(jit,&src->offset,4);
+ }
+ }
+ dummy.type=AV_IREG;
+ dummy.reg=Str2Reg("RDI");
+ IMov(jit,rpn,&dummy,&dummy2,FALSE);
+ if(dst->offset) {
+ //ADD RDI,xxxxxxxx
+ JIT_AppendAsmText(jit,"\x48\x81\xC7",3);
+ JIT_AppendAsmText(jit,&dst->offset,4);
+ }
+ }
+ loop:
+ switch(len) {
+ case 0:
+ goto en;
+ case 1:
+ //MOVSB
+ JIT_AppendAsmText(jit,"\xA4",1);
+ goto en;
+ case 2:
+ //MOVSW
+ JIT_AppendAsmText(jit,"\x66\xA5",2);
+ goto loop;
+ case 3:
+ //MOVSW+MOVSB
+ JIT_AppendAsmText(jit,"\x66\xA5""\xA4",2+1);
+ goto en;
+ case 4:
+ //MOVSD
+ JIT_AppendAsmText(jit,"\xA5",1);
+ goto en;
+ case 5:
+ //MOVSD+MOVSB
+ JIT_AppendAsmText(jit,"\xA5""\xA4",1+1);
+ goto en;
+ case 6:
+ //MOVSD+MOVSW
+ JIT_AppendAsmText(jit,"\xA5""\x66\xA5",1+2);
+ goto en;
+ case 7:
+ //MOVSD+MOVSW+MOVSB
+ JIT_AppendAsmText(jit,"\xA5""\x66\xA5""\xA4",1+2+1);
+ goto en;
+ case 8:
+ //Juicy 64 bit one(MOVSQ)
+ JIT_AppendAsmText(jit,"\x48\xA5",2);
+ goto en;
+ default:
+ if(IRegIsAliveAfter(rpn,rcx=Str2Reg("RCX")))
+ IPushR(jit,rcx->code);
+ IMovRI(jit,rcx->code,len/8);
+ //REP MOVSQ
+ JIT_AppendAsmText(jit,"\xF3\x48\xA5",3);
+ len%=8;
+ if(IRegIsAliveAfter(rpn,rcx=Str2Reg("RCX")))
+ IPopR(jit,rcx->code);
+ goto loop;
+ }
+ en:
+}
+U0 JitTypecastDerefs(JIT *jit) {
+ CRPN *rpn,*next;
+ I64 iter;
+ for(rpn=FirstRPN(jit->cur_rpn_start);rpn;) {
+ next=rpn->next;
+ if(rpn->type.code!=OP_TYPECAST_BIT4BIT)
+ goto next;
+ if(rpn->next->type.code!=OP_DEREF)
+ goto next;
+ if(rpn->flags&RPN_F_NO_TYPECAST)
+ goto next;
+ if(rpn->type.is_flt)
+ rpn->next->type.is_flt=TRUE,rpn->next->operands[2](I64)=8;
+ else {
+ rpn->next->type.is_flt=FALSE;
+ rpn->next->operands[2](I64)=rpn->operands[1](I64);
+ }
+ RPNFree(rpn);
+ next:
+ rpn=next;
+ }
+}
+U8 *JitEmitCode(JIT *jit,I64 argc) {
+ CVector *flat=VectorNew,*incoming,*outgoing;
+ I64 idx,idx2,foffset,bytes,body_size,prolog_size,taddr;
+ U8 *tmp,*epilog,*body_code;
+ U16 word;
+ U32 dword;
+ CRPN *rpn,*prev,*jmp_to;
+ jit->live_icap=(jit->ireg_stk_start=jit->tireg_cnt=jit->vireg_cnt+1);
+ jit->tfreg_cnt=jit->cur_tfreg=jit->vfreg_cnt+1;
+ FoldConstants(jit);
+ JitTypecastDerefs(jit);
+ JIT_PropigateAssigns(jit);
+ for(rpn=FirstRPN(jit->cur_rpn_start);rpn;rpn=rpn->next) {
+ if(rpn->type.code==OP_JMP)
+ rpn->operands[0]=GetRPNEnterLabel(rpn->operands[0]);
+ }
+ CacheRPNSuccessors(jit);
+ TellArgumentsToBePushed(jit);
+ FlattenRPNTo(FirstRPN(jit->cur_rpn_start),flat);
+ RPN_AssignOperandValues(jit,FirstRPN(jit->cur_rpn_start),NULL);
+ AssignX87Regs(jit,flat);
+ NullifyUselessDests(jit,flat);
+ ComputeRPNLiveness(jit,FirstRPN(jit->cur_rpn_start));
+ //Aligned to 8
+ foffset=-jit->allocai_size;
+ //We started tireg_cnt at vireg_cnt
+ foffset-=8*(jit->tireg_cnt);
+ jit->ireg_shadows=foffset;
+ //DITTO
+ foffset-=8*(jit->tfreg_cnt+1);
+ jit->freg_shadows=foffset;
+ jit->fpu_stk_size=0;
+ outgoing=VectorNew;
+ for(idx=0;idx!=flat->size;idx++) {
+ rpn=flat->data[idx];
+ incoming=VectorNew;
+ for(idx2=0;idx2!=outgoing->size;idx2+=2) {
+ if(rpn->flags&RPN_F_ASM_TAINTED||rpn->flags&RPN_F_SPILL_ALL) {
+ goto skip;
+ }
+ if(IsControlNode(rpn))
+ if(!Bt(rpn->live_in,outgoing->data[idx2]))
+ goto skip;
+ VectorPush(rpn->r_map,outgoing->data[idx2]);
+ VectorPush(rpn->r_map,outgoing->data[idx2+1]);
+ VectorPush(incoming,outgoing->data[idx2]);
+ VectorPush(incoming,outgoing->data[idx2+1]);
+ skip:
+ }
+ UnspillRPNRegs(jit,rpn,TRUE);
+ if(rpn->type.code==OP_JMP_TABLE) {
+ rpn->r_map->size=0;
+ if(rpn->next->my_avalue.type==AV_VIREG)
+ rpn->next->my_avalue.type=AV_IREG_SHADOW;
+ rpn->my_avalue.type=AV_UNOCC;
+ }
+ outgoing->size=0;
+ for(idx2=0;idx2!=rpn->r_map->size;idx2+=2) {
+ VectorPush(outgoing,rpn->r_map->data[idx2]);
+ VectorPush(outgoing,rpn->r_map->data[idx2+1]);
+ }
+ rpn->in_r_map=incoming;
+ }
+ VectorFree(outgoing);
+ #ifdef JIT_DBG
+ DumpRPN(FirstRPN(jit->cur_rpn_start));
+ #endif
+ jit->fpu_stk_size=0;
+ //This generates the body,we will need to generate a prolog and epilog
+ CompileOps(jit,flat);
+ //Patch ops
+ for(idx=0;idx!=flat->size;idx++) {
+ rpn=flat->data[idx];
+ switch(rpn->type.code) {
+ case OP_JMP_TABLE:
+ for(idx2=0;idx2!=rpn->jmp_table_trampolines->size;idx2+=2) {
+ jmp_to=rpn->jmp_table_trampolines->data[idx2];
+ taddr=rpn->jmp_table_trampolines->data[idx2+1];
+ (jit->buffer+taddr)(I32*)[0]=GetRPNEnterLabel(jmp_to)->bin_off-(taddr+4);
+ }
+ break;
+ case OP_REF_DATA:
+ Patch32(jit,rpn->patch_addr,rpn->operands[0](CRPN*)->bin_off);
+ break;
+ case OP_RETURN:
+ //jit->buf_size points to epilog
+ Patch32(jit,rpn->patch_addr,jit->buf_size);
+ break;
+ case OP_JMP:
+ Patch32(jit,rpn->patch_addr,GetRPNEnterLabel(rpn->operands[0](CRPN*))->bin_off);
+ break;
+ }
+ }
+ //
+ // Hacky solution,backup the buffer and size,write the prolog,then append the eplilog
+ //
+ body_size=jit->buf_size;
+ body_code=jit->buffer;
+ jit->buffer=NULL;
+ jit->buf_cap=jit->buf_size=0;
+ //PUSH rbp
+ //MOV rbp,rsp
+ //SUB rsp,foffset
+ //
+ JIT_AppendAsmText(jit,"\x55\x48\x89\xE5\x48\x81\xEC",4+3);
+ foffset-=8; //TODO REMOVE
+ I64 fstato=foffset;
+ foffset=-foffset;
+ JIT_AppendAsmText(jit,&foffset.u32[0],4);
+ for(idx=0;idx!=jit->tainted_caller_saved->size;idx++)
+ IPushR(jit,jit->tainted_caller_saved->data[idx]);
+ foffset=-foffset;
+ foffset-=jit->tainted_caller_saved->size*8;
+ //FSTSW AX
+ //SHR AX,11
+ //AND AX,0b111
+ //MOV [RBP+offset],AX
+ JIT_AppendAsmText(jit,"\x9B\xDF\xE0\x66\xC1\xE8\x0B\x66\x83\xE0\x07\x66\x89\x85",0xb+3);
+ JIT_AppendAsmText(jit,&fstato.u32[0],4);
+ tmp=MAlloc(jit->buf_cap=body_size+jit->buf_size+128);
+ MemCpy(tmp,jit->buffer,prolog_size=jit->buf_size);
+ Free(jit->buffer),jit->buffer=tmp;
+ //
+ JIT_AppendAsmText(jit,body_code,body_size);
+ Free(body_code);
+ //Trigers a segfault when fpu top is mismatched
+ //FSTSW AX
+ //SHR AX,11
+ //AND AX,7
+ //CMP AX,[RBP+0x11223344]
+ //JE exit
+ //MOV RAX,[0]
+ //exit:
+ IPushR(jit,0);
+ JIT_AppendAsmText(jit,"\x9B\xDF\xE0\x66\xC1\xE8\x0B\x66\x83\xE0\x07\x66\x3B\x85",0xb+3);
+ JIT_AppendAsmText(jit,&fstato.u32[0],4);
+ JIT_AppendAsmText(jit,"\x74\x08\x48\x8B\x04\x25\x00\x00\x00\x00",0xa);
+ IPopR(jit,0);
+ //LEA RSP,[RBP+foffset]
+ JIT_AppendAsmText(jit,"\x48\x8D\xA5",3);
+ JIT_AppendAsmText(jit,&foffset.u32[0],4);
+ for(idx=jit->tainted_caller_saved->size-1;idx>=0;idx--) {
+ IPopR(jit,jit->tainted_caller_saved->data[idx]);
+ }
+ JIT_AppendAsmText(jit,"\xC9\xC2",2); //LEAVE,RET1 8*argc
+ word=8*argc;
+ JIT_AppendAsmText(jit,&word,2);
+ for(idx=0;idx!=flat->size;idx++) {
+ rpn=flat->data[idx];
+ switch(rpn->type.code) {
+ case OP_RELOCATION:
+ rpn->operands[0](U0**)[0]=jit->buffer+prolog_size+rpn->patch_addr;
+ break;
+ case OP_DUMP_PTR:
+ rpn->operands[0](U0**)[0]=jit->buffer+prolog_size+rpn->bin_off;
+ break;
+ }
+ }
+ Free(epilog);
+ VectorFree(flat);
+ return jit->buffer;
+}
+class CBreakpoint {
+ I64 enabled;
+ CRPN *at;
+ I64 user_data[0];
+};
+CRPN *JIT_BREAKPOINT(JIT *jit,U0 *ctrl,CBreakpoint *bp,U0 (*routine)()) {
+ CRPN *ret=jit_rpnNew(jit,OP_BREAKPOINT);
+ ret->operands[0]=ctrl(CAsmValue*);
+ ret->operands[1]=bp(CAsmValue*);
+ ret->operands[2]=routine(CAsmValue*);
+ return ret;
+}
+CRPN *JIT_GetBreakpointNodeByPtr(JIT *jit,U0 *ptr) {
+ CRPN *st=FirstRPN(jit->cur_rpn_start);
+ CRPN *pbp=NULL;
+ for(;st;st=st->next) {
+ if(st->type.code==OP_BREAKPOINT) {
+ if(pbp) {
+ if(jit->buffer(U8*)+pbp->bin_off<=ptr<jit->buffer(U8*)+st->bin_off)
+ return pbp;
+ }
+ pbp=st;
+ }
+ }
+ if(!pbp) return NULL;
+ return pbp;
+}
+CBreakpoint *JIT_GetBreakpointByPtr(JIT *jit,U0 *ptr) {
+ CRPN *pbp=JIT_GetBreakpointNodeByPtr(jit,ptr);
+ if(!pbp) return NULL;
+ return pbp->operands[1](CBreakpoint*);
+}
+//Make less work for the garbage collector
+CRPN *JIT_RemoveNonDebuggerInfo(JIT *jit) {
+ CRPN *cur=FirstRPN(jit->cur_rpn_start),*next;
+ jit->cur_rpn_start=NULL;
+ for(;cur;cur=next) {
+ next=cur->next;
+ if(cur->type.code!=OP_BREAKPOINT)
+ RPNFree(cur);
+ else
+ jit->cur_rpn_start=cur;
+ }
+}
+//See debuggerAsm.yasm
+class CDebuggerRegs {
+ I64 dummy2; //0
+ I64 RBX; //8
+ I64 RCX; //16
+ I64 RDX; //24
+ I64 RSI; //32
+ I64 RDI; //40
+ I64 dummy; //48
+ I64 RBP; //56
+ I64 R8; //64
+ I64 R9; //72
+ I64 R10; //80
+ I64 R11; //88
+ I64 R12; //96
+ I64 R13; //112
+ I64 R14; //120
+ I64 R15; //128
+};
+I64 *JIT_GetVregPtr(JIT *parent,CDebuggerRegs *regs,U0 *ptr,I64 vreg) {
+ CRPN *bp_n=JIT_GetBreakpointNodeByPtr(parent,ptr);
+ if(!bp_n) return NULL;
+ if(-1==RMapGetPhysicalReg(bp_n->r_map,vreg)) {
+ return &(regs->RBP(U8*)+parent->ireg_shadows)(I64*)[vreg];
+ }
+ switch(RMapGetPhysicalReg(bp_n->r_map,vreg)) {
+ //case 0: RAX is only used as an accumulator
+ case 1: return &regs->RCX;
+ case 2: return &regs->RDX;
+ case 3: return &regs->RBX;
+ //case 4: No way am i using the stack register as a gp
+ case 5: return &regs->RBP;
+ case 6: return &regs->RSI;
+ case 7: return &regs->RDI;
+ case 8: return &regs->R8;
+ case 9: return &regs->R9;
+ case 10: return &regs->R10;
+ case 11: return &regs->R11;
+ case 12: return &regs->R12;
+ case 13: return &regs->R13;
+ case 14: return &regs->R14;
+ case 15: return &regs->R15;
+ }
+ return NULL;
+}
+I64 *JIT_GetVregPtrFromParent(JIT *parent,U0 *ptr,U0 *rbp,I64 vreg) {
+ CRPN *bp_n=JIT_GetBreakpointNodeByPtr(parent,ptr);
+ if(!bp_n) return NULL;
+ //If its stored in a vreg,its not spilled to the stack
+ if(-1!=RMapGetPhysicalReg(bp_n->r_map,vreg)) return NULL;
+ return &(rbp(U8*)+parent->ireg_shadows)(I64*)[vreg];
+}
+class jit_debugger_ctrl {
+ #define JIT_DBG_STEP 1
+ #define JIT_DBG_NEXT 2
+ #define JIT_DBG_FIN 3
+ I64 code;
+ U0 *prev_stack_ptr;
+ //Our silly debugger "enters" into functions,but we will need the last known RIP to compute which breakpoint we were at before entering a breakpoint.
+ U0 *last_rip;
+};
+U0 JIT_ASM_TAINT_LABEL(CRPN *op) {
+ op->flags|=RPN_F_ASM_TAINTED;
+}
+CRPN *JIT_MOV(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN);
+}
+CRPN *JIT_F64(JIT *jit,F64 f) {
+ return jit_rpnFlt(jit,f);
+}
+CRPN *JIT_I64(JIT *jit,I64 i) {
+ return jit_rpnInt(jit,i);
+}
+CRPN *JIT_JMP(JIT *jit,CRPN *to) {
+ CRPN *ret=jit_rpnNew(jit,OP_JMP);
+ ret->operands[0]=to;
+ return ret;
+}
+CRPN *JIT_LABEL(JIT *jit) {
+ CRPN *ret=jit_rpnBodyStart(jit);
+ jit_rpnBodyEnd(jit,ret);
+ return ret;
+}
+CRPN *JIT_PATCH(JIT *jit,CRPN *item,CRPN *to=NULL) {
+ if(!to)
+ to=JIT_LABEL(jit);
+ item->operands[0]=to;
+ return to;
+}
+
+//Tested 1
+CRPN *JIT_FUNC_CALL(JIT *jit,I64 cnt,I64 vargs_base=-1) {
+ CRPN *ret=jit_rpnNew(jit,OP_CALL);
+ ret->type.body_length=cnt;
+ if(vargs_base!=-1)
+ ret->type.vargs_base=vargs_base;
+ else
+ ret->type.vargs_base=cnt;
+ return ret;
+}
+//Tested 1
+CRPN *JIT_GETARGI(JIT *jit,I64 a) {
+ CRPN *ret=jit_rpnNew(jit,OP_GETARG);
+ jit_rpnInt(jit,a);
+ return ret;
+}
+//Tested 1
+CRPN *JIT_GETARGF(JIT *jit,I64 a) {
+ CRPN *ret=jit_rpnNewF(jit,OP_GETARG);
+ jit_rpnInt(jit,a);
+ return ret;
+}
+//Tested 1
+CRPN *JIT_RET(JIT *jit) {
+ return jit_rpnNew(jit,OP_RETURN);
+}
+//Tested 1
+CRPN *JIT_ADDI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ADD);
+}
+//Tested 1
+CRPN *JIT_SUBI(JIT *jit) {
+ return jit_rpnNew(jit,OP_SUB);
+}
+//Tested 1
+CRPN *JIT_NEGI(JIT *jit) {
+ return jit_rpnNew(jit,OP_NEG);
+}
+CRPN *JIT_FPOS(JIT *jit) {
+ return jit_rpnNewF(jit,OP_POS);
+}
+CRPN *JIT_POSI(JIT *jit) {
+ return jit_rpnNew(jit,OP_POS);
+}
+//Tested 1
+CRPN *JIT_MULI(JIT *jit) {
+ return jit_rpnNew(jit,OP_MUL);
+}
+//Tested 1
+CRPN *JIT_DIVI(JIT *jit) {
+ return jit_rpnNew(jit,OP_DIV);
+}
+//Tested 1
+CRPN *JIT_MODI(JIT *jit) {
+ return jit_rpnNew(jit,OP_MOD);
+}
+//tested 1
+CRPN *JIT_ORI(JIT *jit) {
+ return jit_rpnNew(jit,OP_OR);
+}
+//tested 1
+CRPN *JIT_XORI(JIT *jit) {
+ return jit_rpnNew(jit,OP_XOR);
+}
+//Tested 1
+CRPN *JIT_ANDI(JIT *jit) {
+ return jit_rpnNew(jit,OP_AND);
+}
+//Tested 1
+CRPN *JIT_LSHI(JIT *jit) {
+ return jit_rpnNew(jit,OP_SHL);
+}
+//Tested 1
+CRPN *JIT_RSHI(JIT *jit) {
+ return jit_rpnNew(jit,OP_SHR);
+}
+//tested
+CRPN *JIT_RSHU(JIT *jit) {
+ return jit_rpnNewU(jit,OP_SHR);
+}
+//TESTED 1
+CRPN *JIT_NOTI(JIT *jit) {
+ return jit_rpnNew(jit,OP_NOT);
+}
+//Tested 1
+CRPN *JIT_LTI(JIT *jit) {
+ return jit_rpnNew(jit,OP_LT);
+}
+//Tested 1
+CRPN *JIT_LTU(JIT *jit) {
+ return jit_rpnNewU(jit,OP_LT);
+}
+//Tested 1
+CRPN *JIT_GTI(JIT *jit) {
+ return jit_rpnNew(jit,OP_GT);
+}
+//Tested 1
+CRPN *JIT_GTU(JIT *jit) {
+ return jit_rpnNewU(jit,OP_GT);
+}
+//Tested 1
+CRPN *JIT_LEI(JIT *jit) {
+ return jit_rpnNew(jit,OP_LE);
+}
+//Tested 1
+CRPN *JIT_LEU(JIT *jit) {
+ return jit_rpnNewU(jit,OP_LE);
+}
+//Tested 1
+CRPN *JIT_GEI(JIT *jit) {
+ return jit_rpnNew(jit,OP_GE);
+}
+//Tested 1
+CRPN *JIT_GEU(JIT *jit) {
+ return jit_rpnNewU(jit,OP_GE);
+}
+//Tested 1
+CRPN *JIT_NEI(JIT *jit) {
+ return jit_rpnNew(jit,OP_NE);
+}
+//Tested 1
+CRPN *JIT_EQI(JIT *jit) {
+ return jit_rpnNew(jit,OP_EQ);
+}
+CRPN *JIT_TYPECAST(JIT *jit,I64 sz=8) {
+ CRPN *ret=jit_rpnNew(jit,OP_TYPECAST_BIT4BIT);
+ ret->operands[1]=sz;
+ return ret;
+}
+CRPN *JIT_FTYPECAST(JIT *jit) {
+ CRPN *ret=jit_rpnNewF(jit,OP_TYPECAST_BIT4BIT);
+ ret->operands[1]=8;
+ return ret;
+}
+CRPN *JIT_REF_DATA(JIT *jit,CRPN *to=NULL) {
+ CRPN *ret=jit_rpnNew(jit,OP_REF_DATA);
+ ret->operands[0]=to;
+ return ret;
+}
+CRPN *JIT_DU8(JIT *jit,I64 v) {
+ CRPN *ret=jit_rpnNew(jit,OP_DU8);
+ ret->operands[0]=v;
+ return ret;
+}
+CRPN *JIT_DU16(JIT *jit,I64 v) {
+ CRPN *ret=jit_rpnNew(jit,OP_DU16);
+ ret->operands[0]=v;
+ return ret;
+}
+CRPN *JIT_DU32(JIT *jit,I64 v) {
+ CRPN *ret=jit_rpnNew(jit,OP_DU32);
+ ret->operands[0]=v;
+ return ret;
+}
+CRPN *JIT_DU64(JIT *jit,U64 v) {
+ CRPN *ret=jit_rpnNew(jit,OP_DU64);
+ ret->operands[0]=v;
+ return ret;
+}
+CRPN *JIT_UDEREF(JIT *jit,I32 off=0,I64 sz=8) {
+ CRPN *ret=jit_rpnNewU(jit,OP_DEREF);
+ ret->operands[1]=off(CAsmValue*);
+ ret->operands[2]=sz(CAsmValue*);
+ return ret;
+}
+CRPN *JIT_UDEREF_NO_TC(JIT *jit,I32 off=0,I64 sz=8) {
+ CRPN *r=JIT_UDEREF(jit,off,sz);
+ r->flags|=RPN_F_NO_TYPECAST;
+ return r;
+}
+CRPN *JIT_DEREF(JIT *jit,I32 off=0,I64 sz=8) {
+ CRPN *ret=jit_rpnNew(jit,OP_DEREF);
+ ret->operands[1]=off(CAsmValue*);
+ ret->operands[2]=sz(CAsmValue*);
+ return ret;
+}
+CRPN *JIT_DEREF_NO_TC(JIT *jit,I32 off=0,I64 sz=8) {
+ CRPN *r=JIT_DEREF(jit,off,sz);
+ r->flags|=RPN_F_NO_TYPECAST;
+ return r;
+}
+CRPN *JIT_FMOV(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN);
+}
+CRPN *JIT_FADD(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ADD);
+}
+CRPN *JIT_FSUB(JIT *jit) {
+ return jit_rpnNewF(jit,OP_SUB);
+}
+CRPN *JIT_FAND(JIT *jit) {
+ return jit_rpnNewF(jit,OP_AND);
+}
+CRPN *JIT_FXOR(JIT *jit) {
+ return jit_rpnNewF(jit,OP_XOR);
+}
+CRPN *JIT_FNEG(JIT *jit) {
+ return jit_rpnNewF(jit,OP_NEG);
+}
+CRPN *JIT_FNOT(JIT *jit) {
+ return jit_rpnNewF(jit,OP_NOT);
+}
+CRPN *JIT_FOR(JIT *jit) {
+ return jit_rpnNewF(jit,OP_OR);
+}
+CRPN *JIT_FSHL(JIT *jit) {
+ return jit_rpnNewF(jit,OP_SHL);
+}
+CRPN *JIT_FSHR(JIT *jit) {
+ return jit_rpnNewF(jit,OP_SHR);
+}
+CRPN *JIT_FMUL(JIT *jit) {
+ return jit_rpnNewF(jit,OP_MUL);
+}
+CRPN *JIT_FDIV(JIT *jit) {
+ return jit_rpnNewF(jit,OP_DIV);
+}
+CRPN *JIT_FPREM(JIT *jit) {
+ return jit_rpnNewF(jit,OP_MOD);
+}
+CRPN *JIT_FLT(JIT *jit) {
+ return jit_rpnNewF(jit,OP_LT);
+}
+CRPN *JIT_FGT(JIT *jit) {
+ return jit_rpnNewF(jit,OP_GT);
+}
+CRPN *JIT_FLE(JIT *jit) {
+ return jit_rpnNewF(jit,OP_LE);
+}
+CRPN *JIT_FGE(JIT *jit) {
+ return jit_rpnNewF(jit,OP_GE);
+}
+CRPN *JIT_FEQ(JIT *jit) {
+ return jit_rpnNewF(jit,OP_EQ);
+}
+CRPN *JIT_FNE(JIT *jit) {
+ return jit_rpnNewF(jit,OP_NE);
+}
+CRPN *JIT_FMOD(JIT *jit) {
+ return jit_rpnNewF(jit,OP_MOD);
+}
+CRPN *JIT_FCALL(JIT *jit,I64 argc,I64 vargs_base=-1) {
+ CRPN *ret=jit_rpnNewF(jit,OP_CALL);
+ ret->type.body_length=argc;
+ if(vargs_base!=-1)
+ ret->type.vargs_base=vargs_base;
+ else
+ ret->type.vargs_base=argc;
+ return ret;
+}
+CRPN *JIT_FDEREF(JIT *jit,I32 off=0) {
+ CRPN *ret=jit_rpnNewF(jit,OP_DEREF);
+ ret->operands[1]=off(CAsmValue*);
+ ret->operands[2]=8;
+ return ret;
+}
+CRPN *JIT_ALIGN_FILL(JIT *jit,I64 align,I64 fill) {
+ CRPN *ret=jit_rpnNew(jit,OP_ALIGN);
+ ret->operands[0]=align(CAsmValue*);
+ ret->operands[1]=fill(CAsmValue*);
+ return ret;
+}
+CRPN *JIT_R(JIT *jit,I64 f) {
+ return jit_rpnNewVreg(jit,f);
+}
+I64 JIT_ALLOCAI(JIT *jit,I64 sz) {
+ CRPN *ret=jit_rpnNew(jit,OP_ALIGN);
+ ret->operands[0]=sz(CAsmValue*);
+ jit->allocai_size+=sz;
+ //https://en.wikipedia.org/wiki/Data_structure_alignment
+ return -(jit->allocai_size=(jit->allocai_size+(8-1))&-8);
+}
+CRPN *JIT_FFRAME(JIT *jit,I64 off) {
+ CRPN *ret=jit_rpnNewF(jit,OP_VARIABLE);
+ ret->my_avalue.type=AV_FFRAME;
+ ret->my_avalue.size=8;
+ ret->my_avalue.offset=off;
+ return ret;
+}
+CRPN *JIT_IFRAME(JIT *jit,I64 off,I64 sz=8) {
+ CRPN *ret=jit_rpnNew(jit,OP_VARIABLE);
+ ret->my_avalue.type=AV_IFRAME;
+ ret->my_avalue.size=sz;
+ ret->my_avalue.offset=off;
+ return ret;
+}
+CRPN *JIT_RBP(JIT *jit) {
+ CRPN *ret=jit_rpnNew(jit,OP_VARIABLE);
+ ret->my_avalue.type=AV_IREG;
+ ret->my_avalue.reg=Str2Reg("RBP");
+ return ret;
+}
+CRPN *JIT_RELOCATION(JIT *jit,U0 **ptr) {
+ CRPN *ret=jit_rpnNew(jit,OP_RELOCATION);
+ ret->operands[0](U0**)=ptr;
+ return ret;
+}
+CRPN *JIT_FASSIGN_ADD(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_AND);
+}
+CRPN *JIT_FASSIGN_SUB(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_SUB);
+}
+CRPN *JIT_FASSIGN_MUL(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_MUL);
+}
+CRPN *JIT_FASSIGN_MOD(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_MOD);
+}
+CRPN *JIT_FASSIGN_DIV(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_DIV);
+}
+CRPN *JIT_FASSIGN_OR(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_OR);
+}
+CRPN *JIT_FASSIGN_AND(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_AND);
+}
+CRPN *JIT_FASSIGN_XOR(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_XOR);
+}
+CRPN *JIT_FASSIGN_SHL(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_SHL);
+}
+CRPN *JIT_FASSIGN_SHR(JIT *jit) {
+ return jit_rpnNewF(jit,OP_ASSIGN_SHR);
+}
+//
+CRPN *JIT_ASSIGN_ADDI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_ADD);
+}
+CRPN *JIT_ASSIGN_SUBI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_SUB);
+}
+CRPN *JIT_ASSIGN_MULI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_MUL);
+}
+CRPN *JIT_ASSIGN_MODI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_MOD);
+}
+CRPN *JIT_ASSIGN_DIVI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_DIV);
+}
+CRPN *JIT_ASSIGN_ORI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_OR);
+}
+CRPN *JIT_ASSIGN_ANDI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_AND);
+}
+CRPN *JIT_ASSIGN_XORI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_XOR);
+}
+CRPN *JIT_ASSIGN_SHLI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_SHL);
+}
+CRPN *JIT_ASSIGN_SHRI(JIT *jit) {
+ return jit_rpnNew(jit,OP_ASSIGN_SHR);
+}
+CRPN *JIT_COMMAI(JIT *jit) {
+ return jit_rpnNew(jit,OP_COMMA);
+}
+CRPN *JIT_FCOMMA(JIT *jit) {
+ return jit_rpnNewF(jit,OP_COMMA);
+}
+CRPN *JIT_FPRE_INC(JIT *jit) {
+ return jit_rpnNewF(jit,OP_PRE_INC);
+}
+CRPN *JIT_FPRE_DEC(JIT *jit) {
+ return jit_rpnNewF(jit,OP_PRE_DEC);
+}
+CRPN *JIT_FPOST_INC(JIT *jit) {
+ return jit_rpnNewF(jit,OP_POST_INC);
+}
+CRPN *JIT_FPOST_DEC(JIT *jit) {
+ return jit_rpnNewF(jit,OP_POST_DEC);
+}
+CRPN *JIT_PRE_INCI(JIT *jit,I64 amt=1) {
+ CRPN *ret=jit_rpnNew(jit,OP_PRE_INC);
+ ret->operands[1](I64)=amt;
+ return ret;
+}
+CRPN *JIT_PRE_DECI(JIT *jit,I64 amt=1) {
+ CRPN *ret=jit_rpnNew(jit,OP_PRE_DEC);
+ ret->operands[1](I64)=amt;
+ return ret;
+}
+CRPN *JIT_POST_INCI(JIT *jit,I64 amt=1) {
+ CRPN *ret=jit_rpnNew(jit,OP_POST_INC);
+ ret->operands[1](I64)=amt;
+ return ret;
+}
+CRPN *JIT_FRET(JIT *jit) {
+ return jit_rpnNewF(jit,OP_RETURN);
+}
+CRPN *JIT_RETI(JIT *jit) {
+ return jit_rpnNew(jit,OP_RETURN);
+}
+CRPN *JIT_POST_DECI(JIT *jit,I64 amt=1) {
+ CRPN *ret=jit_rpnNew(jit,OP_POST_DEC);
+ ret->operands[1](I64)=amt;
+ return ret;
+}
+CRPN *JIT_DUMP_PTR(JIT *jit,U0 **ptr) {
+ CRPN *ret=jit_rpnNew(jit,OP_DUMP_PTR);
+ ret->operands[0](U0**)=ptr;
+ return ret;
+}
+CRPN *JIT_JMP_TABLE(JIT *jit,I64 len) {
+ CRPN *ret=jit_rpnNew(jit,OP_JMP_TABLE);
+ ret->type.body_length=len;
+ ret->jmp_table=MAlloc(len*sizeof(CRPN*));
+ return ret;
+}
+U8 *HexifyStr(U8 *str,I64 len) {
+ U8 *ret=MAlloc(len*2+1),*rptr;
+ I64 idx=0;
+ U8 *hex_digits="0123456789ABCDEF";
+ for(rptr=ret;idx!=len;idx++) {
+ *rptr++=hex_digits[(str[idx]>>4)&0xf];
+ *rptr++=hex_digits[str[idx]&0xf];
+ }
+ return ret;
+}
+U0 JitDumpBytes(JIT *jit) {
+ U8 *hex=HexifyStr(jit->buffer,jit->buf_size);
+ "\n\n\n%s\n\n\n",hex;
+ Free(hex);
+}
+#ifdef JIT_DBG
+U0 FCallTests1() {
+ I64 f1,f2;
+ JIT *jit;
+ "=== [FUNC_CALL 1] ===\n";
+ jit=jit_Init;
+ CRPN *body0=jit_rpnBodyStart(jit);
+ JIT_FUNC_CALL(jit,3);
+ JIT_R(jit,0);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,2);
+ JIT_I64(jit,2);
+ //
+ JIT_F64(jit,3);
+ jit_rpnBodyEnd(jit,body0);
+ JitEmitCode(jit);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+ "=== [FUNC_CALL 2] ===\n";
+ jit=jit_Init;
+ JIT_FADD(jit);
+ JIT_FMUL(jit);
+ JIT_F64(jit,1.0);
+ JIT_F64(jit,2.0);
+ //
+ JIT_FUNC_CALL(jit,1);
+ JIT_R(jit,0);
+ //
+ JIT_FDIV(jit);
+ JIT_F64(jit,4.0);
+ JIT_F64(jit,5.0);
+ //FADD
+ JIT_F64(jit,3.0);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+ //Test for not prigating pushed arguments(whoose my_avalue would be overwriten with a AV_PUSH)
+ "=== [FUNC_CALL 3] ===\n";
+ jit=jit_Init;
+ JIT_FUNC_CALL(jit,2);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,0);
+ JIT_MOV(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,1);
+ JIT_I64(jit,0x11223344);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+FCallTests1;
+U0 GetArgTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ "=== [OP_GETARG 1] ===\n";
+ jit=jit_Init;
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_GETARGI(jit,0);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_GETARGF(jit,1);
+ //
+ JIT_FRET(jit);
+ JIT_FADD(jit);
+ JIT_FFRAME(jit,off);
+ JIT_R(jit,0);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+GetArgTests1;
+U0 ReturnTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ "=== [OP_RET 1] ===\n";
+ jit=jit_Init;
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,8);
+ JIT_RET(jit);
+ JIT_R(jit,0);
+ //
+ JIT_RET(jit);
+ JIT_R(jit,1);
+ //
+ JIT_FRET(jit);
+ JIT_FFRAME(jit,off);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+ReturnTests1;
+U0 AddTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ body=jit_rpnBodyStart(jit);
+ "=== [Add tests 1] ===\n";
+ off=JIT_ALLOCAI(jit,16);
+ //
+ JIT_MOV(jit);
+ JIT_IFRAME(jit,off,4);
+ JIT_ADDI(jit);
+ JIT_ADDI(jit);
+ JIT_ADDI(jit);
+ JIT_I64(jit,101);
+ JIT_R(jit,0);
+ JIT_IFRAME(jit,off);
+ JIT_FFRAME(jit,off+8);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off+8);
+ JIT_FADD(jit);
+ JIT_FADD(jit);
+ JIT_FADD(jit);
+ JIT_F64(jit,101);
+ JIT_R(jit,0);
+ JIT_IFRAME(jit,off);
+ JIT_FFRAME(jit,off+8);
+ //Communitive operation reduction
+ JIT_MOV(jit);
+ JIT_IFRAME(jit,off+8);
+ JIT_ADDI(jit);
+ JIT_ADDI(jit);
+ JIT_ADDI(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,1);
+ JIT_I64(jit,2);
+ JIT_I64(jit,3);
+ jit_rpnBodyEnd(jit,body);
+ //
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+AddTests1;
+U0 SubTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [Sub tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,8);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_SUBI(jit);
+ JIT_SUBI(jit);
+ JIT_SUBI(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,1);
+ JIT_I64(jit,2);
+ JIT_I64(jit,3);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FSUB(jit);
+ JIT_FSUB(jit);
+ JIT_FSUB(jit);
+ JIT_F64(jit,1);
+ JIT_F64(jit,1);
+ JIT_F64(jit,2);
+ JIT_F64(jit,3);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FSUB(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FFRAME(jit,off);
+ jit_rpnBodyEnd(jit,body);
+ //
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+SubTests1;
+U0 NegTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off,r;
+ jit=jit_Init;
+ body=jit_rpnBodyStart(jit);
+ "=== [NEG tests 1] ===\n";
+ off=JIT_ALLOCAI(jit,8);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_NEGI(jit);
+ JIT_I64(jit,1);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_NEGI(jit);
+ JIT_R(jit,0);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FNEG(jit);
+ JIT_F64(jit,1);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FNEG(jit);
+ JIT_FFRAME(jit,off);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+NegTests1;
+U0 MulTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off,r;
+ jit=jit_Init;
+ "=== [Mul tests] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_MULI(jit);
+ JIT_MULI(jit);
+ JIT_MULI(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,1);
+ JIT_I64(jit,2);
+ JIT_I64(jit,3);
+ //
+ JIT_MOV(jit);
+ JIT_IFRAME(jit,off);
+ JIT_MULI(jit);
+ JIT_I64(jit,2);
+ JIT_I64(jit,3);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off+8);
+ JIT_FMUL(jit);
+ JIT_FMUL(jit);
+ JIT_FMUL(jit);
+ JIT_F64(jit,3);
+ JIT_F64(jit,4);
+ JIT_FMUL(jit);
+ JIT_F64(jit,1);
+ JIT_F64(jit,2);
+ JIT_FFRAME(jit,off+8);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+ //
+ "=== [Mul tests(shift reduction)] ===\n";
+ jit=jit_Init;
+ body=jit_rpnBodyStart(jit);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,1);
+ for(r=0;r!=64;r++) {
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_MULI(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,1<<r);
+ }
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+MulTests1;
+U0 DivTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [Div tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_DIVI(jit);
+ JIT_R(jit,1);
+ JIT_R(jit,2);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off+8);
+ JIT_FDIV(jit);
+ JIT_FFRAME(jit,off+8);
+ JIT_FFRAME(jit,off);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+DivTests1;
+U0 ModTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [Mod tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_MODI(jit);
+ JIT_MODI(jit);
+ JIT_R(jit,1);
+ JIT_R(jit,2);
+ JIT_IFRAME(jit,off);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off+8);
+ JIT_FMOD(jit);
+ JIT_FFRAME(jit,off+8);
+ JIT_FFRAME(jit,off);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+ModTests1;
+U0 OrTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [OR tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_ORI(jit);
+ JIT_R(jit,1);
+ JIT_R(jit,2);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FOR(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FFRAME(jit,off+8);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+OrTests1;
+U0 XorTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [XOR tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_XORI(jit);
+ JIT_R(jit,1);
+ JIT_IFRAME(jit,off);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FXOR(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FXOR(jit);
+ JIT_F64(jit,1);
+ JIT_FFRAME(jit,off+8);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+XorTests1;
+U0 AndTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [AND tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_ANDI(jit);
+ JIT_IFRAME(jit,off);
+ JIT_IFRAME(jit,off+8);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FAND(jit);
+ JIT_R(jit,0);
+ JIT_IFRAME(jit,off+8);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+AndTests1;
+U0 ShlTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [SHL Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_LSHI(jit);
+ JIT_IFRAME(jit,off);
+ JIT_IFRAME(jit,off+8);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FSHL(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FFRAME(jit,off+8);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FSHL(jit);
+ JIT_FFRAME(jit,off);
+ JIT_R(jit,0);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+ShlTests1;
+U0 ShrTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [SHR Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_RSHI(jit);
+ JIT_IFRAME(jit,off);
+ JIT_IFRAME(jit,off+8);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FSHR(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FFRAME(jit,off+8);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FSHR(jit);
+ JIT_FFRAME(jit,off);
+ JIT_R(jit,0);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+ShrTests1;
+U0 ShrUTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [SHRU Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_RSHU(jit);
+ JIT_R(jit,0);
+ JIT_IFRAME(jit,off+8);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+ShrUTests1;
+U0 NotTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [NOT Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_NOTI(jit);
+ JIT_R(jit,0);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FNOT(jit);
+ JIT_FFRAME(jit,off+8);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+
+ JIT_FREE(jit);
+}
+NotTests1;
+U0 CmpTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [CMP Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_LTI(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_GTI(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,2);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_GEI(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,3);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_LEI(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,4);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_LTU(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_GTU(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,2);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_GEU(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,3);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_LEU(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,4);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FLT(jit);
+ JIT_FFRAME(jit,off);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_FGT(jit);
+ JIT_FFRAME(jit,off);
+ JIT_F64(jit,2);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_FGE(jit);
+ JIT_FFRAME(jit,off);
+ JIT_F64(jit,1.2);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FLE(jit);
+ JIT_R(jit,0);
+ JIT_FFRAME(jit,off);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+CmpTests1;
+U0 NeTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [NE Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_NEI(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_FNE(jit);
+ JIT_R(jit,0);
+ JIT_FFRAME(jit,off+8);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+NeTests1;
+U0 EqTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [EQ Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_EQI(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_FEQ(jit);
+ JIT_R(jit,0);
+ JIT_FFRAME(jit,off+8);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+EqTests1;
+U0 IncTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [INC Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,0);
+ JIT_MOV(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_POST_INCI(jit);
+ JIT_R(jit,1);
+ //
+ JIT_PRE_INCI(jit);
+ JIT_R(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_POST_INCI(jit,8);
+ JIT_R(jit,1);
+ //
+ JIT_PRE_INCI(jit,8);
+ JIT_R(jit,1);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FPOST_INC(jit);
+ JIT_FFRAME(jit,off+8);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FPRE_INC(jit);
+ JIT_FFRAME(jit,off+8);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+IncTests1;
+U0 DecTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [DEC Tests 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,0);
+ JIT_MOV(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_POST_DECI(jit);
+ JIT_R(jit,1);
+ //
+ JIT_PRE_DECI(jit);
+ JIT_R(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_POST_DECI(jit,8);
+ JIT_R(jit,1);
+ //
+ JIT_PRE_DECI(jit,8);
+ JIT_R(jit,1);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FPOST_DEC(jit);
+ JIT_FFRAME(jit,off+8);
+ //
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FPRE_DEC(jit);
+ JIT_FFRAME(jit,off+8);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+DecTests1;
+U0 DerefTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off;
+ jit=jit_Init;
+ "=== [DEREF Tests 1] ===\n";
+ //
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_ADDI(jit);
+ JIT_RBP(jit);
+ JIT_I64(jit,off);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_DEREF(jit);
+ JIT_R(jit,0);
+ //
+ JIT_MOV(jit);
+ JIT_DEREF(jit);
+ JIT_DEREF(jit);
+ JIT_DEREF(jit);
+ JIT_R(jit,0);
+ JIT_R(jit,1);
+ //Test offset merging
+ JIT_MOV(jit);
+ JIT_DEREF(jit);
+ JIT_ADDI(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,123);
+ JIT_I64(jit,3);
+ //Ditto
+ JIT_MOV(jit);
+ JIT_DEREF(jit);
+ JIT_ADDI(jit);
+ JIT_I64(jit,123);
+ JIT_R(jit,1);
+ JIT_I64(jit,4);
+ //
+ JIT_FMOV(jit);
+ JIT_FDEREF(jit);
+ JIT_ADDI(jit);
+ JIT_I64(jit,123);
+ JIT_R(jit,1);
+ JIT_F64(jit,4);
+
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+DerefTests1;
+U0 BigMoveTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off,r;
+ jit=jit_Init;
+ "=== [BIG MOVE 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ for(r=0;r!=20;r++) {
+ JIT_MOV(jit);
+ JIT_R(jit,r);
+ JIT_I64(jit,r);
+ }
+ //
+ JIT_MOV(jit);
+ JIT_DEREF(jit,,1024);
+ JIT_R(jit,0xb);
+ JIT_DEREF(jit,1025,1024);
+ JIT_R(jit,0xc);
+ //
+ JIT_MOV(jit);
+ JIT_DEREF(jit,256,1024);
+ JIT_R(jit,0xc);
+ JIT_DEREF(jit,,256);
+ JIT_R(jit,0xb);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ for(r=0;r!=19;r++)
+ JIT_ADDI(jit);
+ for(r=0;r!=20;r++)
+ JIT_R(jit,r);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+BigMoveTests1;
+U0 TypecastTests1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off,r;
+ jit=jit_Init;
+ "=== [TYPECAST 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,16);
+
+ JIT_MOV(jit);
+ JIT_R(jit,1);
+ JIT_I64(jit,1);
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off+0);
+ JIT_F64(jit,2.0);
+ //De-facto bit for bit typecast
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off+8);
+ JIT_FTYPECAST(jit);
+ JIT_R(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_IFRAME(jit,off+0);
+ JIT_TYPECAST(jit);
+ JIT_FFRAME(jit,off+8);
+ //Test tyepcasting derefernces
+ JIT_FMOV(jit);
+ JIT_FDEREF(jit);
+ JIT_ADDI(jit);
+ JIT_RBP(jit);
+ JIT_I64(jit,off+1);
+ JIT_F64(jit,2.0);
+ //
+ JIT_FTYPECAST(jit);
+ JIT_R(jit,1);
+ //
+ JIT_MOV(jit);
+ JIT_DEREF(jit);
+ JIT_ADDI(jit);
+ JIT_RBP(jit);
+ JIT_I64(jit,off);
+ JIT_TYPECAST(jit);
+ JIT_FFRAME(jit,off+8);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+TypecastTests1;
+//
+//Here we add lots of register variables to check for spilling
+//
+U0 GrindTest1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off,r;
+ jit=jit_Init;
+ "=== [GRIND 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,8);
+ for(r=0;r!=20;r++) {
+ JIT_MOV(jit);
+ JIT_R(jit,r);
+ JIT_I64(jit,r);
+ }
+ JIT_MOV(jit);
+ JIT_IFRAME(jit,off);
+ for(r=0;r!=19;r++)
+ JIT_ADDI(jit);
+ for(r=0;r!=20;r++)
+ JIT_R(jit,r);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+ //Test for not messing with rdx when __Div-ing
+ "=== [GRIND 1.5] ===\n";
+ jit=jit_Init;
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,8);
+ for(r=0;r!=20;r++) {
+ JIT_MOV(jit);
+ JIT_R(jit,r);
+ JIT_I64(jit,r);
+ }
+ JIT_MOV(jit);
+ JIT_IFRAME(jit,off);
+ for(r=0;r!=19;r++)
+ JIT_DIVI(jit);
+ for(r=0;r!=20;r++)
+ JIT_R(jit,r);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+
+}
+GrindTest1;
+//Grind the arguments to the function to test AV_PUSH
+U0 GrindTest2() {
+ JIT *jit;
+ CRPN *body;
+ I64 off,r;
+ jit=jit_Init;
+ "=== [GRIND 2] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,8);
+ for(r=0;r!=20;r++) {
+ JIT_MOV(jit);
+ JIT_R(jit,r);
+ JIT_I64(jit,r);
+ }
+ JIT_MOV(jit);
+ JIT_IFRAME(jit,off);
+ //Our architypes are
+ //IArithUnop
+ //IIncOp
+ //IArithOp
+ //FPUOp
+ //__Div
+ //ShiftOp
+ //OP_INLINE_PUSH
+ JIT_FUNC_CALL(jit,7);
+ JIT_R(jit,0);
+ //1. IArithUnop
+ JIT_NEGI(jit);
+ JIT_R(jit,1);
+ //2. IIncOp
+ JIT_PRE_INCI(jit);
+ JIT_R(jit,2);
+ //3. IArithOp
+ JIT_ADDI(jit);
+ JIT_R(jit,3);
+ JIT_R(jit,4);
+ //4. FPUOp
+ JIT_FDIV(jit);
+ JIT_F64(jit,1);
+ JIT_FFRAME(jit,off);
+ //5. __Div
+ JIT_DIVI(jit);
+ JIT_R(jit,5);
+ JIT_R(jit,6);
+ //6. ShiftOp
+ JIT_LSHI(jit);
+ JIT_R(jit,7);
+ JIT_R(jit,8);
+ //7. OP_INPLACE_PUSH
+ JIT_R(jit,9);
+ // Do a sum of registers to test for spilled registers
+ JIT_MOV(jit);
+ JIT_IFRAME(jit,off);
+ for(r=0;r!=19;r++)
+ JIT_ADDI(jit);
+ for(r=0;r!=20;r++)
+ JIT_R(jit,r);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+ "=== [GRIND 2.5] ===\n";
+ jit=jit_Init;
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,40);
+ //Test spilling Floating point values at time of function call
+ JIT_FMOV(jit);
+ JIT_FFRAME(jit,off);
+ JIT_FADD(jit); //FADD,FCALL
+ JIT_FADD(jit);
+ JIT_FFRAME(jit,off+8);
+ JIT_FFRAME(jit,off+16);
+ JIT_FCALL(jit,1);
+ JIT_R(jit,0);
+ JIT_FADD(jit);
+ JIT_FFRAME(jit,off+24);
+ JIT_FFRAME(jit,off+32);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+GrindTest2;
+U0 RelocTest1() {
+ JIT *jit;
+ CRPN *body;
+ I64 off,r;
+ U8 *pat;
+ jit=jit_Init;
+ "=== [RELOC 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,8);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_RELOCATION(jit,&pat);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ *pat=0xB0b15C001;
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+RelocTest1;
+U0 IfTest1() {
+ JIT *jit;
+ CRPN *body,*t,*f;
+ I64 off,r;
+ jit=jit_Init;
+ //Test switching to different register mappings per jmp
+ "=== [IF 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,8);
+ for(r=0;r!=20;r++) {
+ JIT_MOV(jit);
+ JIT_R(jit,r);
+ JIT_I64(jit,r);
+ }
+ jit_rpnIf(jit);
+ JIT_R(jit,0);
+ //
+ t=jit_rpnBodyStart(jit);
+ //Reverse order
+ for(r=20-1;r>=0;r--) {
+ JIT_MOV(jit);
+ JIT_R(jit,r);
+ JIT_I64(jit,r);
+ }
+ jit_rpnBodyEnd(jit,t);
+ //
+ f=jit_rpnBodyStart(jit);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,123);
+ /*
+ //Reverse order
+ for(r=0;r!=19;r++)
+ JIT_SUBI(jit);
+ for(r=20-1;r>=0;r--)
+ JIT_R(jit,r);
+ */
+ jit_rpnBodyEnd(jit,f);
+ //
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ //Forward order
+ for(r=0;r!=19;r++)
+ JIT_ADDI(jit);
+ for(r=0;r!=20;r++)
+ JIT_R(jit,r);
+ //
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+IfTest1;
+U0 JmpTest1() {
+ JIT *jit;
+ CRPN *body,*jmp;
+ I64 off,r;
+ jit=jit_Init;
+ //Test switching to different register mappings per jmp
+ "=== [JMP 1] ===\n";
+ body=jit_rpnBodyStart(jit);
+ off=JIT_ALLOCAI(jit,8);
+ for(r=0;r!=20;r++) {
+ JIT_MOV(jit);
+ JIT_R(jit,r);
+ JIT_I64(jit,r);
+ }
+ jit_rpnIf(jit);
+ JIT_R(jit,0);
+ //
+ jmp=JIT_JMP(jit,NULL);
+ // "NULL" false case
+ JIT_I64(jit,-1);
+ for(r=19;r>=0;r--) {
+ JIT_MOV(jit);
+ JIT_R(jit,r);
+ JIT_I64(jit,r);
+ }
+ //Test swapping register mapping
+ JIT_PATCH(jit,jmp,JIT_LABEL(jit));
+ JIT_MOV(jit);
+ JIT_R(jit,19);
+ for(r=0;r!=19;r++)
+ JIT_ADDI(jit);
+ for(r=0;r!=20;r++)
+ JIT_R(jit,r);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ JIT_FREE(jit);
+}
+JmpTest1;
+U0 JTabTests1() {
+ JIT *jit;
+ CRPN *body,*j1,*j2,*j3,*d;
+ I64 off,r;
+ jit=jit_Init;
+ body=jit_rpnBodyStart(jit);
+ JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_I64(jit,1);
+ j1=JIT_JMP_TABLE(jit,3);
+ JIT_R(jit,0);
+ JIT_RETI(jit);
+ JIT_I64(jit,0);
+ //
+ j1->jmp_table[0]=JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_ADDI(jit);
+ JIT_R(jit,0);
+ JIT_R(jit,1);
+ //
+ j1->jmp_table[1]=JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_MULI(jit);
+ JIT_R(jit,0);
+ JIT_R(jit,2);
+ //
+ j1->jmp_table[2]=JIT_MOV(jit);
+ JIT_R(jit,0);
+ JIT_SUBI(jit);
+ JIT_R(jit,0);
+ JIT_R(jit,3);
+ jit_rpnBodyEnd(jit,body);
+ JitEmitCode(jit,0);
+ JitDumpBytes(jit);
+ DumpRPN(FirstRPN(jit->cur_rpn_start));
+ JIT_FREE(jit);
+}
+JTabTests1;
+#endif
+/*
+//Count to 10
+jit=jit_Init;
+CRPN *body0=jit_rpnBodyStart(jit);
+I64 frame=JIT_ALLOCAI(jit,16);
+JIT_FMOV(jit);
+JIT_FFRAME(jit,0);
+JIT_F64(jit,0.0);
+JIT_FMOV(jit);
+JIT_FFRAME(jit,8);
+JIT_F64(jit,1.0);
+CRPN *if_op=JIT_LABEL(jit);
+jit_rpnIf(jit);
+JIT_FLT(jit);
+JIT_F64(jit,10.0);
+JIT_FFRAME(jit,0);
+CRPN *body=jit_rpnBodyStart(jit);
+JIT_FMOV(jit);
+JIT_FFRAME(jit,0);
+JIT_FADD(jit);
+JIT_FADD(jit);
+JIT_FFRAME(jit,0);
+JIT_F64(jit,101);
+JIT_FADD(jit);
+JIT_FFRAME(jit,8);
+JIT_F64(jit,102);
+JIT_JMP(jit,if_op);
+jit_rpnBodyEnd(jit,body);
+body=jit_rpnBodyStart(jit);
+JIT_RET(jit);
+JIT_I64(jit,0);
+jit_rpnBodyEnd(jit,body);
+jit_rpnBodyEnd(jit,body0);
+"==== [Count to 10] ====\n";
+"%s\n",JitEmitCode(jit,0);
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Debian_pkg.sh b/Debian_pkg.sh
index 1fe099d..8a71abd 100755
--- a/Debian_pkg.sh
+++ b/Debian_pkg.sh
@@ -1,15 +1,16 @@
#/bin/tcsh
+tcsh makeBSD.tcsh
set STAGEDIR = `pwd`/debian
mkdir -p ${STAGEDIR}
mkdir -p ${STAGEDIR}/usr
mkdir -p ${STAGEDIR}/usr/local
mkdir -p ${STAGEDIR}/usr/local/bin
mkdir -p ${STAGEDIR}/usr/local/include/HolyC
-cp 3d_loader ${STAGEDIR}/usr/local/bin/3d
+cp 3d_loader2 ${STAGEDIR}/usr/local/bin/3d
strip ${STAGEDIR}/usr/local/bin/3d
chmod +x ${STAGEDIR}/usr/local/bin/3d
set files = ( \
- HCRT.BIN \
+ HCRT_TOS.BIN \
)
rm ${STAGEDIR}/plist
echo "/usr/local/bin/3d" >> ${STAGEDIR}/plist
diff --git a/FFI_SYSV.yasm b/FFI_SYSV.yasm
new file mode 100644
index 0000000..88509c8
--- /dev/null
+++ b/FFI_SYSV.yasm
@@ -0,0 +1,223 @@
+;Poo Poo FFI for SystemV to TempleOS
+;
+; Push arguments as normal
+;
+%macro TOS_ffi 3
+GLOBAL FFI_%1
+EXTERN STK_%2
+FFI_%1:
+PUSH RBP
+MOV RBP,RSP
+AND RSP,-0x10
+PUSH RSI
+PUSH RDI
+PUSH R10
+PUSH R11
+LEA RDI,[RBP+8+8]
+CALL STK_%2
+POP R11
+POP R10
+POP RDI
+POP RSI
+LEAVE
+RET 8*%3
+%endmacro
+
+GLOBAL FFI_CALL_TOS_0
+FFI_CALL_TOS_0:
+PUSH RBP
+MOV RBP,RSP
+PUSH RBX
+CALL RDI
+POP RBX
+LEAVE
+RET
+
+
+GLOBAL FFI_CALL_TOS_1
+FFI_CALL_TOS_1:
+PUSH RBP
+MOV RBP,RSP
+PUSH RBX
+PUSH RSI
+CALL RDI
+POP RBX
+LEAVE
+RET
+
+GLOBAL FFI_CALL_TOS_2
+FFI_CALL_TOS_2:
+PUSH RBP
+MOV RBP,RSP
+PUSH RBX
+PUSH RDX
+PUSH RSI
+CALL RDI
+POP RBX
+LEAVE
+RET
+
+GLOBAL FFI_CALL_TOS_3
+FFI_CALL_TOS_3:
+PUSH RBP
+MOV RBP,RSP
+PUSH RBX
+PUSH RCX
+PUSH RDX
+PUSH RSI
+CALL RDI
+POP RBX
+LEAVE
+RET
+
+GLOBAL FFI_CALL_TOS_4
+FFI_CALL_TOS_4:
+PUSH RBP
+MOV RBP,RSP
+PUSH RBX
+PUSH R8
+PUSH RCX
+PUSH RDX
+PUSH RSI
+CALL RDI
+POP RBX
+LEAVE
+RET
+
+TOS_ffi EnterTry,EnterTry,0 ;
+TOS_ffi PopTryFrame,PopTryFrame,0 ;
+TOS_ffi GCollect,GCollect,0 ;
+TOS_ffi Del,Del,1 ;
+TOS_ffi throw,throw,1 ;
+TOS_ffi ExitCatch,ExitCatch,0 ;
+TOS_ffi BFFS,BFFS,1 ;
+TOS_ffi BCLZ,BCLZ, 1;
+TOS_ffi __GetStr,__GetStr,1 ;
+TOS_ffi MemNCpy,MemNCpy,3 ;
+TOS_ffi __Move,__Move,2 ;
+TOS_ffi Cd,Cd,1 ;
+TOS_ffi DirCur,DirCur,0 ;
+TOS_ffi DirMk,DirMk,1 ;
+TOS_ffi FileNameAbs,FileNameAbs,1 ;
+TOS_ffi IsDir,IsDir,1 ;
+TOS_ffi FileWrite,FileWrite,3 ;
+TOS_ffi FileRead,FileRead,2 ;
+TOS_ffi __Dir,__Dir,1 ;
+TOS_ffi IsWindows,IsWindows,0 ;
+TOS_ffi IsMac,IsMac,0 ;
+TOS_ffi CreateTagsAndErrorsFiles,CreateTagsAndErrorsFiles,3 ;
+TOS_ffi hc_SDL_GetWindowTitle,hc_SDL_GetWindowTitle,1 ;
+TOS_ffi SDL_GetClipboardText,SDL_GetClipboardText,0 ;
+TOS_ffi GetSurfaceW,GetSurfaceW,1 ;
+TOS_ffi GetSurfaceH,GetSurfaceH,1 ;
+TOS_ffi ForeachFunc,ForeachFunc,1 ;
+TOS_ffi log2,log2,1 ;
+TOS_ffi UnblockSignals,UnblockSignals,0 ;
+TOS_ffi SDL_Init,SDL_Init,1 ;
+TOS_ffi SDL_WasInit,SDL_WasInit,0 ;
+TOS_ffi SDL_CreateWindow,SDL_CreateWindow,6 ;
+TOS_ffi SDL_SetTextureBlendMode,SDL_SetTextureBlendMode,2 ;
+TOS_ffi SDL_CreateWindowAndRenderer,SDL_CreateWindowAndRenderer,5 ;
+TOS_ffi SDL_DestroyWindow,SDL_DestroyWindow,1 ;
+TOS_ffi SDL_DisableScreenSaver,SDL_DisableScreenSaver,0 ;
+TOS_ffi SDL_GetGrabbedWindow,SDL_GetGrabbedWindow,0 ;
+TOS_ffi SDL_GetWindowPosition,SDL_GetWindowPosition,3 ;
+TOS_ffi SDL_GetWindowMinimumSize,SDL_GetWindowMinimumSize,3 ;
+TOS_ffi SDL_GetWindowMaximumSize,SDL_GetWindowMaximumSize,3 ;
+TOS_ffi SDL_GetWindowSize,SDL_GetWindowSize,3 ;
+TOS_ffi SDL_HideWindow,SDL_HideWindow,1 ;
+TOS_ffi SDL_MaximizeWindow,SDL_MaximizeWindow,1 ;
+TOS_ffi SDL_MinimizeWindow,SDL_MinimizeWindow,1 ;
+TOS_ffi SDL_SetWindowBordered,SDL_SetWindowBordered,2 ;
+TOS_ffi SDL_SetWindowFullscreen,SDL_SetWindowFullscreen,2 ;
+TOS_ffi SDL_SetWindowMaximumSize,SDL_SetWindowMaximumSize,3 ;
+TOS_ffi SDL_SetWindowMinimumSize,SDL_SetWindowMinimumSize,3 ;
+TOS_ffi SDL_SetWindowResizable,SDL_SetWindowResizable,2 ;
+TOS_ffi SDL_SetWindowSize,SDL_SetWindowSize,3 ;
+TOS_ffi SDL_SetWindowTitle,SDL_SetWindowTitle,2 ;
+TOS_ffi SDL_ShowWindow,SDL_ShowWindow,1 ;
+TOS_ffi SDL_CreateRenderer,SDL_CreateRenderer,3 ;
+TOS_ffi SDL_CreateTexture,SDL_CreateTexture,5 ;
+TOS_ffi SDL_GetRenderer,SDL_GetRenderer,1 ;
+TOS_ffi SDL_GetRendererOutputSize,SDL_GetRendererOutputSize,3 ;
+TOS_ffi SDL_GetRenderTarget,SDL_GetRenderTarget,1 ;
+TOS_ffi SDL_GetTextureAlphaMod,SDL_GetTextureAlphaMod,2 ;
+TOS_ffi SDL_GetTextureColorMod,SDL_GetTextureColorMod,2 ;
+TOS_ffi SDL_RenderClear,SDL_RenderClear,1 ;
+TOS_ffi SDL_RenderCopy,SDL_RenderCopy,4 ;
+TOS_ffi SDL_RenderDrawLine,SDL_RenderDrawLine,5 ;
+TOS_ffi SDL_RenderDrawPoint,SDL_RenderDrawPoint,3 ;
+TOS_ffi SDL_RenderDrawPoints,SDL_RenderDrawPoints,3 ;
+TOS_ffi SDL_RenderDrawRect,SDL_RenderDrawRect,2 ;
+TOS_ffi SDL_RenderDrawRects,SDL_RenderDrawRects,3 ;
+TOS_ffi SDL_RenderFillRects,SDL_RenderFillRects,3 ;
+TOS_ffi SDL_RenderGetClipRect,SDL_RenderGetClipRect,2 ;
+TOS_ffi SDL_RenderPresent,SDL_RenderPresent,1 ;
+TOS_ffi SDL_RenderSetClipRect,SDL_RenderSetClipRect,2 ;
+TOS_ffi SDL_SetTextureAlphaMod,SDL_SetTextureAlphaMod,2 ;
+TOS_ffi SDL_SetTextureColorMod,SDL_SetTextureColorMod,4 ;
+TOS_ffi SDL_UpdateTexture,SDL_UpdateTexture,4 ;
+TOS_ffi SDL_QueryTexture,SDL_QueryTexture,6 ;
+TOS_ffi SDL_SetClipboardText,SDL_SetClipboardText,1 ;
+TOS_ffi SDL_PollEvent,SDL_PollEvent,1 ;
+TOS_ffi SDL_WaitEvent,SDL_WaitEvent,1 ;
+TOS_ffi SDL_DestroyRenderer,SDL_DestroyRenderer,1
+TOS_ffi SDL_DestroyTexture,SDL_DestroyTexture,1 ;
+TOS_ffi SDL_StartTextInput,SDL_StartTextInput,0 ;
+TOS_ffi SDL_StopTextInput,SDL_StopTextInput,0 ;
+TOS_ffi SDL_GetError,SDL_GetError,0 ;
+TOS_ffi SDL_ClearError,SDL_ClearError,0 ;
+TOS_ffi SDL_FlushEvent,SDL_FlushEvent,1 ;
+TOS_ffi SDL_CreateRGBSurface,SDL_CreateRGBSurface,8 ;
+TOS_ffi SDL_CreateRGBSurfaceFrom,SDL_CreateRGBSurfaceFrom,9 ;
+TOS_ffi SDL_UpperBlit,SDL_UpperBlit,4 ;
+TOS_ffi SDL_FillRect,SDL_FillRect,3 ;
+TOS_ffi SDL_FillRects,SDL_FillRects,4 ;
+TOS_ffi SDL_GetClipRect,SDL_GetClipRect,2 ;
+TOS_ffi SDL_GetColorKey,SDL_GetColorKey,2 ;
+TOS_ffi SDL_GetSurfaceAlphaMod,SDL_GetSurfaceAlphaMod,2 ;
+TOS_ffi SDL_GetSurfaceColorMod,SDL_GetSurfaceColorMod,4 ;
+TOS_ffi SDL_LockSurface,SDL_LockSurface,1 ;
+TOS_ffi SDL_UnlockSurface,SDL_UnlockSurface,1 ;
+TOS_ffi SDL_SetClipRect,SDL_SetClipRect,2 ;
+TOS_ffi SDL_SetColorKey,SDL_SetColorKey,3 ;
+TOS_ffi SDL_SetSurfaceColorMod,SDL_SetSurfaceColorMod,4 ;
+TOS_ffi SDL_SetSurfaceAlphaMod,SDL_SetSurfaceAlphaMod,2 ;
+TOS_ffi SDL_SetSurfaceRLE,SDL_SetSurfaceRLE,2 ;
+TOS_ffi SDL_BlitSurface,SDL_BlitSurface,4 ;
+TOS_ffi SDL_BlitScaled,SDL_BlitScaled,4 ;
+TOS_ffi SDL_FreeSurface,SDL_FreeSurface,1 ;
+TOS_ffi SDL_UpdateWindowSurface,SDL_UpdateWindowSurface,1 ;
+TOS_ffi SDL_GetWindowSurface,SDL_GetWindowSurface,1 ;
+TOS_ffi __GetBuiltinMacrosText,__GetBuiltinMacrosText,0 ;
+TOS_ffi exit,exit,1 ;
+TOS_ffi trunc,trunc,1 ;
+TOS_ffi round,round,1 ;
+TOS_ffi log10,log10,1 ;
+TOS_ffi log,log,1 ;
+TOS_ffi floor,floor,1 ;
+TOS_ffi ceil,ceil,1 ;
+TOS_ffi tan,tan,1 ;
+TOS_ffi sqrt,sqrt,1 ;
+TOS_ffi sin,sin,1 ;
+TOS_ffi cos,cos,1 ;
+TOS_ffi memset,memset,3 ;
+TOS_ffi abs,abs,1 ;
+TOS_ffi atan,atan,1 ;
+TOS_ffi GetFs,GetFs,0 ;
+TOS_ffi strstr,strstr,2 ;
+TOS_ffi strncpy,strncpy,3 ;
+TOS_ffi strcpy,strcpy,2 ;
+TOS_ffi strncmp,strncmp,3 ;
+TOS_ffi strcmp,strcmp,2 ;
+TOS_ffi strlen,strlen,1 ;
+TOS_ffi PoopMAlloc,PoopMAlloc,1 ;
+TOS_ffi PoopFree,PoopFree,1 ;
+TOS_ffi PoopSetGCEnable,PoopSetGCEnable,1 ;
+TOS_ffi pow,pow,2 ;
+TOS_ffi BoundsCheck,BoundsCheck,2 ;
+TOS_ffi TOSPrint,TOSPrint,2 ;
+TOS_ffi Signal,Signal,2 ;
+TOS_ffi RegisterRuntimeClasses,RegisterRuntimeClasses,4 ;
+TOS_ffi MSize,MSize,1 ;
+TOS_ffi GetBuiltinMacrosText,GetBuiltinMacrosText,0 ;
diff --git a/FFI_WIN64.yasm b/FFI_WIN64.yasm
new file mode 100644
index 0000000..13e0bea
--- /dev/null
+++ b/FFI_WIN64.yasm
@@ -0,0 +1,237 @@
+;Poo Poo FFI for SystemV to TempleOS
+
+;
+; Push arguments as normal
+;
+%macro TOS_ffi 3
+GLOBAL FFI_%1
+EXTERN STK_%2
+FFI_%1:
+PUSH RBP
+MOV RBP,RSP
+AND RSP,-0x10
+PUSH R10
+PUSH R11
+LEA RCX,[RBP+8+8]
+PUSH R9
+PUSH R8
+PUSH RDX
+PUSH RCX
+CALL STK_%2
+ADD RSP,0x20
+POP R11
+POP R10
+LEAVE
+RET 8*%3
+
+%endmacro
+
+GLOBAL FFI_CALL_TOS_0
+FFI_CALL_TOS_0:
+PUSH RBP
+MOV RBP,RSP
+MOV RAX,RCX
+PUSH RBX
+CALL RAX
+POP RBX
+LEAVE
+RET
+
+GLOBAL FFI_CALL_TOS_1
+FFI_CALL_TOS_1:
+PUSH RBP
+MOV RBP,RSP
+MOV RAX,RCX
+PUSH RBX
+PUSH RDX
+CALL RAX
+POP RBX
+LEAVE
+RET
+
+GLOBAL FFI_CALL_TOS_2
+FFI_CALL_TOS_2:
+PUSH RBP
+MOV RBP,RSP
+MOV RAX,RCX
+PUSH RBX
+PUSH R8
+PUSH RDX
+CALL RAX
+POP RBX
+LEAVE
+RET
+
+GLOBAL FFI_CALL_TOS_3
+FFI_CALL_TOS_3:
+PUSH RBP
+MOV RBP,RSP
+MOV RAX,RCX
+PUSH RBX
+PUSH R9
+PUSH R8
+PUSH RDX
+CALL RAX
+POP RBX
+LEAVE
+RET
+
+;https://docs.microsoft.com/en-us/cpp/build/stack-usage?view=msvc-170
+; Fist stack arg:0x30
+; R9 HOME+0x28
+; R8 HOME+0x20
+; RDX HOME+0x18
+; RCX HOME+0x10
+; RET ADDR+8
+; RBP
+GLOBAL FFI_CALL_TOS_4
+FFI_CALL_TOS_4:
+PUSH RBP
+MOV RBP,RSP
+PUSH RBX
+PUSH QWORD [RBP+0x30]
+PUSH R9
+PUSH R8
+PUSH RDX
+CALL RCX
+POP RBX
+LEAVE
+RET
+
+TOS_ffi EnterTry,EnterTry,0 ;
+TOS_ffi PopTryFrame,PopTryFrame,0 ;
+TOS_ffi GCollect,GCollect,0 ;
+TOS_ffi Del,Del,1 ;
+TOS_ffi throw,throw,1 ;
+TOS_ffi ExitCatch,ExitCatch,0 ;
+TOS_ffi BFFS,BFFS,1 ;
+TOS_ffi BCLZ,BCLZ, 1;
+TOS_ffi __GetStr,__GetStr,1 ;
+TOS_ffi MemNCpy,MemNCpy,3 ;
+TOS_ffi __Move,__Move,2 ;
+TOS_ffi Cd,Cd,1 ;
+TOS_ffi DirCur,DirCur,0 ;
+TOS_ffi DirMk,DirMk,1 ;
+TOS_ffi FileNameAbs,FileNameAbs,1 ;
+TOS_ffi IsDir,IsDir,1 ;
+TOS_ffi FileWrite,FileWrite,3 ;
+TOS_ffi FileRead,FileRead,2 ;
+TOS_ffi __Dir,__Dir,1 ;
+TOS_ffi IsWindows,IsWindows,0 ;
+TOS_ffi IsMac,IsMac,0 ;
+TOS_ffi CreateTagsAndErrorsFiles,CreateTagsAndErrorsFiles,3 ;
+TOS_ffi hc_SDL_GetWindowTitle,hc_SDL_GetWindowTitle,1 ;
+TOS_ffi SDL_GetClipboardText,SDL_GetClipboardText,0 ;
+TOS_ffi GetSurfaceW,GetSurfaceW,1 ;
+TOS_ffi GetSurfaceH,GetSurfaceH,1 ;
+TOS_ffi ForeachFunc,ForeachFunc,1 ;
+TOS_ffi log2,log2,1 ;
+TOS_ffi UnblockSignals,UnblockSignals,0 ;
+TOS_ffi SDL_Init,SDL_Init,1 ;
+TOS_ffi SDL_WasInit,SDL_WasInit,0 ;
+TOS_ffi SDL_CreateWindow,SDL_CreateWindow,6 ;
+TOS_ffi SDL_SetTextureBlendMode,SDL_SetTextureBlendMode,2 ;
+TOS_ffi SDL_CreateWindowAndRenderer,SDL_CreateWindowAndRenderer,5 ;
+TOS_ffi SDL_DestroyWindow,SDL_DestroyWindow,1 ;
+TOS_ffi SDL_DisableScreenSaver,SDL_DisableScreenSaver,0 ;
+TOS_ffi SDL_GetGrabbedWindow,SDL_GetGrabbedWindow,0 ;
+TOS_ffi SDL_GetWindowPosition,SDL_GetWindowPosition,3 ;
+TOS_ffi SDL_GetWindowMinimumSize,SDL_GetWindowMinimumSize,3 ;
+TOS_ffi SDL_GetWindowMaximumSize,SDL_GetWindowMaximumSize,3 ;
+TOS_ffi SDL_GetWindowSize,SDL_GetWindowSize,3 ;
+TOS_ffi SDL_HideWindow,SDL_HideWindow,1 ;
+TOS_ffi SDL_MaximizeWindow,SDL_MaximizeWindow,1 ;
+TOS_ffi SDL_MinimizeWindow,SDL_MinimizeWindow,1 ;
+TOS_ffi SDL_SetWindowBordered,SDL_SetWindowBordered,2 ;
+TOS_ffi SDL_SetWindowFullscreen,SDL_SetWindowFullscreen,2 ;
+TOS_ffi SDL_SetWindowMaximumSize,SDL_SetWindowMaximumSize,3 ;
+TOS_ffi SDL_SetWindowMinimumSize,SDL_SetWindowMinimumSize,3 ;
+TOS_ffi SDL_SetWindowResizable,SDL_SetWindowResizable,2 ;
+TOS_ffi SDL_SetWindowSize,SDL_SetWindowSize,3 ;
+TOS_ffi SDL_SetWindowTitle,SDL_SetWindowTitle,2 ;
+TOS_ffi SDL_ShowWindow,SDL_ShowWindow,1 ;
+TOS_ffi SDL_CreateRenderer,SDL_CreateRenderer,3 ;
+TOS_ffi SDL_CreateTexture,SDL_CreateTexture,5 ;
+TOS_ffi SDL_GetRenderer,SDL_GetRenderer,1 ;
+TOS_ffi SDL_GetRendererOutputSize,SDL_GetRendererOutputSize,3 ;
+TOS_ffi SDL_GetRenderTarget,SDL_GetRenderTarget,1 ;
+TOS_ffi SDL_GetTextureAlphaMod,SDL_GetTextureAlphaMod,2 ;
+TOS_ffi SDL_GetTextureColorMod,SDL_GetTextureColorMod,2 ;
+TOS_ffi SDL_RenderClear,SDL_RenderClear,1 ;
+TOS_ffi SDL_RenderCopy,SDL_RenderCopy,4 ;
+TOS_ffi SDL_RenderDrawLine,SDL_RenderDrawLine,5 ;
+TOS_ffi SDL_RenderDrawPoint,SDL_RenderDrawPoint,3 ;
+TOS_ffi SDL_RenderDrawPoints,SDL_RenderDrawPoints,3 ;
+TOS_ffi SDL_RenderDrawRect,SDL_RenderDrawRect,2 ;
+TOS_ffi SDL_RenderDrawRects,SDL_RenderDrawRects,3 ;
+TOS_ffi SDL_RenderFillRects,SDL_RenderFillRects,3 ;
+TOS_ffi SDL_RenderGetClipRect,SDL_RenderGetClipRect,2 ;
+TOS_ffi SDL_RenderPresent,SDL_RenderPresent,1 ;
+TOS_ffi SDL_RenderSetClipRect,SDL_RenderSetClipRect,2 ;
+TOS_ffi SDL_SetTextureAlphaMod,SDL_SetTextureAlphaMod,2 ;
+TOS_ffi SDL_SetTextureColorMod,SDL_SetTextureColorMod,4 ;
+TOS_ffi SDL_UpdateTexture,SDL_UpdateTexture,4 ;
+TOS_ffi SDL_QueryTexture,SDL_QueryTexture,6 ;
+TOS_ffi SDL_SetClipboardText,SDL_SetClipboardText,1 ;
+TOS_ffi SDL_PollEvent,SDL_PollEvent,1 ;
+TOS_ffi SDL_WaitEvent,SDL_WaitEvent,1 ;
+TOS_ffi SDL_DestroyRenderer,SDL_DestroyRenderer,1
+TOS_ffi SDL_DestroyTexture,SDL_DestroyTexture,1 ;
+TOS_ffi SDL_StartTextInput,SDL_StartTextInput,0 ;
+TOS_ffi SDL_StopTextInput,SDL_StopTextInput,0 ;
+TOS_ffi SDL_GetError,SDL_GetError,0 ;
+TOS_ffi SDL_ClearError,SDL_ClearError,0 ;
+TOS_ffi SDL_FlushEvent,SDL_FlushEvent,1 ;
+TOS_ffi SDL_CreateRGBSurface,SDL_CreateRGBSurface,8 ;
+TOS_ffi SDL_CreateRGBSurfaceFrom,SDL_CreateRGBSurfaceFrom,9 ;
+TOS_ffi SDL_UpperBlit,SDL_UpperBlit,4 ;
+TOS_ffi SDL_FillRect,SDL_FillRect,3 ;
+TOS_ffi SDL_FillRects,SDL_FillRects,4 ;
+TOS_ffi SDL_GetClipRect,SDL_GetClipRect,2 ;
+TOS_ffi SDL_GetColorKey,SDL_GetColorKey,2 ;
+TOS_ffi SDL_GetSurfaceAlphaMod,SDL_GetSurfaceAlphaMod,2 ;
+TOS_ffi SDL_GetSurfaceColorMod,SDL_GetSurfaceColorMod,4 ;
+TOS_ffi SDL_LockSurface,SDL_LockSurface,1 ;
+TOS_ffi SDL_UnlockSurface,SDL_UnlockSurface,1 ;
+TOS_ffi SDL_SetClipRect,SDL_SetClipRect,2 ;
+TOS_ffi SDL_SetColorKey,SDL_SetColorKey,3 ;
+TOS_ffi SDL_SetSurfaceColorMod,SDL_SetSurfaceColorMod,4 ;
+TOS_ffi SDL_SetSurfaceAlphaMod,SDL_SetSurfaceAlphaMod,2 ;
+TOS_ffi SDL_SetSurfaceRLE,SDL_SetSurfaceRLE,2 ;
+TOS_ffi SDL_BlitSurface,SDL_BlitSurface,4 ;
+TOS_ffi SDL_BlitScaled,SDL_BlitScaled,4 ;
+TOS_ffi SDL_FreeSurface,SDL_FreeSurface,1 ;
+TOS_ffi SDL_UpdateWindowSurface,SDL_UpdateWindowSurface,1 ;
+TOS_ffi SDL_GetWindowSurface,SDL_GetWindowSurface,1 ;
+TOS_ffi __GetBuiltinMacrosText,__GetBuiltinMacrosText,0 ;
+TOS_ffi exit,exit,1 ;
+TOS_ffi trunc,trunc,1 ;
+TOS_ffi round,round,1 ;
+TOS_ffi log10,log10,1 ;
+TOS_ffi log,log,1 ;
+TOS_ffi floor,floor,1 ;
+TOS_ffi ceil,ceil,1 ;
+TOS_ffi tan,tan,1 ;
+TOS_ffi sqrt,sqrt,1 ;
+TOS_ffi sin,sin,1 ;
+TOS_ffi cos,cos,1 ;
+TOS_ffi memset,memset,3 ;
+TOS_ffi abs,abs,1 ;
+TOS_ffi atan,atan,1 ;
+TOS_ffi GetFs,GetFs,0 ;
+TOS_ffi strstr,strstr,2 ;
+TOS_ffi strncpy,strncpy,3 ;
+TOS_ffi strcpy,strcpy,2 ;
+TOS_ffi strncmp,strncmp,3 ;
+TOS_ffi strcmp,strcmp,2 ;
+TOS_ffi strlen,strlen,1 ;
+TOS_ffi PoopMAlloc,PoopMAlloc,1 ;
+TOS_ffi PoopFree,PoopFree,1 ;
+TOS_ffi PoopSetGCEnable,PoopSetGCEnable,1 ;
+TOS_ffi pow,pow,2 ;
+TOS_ffi BoundsCheck,BoundsCheck,2 ;
+TOS_ffi TOSPrint,TOSPrint,2 ;
+TOS_ffi Signal,Signal,2 ;
+TOS_ffi RegisterRuntimeClasses,RegisterRuntimeClasses,4 ;
+TOS_ffi MSize,MSize,1 ;
+TOS_ffi GetBuiltinMacrosText,GetBuiltinMacrosText,0 ;
diff --git a/FULL_RUNTIME.HC b/FULL_RUNTIME.HC
index bbfabed..fc7e07b 100644
--- a/FULL_RUNTIME.HC
+++ b/FULL_RUNTIME.HC
@@ -1,5 +1,5 @@
#define BOUNDS_CHECK
#define SIGNAL
#define RUNTIME_C
-#include "PARSER.HC"
+#include "PARSER2.HC"
#include "HolyEd/EDITOR.HC"
diff --git a/FreeBSD_pkg.sh b/FreeBSD_pkg.sh
index 0bc6345..fb25a46 100755
--- a/FreeBSD_pkg.sh
+++ b/FreeBSD_pkg.sh
@@ -9,11 +9,11 @@ mkdir -p ${STAGEDIR}/usr
mkdir -p ${STAGEDIR}/usr/local
mkdir -p ${STAGEDIR}/usr/local/bin
mkdir -p ${STAGEDIR}/usr/local/include/HolyC
-cp 3d_loader ${STAGEDIR}/usr/local/bin/3d
+cp 3d_loader2 ${STAGEDIR}/usr/local/bin/3d
strip ${STAGEDIR}/usr/local/bin/3d
chmod +x ${STAGEDIR}/usr/local/bin/3d
set files = ( \
- HCRT.BIN \
+ HCRT_TOS.BIN \
)
rm ${STAGEDIR}/plist
echo "/usr/local/bin/3d" >> ${STAGEDIR}/plist
diff --git a/HCRT/ASM.HC b/HCRT/ASM.HC
index ddd99cb..22e6e17 100755
--- a/HCRT/ASM.HC
+++ b/HCRT/ASM.HC
@@ -2,11 +2,13 @@ static U8 *SkipComment(U8 *text) {
loop:
U8 *orig=text;
if(0==StrNCmp(text,"/*",2)) {
- text=StrMatch(text+2,"*/")+2;
+ text=2+StrMatch(text+2,"*/");
} else if(0==StrNCmp(text,"//",2)) {
text=StrFirstOcc(text,"\n")+1;
}
- while(Bt(&char_bmp_white_space,*text)) text++;
+ while(Bt(&char_bmp_white_space,*text)) {
+ text++;
+ }
if(orig!=text) goto loop;
return text;
}
@@ -260,7 +262,7 @@ U0 ParseOpcodes(U8 *text) {
opc.args[argument++].type=OPCA_STI,Free(name2);
goto attrloop;
} else {
- "%s\n",text;
+ //TOSPrint("%s\n",text);
throw('Asm');
}
} else if(*text=='!') {
@@ -314,6 +316,7 @@ U0 ParseOpcodes(U8 *text) {
text+=2;
goto attrloop;
} else {
+ "%s\n",text;
throw('Asm');
}
oen:
@@ -366,16 +369,26 @@ Bool __X64RegIsIntExt(I64 code) {
#define X64ModRMIndir8 0b01
#define X64ModRMIndir32 0b10
#define X64ModRMDirect 0b11
-I64 X64ImmSize(U64 imm) {
- if(imm<=0xff) {
- return 1;
- } else if(imm<=0xffff) {
- return 2;
- } else if(imm<=0xffFFffFF) {
- return 4;
+I64 X64ImmSize(I64 imm,I64 dst_sz) {
+ if(imm&(1<<63)) {
+ if(I8_MIN<=imm<=I8_MAX) {
+ return 1;
+ } else if(I16_MIN<=imm<=I16_MAX) {
+ return 2;
+ } else if(I32_MIN<=imm<=I32_MAX) {
+ return 4;
+ }
+ return 8;
}
+ if(imm(U64)<=I8_MAX) return 1;
+ if(dst_sz==1&&imm(U64)<=U8_MAX) return 1;
+ if(imm(U64)<=I16_MAX) return 2;
+ if(dst_sz==2&&imm(U64)<=U16_MAX) return 2;
+ if(imm(U64)<=I32_MAX) return 4;
+ if(dst_sz==4&&imm(U64)<=U32_MAX) return 4;
return 8;
}
+
U8 X64Rex(U8 w,U8 r,U8 x,U8 b) {
U8 wrxb=(w<<3)|(r<<2)|(x<<1)|(b);
if(wrxb) return (0b0100<<4)|wrxb;
@@ -424,8 +437,9 @@ U8 X64SIB(I64 s,I64 i,I64 b) {
case 2: s=1; break;
case 4: s=2; break;
case 8: s=3; break;
- AsmError="Invalid SIB scale";
- default: throw('Asm');
+ default:
+ AsmError="Invalid SIB scale";
+ throw('Asm');
}
return (s<<6)|((i&7)<<3)|(b&7);
}
@@ -466,13 +480,12 @@ U8 *X86ModRMSIBDisp(U8 *it,I64 size,U8 *opcode,I64 opc_len,CReg *reg,I64 scale,C
if(base==HashFind("RIP",regs)) {
if(scale||index) {
AsmError="RIP addressing must not have a scale.";
- throw('Asm');
+ throw('Asm');
}
mdrmcode=X64ModRMIndir;
mdrmrm=HashFind("RBP",regs)(CReg*)->code;
disps=4;
} else if(!index) {
- if(scale) throw('Asm');
sibi=HashFind("RSP",regs)(CReg*)->code;
if(!base) {
SIB=TRUE;
@@ -482,7 +495,7 @@ U8 *X86ModRMSIBDisp(U8 *it,I64 size,U8 *opcode,I64 opc_len,CReg *reg,I64 scale,C
disps=4;
} else if(base==HashFind("RBP",regs)||base==HashFind("R13",regs)) {
if(mdrmcode==X64ModRMIndir) {
- if(disp) throw('Asm');
+ if(disp) Debugger,throw('Asm');
disps=1;
mdrmcode=X64ModRMIndir8;
}
@@ -495,7 +508,7 @@ U8 *X86ModRMSIBDisp(U8 *it,I64 size,U8 *opcode,I64 opc_len,CReg *reg,I64 scale,C
I64 rrc=0;
if(reg) rrc=reg->code;
rex=X64Rex(
- size==8,
+ size==8||(reg&&reg->type==GP_64), //We do reg&& to ensure that reg is not NULL,HolyC makes && fail if the first argument is false
rrc>>3,
0,
__X64RegIsIntExt(base->code)
@@ -504,8 +517,8 @@ U8 *X86ModRMSIBDisp(U8 *it,I64 size,U8 *opcode,I64 opc_len,CReg *reg,I64 scale,C
for(byte=0;byte!=opc_len;byte++) *it++=opcode[byte];
*it++=X64ModRM(mdrmcode,rrc,base->code);
goto insdisp;
- if(SIB) throw('Asm');
- if(!mdrmrm) throw('Asm');
+ if(SIB) Debugger,throw('Asm');
+ if(!mdrmrm) Debugger,throw('Asm');
}
} else if(index==HashFind("RSP",regs)) {
if(scale!=1) AsmError="RSP Must have no scale or a scale of 1.",throw('Asm');
@@ -539,7 +552,7 @@ U8 *X86ModRMSIBDisp(U8 *it,I64 size,U8 *opcode,I64 opc_len,CReg *reg,I64 scale,C
I64 treg=0;
if(reg) treg=reg->code;
rex=X64Rex(
- size==8,
+ size==8||(reg&&reg->type==GP_64),
__X64RegIsIntExt(treg),
SIB&&__X64RegIsIntExt(sibi),
tmp
@@ -564,8 +577,9 @@ U8 *X86ModRMSIBDisp(U8 *it,I64 size,U8 *opcode,I64 opc_len,CReg *reg,I64 scale,C
it(U32*)[0]=disp;
it+=4;
break;
- AsmError="Displacement is too big.";
- default: throw('Asm');
+ default:
+ AsmError="Displacement is too big.";
+ throw('Asm');
}
return it;
}
@@ -642,6 +656,29 @@ U0 SibTests() {
U0 X64ModeFree(X64Mode *m) {
Free(m);
}
+I64 OpcodeDestSize(COpcode *opc) {
+ I64 i,os,f=0;
+ for(i=0;i!=opc->arg_count;i++) {
+ switch(opc->args[i].type) {
+ start:
+ case OPCA_M8: os=1;break;
+ case OPCA_M16: os=2;break;
+ case OPCA_M32: os=4;break;
+ case OPCA_M64: os=8;break;
+ case OPCA_R8: os=1;break;
+ case OPCA_R16: os=2;break;
+ case OPCA_R32: os=4;break;
+ case OPCA_R64: os=8;break;
+ case OPCA_RM8: os=1;break;
+ case OPCA_RM16: os=2;break;
+ case OPCA_RM32: os=4;break;
+ case OPCA_RM64: os=8;break;
+ end:
+ f=MaxI64(os,f);
+ }
+ }
+ return f;
+}
/**
* Jumps are not encoded here
*/
@@ -729,24 +766,27 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
goto r64;
case OPCA_IMM8:
if(modes[arg]->type==X64O_IMM)
- if(X64ImmSize(modes[arg]->imm)<=1)
+ if(X64ImmSize(modes[arg]->imm,OpcodeDestSize(opc))<=1)
goto pass;
goto fail;
case OPCA_IMM16:
if(modes[arg]->type==X64O_IMM)
- if(X64ImmSize(modes[arg]->imm)<=2)
- goto pass;
+ if(X64ImmSize(modes[arg]->imm,OpcodeDestSize(opc))<=2)
+ if(StrCmp(name,"PUSH")) //TempleOS uses the 16 bit overide for PUSH for some reason,so dont use it
+ goto pass;
goto fail;
case OPCA_IMM32:
if(modes[arg]->type==X64O_IMM)
- if(X64ImmSize(modes[arg]->imm)<=4)
+ if(X64ImmSize(modes[arg]->imm,OpcodeDestSize(opc))<=4)
goto pass;
goto fail;
case OPCA_IMM64:
if(modes[arg]->type==X64O_IMM)
- if(X64ImmSize(modes[arg]->imm)<=8)
+ if(X64ImmSize(modes[arg]->imm,OpcodeDestSize(opc))<=8)
goto pass;
goto fail;
+ //TempleOS's assembler seems to not see the difference between signed and unsigned(in terms of encoding),so use signed values always.
+ /*
case OPCA_UIMM8:
if(modes[arg]->type==X64O_IMM)
if(modes[arg]->imm<=U8_MAX)
@@ -754,19 +794,20 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
goto fail;
case OPCA_UIMM16:
if(modes[arg]->type==X64O_IMM)
- if(modes[arg]->imm<=U16_MAX)
- goto pass;
+ if(modes[arg]->imm(U64)<=U16_MAX)
+ if(StrCmp(name,"PUSH")) //TempleOS uses the 16 bit overide for PUSH for some reason,so dont use it
+ goto pass;
goto fail;
case OPCA_UIMM32:
if(modes[arg]->type==X64O_IMM)
- if(modes[arg]->imm<=U32_MAX)
+ if(modes[arg]->imm(U64)<=U32_MAX)
goto pass;
goto fail;
case OPCA_UIMM64:
if(modes[arg]->type==X64O_IMM)
- if(modes[arg]->imm<=U64_MAX)
- goto pass;
+ goto pass;
goto fail;
+ */
case OPCA_SREG:
if(modes[arg]->type==X64O_REG)
if(modes[arg]->reg->type==SREG)
@@ -835,6 +876,7 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
goto pass;
goto fail;
default:
+ goto fail;
throw('???');
}
fail:;
@@ -861,7 +903,7 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
case OPCA_M8:
op_sz=1;
break;
- case OPCA_RM16:
+ case OPCA_RM16:
case OPCA_M16:
op_sz=2;
break;
@@ -895,6 +937,14 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
imm=modes[arg]->mem.disp;
}
}
+ if(opc->flags&OPC_F_STI) {
+ for(arg=0;arg!=argc;arg++) {
+ if(opc->args[arg].type=OPCA_STI) {
+ add=modes[arg].reg->code;
+ break;
+ }
+ }
+ }
if(opc->flags&OPC_F_SR) {
for(arg=0;arg!=argc;arg++) {
switch(opc->args[arg].type) {
@@ -1034,21 +1084,23 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
//TODO
if(rex48) {
*endptr++=0x48;
- } else if(rexb||rexw&&!(mem||mdrmR)) {
+ } else if((rexb||rexw)&&!(mem||mdrmR)) {
*endptr++=X64Rex(rexw,0,0,rexb);
}
if(mem||mdrmR) {
if(mem->type==X64O_REG) {
- rexb=0!=mem->reg->code&0b1000;
- rexw=mem->reg->type==GP_64;
- Bool rexr=FALSE;
- if(mdrmR) rexr=0!=mdrmR->code&0b1000;
- if(X64Rex(rexw,rexr,0,rexb)) *endptr++=X64Rex(rexw,rexr,0,rexb);
- I64 rmasked=0;
- if(mdrmR) rmasked=mdrmR->code&7;
- MemNCpy(endptr,opcadd,opc->bcnt);
- endptr+=opc->bcnt;
- *endptr++=X64ModRM(0b11, rmasked,mem->reg->code&7);
+ rexb=0!=mem->reg->code&0b1000;
+ rexw=mem->reg->type==GP_64;
+ Bool rexr=FALSE;
+ if(mdrmR) rexr=0!=mdrmR->code&0b1000;
+ if(mdrmR&&mdrmR->type==GP_64)
+ rexw=TRUE;
+ if(X64Rex(rexw,rexr,0,rexb)) *endptr++=X64Rex(rexw,rexr,0,rexb);
+ I64 rmasked=0;
+ if(mdrmR) rmasked=mdrmR->code&7;
+ MemNCpy(endptr,opcadd,opc->bcnt);
+ endptr+=opc->bcnt;
+ *endptr++=X64ModRM(0b11, rmasked,mem->reg->code&7);
} else {
I64 sibs=0;
if(mem) sibs=mem->mem.scale;
@@ -1078,25 +1130,24 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
endptr+=opc->bcnt;
}
if(immsz) {
- if(ret_after_encode) {
+ if(ret_after_encode)
if(immoff) *immoff=endptr-origip;
- switch(immsz) {
- case 1:
- *endptr++=imm;
- break;
- case 2:
- endptr(U16*)[0]=imm;
- endptr+=2;
- break;
- case 4:
- endptr(U32*)[0]=imm;
- endptr+=4;
- break;
- case 8:
- endptr(U64*)[0]=imm;
- endptr+=8;
- break;
- }
+ switch(immsz) {
+ case 1:
+ *endptr++=imm;
+ break;
+ case 2:
+ endptr(U16*)[0]=imm;
+ endptr+=2;
+ break;
+ case 4:
+ endptr(U32*)[0]=imm;
+ endptr+=4;
+ break;
+ case 8:
+ endptr(U64*)[0]=imm;
+ endptr+=8;
+ break;
}
}
if(ret_after_encode) {
@@ -1116,17 +1167,12 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
opc=HashFind(name,opcodes);
if(opc->type==HASH_TYPE_OPCODE_ALIAS)
opc=opc(COpcodeAlias*)->opcode;
- I64 iter=0,min=-1,max=0;
- for(iter=0;iter!=item;iter++,opc=opc->next_op) {
- max=MaxI64(operand_sizes[iter],max);
- }
+ I64 iter=0,min=-1;
opc=HashFind(name,opcodes);
if(opc->type==HASH_TYPE_OPCODE_ALIAS)
opc=opc(COpcodeAlias*)->opcode;
COpcode *finalop=NULL;
for(iter=0;iter!=item;iter++,opc=opc->next_op) {
- //Eliminate out canidates that are below the maximum operand size
- if(operand_sizes[iter]<max) sizes[iter]=-1;
if(sizes[iter]!=-1) {
if(min==-1) goto accept;
if(sizes[iter]<sizes[min]) {
@@ -1138,7 +1184,8 @@ U8 *EncodeOpcode(U8 *ip,U8 *name,Bool *is_jmp,I64 *sibooff ,I64 *immoff,I64 *imm
}
Free(sizes),Free(operand_sizes);
if(min==-1) {
- AsmError="Invalid opcode usage.";
+ "%d,%d\n",modes[0]->type,modes[1]->type;
+ AsmError=MStrPrint("Invalid opcode usage of '%s'.",name);
throw('Asm');
}
if(ip) {
@@ -1203,3 +1250,25 @@ EncodeOpcode(buffer,"MOVSX",r64,rm8);
*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HCRT/BITS.HC b/HCRT/BITS.HC
index e610d71..3540d4c 100755
--- a/HCRT/BITS.HC
+++ b/HCRT/BITS.HC
@@ -256,7 +256,7 @@ I64 bitsperbyte[]={
7, //254
8, //255
};
-I64 BCnt(I64 value) {
+I64 BCnt(U64 value) {
I64 count=0;
while(value!=0) {
count+=bitsperbyte[value&0xff];
@@ -312,3 +312,4 @@ U32 BFieldExtU32(U8 *f,I64 bit,I64 size) {
res&=(1<<size)-1;
return res;
}
+
diff --git a/HCRT/CHAR.HC b/HCRT/CHAR.HC
index 86de16f..86cb2f1 100755
--- a/HCRT/CHAR.HC
+++ b/HCRT/CHAR.HC
@@ -262,8 +262,8 @@ and take addr.
ch=*fmt++;
}
}
- buf=MAlloc(len+1);
- for (i=0;i<len;i++)
+ buf=MAlloc(len+1);
+ for (i=0;i<len;i++)
buf[i]=*src++;
buf[i]=0;
switch (ch) {
@@ -271,7 +271,7 @@ and take addr.
if (cur_arg>=argc)
throw('Scan');
pptr=argv[cur_arg++];
- StrCpy(*pptr,buf);
+ StrCpy(*pptr,buf);
break;
case 'c':
if (cur_arg>=argc)
@@ -464,3 +464,6 @@ U8 *StrLastOcc(U8 *str,U8 *marker) {
if(ch) return &str[cnt];
return NULL;
}
+
+
+
diff --git a/HCRT/HASH.HC b/HCRT/HASH.HC
index 23a1289..afb329b 100755
--- a/HCRT/HASH.HC
+++ b/HCRT/HASH.HC
@@ -12,7 +12,6 @@ I64 HashStr(U8* str) {
r *= 31;
r += str[l];
}
-
return r;
}
CHash* HashFind(U8* needle, CHashTable* table) {
@@ -61,3 +60,5 @@ loop:
Free(table);
}
+
+
diff --git a/HCRT/HCRT.HC b/HCRT/HCRT.HC
index 9ce1c6e..d61b4e1 100755
--- a/HCRT/HCRT.HC
+++ b/HCRT/HCRT.HC
@@ -12,3 +12,7 @@
#include "LEXER.HC"
//#include "../HolyEd/EDITOR.HC"
+
+
+
+
diff --git a/HCRT/HCRT.HH b/HCRT/HCRT.HH
index bc5d3d5..a1c57d2 100755
--- a/HCRT/HCRT.HH
+++ b/HCRT/HCRT.HH
@@ -173,6 +173,7 @@ extern Bool FifoI64Rem(CFifoI64 *f,I64 *_q);
extern Bool FifoI64Peek(CFifoI64 *f,I64 *_q);
extern U0 FifoI64Flush(CFifoI64 *f);
extern I64 FifoI64Cnt(CFifoI64 *f);
+U0 LoadBinModule(U8 *fn,Bool verbose=FALSE);
#define CDIR_FILENAME_LEN 1024
//FILE.HC
class CDirEntry
@@ -459,184 +460,9 @@ U0 SDL_FreeSurface(SDL_Surface*);
I64 SDL_UpdateWindowSurface(SDL_Window*);
I64 SDL_GetColorKey(SDL_Surface*,U32*);
#endif
+U0 Del(U8 *);
U8 *__GetBuiltinMacrosText();
CFs *Fs();
-class JIT;
-class JIT_OP;
-extern U0 jit_disable_optimization(JIT *jit,I64 opts);
-extern U0 jit_enable_optimization(JIT *jit,I64 opts);
-extern JIT *jit_init();
-extern U0 jit_dump_ops(JIT *j,I64 verbosity=1);
-extern U0 jit_generate_code(JIT *j,I64 verbose=1);
-extern JIT_OP *jit_andi(JIT *j,I64 r,I64 a,I64 b);
-extern JIT_OP *jit_andr(JIT *j,I64 r,I64 a,I64 b);
-extern I64 R_FP();
-extern I64 jit_FR(I64 r);
-extern I64 jit_binsize(JIT *op);
-extern JIT_OP *jit_allocai(JIT *op,I64 s);
-extern I64 jit_R(I64 r);
-extern JIT_OP *jit_get_label(I64 r);
-extern JIT_OP *jit_prolog(JIT *j,U0 *fptr);
-extern JIT_OP *jit_movr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_movi(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_jmpi(JIT *j,JIT_OP *op);
-extern JIT_OP *jit_jmpr(JIT *j,I64 r);
-extern JIT_OP *jit_patch(JIT *j,JIT_OP *op);
-extern JIT_OP *jit_prepare(JIT *j);
-extern JIT_OP *jit_putargi(JIT *j,I64 a);
-extern JIT_OP *jit_putargr(JIT *j,I64 a);
-extern JIT_OP *jit_call(JIT *j,U0 *loc);
-extern JIT_OP *jit_callr(JIT *j,I64 a);
-extern JIT_OP *jit_retr(JIT *j,I64 r);
-extern JIT_OP *jit_reti(JIT *j,I64 o);
-extern JIT_OP *jit_retval(JIT *j,I64 r);
-extern JIT_OP *jit_getarg(JIT *j,I64 r,I64 a);
-extern JIT_OP *jit_declare_arg(JIT *j,I64 a,I64 t);
-extern JIT_OP *jit_addr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_addi(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_subr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_subi(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_negr(JIT *j,I64 d,I64 a);
-extern JIT_OP *jit_mulr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_muli(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_mulr_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_muli_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_divr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_divi(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_divr_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_divi_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_modr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_modi(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_modr_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_modi_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_orr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ori(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_xorr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_xori(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_lshr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_lshi(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_rshr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_rshi(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_rshr_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_rshi_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_notr(JIT *j,I64 d,I64 a);
-extern JIT_OP *jit_bltr(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_blti(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bltr_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_blti_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bler(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_blei(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bler_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_blei_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bgtr(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bgti(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bgtr_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bgti_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bger(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bgei(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bger_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bgei_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_beqr(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_beqi(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bner(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_bnei(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_ger_u(JIT *j,JIT_OP * op,I64 a,I64 b);
-extern JIT_OP *jit_gei_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ger(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_gei(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ler_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_lei_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ler(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_lei(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_gtr_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_gti_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_gtr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_gti(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ltr_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_lti_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ltr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_lti(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_eqr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_eqi(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ner(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_nei(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ldr(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ldi(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ldxr(JIT *j,I64 d,I64 a ,I64 b,I64 c);
-extern JIT_OP *jit_ldxi(JIT *j,I64 d,I64 a ,I64 b,I64 c);
-extern JIT_OP *jit_ldr_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ldi_u(JIT *j,I64 d,I64 a ,I64 b);
-extern JIT_OP *jit_ldxr_u(JIT *j,I64 d,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_ldxi_u(JIT *j,I64 d,I64 a ,I64 b,I64 c);
-extern JIT_OP *jit_str(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_sti(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_stxr(JIT *j,I64 a,I64 b,I64 c ,I64 d);
-extern JIT_OP *jit_stxi(JIT *j,I64 a,I64 b,I64 c,I64 d);
-extern JIT_OP *jit_fmovr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_fmovi(JIT *j,I64 a,F64 b);
-extern JIT_OP *jit_faddr(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_faddi(JIT *j,I64 a,I64 b,F64 c);
-extern JIT_OP *jit_fsubr(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_fsubi(JIT *j,I64 a,I64 b,F64 c);
-extern JIT_OP *jit_fmulr(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_fmuli(JIT *j,I64 a,I64 b,F64 c);
-extern JIT_OP *jit_fdivr(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_fdivi(JIT *j,I64 a,I64 b,F64 c);
-extern JIT_OP *jit_fnegr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_extr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_truncr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_floorr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_ceilr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_roundr(JIT *j,I64 a,I64 b);
-extern U0 *jit_get_breakpoint_by_ptr(JIT *j,U0 *op);
-extern I64 jit_FunctionParents(U0 **a,I64 b);
-extern I64 jit_ParentFramePtrs(U0 **a,I64 b);
-extern I64 jit_bin_size(JIT *j);
-extern JIT_OP *jit_fbltr(JIT *j,JIT_OP *op,I64 a,I64 b);
-extern JIT_OP *jit_fblti(JIT *j,JIT_OP *op,I64 a,F64 b);
-extern JIT_OP *jit_fbgtr(JIT *j,JIT_OP *op,I64 a,I64 b);
-extern JIT_OP *jit_fbgti(JIT *j,JIT_OP *op,I64 a,F64 b);
-extern JIT_OP *jit_fbger(JIT *j,JIT_OP *op,I64 a,I64 b);
-extern JIT_OP *jit_fbgei(JIT *j,JIT_OP *op,I64 a,F64 b);
-extern JIT_OP *jit_fbler(JIT *j,JIT_OP *op,I64 a,I64 b);
-extern JIT_OP *jit_fblei(JIT *j,JIT_OP *op,I64 a,F64 b);
-extern JIT_OP *jit_fbeqr(JIT *j,JIT_OP *op,I64 a,I64 b);
-extern JIT_OP *jit_fbeqi(JIT *j,JIT_OP *op,I64 a,F64 b);
-extern JIT_OP *jit_fbner(JIT *j,JIT_OP *op,I64 a,I64 b);
-extern JIT_OP *jit_fbnei(JIT *j,JIT_OP *op,I64 a,F64 b);
-extern JIT_OP *jit_fstr(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_fsti(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_fstxi(JIT *j,I64 a,I64 b,I64 c,I64 d);
-extern JIT_OP *jit_fstxr(JIT *j,I64 a,I64 b,I64 c,I64 d);
-extern JIT_OP *jit_fldr(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_fldi(JIT *j,I64 a,I64 b,I64 c);
-extern JIT_OP *jit_fldxi(JIT *j,I64 a,I64 b,I64 c,I64 d);
-extern JIT_OP *jit_fldxr(JIT *j,I64 a,I64 b,I64 c,I64 d);
-extern JIT_OP *jit_fputargi(JIT *j,F64 a,I64 b);
-extern JIT_OP *jit_fputargr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_freti(JIT *j,F64 a,I64 b);
-extern JIT_OP *jit_fretr(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_fretval(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_ref_code(JIT *j,I64 a,JIT_OP*op);
-extern JIT_OP *jit_ref_data(JIT *j,I64 a,JIT_OP*op);
-extern JIT_OP *jit_taint_label(JIT *j,JIT_OP *op);
-extern JIT_OP *jit_end_asm_blk(JIT *j);
-extern JIT_OP *jit_code_align(JIT *j,I64 a);
-extern JIT_OP *jit_code_align_fill(JIT *j,I64 a,I64 b);
-extern JIT_OP *jit_data_str(JIT *j,U8 * a);
-extern JIT_OP *jit_data_byte(JIT *j,I64 a);
-extern JIT_OP *jit_data_word(JIT *j,I64 a);
-extern JIT_OP *jit_data_dword(JIT *j,I64 a);
-extern JIT_OP *jit_data_qword(JIT *j,I64 a);
-extern JIT_OP *jit_data_ref_code(JIT *j,JIT_OP *op);
-extern JIT_OP *jit_data_ref_data(JIT *j,JIT_OP *op);
-extern JIT_OP *jit_dump_ptr(JIT *j,U0 **op);
-extern JIT_OP *jit_relocation(JIT *j,I64 a,U0 **b);
-extern JIT_OP *jit_data_bytes(JIT *j,I64 a,U0* b);
-extern I64 *jit_debugger_get_reg_ptr(JIT *j,U0 *a,JIT_OP *op,I64 r);
-extern I64 *jit_debugger_get_vreg_ptr_from_parent(JIT *j,U0 *a,JIT_OP *op,I64 r);
-extern U0 jit_free(JIT *j);
-extern JIT_OP *jit_prepare(JIT *j);
extern U0 HCSetJmp();
extern U0 PopTryFrame();
extern U0 EnterTry();
@@ -707,14 +533,9 @@ extern U0 *HC_CreateI64(I64 a);
extern U0 *HC_CreateF64(F64 f);
extern U0 *HC_SetPosFromLexer(U0 *a,U8 *b,I64 c);
extern U0 Debugger(U0 *regs=NULL,U0 *bp=NULL,U0 *caller=NULL);
-extern JIT_OP *jit_breakpoint(JIT *a,U0 *b,U0 *c,U0 *d);
extern U0 ForeachFuncInTable(U0(*fptr)());
extern U0 VirtAlloc(I64 a);
extern U0 VirtFree(U0* p,I64 s);
-#define JIT_SIGNED_NUM 0
-#define JIT_UNSIGNED_NUM 1
-#define JIT_FLOAT_NUM 2
-#define JIT_PTR 3
U0 WriteTagsAndErrsToFile(U8 *src,U8 *tags=NULL,U8 *errs=NULL);
I64 PoopSetGCEnable(I64 en);
I64 GetUnique();
@@ -722,3 +543,7 @@ U0 Debugger();
//For internal use
U0 RegisterRuntimeClasses(U0*gt,U0*fwd,U0*am,U0 *cat);
#endif
+
+
+
+
diff --git a/HCRT/HCRT_TOS.BIN b/HCRT/HCRT_TOS.BIN
new file mode 100644
index 0000000..f6b4e4b
--- /dev/null
+++ b/HCRT/HCRT_TOS.BIN
Binary files differ
diff --git a/HCRT/LEXER.HC b/HCRT/LEXER.HC
index a1181cd..fa73050 100755
--- a/HCRT/LEXER.HC
+++ b/HCRT/LEXER.HC
@@ -1,4 +1,5 @@
#include "../LEXER.HH"
+U0 LoadBinModule(U8 *fn,Bool verbose=FALSE);
class CLexFile
{
CLexFile *next;
@@ -895,14 +896,13 @@ lex_check_comment:
LexWarn(cc,"Unable to include file \"%q\".",cc->cur_str);
goto lex_cont;
}
- /*
if(FileExtDot(buf2)) {
if(!StrCmp(FileExtDot(buf2),".BIN")) {
- LoadBinFile(buf2);
+ LoadBinModule(buf2);
Free(buf2);
goto lex_cont;
}
- }*/
+ }
buf3=buf2;
if(IsWindows) {
if(StrOcc(buf2,'\\')) {
@@ -1153,9 +1153,9 @@ U8 *LexMatchFile(CCmpCtrl *cc,U8 *name) {
for(;tmph;tmph=tmph->next) {
bptr2=tmph->str;
while(bptr2=StrFirstOcc(bptr2,delim)) {
- if(!StrCmp(++bptr2,name)) return tmph->str;
+ if(!StrCmp(++bptr2,name)) return StrNew(tmph->str);
}
- if(!StrCmp(tmph->str,name)) return tmph->str;
+ if(!StrCmp(tmph->str,name)) return StrNew(tmph->str);
}
}
return NULL;
@@ -1181,3 +1181,6 @@ U0 StreamPrint(U8 *fmt,...) {
}
Free(buf);
}
+
+
+
diff --git a/HCRT/PRINT.HC b/HCRT/PRINT.HC
index 9e496d5..eed5541 100755
--- a/HCRT/PRINT.HC
+++ b/HCRT/PRINT.HC
@@ -811,7 +811,7 @@ sp_out_e:
{
flags|=PRTF_NEG;
d=-d;
- }
+ }
sp_out_eng: //Engineering notation
if (d==inf) goto sp_out_inf;
if (d)
@@ -1047,3 +1047,7 @@ U8 *MStrPrint(U8 *fmt,...)
Free(buf);
return res;
}
+
+
+
+
diff --git a/HolyEd/EDITOR.HC b/HolyEd/EDITOR.HC
index b794024..1115e39 100755
--- a/HolyEd/EDITOR.HC
+++ b/HolyEd/EDITOR.HC
@@ -507,7 +507,7 @@ U0 SDL_DrawWin(...) {
I32 rx=SDL_GetSurfaceWidth(w->text),ry=SDL_GetSurfaceHeight(w->text);
SDL_Rect sbox={w->begx*FONT_X2,w->begy*FONT_Y2,rx/FONT_X2*FONT_X2,ry/FONT_Y2*FONT_Y2};
SDL_Rect wbox={0,0,rx/FONT_X2*FONT_X2,ry/FONT_Y2*FONT_Y2};
- SDL_BlitScaled(w->text,&wbox,winsurf,&sbox);
+ SDL_BlitSurface(w->text,&wbox,winsurf,&sbox);
if(w->cur_enabled) {
SDL_Rect crect={w->begx*FONT_X2+w->curx*FONT_X2,w->begy*FONT_Y2+w->cury*FONT_Y2+FONT_Y2-2,FONT_X2,4};
SDL_FillRect(winsurf,&crect,0xff000000);
@@ -768,7 +768,7 @@ U0 FocusCursor(CEditor *ed,I64 lmargin=0) {
ed->x_scroll=ed->curx-w+1;
}
if(ed->cury<ed->vp_start_line) {
- ed->vp_start_line=ed->cury;
+ ed->vp_start_line=ed->cury;
} else if(ed->vp_start_line+SDL_WinY(ed->window)-ed->margin_top<=ed->cury) {
ed->vp_start_line=ed->cury-SDL_WinY(ed->window)+1+ed->margin_top;
}
@@ -1582,7 +1582,7 @@ I64 DrawEditor(CEditor *ed,I64 flags=ED_DRAW_DFT ,U8 *dialogtxt=NULL,I64 mb_acti
}
U0 EdUp(CEditor *ed) {
if(ed->cury>0) {
- --ed->cury;
+ ed->cury--;
if(ed->cury<ed->vp_start_line)
ed->vp_start_line=ed->cury;
if(ed->_curx>RopeLength(GetLine(ed, ed->cury)->text))
@@ -1606,7 +1606,7 @@ U0 EdDown(CEditor *ed) {
}
}
#define ED_MOVE_DONT_SKIP_TAB 1
-U0 EdRight(CEditor *ed,I64 flags=0) {
+U0 EdRight(CEditor *ed,I64 flags=0) {
CLine *rline=GetLine(ed,ed->cury);
U8 *text=Rope2Str(rline->text);
I64 x=ed->curx,cnt=0;
@@ -2499,7 +2499,7 @@ I64 OpenFile(U8 *name,I64 ln=0) {
CBuffer *buf;
if(buf=HashFind(name,buffers)) {
Free(name);
- buf->ed->cury=MinI64(ln,GetLineCount(buf->ed));
+ buf->ed->cury=MaxI64(0,MinI64(ln,GetLineCount(buf->ed)-1));
return Edit(buf->ed);
}
I64 cnt;
@@ -2508,7 +2508,7 @@ I64 OpenFile(U8 *name,I64 ln=0) {
CEditor *new=EditorNew();
EditorInsText(new,text,0);
new->fn=StrNew(name);
- new->cury=MinI64(ln,GetLineCount(new));
+ new->cury=MaxI64(0,MinI64(ln,GetLineCount(new)-1));
Free(text);
CreateTagsAndErrorsFiles("TAGS","ERRS",new->fn);
new->tags=ReadTags("TAGS");
@@ -2902,3 +2902,7 @@ U0 Ed(U8 *fn) {
+
+
+
+
diff --git a/HolyEd/ROPE.HC b/HolyEd/ROPE.HC
index 2c21424..e8f3fab 100755
--- a/HolyEd/ROPE.HC
+++ b/HolyEd/ROPE.HC
@@ -80,8 +80,8 @@ CRope *RopeAppendText(CRope *a,U8 *text) {
U8 buffer[ROPE_LEN+1];
buffer[ROPE_LEN]=0;
CRope *r=MAlloc(sizeof(CRope));
- I64 len;
- r->isLeaf=TRUE,StrNCpy(r->buffer,text,len=MinI64(ROPE_LEN,StrLen(text)));
+ I64 len=MinI64(ROPE_LEN,StrLen(text));
+ r->isLeaf=TRUE,StrNCpy(r->buffer,text,len);
buffer[len]=0;
r->text_length=len;
if(text[len]!=0)
diff --git a/PARSER.HC b/PARSER2.HC
index 08eed81..89957ec 100755
--- a/PARSER.HC
+++ b/PARSER2.HC
@@ -1,5 +1,5 @@
-#include "HCRT/HCRT.HC" //Requires nitty gritty of the runtime
-#include "VECTOR.HC"
+#include "HCRT/HCRT.HC"
+#include "CODEGEN.HC"
#ifdef SIGNAL
#include "SIGNAL.HC"
ArmSignals;
@@ -34,12 +34,10 @@ Bool IsHTTType(I64 t) {
return FALSE;
}
class _CBreakpoint;
-class jit_debugger_regs;
-U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr);
+U0 DebuggerRoutine(CDebuggerRegs *regs,_CBreakpoint *bp,U8 *caller_ptr);
class CType;
class AST;
class CRelocation;
-CType *AssignTypeToNode(AST *a,CType *arr_t=NULL);
extern U0 FreeAST(AST *a);
class CCompStringRef {
CCompStringRef *next;
@@ -49,31 +47,6 @@ class CCompString:CHash {
U8 *data;
CCompStringRef *refs;
};
-class CIRValue {
- CIRValue *last;
- #define IRV_INT 1
- #define IRV_FLOAT 2
- #define IRV_FREG 3
- #define IRV_REG 4
- #define IRV_STR 5
- #define IRV_INDIRX 6 //Comes with offsett
- I64 type;
- union {
- I64 reg;
- F64 flt;
- I64 int;
- class {
- CType *type;
- I64 reg;
- I64 offset;
- } indirx;
- U0 *indir;
- };
- CType *type2;
-};
-CIRValue *IRValueClone(CIRValue *v) {
- return MemCpy(MAlloc(sizeof(*v)),v,sizeof(*v));
-}
class CBreakLst {
CBreakLst *last;
U0 *start_code_label; //This is used for sub-switches
@@ -116,8 +89,7 @@ class CUnresolvedLabel:CHash {
AST *stmt;
};
class CCompiler {
- CIRValue *stack;
- U0 *jit;
+ JIT *jit;
CHashTable *globals,*locals,
//See HexifyString and CCompString
*cur_strings,*breakpoints,*labels,
@@ -136,11 +108,11 @@ class CCompiler {
CSwitchTable *swit_table;
CType *ret_type;
CRelocation *relocations;
- I64 first_avail_ireg;
- I64 first_avail_freg,
+ I64 first_avail_reg,
error_count,
//Used for local labels in assembler
- label_scope;
+ label_scope,
+ cur_tmp_reg;
U0 *func_ptr;
I64 frame_off;
CCmpCtrl *cc;
@@ -226,7 +198,7 @@ class CLinkage {
};
class CFunction:CHashSrcSym {
CLinkage link;
- U0 *jit;
+ JIT *jit;
U0 *func_ptr;
CType *hc_type;
U0 *func_ptr;
@@ -253,7 +225,6 @@ CCompilerState *NewCompilerState() {
*ret=Compiler;
if(GlobalCompiler==&Compiler)
GlobalCompiler=ret;
- Compiler.stack=NULL;
Compiler.locals=HashTableNew(0x100);
Compiler.labels=HashTableNew(0x10);
Compiler.asm_tainted_label_names=HashTableNew(0x10);
@@ -263,19 +234,18 @@ CCompilerState *NewCompilerState() {
Compiler.swit_table=NULL;
Compiler.asm_patches=NULL;
Compiler.in_func=0;
- Compiler.jit=jit_init();
+ Compiler.jit=jit_Init;
Compiler.frame_off=0;
Compiler.unresolved_labels=HashTableNew(0x10);
if(Compiler.aot_mode)
Compiler.cur_strings=HashTableNew(0x10);
- jit_prolog(Compiler.jit,&Compiler.func_ptr);
+ jit_rpnBodyStart(Compiler.jit);
if(Compiler.debug_mode) {
- jit_movr(Compiler.jit,jit_R(1),R_FP);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(1));
- jit_call(Compiler.jit,&EnterFunc);
+ JIT_FUNC_CALL(Compiler.jit,1);
+ JIT_RBP(Compiler.jit);
+ JIT_I64(Compiler.jit,&EnterFunc);
}
- Compiler.first_avail_freg=2,Compiler.first_avail_ireg=3;
+ Compiler.first_avail_reg=1;
return ret;
}
U0 HTT_LocalDestroy(CHash *);
@@ -290,7 +260,7 @@ U0 ResetCompilerData() {
if(Compiler.aot_mode)
HashTableDel(Compiler.cur_strings,&CompStringDestroy);
if(Compiler.jit)
- jit_free(Compiler.jit),Compiler.jit=NULL;
+ JIT_FREE(Compiler.jit),Compiler.jit=NULL;
Compiler.locals=HashTableNew(0x100);
Compiler.asm_tainted_label_names=HashTableNew(0x10);
Compiler.cur_strings=HashTableNew(0x100);
@@ -419,7 +389,7 @@ Bool IsPtrType(CType *t) {
Bool IsF64(CType *t) {
if(t->is_flt) return TRUE;
if(IsStructType(t))
- if(t->base)
+ if(t->base)
return IsF64(t->base);
return FALSE;
}
@@ -444,9 +414,8 @@ CType *DerefedType(CType *t) {
return t(CType*)->base;
}
if(t->star_cnt==0) {
- "DEREF NONPTR,%s\n",t->str;
- Backtrace(0,0);
- throw('Compile');
+ //Error should be raised elsewhere
+ return HashFind("I64i",Compiler.globals);
}
//Pointer types appear after base type in memory
return t-1;
@@ -682,7 +651,7 @@ U0 HTT_LocalDestroy(CHash *h) {
}
U0 FreeFunction(CFunction *f) {
if(f->locals) HashTableDel(f->locals,&HTT_LocalDestroy);
- if(f->jit) jit_free(f->jit);
+ if(f->jit) JIT_FREE(f->jit);
}
U0 PatchAsmPatcher(CFunction *parent,CAsmPatcher *patcher);
AST *LSP(CCmpCtrl *ctrl,AST *a=NULL) {
@@ -698,7 +667,7 @@ AST *LSP(CCmpCtrl *ctrl,AST *a=NULL) {
Free(dummy.src_link);
return a;
}
-extern I64 EvalAST(AST *a);
+extern I64 EvalAST(AST *a,Bool no_eval=FALSE);
extern F64 EvalASTF64(AST *a);
I64 __ScanForCases(AST *a,I64 last=0,I64 *min,I64 *max,Bool *has_dft) {
I64 lo,hi;
@@ -741,18 +710,14 @@ I64 __GetCases(AST *a,I64 last=0,I64 min,I64 max,U0 **tab) {
I64 lo,hi;
for(;a;a=a->next) {
if(a->type==AST_CASE) {
- if(Compiler.error_count) {
- lo=hi=++last;
- } else {
- if(a->cs.low)
- last=lo=EvalAST(a->cs.low);
- else
- lo=++last;
- if(a->cs.high)
- last=hi=EvalAST(a->cs.high);
- else
- hi=lo;
- }
+ if(a->cs.low)
+ last=lo=EvalAST(a->cs.low);
+ else
+ lo=++last;
+ if(a->cs.high)
+ last=hi=EvalAST(a->cs.high);
+ else
+ hi=lo;
for(;lo<=hi;lo++)
tab[lo-min]=a;
} else if(a->type==AST_SUBSWIT) {
@@ -763,7 +728,6 @@ I64 __GetCases(AST *a,I64 last=0,I64 min,I64 max,U0 **tab) {
tab[lo-min]=a;
}
}
- return last;
}
U0 **__CreateCaseTable(AST *a) {
@@ -921,6 +885,34 @@ en:
return ret;
}
CType *GetType(U8 *name,I64 ptr_lvl=0);
+CType *AssignTypeToNode(AST *a,CType *arr_t=NULL,Bool dont_call_lone_name=FALSE);
+U0 WarnOnWeirdPass(CType *want,AST *have);
+Bool IsLValue(AST *a) {
+ CVariable *var;
+ CType *t;
+ switch(a->type) {
+ case AST_EXPLICIT_TC:
+ return IsLValue(a->typecast.base);
+ case AST_NAME:
+ if(Compiler.in_func)
+ if(var=HashFind(a->name,Compiler.locals))
+ return var->type==HTT_VAR;
+ if(var=HashFind(a->name,Compiler.globals))
+ return var->type==HTT_VAR;
+ break;
+ case AST_DERREF:
+ if(DerefedType(t=AssignTypeToNode(a->unopArg))->type!=HTT_ARRAY_TYPE)
+ return t->type!=HTT_FUNC_TYPE;
+ break;
+ case AST_ARRAY_ACCESS:
+ if(DerefedType(t=AssignTypeToNode(a->binop.a))->type!=HTT_ARRAY_TYPE)
+ return t->type!=HTT_FUNC_TYPE;
+ break;
+ case AST_MEMBER:
+ return AssignTypeToNode(a->member_acc.base)->type!=HTT_ARRAY_TYPE;
+ }
+ return FALSE;
+}
U0 WarnOnWeirdPass(CType *want,AST *have) {
CType *have2=AssignTypeToNode(have);
CType *ow=want,*oh=have2;
@@ -950,32 +942,6 @@ U0 WarnOnWeirdPass(CType *want,AST *have) {
}
}
}
-Bool IsLValue(AST *a) {
- CVariable *var;
- CType *t;
- switch(a->type) {
- case AST_EXPLICIT_TC:
- return IsLValue(a->typecast.base);
- case AST_NAME:
- if(Compiler.in_func)
- if(var=HashFind(a->name,Compiler.locals))
- return var->type==HTT_VAR;
- if(var=HashFind(a->name,Compiler.globals))
- return var->type==HTT_VAR;
- break;
- case AST_DERREF:
- if(DerefedType(t=AssignTypeToNode(a->unopArg))->type!=HTT_ARRAY_TYPE)
- return t->type!=HTT_FUNC_TYPE;
- break;
- case AST_ARRAY_ACCESS:
- if(DerefedType(t=AssignTypeToNode(a->binop.a))->type!=HTT_ARRAY_TYPE)
- return t->type!=HTT_FUNC_TYPE;
- break;
- case AST_MEMBER:
- return AssignTypeToNode(a->member_acc.base)->type!=HTT_ARRAY_TYPE;
- }
- return FALSE;
-}
Bool CheckForCaseOverlap(AST *a,I64 lo,I64 hi,AST **cases,Bool has_dft) {
AST *cur;
I64 idx;
@@ -1010,105 +976,8 @@ Bool CheckForCaseOverlap(AST *a,I64 lo,I64 hi,AST **cases,Bool has_dft) {
}
}
}
-//Use with asm patcher to detirmine if a value needs to be "Patched" with global values
-//Also,statics are treated as globals,as they stay resident in memory like globals.
-Bool AsmReferencesNonLocals(AST *a,Bool inc_labels=FALSE) {
- Bool ret=FALSE;
- I64 cnt;
- CVariable *local;
- switch(a->type) {
- case AST_MEMBER:
- ret|=AsmReferencesNonLocals(a->member_acc.base,inc_labels);
- break;
- case AST_PRE_DEC:
- case AST_PRE_INC:
- case AST_POS:
- case AST_NEG:
- case AST_LNOT:
- case AST_BNOT:
- case AST_DERREF:
- case AST_ADDROF:
- case AST_PAREN:
- case AST_POST_INC:
- case AST_POST_DEC:
- ret|=AsmReferencesNonLocals(a->unopArg,inc_labels);
- break;
- case AST_COMMA:
- case AST_ADD:
- case AST_SUB:
- case AST_MUL:
- case AST_DIV:
- case AST_MOD:
- case AST_LSHIFT:
- case AST_RSHIFT:
- case AST_POW:
- case AST_BAND:
- case AST_BXOR:
- case AST_BOR:
- case AST_LT:
- case AST_GT:
- case AST_LE:
- case AST_EQ:
- case AST_NE:
- case AST_GE:
- case AST_LAND:
- case AST_LOR:
- case AST_LXOR:
- case AST_ASSIGN:
- case AST_ASSIGN_SHL:
- case AST_ASSIGN_SHR:
- case AST_ASSIGN_MUL:
- case AST_ASSIGN_DIV:
- case AST_ASSIGN_BAND:
- case AST_ASSIGN_BOR:
- case AST_ASSIGN_BXOR:
- case AST_ASSIGN_ADD:
- case AST_ASSIGN_SUB:
- case AST_ASSIGN_MOD:
- ret|=AsmReferencesNonLocals(a->binop.a,inc_labels);
- ret|=AsmReferencesNonLocals(a->binop.b,inc_labels);
- break;
- case AST_ARRAY_ACCESS:
- ret|=AsmReferencesNonLocals(a->arr_acc.base,inc_labels);
- ret|=AsmReferencesNonLocals(a->arr_acc.index,inc_labels);
- break;
- case AST_NAME:
- if(!inc_labels) {
- if(local=HashFind(a->name,Compiler.locals))
- return !!(local->link.type&LINK_STATIC);
- else if(HashFind(a->name,Compiler.globals)||HashFind(a->name,Compiler.labels))
- return TRUE;
- //Could be a label
- return TRUE;
- } else {
- if((local=HashFind(a->name,Compiler.locals))||HashFind(a->name,Compiler.labels)) {
- if(local&&(local->link.type&LINK_STATIC))
- return TRUE;
- } else if(HashFind(a->name,Compiler.globals))
- return TRUE;
- //Could be a label
- return FALSE;
- }
- break;
- case AST_RANGE:
- cnt=MSize(a->range.values)/sizeof(AST*);
- while(--cnt>=0)
- ret|=AsmReferencesNonLocals(a->range.values[cnt],inc_labels);
- break;
- case AST_IMPLICIT_TC:
- case AST_EXPLICIT_TC:
- ret|=AsmReferencesNonLocals(a->typecast.base,inc_labels);
- break;
- case AST_FUNC_CALL:
- ret|=AsmReferencesNonLocals(a->func_call.base,inc_labels);
- cnt=MSize(a->func_call.args)/sizeof(AST*);
- while(--cnt>=0)
- if(a->func_call.args[cnt])
- ret|=AsmReferencesNonLocals(a->func_call.args[cnt],inc_labels);
- }
- return ret;
-}
-CType *AssignTypeToNode(AST *a,CType *arr_t=NULL) {
+extern U8 *PrintAST(AST *a);
+CType *AssignTypeToNode(AST *a,CType *arr_t=NULL,Bool dont_call_lone_name=FALSE) {
if(a->type!=AST_SIZEOF&&a->type2) return a->type2;
I64 dim,sdim,cnt,idx,lo,hi;
CType *ret=HashFind("I64i",Compiler.globals),*type1,*type2;
@@ -1461,6 +1330,7 @@ CType *AssignTypeToNode(AST *a,CType *arr_t=NULL) {
var->isReg=FALSE;
}
ret=GetType("U8i")+1;
+ break;
} else if(Compiler.in_func) {
if(var=HashFind(a->name,Compiler.locals)) {
if(var->type==HTT_VAR) {
@@ -1472,18 +1342,21 @@ CType *AssignTypeToNode(AST *a,CType *arr_t=NULL) {
ParserFail2(a,"Expected variable.");
}
}
- if(var=HashFind(a->name,Compiler.globals)) {
+ if((var=HashFind(a->name,Compiler.globals))&&!dont_call_lone_name) {
if(var->type==HTT_VAR) {
ret=var->hc_type;
+ break;
} else if(var->type==HTT_FUNC) {
func=var;
//Ensure all arguments are implicit
idx=MSize(func->hc_type->arg_values)/sizeof(I64**);
while(--idx>=0)
- if(!func->hc_type->arg_values[idx])
+ if(!func->hc_type->arg_values[idx])
ParserFail2(a,"Implicit function call is missing defualt arguments.");
+
//Functions on their own are impliclty called
ret=func->hc_type->ret_type;
+ break;
} else
ParserFail2(a,"Expected variable.");
} else if(Compiler.asm_mode) {
@@ -1494,8 +1367,12 @@ CType *AssignTypeToNode(AST *a,CType *arr_t=NULL) {
//May be a label
ret=GetType("U8i")+1;
break;
- } else
+ } else if(!var)
ParserFail2(a,"Unknown symbol '%s'.",a->name);
+ else if(var->type==HTT_VAR)
+ ret=var->hc_type;
+ else if(var->type==HTT_FUNC)
+ ret=var(CFunction*)->hc_type;
break;
case AST_IMPLICIT_TC:
//TODO
@@ -1647,6 +1524,8 @@ CType *AssignTypeToNode(AST *a,CType *arr_t=NULL) {
case AST_ASSIGN_MOD:
goto asn_binop;
break;
+ default:
+ ret=GetType("U0");
}
} catch {
ret=HashFind("I64i",Compiler.globals);
@@ -1655,6 +1534,104 @@ CType *AssignTypeToNode(AST *a,CType *arr_t=NULL) {
a->type2=ret;
return a->type2;
}
+//Use with asm patcher to detirmine if a value needs to be "Patched" with global values
+//Also,statics are treated as globals,as they stay resident in memory like globals.
+Bool AsmReferencesNonLocals(AST *a,Bool inc_labels=FALSE) {
+ Bool ret=FALSE;
+ I64 cnt;
+ CVariable *local;
+ switch(a->type) {
+ case AST_MEMBER:
+ ret|=AsmReferencesNonLocals(a->member_acc.base,inc_labels);
+ break;
+ case AST_PRE_DEC:
+ case AST_PRE_INC:
+ case AST_POS:
+ case AST_NEG:
+ case AST_LNOT:
+ case AST_BNOT:
+ case AST_DERREF:
+ case AST_ADDROF:
+ case AST_PAREN:
+ case AST_POST_INC:
+ case AST_POST_DEC:
+ ret|=AsmReferencesNonLocals(a->unopArg,inc_labels);
+ break;
+ case AST_COMMA:
+ case AST_ADD:
+ case AST_SUB:
+ case AST_MUL:
+ case AST_DIV:
+ case AST_MOD:
+ case AST_LSHIFT:
+ case AST_RSHIFT:
+ case AST_POW:
+ case AST_BAND:
+ case AST_BXOR:
+ case AST_BOR:
+ case AST_LT:
+ case AST_GT:
+ case AST_LE:
+ case AST_EQ:
+ case AST_NE:
+ case AST_GE:
+ case AST_LAND:
+ case AST_LOR:
+ case AST_LXOR:
+ case AST_ASSIGN:
+ case AST_ASSIGN_SHL:
+ case AST_ASSIGN_SHR:
+ case AST_ASSIGN_MUL:
+ case AST_ASSIGN_DIV:
+ case AST_ASSIGN_BAND:
+ case AST_ASSIGN_BOR:
+ case AST_ASSIGN_BXOR:
+ case AST_ASSIGN_ADD:
+ case AST_ASSIGN_SUB:
+ case AST_ASSIGN_MOD:
+ ret|=AsmReferencesNonLocals(a->binop.a,inc_labels);
+ ret|=AsmReferencesNonLocals(a->binop.b,inc_labels);
+ break;
+ case AST_ARRAY_ACCESS:
+ ret|=AsmReferencesNonLocals(a->arr_acc.base,inc_labels);
+ ret|=AsmReferencesNonLocals(a->arr_acc.index,inc_labels);
+ break;
+ case AST_NAME:
+ if(!inc_labels) {
+ if(local=HashFind(a->name,Compiler.locals))
+ return local->isReg=FALSE,!!(local->link.type&LINK_STATIC);
+ else if(HashFind(a->name,Compiler.globals)||HashFind(a->name,Compiler.labels))
+ return TRUE;
+ //Could be a label
+ return TRUE;
+ } else {
+ if((local=HashFind(a->name,Compiler.locals))||HashFind(a->name,Compiler.labels)) {
+ if(local&&(local->link.type&LINK_STATIC))
+ return local->isReg=FALSE,TRUE;
+ } else if(HashFind(a->name,Compiler.globals))
+ return TRUE;
+ //Could be a label
+ return FALSE;
+ }
+ break;
+ case AST_RANGE:
+ cnt=MSize(a->range.values)/sizeof(AST*);
+ while(--cnt>=0)
+ ret|=AsmReferencesNonLocals(a->range.values[cnt],inc_labels);
+ break;
+ case AST_IMPLICIT_TC:
+ case AST_EXPLICIT_TC:
+ ret|=AsmReferencesNonLocals(a->typecast.base,inc_labels);
+ break;
+ case AST_FUNC_CALL:
+ ret|=AsmReferencesNonLocals(a->func_call.base,inc_labels);
+ cnt=MSize(a->func_call.args)/sizeof(AST*);
+ while(--cnt>=0)
+ if(a->func_call.args[cnt])
+ ret|=AsmReferencesNonLocals(a->func_call.args[cnt],inc_labels);
+ }
+ return ret;
+}
_extern Prec14 AST * ParseExprNoComma(CCmpCtrl *cc);
_extern Prec15 AST * ParseExpr(CCmpCtrl *cc);
AST *Prec0(CCmpCtrl *cc) {
@@ -1671,8 +1648,8 @@ AST *Prec0(CCmpCtrl *cc) {
if(cc->token==TK_STR) {
//-1 ignores nul byte
tmp_s=MAlloc(MSize(ret->string)-1+cc->cur_str_len);
- StrNCpy(tmp_s,ret->string,MSize(ret->string)-1);
- StrNCpy(tmp_s+MSize(ret->string)-1,cc->cur_str,cc->cur_str_len);
+ MemCpy(tmp_s,ret->string,MSize(ret->string)-1);
+ MemCpy(tmp_s+MSize(ret->string)-1,cc->cur_str,cc->cur_str_len);
Free(ret->string);
ret->string=tmp_s;
goto sloop;
@@ -1715,6 +1692,7 @@ extern CType *ParseType(CType *_bt=NULL,CCmpCtrl *cc,AST **name,Bool base_type_o
AST *Prec1(CCmpCtrl *cc) {
AST *un=Prec0(cc),*args[0xff];
if(!un) return NULL;
+ MemSet(args,0,sizeof(args));
AST *ret=NULL,*tmp,*tmp2;
CType *t;
I64 idx=0;
@@ -2010,7 +1988,6 @@ Bool IsForward(CHash *item) {
}
return FALSE;
}
-extern U8 *PrintAST(AST *a);
U8 *__PrintAST(AST *a) {
I64 idx,cnt;
U8 *tmp1,*tmp2,*tmp3,*tmp4;
@@ -2020,7 +1997,7 @@ U8 *__PrintAST(AST *a) {
case AST_NOP:
return StrNew("NOP");
case AST_DECL:
- tmp3=MStrPrint("%s %s=%s",a->decl.type->str,a->decl.name,tmp2=PrintAST(a->decl.dft));
+ tmp3=MStrPrint("%s %s=%s",a->decl.type->str,a->decl.name->name,tmp2=PrintAST(a->decl.dft));
Free(tmp1),Free(tmp2);
return tmp3;
case AST_ARRAY_LITERAL:
@@ -2320,9 +2297,8 @@ unop:
);
case AST_LASTCLASS:
return StrNew("Lastclass\n");
- default:
- throw('AST');
}
+ return StrNew("UNK");
}
U8 *HexifyString(U8 *str,I64 len) {
U8 *ret=MAlloc(2*len+1);
@@ -2409,7 +2385,7 @@ AST *ParsePrint(CCmpCtrl *cc,Bool instant_eval=FALSE) {
len=MSize(ret->print.text)-1+cc->cur_str_len;
old=ret->print.text;
ret->print.text=StrNCpy(MAlloc(len),ret->print.text,MSize(old)); //Ignore NULL byte
- StrNCpy(ret->print.text+MSize(old)-1,cc->cur_str,cc->cur_str_len);
+ MemCpy(ret->print.text+MSize(old)-1,cc->cur_str,cc->cur_str_len);
Free(old);
}
loop:
@@ -2434,6 +2410,9 @@ AST *ParseGoto(CCmpCtrl *cc) {
AST *r;
CUnresolvedLabel *unresolved;
if(cc->token==TK_IDENT&&!StrCmp("goto",cc->cur_str)) {
+ r=MAlloc(sizeof(AST));
+ r->type=AST_GOTO;
+ LSP(cc,r);
Lex(cc);
if(cc->token!=TK_IDENT) ParserFail(cc,"Expected name.");
name=StrNew(cc->cur_str);
@@ -2441,8 +2420,6 @@ AST *ParseGoto(CCmpCtrl *cc) {
Lex(cc);
if(cc->token!=';') ParserFail(cc,"Expected ';'.");
Lex(cc);
- r=MAlloc(sizeof(AST));
- r->type=AST_GOTO;
r->name=name;
if(HashFind(name,Compiler.labels)) {
} else {
@@ -2539,7 +2516,7 @@ AST *ParseFor(CCmpCtrl *cc,Bool instant_eval=FALSE) {
AssignTypeToNode(ret);
return ret;
}
-CFunction *CompilerEmitCode();
+CFunction *CompilerEmitCode(I64 arity);
AST *ParseWhile(CCmpCtrl *cc,Bool instant_eval=FALSE) {
AST *cond=NULL,*body=NULL,*ret,*posit;
I64 old;
@@ -2774,7 +2751,7 @@ CTypeMember *ParseMembers(CCmpCtrl *cc,CTypeMember *inher=NULL) {
cur_pos=LSP(cc);
Lex(cc);
FreeAST(cur_pos);
- meta_exp=ParseExpr(cc),AssignTypeToNode(meta_exp);
+ meta_exp=ParseExprNoComma(cc),AssignTypeToNode(meta_exp);
meta->value=EvalAST(meta_exp);
meta->last=tmp->meta;
if(tmp->meta)
@@ -2872,7 +2849,7 @@ CType *ParseType(CType *_bt=NULL,CCmpCtrl *cc,AST **name,Bool base_type_only=FAL
if(tname)
forward_t=GetType(tname);
else forward_t=NULL;
- if(Compiler.aot_mode&&forward_t&&!forward_t->is_fwd) ParserFail2(LSP(cc,NULL),"Redefinition of class %s.",forward_t->str);
+ //if(Compiler.aot_mode&&forward_t&&!forward_t->is_fwd) ParserFail2(LSP(cc,NULL),"Redefinition of class %s.",forward_t->str);
if(tname) HashAdd(_bt,Compiler.globals);
forward_t=NULL;
if(inher) {
@@ -2983,7 +2960,7 @@ CType *ParseType(CType *_bt=NULL,CCmpCtrl *cc,AST **name,Bool base_type_only=FAL
if(tname)
ftype=GetType(tname);
else ftype=NULL;
- if(Compiler.aot_mode&&ftype&&!ftype->is_fwd) ParserFail2(LSP(cc,NULL),"Redefinition of union %s.",ftype->str);
+ //if(Compiler.aot_mode&&ftype&&!ftype->is_fwd) ParserFail2(LSP(cc,NULL),"Redefinition of union %s.",ftype->str);
if(tname) HashAdd(_bt,Compiler.globals);
if(inher) {
_bt->inher=inher;
@@ -3052,7 +3029,7 @@ CType *ParseType(CType *_bt=NULL,CCmpCtrl *cc,AST **name,Bool base_type_only=FAL
bt=_bt;
goto loop1;
}
- if(cc->token==TK_IDENT&&(find=HashFind(cc->cur_str,Compiler.globals)) );
+ if(cc->token==TK_IDENT&&(find=HashFind(cc->cur_str,Compiler.globals)));
else return NULL;
if(!IsHTTType(find->type)) return NULL;
Lex(cc);
@@ -3244,6 +3221,7 @@ CType *ParseType(CType *_bt=NULL,CCmpCtrl *cc,AST **name,Bool base_type_only=FAL
ftype[idx+1]->str=MStrPrint("%s*",ftype[idx]->str);
ftype[idx+1]->sz=ftype[idx+1]->align=8;
}
+ //"%d,%d\n",idx,cnt;
//Prevent from getting sweep away by gc
HashAdd(ftype,Compiler.globals);
bt=ftype+star_cnt;
@@ -3522,7 +3500,7 @@ AST *ParseDecls(CCmpCtrl *cc,Bool instant_eval=FALSE) {
if(link) var->link=*link;
try {
if(Compiler.in_func) {
- if(IsInteger(var->hc_type)||IsF64(var->hc_type))
+ if(IsInteger(var->hc_type))
if(var->hc_type->type!=HTT_ARRAY_TYPE)
var->isReg=TRUE;
if(HashFind(var->str,Compiler.locals))
@@ -3673,63 +3651,7 @@ AST *ParseStmt(CCmpCtrl *cc,Bool instant_eval=FALSE,Bool allow_cases=FALSE) {
}
return NULL;
}
-U0 PushIRReg(CType *type,I64 reg) {
- CIRValue *new=MAlloc(sizeof(CIRValue));
- new->type=IRV_REG;
- new->reg=reg;
- new->last=Compiler.stack;
- Compiler.stack=new;
- new->type2=type;
-}
-U0 PushIRFReg(CType *type,I64 reg) {
- CIRValue *new=MAlloc(sizeof(CIRValue));
- new->type=IRV_FREG;
- new->reg=reg;
- new->last=Compiler.stack;
- Compiler.stack=new;
- new->type2=type;
-}
-U0 PushIRInt(I64 i) {
- CIRValue *new=MAlloc(sizeof(CIRValue));
- new->type=IRV_INT;
- new->int=i;
- new->last=Compiler.stack;
- new->type2=HashFind("I64i",Compiler.globals);
- Compiler.stack=new;
-}
-U0 PushIRFlt(F64 f) {
- CIRValue *new=MAlloc(sizeof(CIRValue));
- new->type=IRV_FLOAT;
- new->flt=f;
- new->last=Compiler.stack;
- new->type2=HashFind("F64",Compiler.globals);
- Compiler.stack=new;
-}
-U0 PushIRIndirX(CType *type,I64 reg,I64 off) {
- CIRValue *new=MAlloc(sizeof(CIRValue));
- new->type=IRV_INDIRX;
- new->indirx.reg=reg;
- new->indirx.offset=off;
- new->indirx.type=type;
- new->last=Compiler.stack;
- new->type2=type;
- Compiler.stack=new;
-}
-U0 PopIRValue(CIRValue **top=NULL) {
- CIRValue *ret=Compiler.stack;
- if(!ret) {
- "NO VALUE ON STACK\n";
- throw('Compile');
- }
- Compiler.stack=ret->last;
- if(top) {
- *top=ret;
- ret->last=NULL;
- } else {
- Free(ret);
- }
-}
-I64 LoadSymPtrIntoReg(U8 *name,I64 reg) {
+I64 LoadSymPtr(U8 *name) {
CVariable *var=HashFind(name,Compiler.globals);
CFunction *func=var;
if(var&&var->type==HTT_VAR) {
@@ -3747,14 +3669,13 @@ I64 LoadSymPtrIntoReg(U8 *name,I64 reg) {
}
CRelocation *new=MAlloc(sizeof(CRelocation)),*last=Compiler.relocations;
StrCpy(new->name,name);
- jit_relocation(Compiler.jit,jit_R(reg),&new->ptr);
+ JIT_RELOCATION(Compiler.jit,&new->ptr);
if(!last)
Compiler.relocations=new;
else {
new->next=last;
Compiler.relocations=new;
}
- return jit_R(reg);
}
CType *GetType(U8 *name,I64 ptr_level=0) {
CType *ret=HashFind(name,Compiler.globals);
@@ -3762,264 +3683,11 @@ CType *GetType(U8 *name,I64 ptr_level=0) {
return ret+ptr_level;
return NULL;
}
-I64 GetFreeIReg(I64 off=0) {
- I64 max=Compiler.first_avail_ireg;
- CIRValue *cur=Compiler.stack;
- while(cur) {
- if(cur->type==IRV_REG) {
- max=MaxI64(cur->reg,max);
- } else if(cur->type==IRV_INDIRX) {
- max=MaxI64(cur->indirx.reg,max);
- }
- cur=cur->last;
- }
- return max+1+off;
-}
-I64 GetFreeFReg(I64 off=0) {
- I64 max=Compiler.first_avail_freg;
- CIRValue *cur=Compiler.stack;
- while(cur) {
- if(cur->type==IRV_FREG) {
- max=MaxI64(cur->reg,max);
- }
- cur=cur->last;
- }
- return max+1+off;
-}
-CIRValue *MovePtrToReg(CIRValue *var,I64 r=-1) {
- CIRValue *ret;
- if(r==-1) r=GetFreeIReg;
- if(var->type!=IRV_INDIRX) {
- "VAIRALBLE INSNT INDIRECT\n";
- throw('Compile');
- }
- if(!var->indirx.offset) {
- jit_movr(Compiler.jit,jit_R(r),jit_R(var->indirx.reg));
- } else {
- jit_movr(Compiler.jit,jit_R(r),jit_R(var->indirx.reg));
- jit_addi(Compiler.jit,jit_R(r),jit_R(r),var->indirx.offset);
- }
- PushIRReg(var->type2,r);
- PopIRValue(&ret);
- return ret;
-}
-U0 CompileBoundsCheck(I64 r,I64 sz,I64 off=0);
/* 0 is b registeddddr
* 1 is a destination register(if needed)
* 2 is func ptr register
*/
-U0 Assign(CIRValue *a,CIRValue *b) {
- if(Compiler.error_count) return;
- I64 br,ar,fr;
- //Load b into register(0) first,then load into a
- if(IsInteger(b->type2)||IsPtrType(b->type2)) {
- br=jit_R(0);
- switch(b->type) {
- case IRV_INT:
- jit_movi(Compiler.jit,jit_R(0),b->int);
- break;
- case IRV_FLOAT:
- jit_movi(Compiler.jit,jit_R(0),b->flt);
- break;
- case IRV_FREG:
- "GOT FREG\n";
- throw('Compile');
- break;
- case IRV_REG:
- br=jit_R(b->reg);
- break;
- case IRV_STR:
- //TODO register string
- jit_movi(Compiler.jit,jit_R(0),b->int);
- break;
- case IRV_INDIRX: //Comes with offsett
- if(IsSigned(b->type2)) {
- if(!b->indirx.offset) {
- CompileBoundsCheck(b->indirx.reg,b->type2->sz);
- jit_ldr(Compiler.jit,jit_R(0),jit_R(b->indirx.reg),b->type2->sz);
- } else {
- CompileBoundsCheck(b->indirx.reg,b->type2->sz,b->indirx.offset);
- jit_ldxi(Compiler.jit,jit_R(0),jit_R(b->indirx.reg),b->indirx.offset,b->type2->sz);
- }
- } else {
- if(!b->indirx.offset) {
- CompileBoundsCheck(b->indirx.reg,b->type2->sz);
- jit_ldr_u(Compiler.jit,jit_R(0),jit_R(b->indirx.reg),b->type2->sz);
- } else {
- CompileBoundsCheck(b->indirx.reg,b->type2->sz,b->indirx.offset);
- jit_ldxi_u(Compiler.jit,jit_R(0),jit_R(b->indirx.reg),b->indirx.offset,b->type2->sz);
- }
- }
- break;
- }
- switch(a->type) {
- case IRV_INT:
- "GOT IRV_INT\n";
- throw('Compile');
- break;
- case IRV_FLOAT:
- "GOT IRV_FLOAT\n";
- throw('Compile');
- break;
- case IRV_FREG:
- jit_extr(Compiler.jit,jit_FR(a->reg),br);
- break;
- case IRV_REG:
- jit_movr(Compiler.jit,jit_R(a->reg),br);
- break;
- case IRV_STR:
- "GOT IRV_STR\n";
- throw('Compile') ;
- break;
- case IRV_INDIRX:
- if(!IsF64(a->type2)) {
- CompileBoundsCheck(a->indirx.reg,a->type2->sz,a->indirx.offset);
- if(!a->indirx.offset) {
- jit_str(Compiler.jit,jit_R(a->indirx.reg),br,a->type2->sz);
- } else {
- jit_stxi(Compiler.jit,a->indirx.offset,jit_R(a->indirx.reg),br,a->type2->sz);
- }
- } else {
- jit_extr(Compiler.jit,jit_FR(0),br);
- br=jit_FR(0);
- CompileBoundsCheck(a->indirx.reg,8,a->indirx.offset);
- if(!a->indirx.offset) {
- jit_fstr(Compiler.jit,jit_R(a->indirx.reg),br,8);
- } else {
- jit_fstxi(Compiler.jit,a->indirx.offset,jit_R(a->indirx.reg),br,8);
- }
- }
- break;
- }
- } else if(IsF64(b->type2)) {
- br=jit_FR(0);
- switch(b->type) {
- case IRV_INT:
- jit_fmovi(Compiler.jit,jit_FR(0),b->int);
- break;
- case IRV_FLOAT:
- jit_fmovi(Compiler.jit,jit_FR(0),b->flt);
- break;
- case IRV_FREG:
- br=jit_FR(b->reg);
- break;
- case IRV_REG:
- jit_extr(Compiler.jit,jit_FR(0),jit_R(b->reg));
- break;
- case IRV_STR:
- //str->flt??? have fun
- //TODO register string
- jit_fmovi(Compiler.jit,jit_FR(0),b->int);
- break;
- case IRV_INDIRX: //Comes with offsett
- CompileBoundsCheck(b->indirx.reg,8,b->indirx.offset);
- if(!b->indirx.offset) {
- jit_fldr(Compiler.jit,jit_FR(0),jit_R(b->indirx.reg),8);
- } else {
- jit_fldxi(Compiler.jit,jit_FR(0),jit_R(b->indirx.reg),b->indirx.offset,8);
- }
- break;
- }
- switch(a->type) {
- case IRV_INT:
- "GOT IRV_INT\n";
- throw('Compile');
- break;
- case IRV_FLOAT:
- "GOT IRV_FLOAT\n";
- throw('Compile');
- break;
- case IRV_FREG:
- jit_fmovr(Compiler.jit,jit_FR(a->reg),br);
- break;
- case IRV_REG:
- jit_truncr(Compiler.jit,jit_R(a->reg),br);
- break;
- case IRV_STR:
- "GOT IRV_STR\n";
- throw('Compile');
- break;
- case IRV_INDIRX:
- if(IsF64(a->type2)) {
- if(!a->indirx.offset) {
- jit_fstr(Compiler.jit,jit_R(a->indirx.reg),br,8);
- } else {
- jit_fstxi(Compiler.jit,a->indirx.offset,jit_R(a->indirx.reg),br,8);
- }
- } else {
- jit_truncr(Compiler.jit,jit_R(0),br);
- br=jit_R(0);
- CompileBoundsCheck(a->indirx.reg,a->type2->sz,a->indirx.offset);
- if(!a->indirx.offset) {
- jit_str(Compiler.jit,jit_R(a->indirx.reg),br,a->type2->sz);
- } else {
- jit_stxi(Compiler.jit,a->indirx.offset,jit_R(a->indirx.reg),br,a->type2->sz);
- }
- }
- break;
- }
- } else {
- //Is an object so copy using MemCpy
- fr=LoadSymPtrIntoReg("MemCpy",2);
- br=jit_R(MovePtrToReg(b,0)->reg);
- ar=jit_R(MovePtrToReg(a,1)->reg);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,ar);
- jit_putargr(Compiler.jit,br);
- jit_putargi(Compiler.jit,b->type2->sz);
- jit_callr(Compiler.jit,fr);
- return;
- }
-}
-CIRValue *MoveToFReg(CIRValue *value_a,I64 off) {
- if(value_a->type==IRV_FREG)
- return value_a;
- CIRValue *value_b;
- PushIRFReg(GetType("F64"),GetFreeFReg+off);
- PopIRValue(&value_b);
- Assign(value_b,value_a);
- Free(value_a);
- return value_b;
-}
-CIRValue *MoveToReg(CIRValue *value_a,I64 off) {
- if(value_a->type==IRV_REG)
- return value_a;
- if(value_a->type==IRV_INDIRX&&value_a->type2->type==HTT_ARRAY_TYPE) {
- value_a->type=IRV_REG;
- value_a->reg=value_a->indirx.reg;
- return value_a;
- }
- CIRValue *value_b;
- if(!(IsInteger(value_a->type2)||IsPtrType(value_a->type2)))
- PushIRReg(value_a->type2,GetFreeIReg(off));
- else
- PushIRReg(value_a->type2,GetFreeIReg(off));
- PopIRValue(&value_b);
- Assign(value_b,value_a);
- Free(value_a);
- return value_b;
-}
-CIRValue *BoolifyValue(CIRValue *value) {
- CIRValue *ret;
- I64 r,fr;
- U0 *pat;
- PushIRReg(GetType("I64i"),r=GetFreeIReg);
- if(IsF64(value->type2)) {
- fr=GetFreeFReg;
- value=MoveToFReg(IRValueClone(value),0);
- jit_movi(Compiler.jit,jit_R(r),1);
- pat=jit_fbnei(Compiler.jit,NULL,jit_FR(value->reg),0.0);
- jit_movi(Compiler.jit,jit_R(r),0);
- jit_patch(Compiler.jit,pat);
- } else {
- value=MoveToReg(IRValueClone(value),0);
- jit_nei(Compiler.jit,jit_R(r),jit_R(value->reg),0);
- }
- Free(value);
- PopIRValue(&ret);
- return ret;
-}
-U0 CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE);
+U0 CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE,Bool get_ptr=FALSE);
U0 CompileArrayLiteral(CType *type,I64 pointer_reg,AST *literal,I64 offset=0) {
I64 cnt=MSize(literal->arr_lit)/sizeof(AST*),idx,o_off=offset;
CTypeMember *mem;
@@ -4029,10 +3697,17 @@ U0 CompileArrayLiteral(CType *type,I64 pointer_reg,AST *literal,I64 offset=0) {
for(idx=0;mem&&idx!=cnt;idx++) {
if(!literal->arr_lit[idx]) {
} if(literal->arr_lit[idx]->type!=AST_ARRAY_LITERAL) {
- PushIRIndirX(mem->type,pointer_reg,offset+mem->offset);
- CompileAST(literal->arr_lit[idx]);
- Assign(Compiler.stack->last,Compiler.stack);
- PopIRValue,PopIRValue;
+ if(IsF64(mem->type)) {
+ JIT_FMOV(Compiler.jit);
+ JIT_FDEREF(Compiler.jit,offset+mem->offset);
+ JIT_R(Compiler.jit,pointer_reg);
+ CompileAST(literal->arr_lit[idx]);
+ } else {
+ JIT_MOV(Compiler.jit);
+ JIT_DEREF(Compiler.jit,offset+mem->offset,mem->type->sz);
+ JIT_R(Compiler.jit,pointer_reg);
+ CompileAST(literal->arr_lit[idx]);
+ }
} else if(literal->arr_lit[idx]->type==AST_ARRAY_LITERAL) {
CompileArrayLiteral(mem->type,pointer_reg,literal->arr_lit[idx],offset+mem->offset);
}
@@ -4043,41 +3718,19 @@ U0 CompileArrayLiteral(CType *type,I64 pointer_reg,AST *literal,I64 offset=0) {
for(idx=0;idx!=cnt;idx++) {
if(!literal->arr_lit[idx]) {
} else if(literal->arr_lit[idx]->type!=AST_ARRAY_LITERAL) {
- PushIRIndirX(d,pointer_reg,offset);
+ if(IsF64(d))
+ JIT_FMOV(Compiler.jit),JIT_FDEREF(Compiler.jit,offset);
+ else
+ JIT_MOV(Compiler.jit),JIT_DEREF(Compiler.jit,offset,d->sz);
+ JIT_R(Compiler.jit,pointer_reg);
CompileAST(literal->arr_lit[idx]);
- Assign(Compiler.stack->last,Compiler.stack);
- PopIRValue,PopIRValue;
} else {
- CompileArrayLiteral(d,pointer_reg,literal->arr_lit[idx],offset);
+ CompileArrayLiteral(d,pointer_reg,literal->arr_lit[idx],offset);
}
- offset+=d->sz;
+ offset+=d->sz;
}
}
}
-Bool FoldIRF64() {
- CIRValue *a;
- if(Compiler.stack->type==IRV_FLOAT)
- return TRUE;
- else if(Compiler.stack->type==IRV_INT) {
- PopIRValue(&a);
- PushIRFlt(a->int);
- Free(a);
- return TRUE;
- }
- return FALSE;
-}
-Bool FoldIRInt() {
- CIRValue *a;
- if(Compiler.stack->type==IRV_INT)
- return TRUE;
- else if(Compiler.stack->type==IRV_FLOAT) {
- PopIRValue(&a);
- PushIRInt(a->flt);
- Free(a);
- return TRUE;
- }
- return FALSE;
-}
U0 PushIRString(U8 *data,I64 len) {
U8 *str=HexifyString(data,len);
CCompString *comp_str;
@@ -4087,8 +3740,7 @@ U0 PushIRString(U8 *data,I64 len) {
if(!Compiler.aot_mode) {
reg_str:
if(comp_str=HashFind(str,Compiler.cur_strings)) {
- jit_movi(Compiler.jit,jit_R(idx=GetFreeIReg),comp_str->data);
- PushIRReg(GetType("U8i")+1,idx);
+ JIT_I64(Compiler.jit,comp_str->data);
} else {
comp_str=MAlloc(sizeof(CCompString));
comp_str->data=MemCpy(MAlloc(len),data,len);
@@ -4102,8 +3754,7 @@ U0 PushIRString(U8 *data,I64 len) {
ref=MAlloc(sizeof(CCompStringRef));
ref->next=comp_str->refs;
comp_str->refs=ref;
- jit_relocation(Compiler.jit,jit_R(idx=GetFreeIReg),&ref->ptr);
- PushIRReg(GetType("U8i")+1,idx);
+ JIT_RELOCATION(Compiler.jit,&ref->ptr);
} else {
comp_str=MAlloc(sizeof(CCompString));
comp_str->data=MemCpy(MAlloc(len),data,len);
@@ -4115,14 +3766,37 @@ U0 PushIRString(U8 *data,I64 len) {
Free(str);
}
U0 CompileAstWithBreakpoint(AST *oc);
-//Will add a patcher to the current functionX
-U0 CompileAsmConst(AST *mode,I64 width,Bool rel=FALSE,I64 label_scope=-2);
+//Will add a patcher to the current function if eval_only is not set
+CAsmPatcher *CompileAsmConst(AST *mode,I64 width,Bool is_rel=FALSE,I64 local_scope=-2,Bool eval_only=FALSE);
U0 CompileOpcode(AST *oc) {
U8 buffer[32],*end_ptr=NULL;
CReg *mbase;
Bool is_jmp,bye_bye=FALSE;
- I64 idx,siboff,immoff,immsz,operand_cnt=MSize(oc->opcode->args)/sizeof(AST*);
+ I64 idx,idx2,siboff,immoff,immsz,operand_cnt=MSize(oc->opcode->args)/sizeof(AST*);
+ CAsmPatcher *a_eval;
+ U0 (*fptr)();
retry:
+ for(idx=0;idx!=operand_cnt;idx++) {
+ if(oc->opcode->args[idx]->x64_mode_offset) {
+ AssignTypeToNode(oc->opcode->args[idx]->x64_mode_offset);
+ if(!AsmReferencesNonLocals(oc->opcode->args[idx]->x64_mode_offset)) {
+ switch(oc->opcode->args[idx]->x64_mode->type) {
+ start:
+ a_eval=CompileAsmConst(oc->opcode->args[idx]->x64_mode_offset,-1,FALSE,oc->label_scope,TRUE);
+ case X64O_IMM:
+ oc->opcode->args[idx]->x64_mode->imm=(*(fptr=a_eval->func_ptr))();
+ break;
+ case X64O_MEM:
+ oc->opcode->args[idx]->x64_mode->mem.disp=(*(fptr=a_eval->func_ptr))();
+ break;
+ end:
+ FreeAST(oc->opcode->args[idx]->x64_mode_offset);
+ oc->opcode->args[idx]->x64_mode_offset=NULL;
+ FreeFunction(a_eval);
+ }
+ }
+ }
+ }
try {
try {
switch(operand_cnt) {
@@ -4157,7 +3831,6 @@ U0 CompileOpcode(AST *oc) {
oc->opcode.args[idx]->x64_mode.imm>>=8;
goto retry;
}
- "SMALL\n";
throw('Compile');
}
if(is_jmp) {
@@ -4165,42 +3838,54 @@ U0 CompileOpcode(AST *oc) {
"TOO MANY\n";
throw('Compile');
}
- jit_data_bytes(Compiler.jit,end_ptr-buffer,buffer);
+ for(idx=0;idx!=end_ptr-buffer;idx++)
+ JIT_DU8(Compiler.jit,buffer[idx]);
CompileAsmConst(oc->opcode->args[0]->x64_mode_offset,4,TRUE,oc->label_scope);
return;
- } else if(immoff!=-1) {
- for(idx=0;idx!=operand_cnt;idx++) {
- if(oc->opcode.args[idx]->x64_mode.type==X64O_IMM) {
- if(oc->opcode.args[idx]->x64_mode_offset) {
- jit_data_bytes(Compiler.jit,immoff,buffer);
- CompileAsmConst(oc->opcode.args[idx]->x64_mode_offset,immsz,FALSE,oc->label_scope); //See the plato-pus!! Seriously,its above someewhere
- return;
- }
- }
- }
- } else if(siboff!=-1) {
+ }
+ idx2=0;
+ if(siboff!=-1) {
for(idx=0;idx!=operand_cnt;idx++) {
if(oc->opcode.args[idx]->x64_mode.type==X64O_MEM) {
if(oc->opcode.args[idx]->x64_mode_offset) {
- jit_data_bytes(Compiler.jit,end_ptr-buffer-4,buffer);
+ for(idx2;idx2<siboff-4;idx2++)
+ JIT_DU8(Compiler.jit,buffer[idx2]);
mbase=oc->opcode.args[idx]->x64_mode.mem.base;
if(mbase&&(mbase==HashFind("RIP",regs)||mbase==HashFind("EIP",regs)))
CompileAsmConst(oc->opcode.args[idx]->x64_mode_offset,4,TRUE,oc->label_scope); //See the plato-pus!! Seriously,its above someewhere
else
CompileAsmConst(oc->opcode.args[idx]->x64_mode_offset,4,FALSE,oc->label_scope); //See the plato-pus!! Seriously,its above someewhere
- return;
+ idx2+=4;
+ break;
}
}
}
}
- jit_data_bytes(Compiler.jit,end_ptr-buffer,buffer);
+ if(immoff!=-1) {
+ for(idx=0;idx!=operand_cnt;idx++) {
+ if(oc->opcode.args[idx]->x64_mode.type==X64O_IMM) {
+ if(oc->opcode.args[idx]->x64_mode_offset) {
+ for(;idx2<immoff;idx2++) {
+ JIT_DU8(Compiler.jit,buffer[idx2]);
+ }
+ CompileAsmConst(oc->opcode.args[idx]->x64_mode_offset,immsz,FALSE,oc->label_scope); //See the plato-pus!! Seriously,its above someewhere
+ idx2+=immsz;
+ break;
+ }
+ }
+ }
+ }
+ for(;idx2<end_ptr-buffer;idx2++)
+ JIT_DU8(Compiler.jit,buffer[idx2]);
}
U0 SetCallStackSize(I64);
-U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE) {
- CIRValue *fargs[0xff];
+I64 GetFreeIReg() {
+ return ++Compiler.cur_tmp_reg;
+}
+U0 CreateBreakpointFor(AST *a);
+U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE,Bool get_ptr=FALSE) {
CHashTable *tar_tab,*old_asm_imports;
CVariable *var;
- CIRValue *value_a,*value_b,*value_c;
I64 idx,cnt,reg_a,reg_b,offset,mult,hi,lo,idx2;
CTypeMember *mem1;
CType *type1,*type2;
@@ -4212,882 +3897,419 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
CFunction *func;
CVector *to_patch;
AST *dummy;
- U0 *op1,*op2,*op3,*op4;
+ CRPN *op1,*op2,*op3,*op4,*op5;
U8 *str;
CCompString *comp_str;
- Bool has_dft;
+ Bool has_dft,is_flt_style;
switch(ast->type) {
case AST_ASM_BLK:
Compiler.asm_mode=TRUE;
old_asm_imports=Compiler.imports;
Compiler.imports=HashTableNew(0x10);
+ op1=jit_rpnBodyStart(Compiler.jit);
if(Compiler.in_func) {
CompileAST(ast->asm_blk_body);
} else {
- op1=jit_jmpi(Compiler.jit,NULL);
+ op1=JIT_JMP(Compiler.jit,NULL);
CompileAST(ast->asm_blk_body);
- jit_patch(Compiler.jit,op1);
+ JIT_PATCH(Compiler.jit,op1);
}
+ jit_rpnBodyEnd(Compiler.jit,op1);
HashTableDel(Compiler.imports);
Compiler.imports=old_asm_imports;
Compiler.asm_mode=FALSE;
- PopIRValue;
- PushIRInt(0);
break;
case AST_OPCODE:
CompileOpcode(ast);
- PushIRInt(0);
break;
case AST_GLOBAL_LABEL:
lab=HashFind(ast->name,Compiler.labels);
if(!lab) throw('Compile');
if(lab->type!=HTT_LABEL||lab->op) throw('Compile');
- jit_dump_ptr(Compiler.jit,&lab->ptr);
+ JIT_DUMP_PTR(Compiler.jit,&lab->ptr);
while(lab->refs->size) {
op1=VectorPop(lab->refs);
- jit_patch(Compiler.jit,op1);
+ JIT_PATCH(Compiler.jit,op1);
}
- lab->op=jit_get_label(Compiler.jit);
- PushIRInt(0);
+ lab->op=JIT_LABEL(Compiler.jit);
break;
case AST_LOCAL_LABEL:
lab=HashFind(ast->name,Compiler.labels);
if(!lab) throw('Compile');
if(lab->type!=HTT_LABEL||lab->op) throw('Compile');
- jit_dump_ptr(Compiler.jit,&lab->ptr);
+ JIT_DUMP_PTR(Compiler.jit,&lab->ptr);
while(lab->refs->size) {
op1=VectorPop(lab->refs);
- jit_patch(Compiler.jit,op1);
+ JIT_PATCH(Compiler.jit,op1);
}
- lab->op=jit_get_label(Compiler.jit);
- PushIRInt(0);
+ lab->op=JIT_LABEL(Compiler.jit);
break;
case AST_DU8:
cnt=MSize(ast->arr_lit)/sizeof(AST*);
for(idx=0;idx!=cnt;idx++) {
if(ast->arr_lit[idx]->type==AST_STRING) {
- jit_data_bytes(Compiler.jit,ast->arr_lit[idx]->string,MSize(ast->arr_lit[idx]->string)-1); //-1 Ignores NULL terminator
+ for(idx2=0;idx2!=MSize(ast->arr_lit[idx]->string)-1;idx2++)
+ JIT_DU8(Compiler.jit,ast->arr_lit[idx]->string(U8*)[idx2]);
} else {
CompileAsmConst(ast->arr_lit[idx],1,ast->label_scope);
}
}
- PushIRInt(0);
break;
case AST_DU16:
cnt=MSize(ast->arr_lit)/sizeof(AST*);
for(idx=0;idx!=cnt;idx++) {
if(ast->arr_lit[idx]->type==AST_STRING) {
- hi=MSize(str=ast->arr_lit[idx]->string)-1; //-1 Ignores NULL terminator
- for(lo=0;lo!=hi;lo++)
- jit_data_word(Compiler.jit,str[lo]);
+ for(idx2=0;idx2!=MSize(ast->arr_lit[idx]->string)-1;idx2++)
+ JIT_DU16(Compiler.jit,ast->arr_lit[idx]->string(U8*)[idx2]);
} else {
CompileAsmConst(ast->arr_lit[idx],2,ast->label_scope);
}
}
- PushIRInt(0);
break;
case AST_DU32:
cnt=MSize(ast->arr_lit)/sizeof(AST*);
for(idx=0;idx!=cnt;idx++) {
if(ast->arr_lit[idx]->type==AST_STRING) {
- hi=MSize(str=ast->arr_lit[idx]->string)-1; //-1 Ignores NULL terminator
- for(lo=0;lo!=hi;lo++)
- jit_data_dword(Compiler.jit,str[lo]);
+ for(idx2=0;idx2!=MSize(ast->arr_lit[idx]->string)-1;idx2++)
+ JIT_DU32(Compiler.jit,ast->arr_lit[idx]->string(U8*)[idx2]);
} else {
CompileAsmConst(ast->arr_lit[idx],4,ast->label_scope);
}
}
- PushIRInt(0);
break;
case AST_DU64:
cnt=MSize(ast->arr_lit)/sizeof(AST*);
for(idx=0;idx!=cnt;idx++) {
if(ast->arr_lit[idx]->type==AST_STRING) {
- hi=MSize(str=ast->arr_lit[idx]->string)-1; //-1 Ignores NULL terminator
- for(lo=0;lo!=hi;lo++)
- jit_data_qword(Compiler.jit,str[lo]);
+ for(idx2=0;idx2!=MSize(ast->arr_lit[idx]->string)-1;idx2++)
+ JIT_DU64(Compiler.jit,ast->arr_lit[idx]->string(U8*)[idx2]);
} else {
CompileAsmConst(ast->arr_lit[idx],8,FALSE,ast->label_scope);
}
}
- PushIRInt(0);
break;
case AST_IMPORT:
imp=MAlloc(sizeof(CHash));
imp->str=StrNew(ast->name);
HashAdd(imp,Compiler.imports);
- PushIRInt(0);
break;
case AST_ALIGN:
- jit_code_align_fill(Compiler.jit,ast->align.to,ast->align.fill);
- PushIRInt(0);
+ JIT_ALIGN_FILL(Compiler.jit,ast->align.to,ast->align.fill);
break;
case AST_BINFILE:
str=FileRead(ast->name,&cnt);
- jit_data_bytes(Compiler.jit,str,cnt);
+ for(idx=0;idx!=8;idx++)
+ JIT_DU8(Compiler.jit,str[idx]);
Free(str);
- PushIRInt(0);
break;
case AST_PRINT:
- PushIRString(ast->print.text,MSize(ast->print.text));
- PushIRReg(HashFind("I64i",Compiler.globals),GetFreeIReg);
- LoadSymPtrIntoReg("Print",Compiler.stack->reg);
- cnt=MSize(ast->print.args)/sizeof(AST*);
- if(cnt) {
- Compiler.frame_off=jit_allocai(Compiler.jit,8*cnt);
- value_b=Compiler.stack;
- for(idx=cnt-1;idx>=0;idx--) {
+ cnt=MSize(ast->print.args)/sizeof(AST*);
+ JIT_FUNC_CALL(Compiler.jit,cnt+2); //+1 for str,+1 for count
+ for(idx=cnt-1;idx>=0;idx--)
CompileAST(ast->print.args[idx]);
- switch(Compiler.stack->type) {
- start:
- case IRV_INDIRX:
- PopIRValue(&value_a);
- if(IsF64(value_a->type2)) {
- value_a=MoveToFReg(value_a,0);
- } else
- value_a=MoveToReg(value_a,0);
- break;
- end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- }
- hi=GetFreeIReg;
- value_b=Compiler.stack;
- switch(value_b->type) {
- case IRV_INT:
- case IRV_STR: //TODO register string
- jit_movi(Compiler.jit,jit_R(hi),value_b->int);
- jit_stxi(Compiler.jit,Compiler.frame_off+8*idx,R_FP,jit_R(hi),8);
- break;
- case IRV_REG:
- jit_stxi(Compiler.jit,Compiler.frame_off+8*idx,R_FP,jit_R(value_b->reg),8);
- break;
- case IRV_FLOAT:
- hi=GetFreeFReg;
- jit_fmovi(Compiler.jit,jit_FR(hi),value_b->flt);
- jit_fstxi(Compiler.jit,Compiler.frame_off+8*idx,R_FP,jit_FR(hi),8);
- break;
- case IRV_FREG:
- jit_fstxi(Compiler.jit,Compiler.frame_off+8*idx,R_FP,jit_FR(value_b->reg),8);
- break;
- }
- PopIRValue;
- }
- hi=GetFreeIReg;
- jit_addi(Compiler.jit,jit_R(hi),R_FP,Compiler.frame_off);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(Compiler.stack->last.reg));
- jit_putargi(Compiler.jit,cnt);
- jit_putargr(Compiler.jit,jit_R(hi));
- } else {
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(Compiler.stack->last.reg));
- jit_putargi(Compiler.jit,0);
- }
- jit_callr(Compiler.jit,jit_R(Compiler.stack->reg));
- PopIRValue,PopIRValue;
- PushIRInt(0);
- break;
- case AST_NOP:
- PushIRInt(0);
- break;
- case AST_DECL:
- if(Compiler.in_func) {
- tar_tab=Compiler.locals;
- } else {
- tar_tab=Compiler.globals;
- }
- var=HashFind(ast->decl.name->name,tar_tab);
- if(ast->decl.dft) {
- if(ast->decl.dft.type==AST_ARRAY_LITERAL) {
- if(Compiler.in_func) {
- var=HashFind(ast->decl.name.name,Compiler.locals);
- if(var&&var->type==HTT_VAR) {
- PushIRReg(var->hc_type,idx=GetFreeIReg);
- jit_addi(Compiler.jit,jit_R(idx),R_FP,var->frame_off);
- arr_assign:
- CompileArrayLiteral(var->hc_type,idx,ast->decl.dft);
- PopIRValue;
- PushIRInt(0);
- break;
+ JIT_I64(Compiler.jit,MSize(ast->print.args)/sizeof(AST*));
+ PushIRString(ast->print.text,MSize(ast->print.text));
+ LoadSymPtr("Print");
+ break;
+ case AST_NOP:
+ JIT_I64(Compiler.jit,-1);
+ break;
+ case AST_DECL:
+ if(Compiler.in_func) {
+ tar_tab=Compiler.locals;
+ } else {
+ tar_tab=Compiler.globals;
+ }
+ var=HashFind(ast->decl.name->name,tar_tab);
+ if(!Compiler.in_func&&IsForward(var))
+ goto no_init;
+ if(ast->decl.dft) {
+ if(ast->decl.dft.type==AST_ARRAY_LITERAL) {
+ op1=jit_rpnBodyStart(Compiler.jit);
+ if(Compiler.in_func) {
+ var=HashFind(ast->decl.name.name,Compiler.locals);
+ if(var&&var->type==HTT_VAR) {
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,lo=GetFreeIReg);
+ JIT_ADDI(Compiler.jit);
+ JIT_RBP(Compiler.jit);
+ JIT_I64(Compiler.jit,var->frame_off);
+ CompileArrayLiteral(var->hc_type,lo,ast->decl.dft);
+ jit_rpnBodyEnd(Compiler.jit,op1);
+ break;
+ }
}
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,lo=GetFreeIReg);
+ LoadSymPtr(ast->decl.name->name);
+ CompileArrayLiteral(var->hc_type,lo,ast->decl.dft);
+ jit_rpnBodyEnd(Compiler.jit,op1);
+ break;
}
- LoadSymPtrIntoReg(ast->decl.name->name,idx=GetFreeIReg);
- PushIRReg(ast->decl.type,idx) ;
- goto arr_assign;
- }
- dummy=MAlloc(sizeof(AST));
- dummy->type=AST_NAME;
- dummy->name=StrNew(var->str);
- CompileAST(dummy,TRUE);
- FreeAST(dummy);
- CompileAST(ast->decl.dft);
- } else if(IsPtrType(var->hc_type)||IsInteger(var->hc_type)) {
- if((!var->is_local)||(var->link.type&LINK_STATIC)||var->hc_type->type==HTT_ARRAY_TYPE) goto no_init;
- dummy=MAlloc(sizeof(AST));
- dummy->type=AST_NAME;
- dummy->name=StrNew(var->str);
- CompileAST(dummy,TRUE);
- FreeAST(dummy);
- PushIRInt(0);
- } else if(IsF64(var->hc_type)) {
- if((!var->is_local)||(var->link.type&LINK_STATIC)) goto no_init;
- dummy=MAlloc(sizeof(AST));
- dummy->type=AST_NAME;
- dummy->name=StrNew(var->str);
- CompileAST(dummy,TRUE);
- FreeAST(dummy);
- PushIRFlt(0.0);
- } else {
- no_init:;
- PushIRInt(0);
+ }
+ if(IsPtrType(var->hc_type)||IsInteger(var->hc_type)) {
+ if((var->is_local)&&(var->link.type&LINK_STATIC)) goto
+ no_init;
+ JIT_MOV(Compiler.jit);
+ dummy=MAlloc(sizeof(AST));
+ dummy->type=AST_NAME;
+ dummy->name=StrNew(var->str);
+ CompileAST(dummy,TRUE);
+ FreeAST(dummy);
+ } else if(IsF64(var->hc_type)) {
+ if((var->is_local)&&(var->link.type&LINK_STATIC)) goto no_init;
+ JIT_FMOV(Compiler.jit);
+ dummy=MAlloc(sizeof(AST));
+ dummy->type=AST_NAME;
+ dummy->name=StrNew(var->str);
+ CompileAST(dummy,TRUE);
+ FreeAST(dummy);
+ } else if(IsStructType(var->hc_type)) {
+ JIT_MOV(Compiler.jit);
+ dummy=MAlloc(sizeof(AST));
+ dummy->type=AST_NAME;
+ dummy->name=StrNew(var->str);
+ CompileAST(dummy,TRUE);
+ FreeAST(dummy);
+ } else {
+ no_init:;
+ JIT_I64(Compiler.jit,-1);
+ break;
+ }
+ if(ast->decl.dft)
+ CompileAST(ast->decl.dft);
+ else
+ JIT_I64(Compiler.jit,0);
break;
- }
- PopIRValue(&value_b);
- PopIRValue(&value_a);
- Assign(value_a,value_b);
- Free(value_a),Free(value_b);
- PushIRInt(0);
- break;
- //Expected the pointer to already be on the stack
- case AST_ARRAY_LITERAL:
- "ARRAY_LITERLA\n";
- throw('Compile');
- break;
- case AST_MEMBER: {
+ break;
+ //Expected the pointer to already be on the stack
+ case AST_ARRAY_LITERAL:
+ "ARRAY_LITERLA\n";
+ throw('Compile');
+ break;
+ case AST_MEMBER:
if(ast->member_acc.base->type==AST_NAME) {
if(type1=GetType(ast->member_acc.base->name)) {
- PushIRInt(MemberOffset(type1,ast->member_acc.member));
+ JIT_I64(Compiler.jit,MemberOffset(type1,ast->member_acc.member));
break;
}
}
type1=AssignTypeToNode(ast->member_acc.base);
- CompileAST(ast->member_acc.base,TRUE);
- PopIRValue(&value_a);
- if(IsPtrType(value_a->type2)) {
+ if(IsPtrType(type1)) {
type1=DerefedType(type1);
if(IsPtrType(type1)) {
"LOTS OF POINTER MEMBER\n";
throw('Compile');
}
- PushIRReg(type1+1,GetFreeIReg);
- PopIRValue(&value_b);
- Assign(value_b,value_a);
- PushIRIndirX(MemberType(type1,ast->member_acc.member),value_b->reg,MemberOffset(type1,ast->member_acc.member));
- Free(value_a),Free(value_b);
- } else {
- if(value_a->type==IRV_INDIRX) {
- value_b=IRValueClone(value_a);
- value_b->indirx.offset+=MemberOffset(type1,ast->member_acc.member);
- value_b->type2=MemberType(type1,ast->member_acc.member);
+ if(AssignTypeToNode(ast)->type==HTT_ARRAY_TYPE)
+ get_ptr=TRUE;
+ if(!get_ptr) {
+ if(IsF64(ast->type2))
+ JIT_FDEREF(Compiler.jit);
+ else if(IsInteger(ast->type2)&&!IsSigned(ast->type2))
+ JIT_UDEREF(Compiler.jit,,ast->type2->sz);
+ else
+ JIT_DEREF(Compiler.jit,,ast->type2->sz);
+ }
+ if(Compiler.bounds_check_mode&&!get_ptr) {
+ JIT_FUNC_CALL(Compiler.jit,2);
+ JIT_I64(Compiler.jit,ast->type2->sz);
+ JIT_ADDI(Compiler.jit);
+ CompileAST(ast->member_acc.base,TRUE,);
+ JIT_I64(Compiler.jit,MemberOffset(type1,ast->member_acc.member));
+ JIT_I64(Compiler.jit,&WhineOnOutOfBounds);
} else {
- value_b=MoveToReg(IRValueClone(value_a),0);
- PushIRIndirX(MemberType(type1,ast->member_acc.member),value_b->reg,0);
- Free(value_b);
- PopIRValue(&value_b);
+ JIT_ADDI(Compiler.jit);
+ CompileAST(ast->member_acc.base,TRUE,);
+ JIT_I64(Compiler.jit,MemberOffset(type1,ast->member_acc.member));
}
- Free(value_a);
- value_a=value_b;
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- }
- }
- //Turn arrays into pointers
- type1=type1=AssignTypeToNode(ast);
- if(type1->type==HTT_ARRAY_TYPE) {
- PopIRValue(&value_a);
- PushIRReg(type1,idx=value_a->indirx.reg);
- if(value_a->indirx.offset)
- jit_addi(Compiler.jit,jit_R(idx),jit_R(idx),value_a->indirx.offset);
-
- }
- break;
- case AST_PAREN:
- CompileAST(ast->unopArg);
- break;
- case AST_INT:
- PushIRInt(ast->int);
- break;
- case AST_FLOAT:
- PushIRFlt(ast->floating);
- break;
- case AST_CHAR:
- PushIRInt(ast->int);
- break;
- case AST_STRING:
- PushIRString(ast->string,MSize(ast->string));
- break;
- case AST_COMMA:
- CompileAST(ast->binop.a);
- PopIRValue;
- CompileAST(ast->binop.b);
- break;
- case AST_ADD:
- CompileAST(ast->binop.a);
- CompileAST(ast->binop.b);
- value_a=IRValueClone(Compiler.stack->last);
- value_b=IRValueClone(Compiler.stack);
- if(IsF64(ast->type2)) {
- if(FoldIRF64) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRF64) {
- Free(value_a),PopIRValue(&value_a);
- PushIRFlt(value_a->flt+value_b->flt);
- Free(value_a),Free(value_b);
- break;
+ } else {
+ //Turn arrays into pointers
+ type1=AssignTypeToNode(ast);
+ type2=AssignTypeToNode(ast->member_acc.base);
+ if(type1->type==HTT_ARRAY_TYPE)
+ get_ptr=TRUE;
+ if(!get_ptr) {
+ if(IsF64(ast->type2))
+ JIT_FDEREF(Compiler.jit);
+ else if(!IsSigned(ast->type2)&&IsInteger(ast->type2))
+ JIT_UDEREF(Compiler.jit,,ast->type2->sz);
+ else
+ JIT_DEREF(Compiler.jit,,ast->type2->sz);
+ }
+ if(Compiler.bounds_check_mode&&!get_ptr) {
+ JIT_FUNC_CALL(Compiler.jit,2);
+ JIT_I64(Compiler.jit,ast->type2->sz);
+ JIT_ADDI(Compiler.jit);
+ CompileAST(ast->member_acc.base,TRUE,,TRUE);
+ JIT_I64(Compiler.jit,MemberOffset(type2,ast->member_acc.member));
+ JIT_I64(Compiler.jit,&WhineOnOutOfBounds);
+ } else {
+ JIT_ADDI(Compiler.jit);
+ CompileAST(ast->member_acc.base,TRUE,,TRUE);
+ JIT_I64(Compiler.jit,MemberOffset(type2,ast->member_acc.member));
}
- value_a=MoveToFReg(value_a,0);
- jit_faddi(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg),value_b->flt);
- Free(value_b);
- PopIRValue;
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
}
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- jit_faddr(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg),jit_FR(value_b->reg));
- PopIRValue,PopIRValue;
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
break;
- }
- if(IsPtrType(value_a->type2)) {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRInt) {
- Free(value_a),PopIRValue(&value_a);
- PushIRInt(value_a->int+value_b->int*DerefedType(value_a->type2)->sz);
- Free(value_a),Free(value_b);
- break;
- }
- value_a=MoveToReg(value_a,0);
- jit_addi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int*DerefedType(value_a->type2)->sz);
- Free(value_b);
- PopIRValue;
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- }
- value_c=MoveToReg(value_b,1);
- jit_muli(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),DerefedType(value_a->type2)->sz);
- value_b=value_c;
- } else if(IsPtrType(value_b->type2)) {
- value_c=MoveToReg(value_a,0);
- jit_muli(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),DerefedType(value_b->type2)->sz);
- value_a=value_c;
- }
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRInt) {
- Free(value_a),PopIRValue(&value_a);
- PushIRInt(value_a->int+value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- value_a=MoveToReg(value_a,0);
- jit_addi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- Free(value_b);
- PopIRValue;
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
+ case AST_PAREN:
+ CompileAST(ast->unopArg);
break;
- }
- if(value_a->type!=IRV_REG) {
- value_c=MoveToReg(value_a,0);
- Free(value_a),value_a=value_c;
- }
- if(value_b->type!=IRV_REG) {
- value_c=MoveToReg(value_b,1);
- Free(value_b),value_b=value_c;
- }
- jit_addr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- PopIRValue,PopIRValue;
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- case AST_SUB:
- CompileAST(ast->binop.a);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(ast->type2)) {
- if(FoldIRF64) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRF64) {
- Free(value_a),PopIRValue(&value_a);
- PushIRFlt(value_a->flt-value_b->flt);
- Free(value_a),Free(value_b);
- break;
- }
- PopIRValue;
- value_a=MoveToFReg(value_a,0);
- jit_fsubi(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg),value_b->flt);
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- }
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- jit_fsubr(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg),jit_FR(value_b->reg));
- PopIRValue,PopIRValue;
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
+ case AST_INT:
+ JIT_I64(Compiler.jit,ast->int);
break;
- }
- if(IsPtrType(value_a->type2)) {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRInt) {
- Free(value_a),PopIRValue(&value_a);
- if(IsPtrType(value_b->type2))
- PushIRInt((value_a->int-value_b->int)/DerefedType(value_a->type2)->sz);
- else
- PushIRInt(value_a->int-value_b->int*DerefedType(value_a->type2)->sz);
- Free(value_a),Free(value_b);
- break;
- }
- value_a=MoveToReg(value_a,0);
- jit_subi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int*DerefedType(value_a->type2)->sz);
- Free(value_b);
- PopIRValue;
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
+ case AST_FLOAT:
+ JIT_F64(Compiler.jit,ast->floating);
+ break;
+ case AST_CHAR:
+ JIT_I64(Compiler.jit,ast->int);
+ break;
+ case AST_STRING:
+ PushIRString(ast->string,MSize(ast->string));
+ break;
+ case AST_COMMA:
+ JIT_COMMAI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ break;
+ case AST_ADD:
+ if(IsF64(ast->type2)) {
+ JIT_FADD(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
break;
}
- if(!IsPtrType(value_b->type2)) {
- value_c=MoveToReg(value_b,1);
- jit_muli(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),DerefedType(value_a->type2)->sz);
- value_b=value_c;
- }
- } else if(IsPtrType(value_b->type2)) {
- //value_a is not a ptr if here
- value_c=MoveToReg(value_a,0);
- jit_muli(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),DerefedType(value_b->type2)->sz);
- value_a=value_c;
- }
- if(value_a->type!=IRV_REG) {
- value_a=MoveToReg(value_a,0);
- }
- if(value_b->type!=IRV_REG) {
- value_b=MoveToReg(value_b,1);
- }
- jit_subr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- if(IsPtrType(value_a->type2)&&IsPtrType(value_b->type2))
- jit_divi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),DerefedType(value_a->type2)->sz);
- PopIRValue,PopIRValue;
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- case AST_MUL:
- CompileAST(ast->binop.a);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(ast->type2)) {
- if(FoldIRF64) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRF64) {
- PopIRValue(&value_a);
- PushIRFlt(value_a->flt*value_b->flt);
- Free(value_b),Free(value_a);
- break;
- }
- PopIRValue;
- value_a=MoveToFReg(value_a,0);
- jit_fmuli(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg),value_b->flt);
- value_a->last=Compiler.stack;
- Free(value_b),Compiler.stack=value_a;
+ if(IsPtrType(ast->binop.a->type2)) {
+ JIT_ADDI(Compiler.jit);
+ JIT_MULI(Compiler.jit);
+ CompileAST(ast->binop.b);
+ JIT_I64(Compiler.jit,DerefedType(ast->binop.a->type2)->sz);
+ CompileAST(ast->binop.a);
break;
- }
- value_b=MoveToFReg(value_b,1);
- value_a=MoveToFReg(value_a,0);
- PopIRValue,PopIRValue;
- jit_fmulr(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg),jit_FR(value_b->reg));
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int*value_b->int);
- Free(value_b),Free(value_a);
- break;
- }
- PopIRValue;
- value_a=MoveToReg(value_a,0);
- jit_muli(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- value_a->last=Compiler.stack;
- Free(value_b),Compiler.stack=value_a;
+ } else if(IsPtrType(ast->binop.b->type2)) {
+ JIT_ADDI(Compiler.jit);
+ JIT_MULI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ JIT_I64(Compiler.jit,DerefedType(ast->binop.b->type2)->sz);
+ CompileAST(ast->binop.b);
break;
}
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_mulr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- case AST_DIV:
- CompileAST(ast->binop.a);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(ast->type2)) {
- if(FoldIRF64) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRF64) {
- PopIRValue(&value_a);
- PushIRFlt(value_a->flt/value_b->flt);
- Free(value_b),Free(value_a);
- break;
- }
- PopIRValue;
- value_a=MoveToFReg(value_a,0);
- jit_fdivi(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg),value_b->flt);
- value_a->last=Compiler.stack;
- Free(value_b),Compiler.stack=value_a;
+ JIT_ADDI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ break;
+ case AST_SUB:
+ if(IsF64(ast->type2)) {
+ JIT_FSUB(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
break;
}
- value_b=MoveToFReg(value_b,1);
- value_a=MoveToFReg(value_a,0);
- PopIRValue,PopIRValue;
- jit_fdivr(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg),jit_FR(value_b->reg));
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int/value_b->int);
- Free(value_b),Free(value_a);
- break;
- }
- PopIRValue;
- value_a=MoveToReg(value_a,0);
- jit_divi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- value_a->last=Compiler.stack;
- Free(value_b),Compiler.stack=value_a;
+ if(IsPtrType(ast->binop.a->type2)&&IsPtrType(ast->binop.b->type2)) {
+ JIT_DIVI(Compiler.jit);
+ JIT_SUBI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ JIT_I64(Compiler.jit,DerefedType(ast->binop.a->type2)->sz);
break;
}
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_divr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- case AST_MOD:
- CompileAST(ast->binop.a);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(ast->type2)) {
- if(FoldIRF64) {
- PopIRValue(&value_b);
- if(FoldIRF64) {
- PopIRValue(&value_a);
- PushIRFlt(FMod(value_a->flt,value_b->flt));
- Free(value_a),Free(value_b);
- break;
- }
- PopIRValue;
- value_a=MoveToFReg(value_a,0);
- LoadSymPtrIntoReg("FMod",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(value_a->reg),8);
- goto mod_end;
- }
- PopIRValue,PopIRValue;
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- LoadSymPtrIntoReg("FMod",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(value_a->reg),8);
- Free(value_b);
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int%value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- PopIRValue;
- value_a=MoveToReg(value_a,0);
- jit_modi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- goto mod_end;
- }
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_modr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- mod_end:
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- case AST_LSHIFT:
- CompileAST(ast->binop.a);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(ast->type2)) {
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- PopIRValue,PopIRValue;
- LoadSymPtrIntoReg("F64Shl",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(value_a->reg),8);
- Free(value_b);
- } else {
- if(FoldIRInt) {
- PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int<<value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- PopIRValue;
- value_a=MoveToReg(value_a,0);
- jit_lshi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- goto lsh_end;
- }
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_lshr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- lsh_end:
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- case AST_RSHIFT:
- CompileAST(ast->binop.a);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(ast->type2)) {
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- PopIRValue,PopIRValue;
- LoadSymPtrIntoReg("F64Shr",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(value_a->reg),8);
- Free(value_b);
- } else if(IsSigned(ast->type2)) {
- if(FoldIRInt) {
- PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int>>value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- value_a=MoveToReg(value_a,0);
- PopIRValue;
- jit_rshi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- goto rsh_end;
- }
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_rshr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- } else {
- if(FoldIRInt) {
- PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int(U64)>>value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- value_a=MoveToReg(value_a,0);
- PopIRValue;
- jit_rshi_u(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- goto rsh_end;
+ if(IsPtrType(ast->binop.a->type2)) {
+ JIT_SUBI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ JIT_MULI(Compiler.jit);
+ CompileAST(ast->binop.b);
+ JIT_I64(Compiler.jit,DerefedType(ast->binop.a->type2)->sz);
+ break;
+ }
+ JIT_SUBI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ break;
+ case AST_MUL:
+ if(IsF64(ast->type2))
+ JIT_FMUL(Compiler.jit);
+ else
+ JIT_MULI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ break;
+ case AST_DIV:
+ if(IsF64(ast->type2))
+ JIT_FDIV(Compiler.jit);
+ else
+ JIT_DIVI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ break;
+ case AST_MOD:
+ if(IsF64(ast->type2))
+ JIT_FMOD(Compiler.jit);
+ else
+ JIT_MODI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ break;
+ case AST_LSHIFT:
+ if(IsF64(ast->type2))
+ JIT_FSHL(Compiler.jit);
+ else
+ JIT_LSHI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ break;
+ case AST_RSHIFT:
+ if(IsF64(ast->type2))
+ JIT_FSHR(Compiler.jit);
+ else if(IsSigned(ast->type2))
+ JIT_RSHI(Compiler.jit);
+ else
+ JIT_RSHU(Compiler.jit);
+ CompileAST(ast->binop.a);
+ CompileAST(ast->binop.b);
+ break;
+ case AST_POW:
+ if(IsF64(ast->type2)) {
+ JIT_FCALL(Compiler.jit,2);
+ if(!IsF64(ast->binop.b->type2))
+ JIT_FPOS(Compiler.jit);
+ CompileAST(ast->binop.b);
+ if(!IsF64(ast->binop.a->type2))
+ JIT_FPOS(Compiler.jit);
+ CompileAST(ast->binop.a);
+ LoadSymPtr("Pow");
+ } else {
+ JIT_FUNC_CALL(Compiler.jit,2);
+ if(!IsInteger(ast->binop.b->type2))
+ JIT_POSI(Compiler.jit);
+ CompileAST(ast->binop.b);
+ if(!IsInteger(ast->binop.a->type2))
+ JIT_POSI(Compiler.jit);
+ CompileAST(ast->binop.a);
+ LoadSymPtr("PowI64");
}
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_rshr_u(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- rsh_end:
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
- case AST_POW:
- CompileAST(ast->binop.a);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(AssignTypeToNode(ast))) {
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- PopIRValue,PopIRValue;
- LoadSymPtrIntoReg("Pow",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(value_a->reg),8);
- Free(value_b);
- } else {
- LoadSymPtrIntoReg("PowI64",2);
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(value_a->reg));
- jit_putargr(Compiler.jit,jit_R(value_b->reg));
- jit_callr(Compiler.jit,jit_R(2));
- jit_retval(Compiler.jit,jit_R(value_a->reg));
- Free(value_b);
- }
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- break;
+ break;
case AST_BAND:
+ if(IsF64(ast->type2))
+ JIT_FAND(Compiler.jit);
+ else
+ JIT_ANDI(Compiler.jit);
CompileAST(ast->binop.a);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(AssignTypeToNode(ast))) {
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- PopIRValue,PopIRValue;
- LoadSymPtrIntoReg("F64And",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(value_a->reg),8);
- } else {
- if(FoldIRInt) {
- PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int&value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- PopIRValue;
- value_a=MoveToReg(value_a,0);
- jit_andi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- goto band_end;
- }
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_andr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- Free(value_b);
- }
- band_end:
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
break;
case AST_BXOR:
+ if(IsF64(ast->type2))
+ JIT_FXOR(Compiler.jit);
+ else
+ JIT_XORI(Compiler.jit);
CompileAST(ast->binop.a);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(AssignTypeToNode(ast))) {
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- PopIRValue,PopIRValue;
- LoadSymPtrIntoReg("F64Xor",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(value_a->reg),8);
- } else {
- if(FoldIRInt) {
- PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int^value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- value_a=MoveToReg(value_a,0);
- PopIRValue;
- jit_xori(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- goto band_end;
- }
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_xorr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- bxor_end:
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
break;
case AST_BOR:
+ if(IsF64(ast->type2))
+ JIT_FOR(Compiler.jit);
+ else
+ JIT_ORI(Compiler.jit);
CompileAST(ast->binop.a);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(AssignTypeToNode(ast))) {
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- PopIRValue,PopIRValue;
- LoadSymPtrIntoReg("F64Or",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(value_a->reg),8);
- } else {
- if(FoldIRInt) {
- PopIRValue(&value_b);
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(value_a->int|value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- value_a=MoveToReg(value_a,0);
- PopIRValue;
- jit_ori(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- goto bor_end;
- }
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_orr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- bor_end:
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
break;
case AST_LT:
//Handled in AST_RANGE
@@ -5099,854 +4321,334 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
//Handled in AST_RANGE
break;
case AST_EQ:
- PushIRReg(GetType("Bool"),GetFreeIReg);
- value_c=Compiler.stack;
+ if(IsF64(ast->binop.a->type2)||IsF64(ast->binop.b->type2))
+ JIT_FEQ(Compiler.jit);
+ else
+ JIT_EQI(Compiler.jit);
CompileAST(ast->binop.a);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(AssignTypeToNode(ast->binop.a))) {
- if(FoldIRF64) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRF64) {
- Free(value_a),PopIRValue(&value_a);
- PopIRValue;
- PushIRInt(value_a->flt==value_b->flt);
- goto eq_end;
- }
- value_a=MoveToFReg(value_a,0);
- PopIRValue;
- jit_movi(Compiler.jit,jit_R(value_c->reg),1);
- op1=jit_fbeqi(Compiler.jit,NULL,jit_FR(value_a->reg),value_b->flt);
- jit_movi(Compiler.jit,jit_R(value_c->reg),0);
- jit_patch(Compiler.jit,op1);
- goto eq_end;
- }
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_movi(Compiler.jit,jit_R(value_c->reg),1);
- op1=jit_fbeqr(Compiler.jit,NULL,jit_FR(value_a->reg),jit_FR(value_b->reg));
- jit_movi(Compiler.jit,jit_R(value_c->reg),0);
- jit_patch(Compiler.jit,op1);
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRInt) {
- Free(value_a),PopIRValue(&value_a);
- PopIRValue;
- PushIRInt(value_a->int==value_b->int);
- goto eq_end;
- }
- value_a=MoveToReg(value_a,0);
- PopIRValue;
- jit_eqi(Compiler.jit,jit_R(value_c->reg),jit_R(value_a->reg),value_b->int);
- goto eq_end;
- }
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_eqr(Compiler.jit,jit_R(value_c->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- eq_end:
- Free(value_b),Free(value_b);
break;
case AST_NE:
+ if(IsF64(ast->binop.a->type2)||IsF64(ast->binop.b->type2))
+ JIT_FNE(Compiler.jit);
+ else
+ JIT_NEI(Compiler.jit);
CompileAST(ast->binop.a);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(AssignTypeToNode(ast->binop.a))||IsF64(AssignTypeToNode(ast->binop.b))) {
- //TODO const fold
- PopIRValue,PopIRValue;
- value_a=MoveToFReg(value_a,0);
- value_b=MoveToFReg(value_b,1);
- PushIRReg(HashFind("I64i",Compiler.globals),GetFreeIReg);
- value_c=Compiler.stack;
- jit_movi(Compiler.jit,jit_R(value_c->reg),1);
- op1=jit_fbner(Compiler.jit,NULL,jit_FR(value_a->reg),jit_FR(value_b->reg));
- jit_movi(Compiler.jit,jit_R(value_c->reg),0);
- jit_patch(Compiler.jit,op1);
- break;
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- if(FoldIRInt) {
- Free(value_a),PopIRValue(&value_a);
- PushIRInt(value_a->int!=value_b->int);
- Free(value_a),Free(value_b);
- break;
- }
- PopIRValue;
- value_a=MoveToReg(value_a,0);
- jit_nei(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),value_b->int);
- goto neq_end;
- }
- value_a=MoveToReg(value_a,0);
- value_b=MoveToReg(value_b,1);
- PopIRValue,PopIRValue;
- jit_ner(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- }
- neq_end:
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
+ break;
break;
case AST_GE:
//Will be handled in AST_RANGE
break;
case AST_LAND:
- PushIRReg(GetType("I64i"),GetFreeIReg);
- value_c=Compiler.stack;
+ lo=GetFreeIReg;
+ JIT_COMMAI(Compiler.jit);
+ jit_rpnIf(Compiler.jit);
CompileAST(ast->binop.a);
- value_a=IRValueClone(Compiler.stack);
- value_a=BoolifyValue(value_a);
- op1=jit_beqi(Compiler.jit,NULL,jit_R(value_a->reg),0);
- PopIRValue,Free(value_a);
+ //if(t)
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,lo);
+ JIT_NEI(Compiler.jit);
CompileAST(ast->binop.b);
- value_b=BoolifyValue(IRValueClone(Compiler.stack));
- Assign(value_c,value_b);
- jit_nei(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),0);
- op2=jit_jmpi(Compiler.jit,NULL);
- jit_patch(Compiler.jit,op1);
- PushIRInt(0);
- Assign(value_c,Compiler.stack),PopIRValue;
- jit_patch(Compiler.jit,op2);
- PopIRValue,Free(value_b);
+ JIT_I64(Compiler.jit,0);
+ //if(f)
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,lo);
+ JIT_I64(Compiler.jit,0);
+ //COMMA
+ JIT_R(Compiler.jit,lo);
break;
case AST_LOR:
- PushIRReg(GetType("I64i"),GetFreeIReg);
- jit_movi(Compiler.jit,jit_R(Compiler.stack->reg),1);
+ lo=GetFreeIReg;
+ JIT_COMMAI(Compiler.jit);
+ jit_rpnIf(Compiler.jit);
CompileAST(ast->binop.a);
- value_a=IRValueClone(Compiler.stack);
- value_a=BoolifyValue(value_a);
- op1=jit_bnei(Compiler.jit,NULL,jit_R(value_a->reg),0);
- PopIRValue;
+ //if(t)
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,lo);
+ JIT_I64(Compiler.jit,1);
+ //if(f)
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,lo);
+ JIT_NEI(Compiler.jit);
CompileAST(ast->binop.b);
- value_b=BoolifyValue(IRValueClone(Compiler.stack));
- op2=jit_bnei(Compiler.jit,NULL,jit_R(value_b->reg),0);
- PopIRValue;
- jit_movi(Compiler.jit,jit_R(Compiler.stack->reg),0);
- jit_patch(Compiler.jit,op1);
- jit_patch(Compiler.jit,op2);
+ JIT_I64(Compiler.jit,0);
+ //COMMA
+ JIT_R(Compiler.jit,lo);
break;
case AST_LXOR:
+ JIT_XORI(Compiler.jit);
+ JIT_NEI(Compiler.jit);
CompileAST(ast->binop.a);
- value_a=BoolifyValue(IRValueClone(Compiler.stack));
- PopIRValue;
- value_c=IRValueClone(value_a);
- value_c->last=Compiler.stack;
- Compiler.stack=value_c;
+ JIT_I64(Compiler.jit,0);
+ JIT_NEI(Compiler.jit);
CompileAST(ast->binop.b);
- value_b=BoolifyValue(IRValueClone(Compiler.stack));
- PopIRValue,PopIRValue;
- jit_xorr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- value_a->last=Compiler.stack;
- Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
+ JIT_I64(Compiler.jit,0);
break;
case AST_ASSIGN:
+ if(IsF64(ast->type2))
+ JIT_FMOV(Compiler.jit);
+ else
+ JIT_MOV(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- PopIRValue,PopIRValue;
- Assign(value_a,value_b),Free(value_b);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- asn_end:
- if(!pass_by_ref&&IsF64(value_a->type2)) {
- PopIRValue(&value_a);
- PushIRFReg(value_a->type2,GetFreeFReg);
- Assign(Compiler.stack,value_a);
- Free(value_a);
- } else if(!pass_by_ref&&(IsPtrType(value_a->type2)||IsInteger(value_a->type2))) {
- PopIRValue(&value_a);
- PushIRReg(value_a->type2,GetFreeIReg);
- Assign(Compiler.stack,value_a);
- Free(value_a);
- }
break;
case AST_ASSIGN_SHL:
+ if(IsF64(ast->type2))
+ JIT_FASSIGN_SHL(Compiler.jit);
+ else
+ JIT_ASSIGN_SHLI(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {
- value_b=MoveToFReg(value_b,1);
- value_c=MoveToFReg(IRValueClone(value_a),0);
- LoadSymPtrIntoReg("F64Shl",0);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_FR(value_c->reg));
- jit_putargr(Compiler.jit,jit_FR(value_b->reg));
- jit_callr(Compiler.jit,jit_R(0));
- PushIRFReg(GetType("F64"),GetFreeFReg);
- jit_fretval(Compiler.jit,jit_FR(Compiler.stack->reg),8);
- Assign(value_a,Compiler.stack);
- PopIRValue;
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- PopIRValue;
- jit_lshi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int);
- Assign(value_a,value_c);
- Free(value_c),Free(value_b);
- goto ashl_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- jit_lshr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- }
- PopIRValue,PopIRValue;
- ashl_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ break;
case AST_ASSIGN_SHR:
+ if(IsF64(ast->type2))
+ JIT_FASSIGN_SHR(Compiler.jit);
+ else
+ JIT_ASSIGN_SHRI(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {
- value_b=MoveToFReg(value_b,1);
- value_c=MoveToFReg(IRValueClone(value_a),0);
- LoadSymPtrIntoReg("F64Shr",0);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_FR(value_c->reg));
- jit_putargr(Compiler.jit,jit_FR(value_b->reg));
- jit_callr(Compiler.jit,jit_R(0));
- PushIRFReg(GetType("F64"),GetFreeFReg);
- jit_fretval(Compiler.jit,jit_FR(Compiler.stack->reg),8);
- Assign(value_a,Compiler.stack);
- PopIRValue;
- } else if(IsSigned(value_a->type2)) {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- jit_rshi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int);
- Assign(value_a,value_c);
- Free(value_c),Free(value_c);
- PopIRValue;
- goto ashl_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- jit_rshr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Free(value_b);
- Assign(value_a,value_c);
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- jit_rshi_u(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int);
- Assign(value_a,value_c);
- Free(value_c),Free(value_b);
- PopIRValue;
- goto ashl_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- jit_rshr_u(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Free(value_b);
- Assign(value_a,value_c);
- }
- PopIRValue,PopIRValue;
- arshr_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ break;
case AST_ASSIGN_MUL:
+ if(IsF64(ast->type2))
+ JIT_FASSIGN_MUL(Compiler.jit);
+ else
+ JIT_ASSIGN_MULI(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {
- if(FoldIRF64) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToFReg(IRValueClone(value_a),0);
- jit_fmuli(Compiler.jit,jit_FR(value_c->reg),jit_FR(value_c->reg),value_b->flt);
- Assign(value_a,value_c);
- Free(value_c);
- PopIRValue;
- goto amul_end;
- }
- value_c=MoveToFReg(IRValueClone(value_a),0),value_b=MoveToFReg(value_b,1);
- jit_fmulr(Compiler.jit,jit_FR(value_c->reg),jit_FR(value_c->reg),jit_FR(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b),Free(value_c);
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- jit_muli(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int);
- Assign(value_a,value_c);
- Free(value_c);
- PopIRValue;
- goto amul_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- jit_mulr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- }
- PopIRValue,PopIRValue;
- amul_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ break;
case AST_ASSIGN_DIV:
+ if(IsF64(ast->type2))
+ JIT_FASSIGN_DIV(Compiler.jit);
+ else
+ JIT_ASSIGN_DIVI(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {value_c=MoveToFReg(IRValueClone(value_a),0),value_b=MoveToFReg(value_b,1);
- jit_fdivr(Compiler.jit,jit_FR(value_c->reg),jit_FR(value_c->reg),jit_FR(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- } else {
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- jit_divr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- }
- PopIRValue,PopIRValue;
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ break;
case AST_ASSIGN_BAND:
+ if(IsF64(ast->type2))
+ JIT_FASSIGN_AND(Compiler.jit);
+ else
+ JIT_ASSIGN_ANDI(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {
- value_b=MoveToFReg(value_b,1);
- value_c=MoveToFReg(IRValueClone(value_a),0);
- LoadSymPtrIntoReg("F64And",0);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_FR(value_c->reg));
- jit_putargr(Compiler.jit,jit_FR(value_b->reg));
- jit_callr(Compiler.jit,jit_R(0));
- PushIRFReg(GetType("F64"),GetFreeFReg);
- jit_fretval(Compiler.jit,jit_FR(Compiler.stack->reg),8);
- Assign(value_a,Compiler.stack);
- PopIRValue;
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- jit_andi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int);
- Assign(value_a,value_c);
- Free(value_c);
- PopIRValue;
- goto aband_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- jit_andr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- }
- PopIRValue,PopIRValue;
- aband_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ break;
case AST_ASSIGN_BOR:
+ if(IsF64(ast->type2))
+ JIT_FASSIGN_OR(Compiler.jit);
+ else
+ JIT_ASSIGN_ORI(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {
- value_b=MoveToFReg(value_b,1);
- value_c=MoveToFReg(IRValueClone(value_a),0);
- LoadSymPtrIntoReg("F64Or",0);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_FR(value_c->reg));
- jit_putargr(Compiler.jit,jit_FR(value_b->reg));
- jit_callr(Compiler.jit,jit_R(0));
- PushIRFReg(GetType("F64"),GetFreeFReg);
- jit_fretval(Compiler.jit,jit_FR(Compiler.stack->reg),8);
- Assign(value_a,Compiler.stack);
- PopIRValue;
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- jit_ori(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int);
- Assign(value_a,value_c);
- Free(value_c);
- PopIRValue;
- goto abor_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- jit_orr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- }
- PopIRValue,PopIRValue;
- abor_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ break;
case AST_ASSIGN_BXOR:
+ if(IsF64(ast->type2))
+ JIT_FASSIGN_XOR(Compiler.jit);
+ else
+ JIT_ASSIGN_XORI(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {
- value_b=MoveToFReg(value_b,1);
- value_c=MoveToFReg(IRValueClone(value_a),0);
- LoadSymPtrIntoReg("F64Xor",0);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_FR(value_c->reg));
- jit_putargr(Compiler.jit,jit_FR(value_b->reg));
- jit_callr(Compiler.jit,jit_R(0));
- PushIRFReg(GetType("F64"),GetFreeFReg);
- jit_fretval(Compiler.jit,jit_FR(Compiler.stack->reg),8);
- Assign(value_a,Compiler.stack);
- PopIRValue;
- } else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- jit_xori(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int);
- Assign(value_a,value_c);
- Free(value_c);
- PopIRValue;
- goto abxor_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- jit_xorr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- }
- PopIRValue,PopIRValue;
- abxor_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ break;
case AST_ASSIGN_ADD:
type1=AssignTypeToNode(ast->binop.a);
if(IsPtrType(type1))
mult=DerefedType(type1)->sz;
else
mult=1;
- CompileAST(ast->binop.a,TRUE);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {
- if(FoldIRF64) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToFReg(IRValueClone(value_a),0);
- jit_faddi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->flt);
- Assign(value_a,value_c);
- Free(value_c);
- PopIRValue;
- goto aadd_end;
- }
- value_c=MoveToFReg(IRValueClone(value_a),0),value_b=MoveToFReg(value_b,1);
- jit_faddr(Compiler.jit,jit_FR(value_c->reg),jit_FR(value_c->reg),jit_FR(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
+ if(IsF64(ast->type2)) {
+ JIT_FASSIGN_ADD(Compiler.jit);
+ CompileAST(ast->binop.a,TRUE);
+ CompileAST(ast->binop.b);
} else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- jit_addi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int*mult);
- Assign(value_a,value_c);
- Free(value_c);
- PopIRValue;
- goto aadd_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- if(mult)
- jit_muli(Compiler.jit,jit_R(value_b->reg),jit_R(value_b->reg),mult);
- jit_addr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- }
- PopIRValue,PopIRValue;
- aadd_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ JIT_ASSIGN_ADDI(Compiler.jit);
+ CompileAST(ast->binop.a,TRUE);
+ if(mult) {
+ JIT_MULI(Compiler.jit);
+ CompileAST(ast->binop.b);
+ JIT_I64(Compiler.jit,mult);
+ } else
+ CompileAST(ast->binop.b);
+ }
+ break;
case AST_ASSIGN_SUB:
type1=AssignTypeToNode(ast->binop.a);
if(IsPtrType(type1))
mult=DerefedType(type1)->sz;
else
mult=1;
- CompileAST(ast->binop.a,TRUE);
- CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- value_a=IRValueClone(Compiler.stack->last);
- if(IsF64(value_a->type2)) {
- value_c=MoveToFReg(IRValueClone(value_a),0),value_b=MoveToFReg(value_b,1);
- jit_fsubr(Compiler.jit,jit_FR(value_c->reg),jit_FR(value_c->reg),jit_FR(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
+ if(IsF64(ast->type2)) {
+ JIT_FASSIGN_SUB(Compiler.jit);
+ CompileAST(ast->binop.a,TRUE);
+ CompileAST(ast->binop.b);
} else {
- if(FoldIRInt) {
- Free(value_b),PopIRValue(&value_b);
- value_c=MoveToReg(IRValueClone(value_a),0);
- jit_subi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int*mult);
- Assign(value_a,value_c);
- Free(value_c);
- PopIRValue;
- goto asub_end;
- }
- value_c=MoveToReg(IRValueClone(value_a),0),value_b=MoveToReg(value_b,1);
- if(mult)
- jit_muli(Compiler.jit,jit_R(value_b->reg),jit_R(value_b->reg),mult);
- jit_subr(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_c);
- Free(value_b);
- }
- PopIRValue,PopIRValue;
- asub_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ JIT_ASSIGN_SUBI(Compiler.jit);
+ CompileAST(ast->binop.a,TRUE);
+ if(mult) {
+ JIT_MULI(Compiler.jit);
+ CompileAST(ast->binop.b);
+ JIT_I64(Compiler.jit,mult);
+ } else
+ CompileAST(ast->binop.b);
+ }
+ break;
case AST_POST_INC:
+ if(IsF64(ast->type2))
+ JIT_FPOST_INC(Compiler.jit);
+ else if(!IsPtrType(ast->type2))
+ JIT_POST_INCI(Compiler.jit);
+ else {
+ mult=DerefedType(ast->type2)->sz;
+ JIT_POST_INCI(Compiler.jit,mult);
+ }
CompileAST(ast->unopArg,TRUE);
- value_a=IRValueClone(Compiler.stack);
- if(IsF64(value_a->type2)) {
- PushIRFReg(value_a->type2,GetFreeFReg);
- Assign(value_b=Compiler.stack,value_a);
- PushIRFReg(value_a->type2,GetFreeFReg);
- Assign(value_c=Compiler.stack,value_a);
- jit_faddi(Compiler.jit,jit_FR(value_c->reg),jit_FR(value_c->reg),1.0);
- Assign(value_a,value_c);
- PopIRValue; //value_c
- value_b=IRValueClone(value_b); //Make unique
- PopIRValue; //value_b
- } else {
- PushIRReg(value_a->type2,GetFreeIReg);
- Assign(value_b=Compiler.stack,value_a);
- PushIRReg(value_a->type2,GetFreeIReg);
- Assign(value_c=Compiler.stack,value_a);
- mult=1;
- if(IsPtrType(value_a->type2)) {
- mult=DerefedType(value_a->type2)->sz;
- }
- jit_addi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),mult);
- Assign(value_a,value_c);
- PopIRValue; //value_c
- value_b=IRValueClone(value_b); //MAke unique
- PopIRValue; //value_b
- }
- Free(value_a);
- PopIRValue; //value_a;
- value_b->last=Compiler.stack;
- Compiler.stack=value_b;
break;
case AST_POST_DEC:
- CompileAST(ast->unopArg,TRUE);
- value_a=IRValueClone(Compiler.stack);
- if(IsF64(value_a->type2)) {
- PushIRFReg(value_a->type2,GetFreeFReg);
- Assign(value_b=Compiler.stack,value_a);
- PushIRFReg(value_a->type2,GetFreeFReg);
- Assign(value_c=Compiler.stack,value_a);
- jit_fsubi(Compiler.jit,jit_FR(value_c->reg),jit_FR(value_c->reg),1.0);
- Assign(value_a,value_c);
- PopIRValue; //value_c
- value_b=IRValueClone(value_b); //Make unique
- PopIRValue; //value_b
- } else {
- PushIRReg(value_a->type2,GetFreeIReg);
- Assign(value_b=Compiler.stack,value_a);
- PushIRReg(value_a->type2,GetFreeIReg);
- Assign(value_c=Compiler.stack,value_a);
- mult=1;
- if(IsPtrType(value_a->type2)) {
- mult=DerefedType(value_a->type2)->sz;
- }
- jit_subi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),mult);
- Assign(value_a,value_c);
- PopIRValue; //value_c
- value_b=IRValueClone(value_b); //MAke unique
- PopIRValue; //value_b
+ if(IsF64(ast->type2))
+ JIT_FPOST_DEC(Compiler.jit);
+ else if(!IsPtrType(ast->type2))
+ JIT_POST_DECI(Compiler.jit);
+ else {
+ mult=DerefedType(ast->type2)->sz;
+ JIT_POST_DECI(Compiler.jit,mult);
}
- PopIRValue; //value_a;
- value_b->last=Compiler.stack;
- Compiler.stack=value_b;
+ CompileAST(ast->unopArg,TRUE);
break;
case AST_ARRAY_ACCESS:
+ if(ast->type2->type==HTT_ARRAY_TYPE)
+ get_ptr=TRUE;
+ if(!get_ptr) {
+ if(IsF64(ast->type2))
+ JIT_FDEREF(Compiler.jit);
+ else if(IsInteger(ast->type2)&&!IsSigned(ast->type2))
+ JIT_UDEREF(Compiler.jit,,ast->type2->sz);
+ else
+ JIT_DEREF(Compiler.jit,,ast->type2->sz);
+ }
+ JIT_ADDI(Compiler.jit);
CompileAST(ast->arr_acc.base);
+ JIT_MULI(Compiler.jit);
+ JIT_I64(Compiler.jit,ast->type2->sz);
CompileAST(ast->arr_acc.index);
- mult=DerefedType(Compiler.stack->last->type2)->sz;
- if(FoldIRInt) {
- PopIRValue(&value_b);
- hi=mult*value_b->int;
- Free(value_b);
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- jit_addi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),hi);
- goto arr_acc_end;
- }
- value_b=IRValueClone(Compiler.stack);
- value_b=MoveToReg(value_b,1); //To integer
- value_a=IRValueClone(Compiler.stack->last);
- value_a=MoveToReg(value_a,0);
- jit_muli(Compiler.jit,jit_R(value_b->reg),jit_R(value_b->reg),mult);
- jit_addr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),jit_R(value_b->reg));
- PopIRValue,PopIRValue;
- Free(value_b);
- arr_acc_end:
- if(DerefedType(value_a->type2)->type==HTT_ARRAY_TYPE) {
- PushIRReg(DerefedType(value_a->type2),value_a->reg);
- } else
- PushIRIndirX(DerefedType(value_a->type2),value_a->reg,0);
- Free(value_a);
break;
case AST_PRE_DEC:
- CompileAST(ast->unopArg,TRUE);
- value_a=IRValueClone(Compiler.stack);
- if(IsF64(value_a->type2)) {
- PushIRFReg(value_a->type2,GetFreeFReg);
- value_b=IRValueClone(Compiler.stack);
- Assign(value_b,value_a);
- jit_fsubi(Compiler.jit,jit_FR(value_b->reg),jit_FR(value_b->reg),1.0);
- PopIRValue;
- } else {
- PushIRReg(value_a->type2,GetFreeIReg);
- value_b=IRValueClone(Compiler.stack);
- Assign(value_b,value_a);
- mult=1;
- if(IsPtrType(value_a->type2)) {
- mult=DerefedType(value_a->type2)->sz;
- }
- jit_subi(Compiler.jit,jit_R(value_b->reg),jit_R(value_b->reg),mult);
- PopIRValue;
+ if(IsF64(ast->type2))
+ JIT_FPRE_DEC(Compiler.jit);
+ else if(!IsPtrType(ast->type2))
+ JIT_PRE_DECI(Compiler.jit);
+ else {
+ mult=DerefedType(ast->type2)->sz;
+ JIT_PRE_DECI(Compiler.jit,mult);
}
- PopIRValue; //value_a;
- Assign(value_a,value_b);
- Free(value_a);
- value_b->last=Compiler.stack;
- Compiler.stack=value_b;
+ CompileAST(ast->unopArg,TRUE);
break;
case AST_PRE_INC:
- CompileAST(ast->unopArg,TRUE);
- value_a=IRValueClone(Compiler.stack);
- if(IsF64(value_a->type2)) {
- PushIRFReg(value_a->type2,GetFreeFReg);
- value_b=IRValueClone(Compiler.stack);
- Assign(value_b,value_a);
- jit_faddi(Compiler.jit,jit_FR(value_b->reg),jit_FR(value_b->reg),1.0);
- PopIRValue;
- } else {
- PushIRReg(value_a->type2,GetFreeIReg);
- value_b=IRValueClone(Compiler.stack);
- Assign(value_b,value_a);
- mult=1;
- if(IsPtrType(value_a->type2)) {
- mult=DerefedType(value_a->type2)->sz;
- }
- jit_addi(Compiler.jit,jit_R(value_b->reg),jit_R(value_b->reg),mult);
- PopIRValue;
+ if(IsF64(ast->type2))
+ JIT_FPRE_INC(Compiler.jit);
+ else if(!IsPtrType(ast->type2))
+ JIT_PRE_INCI(Compiler.jit);
+ else {
+ mult=DerefedType(ast->type2)->sz;
+ JIT_PRE_INCI(Compiler.jit,mult);
}
- PopIRValue; //value_a;
- Assign(value_a,value_b),Free(value_a);
- value_b->last=Compiler.stack;
- Compiler.stack=value_b;
+ CompileAST(ast->unopArg,TRUE);
break;
case AST_POS:
CompileAST(ast->unopArg);
break;
case AST_NEG:
+ if(IsF64(ast->type2))
+ JIT_FNEG(Compiler.jit);
+ else
+ JIT_NEGI(Compiler.jit);
CompileAST(ast->unopArg);
- value_a=IRValueClone(Compiler.stack);
- if(IsF64(value_a->type2)) {
- if(FoldIRF64) {
- Free(value_a);
- PopIRValue(&value_a);
- PushIRFlt(-value_a->flt);
- Free(value_a);
- break;
- }
- Free(value_a);
- PopIRValue(&value_a);
- value_a=MoveToFReg(value_a,0);
- jit_fnegr(Compiler.jit,jit_FR(value_a->reg),jit_FR(value_a->reg));
- } else {
- if(FoldIRInt) {
- Free(value_a);
- PopIRValue(&value_a);
- PushIRInt(-value_a->int);
- Free(value_a);
- break;
- }
- Free(value_a);
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- jit_negr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg));
- }
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
break;
case AST_LNOT:
+ if(IsF64(ast->type2))
+ JIT_FEQ(Compiler.jit),JIT_F64(Compiler.jit,0.0);
+ else
+ JIT_EQI(Compiler.jit),JIT_I64(Compiler.jit,0);
CompileAST(ast->unopArg);
- value_a=IRValueClone(Compiler.stack);
- if(IsF64(ast->unopArg->type2)) {
- if(FoldIRF64) {
- PopIRValue(&value_a);
- PushIRInt(!value_a->flt);
- Free(value_a);
- break;
- }
- value_a=MoveToFReg(value_a,0);
- PopIRValue;
- PushIRReg(GetType("I64i"),idx=GetFreeIReg);
- jit_movi(Compiler.jit,jit_R(idx),1);
- op1=jit_fbeqi(Compiler.jit,NULL,jit_FR(value_a->reg),0.0);
- jit_movi(Compiler.jit,jit_R(idx),0);
- jit_patch(Compiler.jit,op1);
- PopIRValue(&value_a);
- } else {
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(!value_a->int);
- Free(value_a);
- break;
- }
- PopIRValue;
- value_a=MoveToReg(value_a,0);
- jit_eqi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),0);
- }
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
break;
case AST_BNOT:
+ if(IsF64(ast->type2))
+ JIT_FNOT(Compiler.jit);
+ else
+ JIT_NOTI(Compiler.jit);
CompileAST(ast->unopArg);
- if(IsF64(ast->unopArg->type2)) {
- //TODO
- } else {
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRInt(~value_a->int);
- Free(value_a);
- break;
- }
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- jit_notr(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg));
- }
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
break;
case AST_DERREF:
- CompileAST(ast->unopArg);
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- if(DerefedType(value_a->type2)->type==HTT_ARRAY_TYPE)
- PushIRReg(DerefedType(value_a->type2),value_a->reg);
- else
- PushIRIndirX(DerefedType(value_a->type2),value_a->reg,0);
- Free(value_a);
+ if(!get_ptr) {
+ if(IsF64(ast->type2))
+ JIT_FDEREF(Compiler.jit);
+ else if(IsInteger(ast->type2)&&!IsSigned(ast->type2))
+ JIT_UDEREF(Compiler.jit,,ast->type2->sz);
+ else
+ JIT_DEREF(Compiler.jit,,ast->type2->sz);
+ }
+ if(Compiler.bounds_check_mode) {
+ JIT_FUNC_CALL(Compiler.jit,2);
+ JIT_I64(Compiler.jit,ast->type2->sz);
+ CompileAST(ast->unopArg);
+ JIT_I64(Compiler.jit,&WhineOnOutOfBounds);
+ } else
+ CompileAST(ast->unopArg);
break;
case AST_ADDROF:
if(Compiler.asm_mode&&ast->unopArg->type==AST_NAME) {
if(var=HashFind(ast->unopArg->name,Compiler.locals)) {
if(var->is_local_unlinked) {
- LoadSymPtrIntoReg(ast->unopArg->name,idx=GetFreeIReg);
- PushIRReg(ast->type2,idx);
+ LoadSymPtr(ast->unopArg->name);
break;
}
- PushIRInt(var->frame_off);
+ JIT_I64(Compiler.jit,var->frame_off);
break;
}
}
- CompileAST(ast->unopArg,TRUE,TRUE);
- if(Compiler.stack->type2->type==HTT_ARRAY_TYPE) {
- if(Compiler.stack->type!=IRV_REG) {
- "STRANGE ADDROF\n";
- throw('Compile');
- }
- Compiler.stack->type2++;
- break;
- }
- if(Compiler.stack->type!=IRV_INDIRX) {
- "NEEDS INDIRX\n";
- throw('Compile');
- }
- PopIRValue(&value_a);
- PushIRReg(ast->type2,idx=value_a->indirx.reg);
- if(value_a->indirx.offset)
- jit_addi(Compiler.jit,jit_R(idx),jit_R(idx),value_a->indirx.offset);
- Free(value_a);
+ CompileAST(ast->unopArg,TRUE,TRUE,TRUE);
break;
case AST_SIZEOF:
- PushIRInt(ast->type2->sz);
+ JIT_I64(Compiler.jit,ast->type2->sz);
break;
case AST_IMPLICIT_TC:
break;
case AST_EXPLICIT_TC:
+ if(IsF64(ast->typecast.to_type)&&!IsF64(ast->typecast.base->type2)) {
+ JIT_FTYPECAST(Compiler.jit);
+ } else
+ JIT_TYPECAST(Compiler.jit,ast->type2->sz);
CompileAST(ast->typecast.base,pass_by_ref);
- if(IsF64(Compiler.stack->type2)) {
- if(IsF64(ast->typecast.to_type))
- Compiler.stack->type2=ast->typecast.to_type;
- else if(IsInteger(ast->typecast.to_type)) {
- if(FoldIRF64) {
- PopIRValue(&value_a);
- PushIRInt(value_a->flt(I64));
- } else {
- PopIRValue(&value_a);
- value_a=MoveToFReg(value_a,0);
- LoadSymPtrIntoReg("Bit4BitF64ToU64",0);
- PushIRReg(ast->typecast.to_type,idx=GetFreeIReg);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- jit_callr(Compiler.jit,jit_R(0));
- jit_retval(Compiler.jit,jit_R(idx));
- }
- Free(value_a);
- }
- } else if(IsInteger(Compiler.stack->type2)) {
- if(IsF64(ast->typecast.to_type)) {
- if(FoldIRInt) {
- PopIRValue(&value_a);
- PushIRFlt(value_a->int(F64));
- } else {
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- LoadSymPtrIntoReg("Bit4BitU64ToF64",0);
- PushIRFReg(ast->typecast.to_type,idx=GetFreeFReg);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(value_a->reg));
- jit_callr(Compiler.jit,jit_R(0));
- jit_fretval(Compiler.jit,jit_FR(idx),8);
- }
- Free(value_a);
- } else if(IsInteger(ast->typecast.to_type)) {
- Compiler.stack->type2=ast->typecast.to_type;
- }
- }
break;
case AST_FUNC_CALL:
- CompileAST(ast->func_call.base,,TRUE);
- value_a=IRValueClone(Compiler.stack);
- if(IsPtrType(value_a->type2)) {
- type1=DerefedType(value_a->type2);
- } else {
- if(value_a->type==IRV_INDIRX) {
- value_a->reg=value_a->indirx.reg;
- value_a->type=IRV_REG;
- }
- type1=value_a->type2;
- }
+ type1=AssignTypeToNode(ast->func_call.base,,TRUE);
+ if(IsPtrType(type1))
+ type1=DerefedType(type1);
cnt=MSize(type1->arg_types)/sizeof(CType*);
- for(idx=0;idx!=cnt;idx++) {
+ idx=MaxI64(cnt,MSize(ast->func_call.args)/sizeof(AST*));
+ if(type1->has_vargs)
+ ++idx,++cnt;
+ if(IsF64(AssignTypeToNode(ast)))
+ op1=JIT_FCALL(Compiler.jit,idx,cnt); //Floating point version
+ else
+ op1=JIT_FUNC_CALL(Compiler.jit,idx,cnt);
+ cnt=MaxI64(MSize(type1->arg_types)/sizeof(CType*),idx);
+ if(type1->has_vargs) {
+ offset=0;
+ cnt=MSize(ast->func_call.args)/sizeof(AST*);
+ for(idx=cnt-1;idx>=MSize(type1->arg_types)/sizeof(CType*);idx--)
+ CompileAST(ast->func_call.args[idx]);
+ //!!! Push the argc as per TempleOS ABI
+ JIT_I64(Compiler.jit,cnt-idx-1);
+ }
+ cnt=MSize(type1->arg_types)/sizeof(CType*);
+ for(idx=cnt-1;idx>=0;idx--) {
if(MSize(ast->func_call.args)/sizeof(AST*)>idx&&ast->func_call.args[idx]) {
+ if(IsF64(type1->arg_types[idx])!=IsF64(AssignTypeToNode(ast->func_call.args[idx]))) {
+ if(IsF64(type1->arg_types[idx]))
+ JIT_FPOS(Compiler.jit);
+ else
+ JIT_POSI(Compiler.jit);
+ }
CompileAST(ast->func_call.args[idx]);
- PopIRValue(&fargs[idx]);
- if(IsF64(type1->arg_types[idx])) {
- fargs[idx]=MoveToFReg(fargs[idx],0);
- }else
- fargs[idx]=MoveToReg(fargs[idx],0);
- fargs[idx].last=Compiler.stack;
- Compiler.stack=fargs[idx];
} else {
if(type1->arg_values[idx]) {
if(type1->arg_values[idx]==&Lastclass) {
@@ -5969,28 +4671,19 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
}
}
PushIRString(type2->str,MSize(type2->str));
- fargs[idx]=Compiler.stack;
} else if(!Compiler.aot_mode) {
if(IsF64(type1->arg_types[idx])) {
- PushIRFReg(GetType("F64"),GetFreeFReg);
- jit_fmovi(Compiler.jit,jit_FR(Compiler.stack->reg),type1->arg_values[idx][0](F64));
- fargs[idx]=Compiler.stack;
+ JIT_F64(Compiler.jit,type1->arg_values[idx][0](F64));
} else {
- PushIRReg(type1->arg_types[idx],GetFreeIReg);
- jit_movi(Compiler.jit,jit_R(Compiler.stack->reg),type1->arg_values[idx][0]);
- fargs[idx]=Compiler.stack;
+ JIT_I64(Compiler.jit,type1->arg_values[idx][0]);
}
} else if(Compiler.aot_mode) {
if(IsF64(type1->arg_types[idx])) {
- PushIRFReg(GetType("F64"),GetFreeFReg);
- LoadSymPtrIntoReg(type1->aot_arg_names[idx],0);
- jit_fldr(Compiler.jit,jit_FR(Compiler.stack->reg),jit_R(0),8);
- fargs[idx]=Compiler.stack;
+ JIT_FDEREF(Compiler.jit);
+ LoadSymPtr(type1->aot_arg_names[idx]);
} else {
- PushIRReg(type1->arg_types[idx],GetFreeIReg);
- LoadSymPtrIntoReg(type1->aot_arg_names[idx],0);
- jit_ldr(Compiler.jit,jit_R(Compiler.stack->reg),jit_R(0),8);
- fargs[idx]=Compiler.stack;
+ JIT_DEREF(Compiler.jit,,8);
+ LoadSymPtr(type1->aot_arg_names[idx]);
}
}
} else {
@@ -5999,222 +4692,133 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
}
}
}
- cnt=MSize(type1->arg_types)/sizeof(CType*);
- for(;idx<cnt;idx++) {
- if(type1->arg_values[idx]==&Lastclass) {
- if(ast->func_call.args[idx-1])
- type2=ast->func_call.args[idx-1]->type2;
- else
- type2=type1->arg_types[idx-1];
- lc_type2:
- switch(type2->type) {
- case HTT_ARRAY_TYPE:
- type2=DerefedType(type2);
- goto lc_type2;
- case HTT_FUNC_TYPE:
- type2=type2->ret_type;
- goto lc_type2;
- default:
- if(type2->star_cnt) {
- type2-=type2->star_cnt;
- goto lc_type2;
- }
- }
- PushIRString(type2->str,MSize(type2->str));
- } else if(!Compiler.aot_mode) {
- if(IsF64(type1->arg_types[idx])) {
- PushIRFReg(type1->arg_types[idx],GetFreeFReg);
- jit_fmovi(Compiler.jit,jit_FR(Compiler.stack->reg),type1->arg_values[idx][0](F64));;
- } else {
- PushIRReg(type1->arg_types[idx],GetFreeIReg);
- jit_movi(Compiler.jit,jit_R(Compiler.stack->reg),type1->arg_values[idx][0]);
- }
- } else if(Compiler.aot_mode) {
- if(IsF64(type1->arg_types[idx])) {
- PushIRFReg(GetType("F64"),GetFreeFReg);
- LoadSymPtrIntoReg(type1->aot_arg_names[idx],0);
- jit_fldr(Compiler.jit,jit_FR(Compiler.stack->reg),jit_R(0),8);
- fargs[idx]=Compiler.stack;
- } else {
- PushIRReg(type1->arg_types[idx],GetFreeIReg);
- LoadSymPtrIntoReg(type1->aot_arg_names[idx],0);
- jit_ldr(Compiler.jit,jit_R(Compiler.stack->reg),jit_R(0),8);
- fargs[idx]=Compiler.stack;
- }
- }
- fargs[idx]=Compiler.stack;
- }
- if(type1->has_vargs) {
- offset=0;
- cnt=MSize(ast->func_call.args)/sizeof(AST*);
- //Look here at the meta sponge,he has something youll want to hear
- // _______
- // /^ ^\
- // | *-[w]-* | <lo is used to point to the register containing argv>
- // | |
- // |_/ \-|
- // \_______/
- //
- lo=jit_allocai(Compiler.jit,8*(cnt-idx));
- for(;idx!=cnt;idx++,++offset) {
- CompileAST(ast->func_call.args[idx]);
- PopIRValue(&fargs[idx]);
- if(IsF64(ast->func_call.args[idx]->type2)) {
- fargs[idx]=MoveToFReg(fargs[idx],0);
- jit_fstxi(Compiler.jit,lo+offset*8,R_FP,jit_FR(fargs[idx]->reg),8);
- } else {
- fargs[idx]=MoveToReg(fargs[idx],0);
- jit_stxi(Compiler.jit,lo+offset*8,R_FP,jit_R(fargs[idx]->reg),8);
- }
- }
- //Look at metasponge above
- jit_addi(Compiler.jit,jit_R(offset=GetFreeIReg),R_FP,lo);
- lo=offset;
- }
- jit_prepare(Compiler.jit);
- cnt=MSize(type1->arg_types)/sizeof(CType*);
- for(idx=0;idx<cnt;idx++) {
- if(fargs[idx].type==IRV_FREG) {
- jit_fputargr(Compiler.jit,jit_FR(fargs[idx]->reg),8);
- } else {
- jit_putargr(Compiler.jit,jit_R(fargs[idx]->reg));
- }
- }
- if(type1->has_vargs) {
- jit_putargi(Compiler.jit,MSize(ast->func_call.args)/sizeof(AST*)-cnt);
- jit_putargr(Compiler.jit,jit_R(lo));
- }
- idx=cnt;
- while(--idx>=0)
- PopIRValue;
- PopIRValue;
- value_a=MoveToReg(value_a,0);
- jit_callr(Compiler.jit,jit_R(value_a->reg));
- Free(value_a);
- if(IsF64(type1(CType*)->ret_type)) {
- PushIRFReg(GetType("F64"),GetFreeFReg);
- jit_fretval(Compiler.jit,jit_FR(Compiler->stack->reg),8);
- } else if(IsInteger(type1->ret_type)) {
- PushIRReg(type1->ret_type,GetFreeIReg);
- jit_retval(Compiler.jit,jit_R(Compiler->stack->reg));
- }
- Compiler.stack->type2=type1->ret_type;
+ if(IsPtrType(ast->func_call.base->type2))
+ CompileAST(ast->func_call.base,,TRUE);
+ else
+ CompileAST(ast->func_call.base,,TRUE,TRUE);
break;
case AST_IF:
+ jit_rpnIf(Compiler.jit);
CompileAST(ast->if_stmt->cond);
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- op1=jit_beqi(Compiler.jit,NULL,jit_R(value_a->reg),0);
- Free(value_a);
- if(ast->if_stmt->body) {
- CompileAstWithBreakpoint(ast->if_stmt->body);
- PopIRValue;
- }
- if(ast->if_stmt->el) {
- op2=jit_jmpi(Compiler.jit,NULL);
- jit_patch(Compiler.jit,op1);
- CompileAstWithBreakpoint(ast->if_stmt->el);
- PopIRValue;
- jit_patch(Compiler.jit,op2);
- } else {
- jit_patch(Compiler.jit,op1);
- }
- PushIRInt(0);
+ if(ast->if_stmt.body)
+ CompileAstWithBreakpoint(ast->if_stmt.body);
+ else
+ JIT_I64(Compiler.jit,-1);
+ if(ast->if_stmt.el)
+ CompileAstWithBreakpoint(ast->if_stmt.el);
+ else
+ JIT_I64(Compiler.jit,-1);
+
break;
+ //TODO add breakpoint
case AST_FOR:
+ op4=jit_rpnBodyStart(Compiler.jit);
if(ast->for_stmt->init)
- CompileAstWithBreakpoint(ast->for_stmt->init),PopIRValue;
- op1=jit_get_label(Compiler.jit);
- if(ast->for_stmt->cond) {
- CompileAstWithBreakpoint(ast->for_stmt->cond);
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- op2=jit_beqi(Compiler.jit,NULL,jit_R(value_a->reg),0);
- } else {
- //Nothing to do
- }
- Free(value_a);
+ CompileAST(ast->for_stmt->init);
breaks=MAlloc(sizeof(*breaks));
breaks->breaks=VectorNew;
breaks->last=Compiler.cur_breaks;
Compiler.cur_breaks=breaks;
- CompileAST(ast->for_stmt->body);
- Compiler.cur_breaks=breaks->last;
- PopIRValue;
- if(ast->for_stmt->inc)
- CompileAST(ast->for_stmt->inc),PopIRValue;
- jit_jmpi(Compiler.jit,op1);
if(ast->for_stmt->cond) {
- jit_patch(Compiler.jit,op2);
+ op1=jit_rpnBodyStart(Compiler.jit);
+ if(Compiler.debug_mode)
+ CreateBreakpointFor(ast->for_stmt->cond);
+ jit_rpnIf(Compiler.jit);
+ CompileAST(ast->for_stmt->cond);
+ //t
+ op2=jit_rpnBodyStart(Compiler.jit);
+ if(ast->for_stmt->body)
+ CompileAstWithBreakpoint(ast->for_stmt->body);
+ if(ast->for_stmt.inc)
+ CompileAstWithBreakpoint(ast->for_stmt->inc);
+ JIT_JMP(Compiler.jit,op1);
+ jit_rpnBodyEnd(Compiler.jit,op2);
+ //f
+ JIT_I64(Compiler.jit,-1);
+ jit_rpnBodyEnd(Compiler.jit,op1);
+ } else {
+ op1=JIT_LABEL(Compiler.jit);
+ if(ast->for_stmt->body)
+ CompileAST(ast->for_stmt->body);
+ if(ast->for_stmt->inc)
+ CompileAST(ast->for_stmt->inc);
+ JIT_JMP(Compiler.jit,op1);
}
+ Compiler.cur_breaks=breaks->last;
while(breaks->breaks->size) {
op3=VectorPop(breaks->breaks);
- jit_patch(Compiler.jit,op3);
+ JIT_PATCH(Compiler.jit,op3);
}
VectorFree(breaks->breaks);
Free(breaks);
- PushIRInt(0);
+ jit_rpnBodyEnd(Compiler.jit,op4);
break;
case AST_DO:
- op1=jit_get_label(Compiler.jit);
+ op1=op4=jit_rpnBodyStart(Compiler.jit);
breaks=MAlloc(sizeof(*breaks));
breaks->breaks=VectorNew;
breaks->last=Compiler.cur_breaks;
Compiler.cur_breaks=breaks;
+ //TODO add breakpoints
CompileAstWithBreakpoint(ast->do_stmt.body);
- PopIRValue;
Compiler->cur_breaks=breaks->last;
- CompileAstWithBreakpoint(ast->do_stmt.cond);
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- jit_bnei(Compiler.jit,op1,jit_R(value_a->reg),0);
- Free(value_a);
+ if(Compiler.debug_mode)
+ CreateBreakpointFor(ast->do_stmt->cond);
+ jit_rpnIf(Compiler.jit);
+ CompileAST(ast->do_stmt.cond);
+ //t
+ JIT_JMP(Compiler.jit,op1);
+ //f
+ JIT_I64(Compiler.jit,-1);
+
while(breaks->breaks->size) {
op3=VectorPop(breaks->breaks);
- jit_patch(Compiler.jit,op3);
+ JIT_PATCH(Compiler.jit,op3);
}
Compiler.cur_breaks=breaks->last;
VectorFree(breaks->breaks);
Free(breaks);
- PushIRInt(0);
+ jit_rpnBodyEnd(Compiler.jit,op4);
break;
case AST_WHILE:
- op1=jit_get_label(Compiler.jit);
- CompileAstWithBreakpoint(ast->while_stmt.cond);
- PopIRValue(&value_a);
- value_a=BoolifyValue(value_a);
- op2=jit_beqi(Compiler.jit,NULL,jit_R(value_a->reg),0);
- Free(value_a);
+ op4=jit_rpnBodyStart(Compiler.jit);
+ //TODO add breakpoints
+ op1=op4;
+ if(Compiler.debug_mode)
+ CreateBreakpointFor(ast->while_stmt->cond);
+ jit_rpnIf(Compiler.jit);
+ CompileAST(ast->while_stmt.cond);
breaks=MAlloc(sizeof(*breaks));
breaks->breaks=VectorNew;
breaks->last=Compiler.cur_breaks;
Compiler.cur_breaks=breaks;
+ //t
+ op2=jit_rpnBodyStart(Compiler.jit);
CompileAstWithBreakpoint(ast->while_stmt.body);
- PopIRValue;
- jit_jmpi(Compiler.jit,op1);
+ JIT_JMP(Compiler.jit,op1);
+ jit_rpnBodyEnd(Compiler.jit,op2);
+ //f
+ JIT_I64(Compiler.jit,-1);
Compiler.cur_breaks=breaks->last;
- jit_patch(Compiler.jit,op2);
while(breaks->breaks->size) {
op3=VectorPop(breaks->breaks);
- jit_patch(Compiler.jit,op3);
+ JIT_PATCH(Compiler.jit,op3);
}
VectorFree(breaks->breaks);
Free(breaks);
- PushIRInt(0);
+ jit_rpnBodyEnd(Compiler.jit,op4);
break;
case AST_META_DATA:
break;
case AST_SWITCH:
- CompileAstWithBreakpoint(ast->switch_stmt.cond); //Conditon
- value_a=IRValueClone(Compiler.stack);
- value_a=MoveToReg(value_a,0);
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- value_c=IRValueClone(value_a);
- //Make a backup register for our condition
- PushIRReg(HashFind("I64i",Compiler.globals),GetFreeIReg); //subswit
- Assign(Compiler.stack,value_a);
- value_a=IRValueClone(Compiler.stack);
+ op5=jit_rpnBodyStart(Compiler.jit);
+ //TODO add breakpoints
+ if(Compiler.debug_mode)
+ CreateBreakpointFor(ast->switch_stmt->cond);
+ reg_a=GetFreeIReg;
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,reg_a);
+ CompileAST(ast->switch_stmt.cond); //Conditon
swit_table=MAlloc(sizeof(*swit_table));
ScanForCases(ast->switch_stmt.body,&lo,&hi,&has_dft);
table=__CreateCaseTable(ast->switch_stmt.body);
@@ -6226,61 +4830,57 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
breaks->last=Compiler.cur_breaks;
Compiler.cur_breaks=breaks;
//
- op1=jit_blti(Compiler.jit,NULL,jit_R(value_a->reg),lo);
- op2=jit_bgti(Compiler.jit,NULL,jit_R(value_a->reg),hi);
- swit_table->dft1=op1,swit_table->dft2=op2;
- swit_table->subswit_var_offset=jit_allocai(Compiler.jit,8);
- jit_movi(Compiler.jit,jit_R(0),0);
- jit_stxi(Compiler.jit,swit_table->subswit_var_offset,R_FP,jit_R(0),8);
- swit_table->enter_point=jit_get_label(Compiler.jit);
+ jit_rpnIf(Compiler.jit);
+ JIT_ORI(Compiler.jit);
+ JIT_GTI(Compiler.jit);
+ JIT_R(Compiler.jit,reg_a);
+ JIT_I64(Compiler.jit,hi);
+ JIT_LTI(Compiler.jit);
+ JIT_R(Compiler.jit,reg_a);
+ JIT_I64(Compiler.jit,lo);
+ //t
+ swit_table->dft1=JIT_JMP(Compiler.jit,NULL);
+ //f
+ JIT_I64(Compiler.jit,-1);
+ swit_table->subswit_var_offset=JIT_ALLOCAI(Compiler.jit,8);
+ JIT_MOV(Compiler.jit);
+ JIT_DEREF(Compiler.jit,swit_table->subswit_var_offset,8);
+ JIT_RBP(Compiler.jit);
+ JIT_I64(Compiler.jit,0);
swit_table->table=MAlloc(sizeof(U0*)*(hi-lo+1));
swit_table->ast_table=table;
- Assign(value_a,value_c);
- jit_subi(Compiler.jit,jit_R(value_a->reg),jit_R(value_a->reg),lo);
+ JIT_PRE_DECI(Compiler.jit,lo);
+ JIT_R(Compiler.jit,reg_a);
+ swit_table->enter_point=JIT_LABEL(Compiler.jit);
//
-
- op4=table[idx=hi-lo];
- for(idx;idx>=0;) {
- idx2=idx;
- while(idx>=0&&op4==table[idx]) {
- --idx;
- }
- op3=jit_bgti(Compiler.jit,NULL,jit_R(value_a->reg),idx);
- swit_table->table[idx2]=op3;
- if(idx!=-1) op4=table[idx];
- }
+ op2=JIT_JMP_TABLE(Compiler.jit,hi-lo+1);
+ JIT_R(Compiler.jit,reg_a);
//
CompileAstWithBreakpoint(ast->switch_stmt.body);
-
if(!has_dft) {
- jit_patch(Compiler.jit,op1);
- jit_patch(Compiler.jit,op2);
+ op4=JIT_PATCH(Compiler.jit,swit_table->dft1);
idx=hi-lo+1;
while(--idx>=0) {
- if((!table[idx])&&swit_table->table[idx])
- jit_patch(Compiler.jit,swit_table->table[idx]);
- else if(table[idx]&&table[idx]->type==AST_DFT&&swit_table->table[idx])
- jit_patch(Compiler.jit,swit_table->table[idx]);
+ if((!table[idx])&&!swit_table->table[idx])
+ swit_table->table[idx]=op4;
}
}
Free(table);
- PopIRValue; //Body
- PopIRValue; //Condition clone
- PopIRValue; //Condition
- PopIRValue;
Compiler.cur_breaks=breaks->last;
Compiler.swit_table=swit_table->last;
+ MemCpy(op2->jmp_table,swit_table->table,MSize(swit_table->table));
Free(swit_table->table);
Free(swit_table);
while(breaks->breaks->size) {
op1=VectorPop(breaks->breaks);
- jit_patch(Compiler.jit,op1);
+ JIT_PATCH(Compiler.jit,op1);
}
VectorFree(breaks->breaks);
- Free(breaks),Free(value_a),Free(value_c);
- PushIRInt(0);
+ Free(breaks);
+ jit_rpnBodyEnd(Compiler.jit,op5);
break;
case AST_SUBSWIT:
+ //TODO add breakpoints
if(!Compiler.swit_table) {
"STRAY SUBSIW;\n";
throw('Compile');
@@ -6288,110 +4888,102 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
breaks=MAlloc(sizeof(*breaks));
breaks->breaks=VectorNew;
breaks->last=Compiler.cur_breaks;
- breaks->start_code_label=jit_get_label(Compiler.jit);
+ breaks->start_code_label=JIT_LABEL(Compiler.jit);
//
Compiler.cur_breaks=breaks;
- jit_movi(Compiler.jit,jit_R(0),1);
- jit_stxi(Compiler.jit,Compiler.swit_table->subswit_var_offset,R_FP,jit_R(0),8);
- if(ast->sub_swit.start_code) {
+ JIT_MOV(Compiler.jit);
+ JIT_DEREF(Compiler.jit,Compiler.swit_table->subswit_var_offset);
+ JIT_RBP(Compiler.jit);
+ JIT_I64(Compiler.jit,1);
+ if(ast->sub_swit.start_code)
CompileAstWithBreakpoint(ast->sub_swit.start_code);
- PopIRValue;
- }
- jit_jmpi(Compiler.jit,Compiler.swit_table->enter_point);
- if(ast->sub_swit.body) {
+ JIT_JMP(Compiler.jit,Compiler.swit_table->enter_point);
+ if(ast->sub_swit.body)
CompileAstWithBreakpoint(ast->sub_swit.body);
- PopIRValue;
- }
Compiler.cur_breaks=breaks->last;
while(breaks->breaks->size) {
op1=VectorPop(breaks->breaks);
- jit_patch(Compiler.jit,op1);
+ JIT_PATCH(Compiler.jit,op1);
}
VectorFree(breaks->breaks);
Free(breaks);
- PushIRInt(0);
break;
case AST_BREAK:
- VectorPush(Compiler.cur_breaks->breaks,jit_jmpi(Compiler.jit,NULL));
- PushIRInt(0);
+ VectorPush(Compiler.cur_breaks->breaks,JIT_JMP(Compiler.jit,NULL));
break;
case AST_DFT:
- jit_patch(Compiler.jit,Compiler.swit_table->dft1);
- jit_patch(Compiler.jit,Compiler.swit_table->dft2);
+ op4=JIT_PATCH(Compiler.jit,Compiler.swit_table->dft1);
cnt=Compiler.swit_table->hi-Compiler.swit_table->lo+1;
while(--cnt>=0) {
if(Compiler.swit_table->ast_table[cnt]==ast)
- if(Compiler.swit_table->table[cnt])
- jit_patch(Compiler.jit,Compiler.swit_table->table[cnt]);
+ Compiler.swit_table->table[cnt]=op4;
}
//Check if in subswit
if(Compiler.cur_breaks->start_code_label) {
- jit_ldxi(Compiler.jit,jit_R(0),R_FP,Compiler.swit_table->subswit_var_offset,8);
- jit_beqi(Compiler.jit,Compiler.cur_breaks->start_code_label,jit_R(0),0);
+ jit_rpnIf(Compiler.jit);
+ JIT_DEREF(Compiler.jit,Compiler.swit_table->subswit_var_offset);
+ JIT_RBP(Compiler.jit);
+ //t
+ JIT_I64(Compiler.jit,-1);
+ //f
+ JIT_JMP(Compiler.jit,Compiler.cur_breaks->start_code_label);
}
- PushIRInt(0);
break;
case AST_CASE:
+ op4=JIT_LABEL(Compiler.jit);
lo=ast->cs._li;
hi=ast->cs._hi;
- for(;lo<=hi;lo++) {
- if(Compiler.swit_table->table[lo-Compiler.swit_table->lo])
- jit_patch(Compiler.jit,Compiler.swit_table->table[lo-Compiler.swit_table->lo]);
- }
+ for(;lo<=hi;lo++)
+ Compiler.swit_table->table[lo-Compiler.swit_table->lo]=op4;
//Check if in subswit
if(Compiler.cur_breaks->start_code_label) {
- jit_ldxi(Compiler.jit,jit_R(0),R_FP,Compiler.swit_table->subswit_var_offset,8);
- jit_beqi(Compiler.jit,Compiler.cur_breaks->start_code_label,jit_R(0),0);
+ jit_rpnIf(Compiler.jit);
+ JIT_DEREF(Compiler.jit,Compiler.swit_table->subswit_var_offset);
+ JIT_RBP(Compiler.jit);
+ //t
+ JIT_I64(Compiler.jit,-1);
+ //f
+ JIT_JMP(Compiler.jit,Compiler.cur_breaks->start_code_label);
}
- PushIRInt(0);
break;
case AST_RETURN:
if(!Compiler.ret_type) {
"NO REUTRN TYPE;\n";
throw('Compile');
}
- if(IsInteger(Compiler.ret_type)) {
- if(!ast->unopArg) {
- if(Compiler.debug_mode) {
- jit_prepare(Compiler.jit);
- jit_call(Compiler.jit,&LeaveFunc);
- }
- jit_reti(Compiler.jit,0);
- PushIRInt(0);
- break;
+ if(Compiler.debug_mode) {
+ lo=GetFreeIReg;
+
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,lo);
+ if(ast->unopArg) {
+ if(IsF64(Compiler.ret_type))
+ JIT_TYPECAST(Compiler.jit);
+ CompileAST(ast->unopArg);
+ } else {
+ JIT_I64(Compiler.jit,0);
}
+ //
+ JIT_FUNC_CALL(Compiler.jit,0);
+ JIT_I64(Compiler.jit,&LeaveFunc);
+ //
+ JIT_RET(Compiler.jit);
+ JIT_R(Compiler.jit,lo);
+ break;
+ }
+ if(!ast->unopArg) {
+ JIT_RETI(Compiler.jit);
+ JIT_I64(Compiler.jit,0);
+ } else if(IsInteger(Compiler.ret_type)) {
+ JIT_RETI(Compiler.jit);
CompileAST(ast->unopArg);
- PopIRValue(&value_a);
- value_a=MoveToReg(value_a,0);
- if(Compiler.debug_mode) {
- jit_prepare(Compiler.jit);
- jit_call(Compiler.jit,&LeaveFunc);
- }
- jit_retr(Compiler.jit,jit_R(value_a->reg));
} else if(IsF64(Compiler.ret_type)) {
- if(!ast->unopArg) {
- if(Compiler.debug_mode) {
- jit_prepare(Compiler.jit);
- jit_call(Compiler.jit,&LeaveFunc);
- }
- jit_freti(Compiler.jit,0.0,8);
- PushIRInt(0);
- break;
- }
- CompileAstWithBreakpoint(ast->unopArg);
- PopIRValue(&value_a);
- value_a=MoveToFReg(value_a,0);
- if(Compiler.debug_mode) {
- jit_prepare(Compiler.jit);
- jit_call(Compiler.jit,&LeaveFunc);
- }
- jit_fretr(Compiler.jit,jit_FR(value_a->reg),8);
+ JIT_FRET(Compiler.jit);
+ CompileAST(ast->unopArg);
}
- PushIRInt(0);
break;
case AST_TYPE:
//What do you want me to do
- PushIRInt(0);
break;
case AST_GOTO:
lab=HashFind(ast->name,Compiler.labels);
@@ -6404,11 +4996,10 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
throw('Compile');
}
if(lab->op) {
- jit_jmpi(Compiler.jit,lab->op);
+ JIT_JMP(Compiler.jit,lab->op);
} else {
- VectorPush(lab->refs,jit_jmpi(Compiler.jit,NULL));
+ VectorPush(lab->refs,JIT_JMP(Compiler.jit,NULL));
}
- PushIRInt(0);
break;
case AST_LABEL:
lab=HashFind(ast->name,Compiler.labels);
@@ -6420,198 +5011,260 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
"NONO_ALBLE\n";
throw('Compile');
}
- jit_dump_ptr(Compiler.jit,&lab->ptr);
+ JIT_DUMP_PTR(Compiler.jit,&lab->ptr);
while(lab->refs->size) {
op1=VectorPop(lab->refs);
- jit_patch(Compiler.jit,op1);
+ JIT_PATCH(Compiler.jit,op1);
}
- lab->op=jit_get_label(Compiler.jit);
- PushIRInt(0);
+ lab->op=JIT_LABEL(Compiler.jit);
break;
case AST_TRY:
//If we are debugging,make a spot to store our call_stack depth,because I am sick of trying to make a SEH compliant things
if(Compiler.debug_mode) {
- lo=jit_allocai(Compiler.jit,8);
- jit_prepare(Compiler.jit);
- jit_call(Compiler.jit,&CallStackSize);
- jit_retval(Compiler.jit,jit_R(0));
- jit_stxi(Compiler.jit,lo,R_FP,jit_R(0),8);
- }
- LoadSymPtrIntoReg("EnterTry",0);
- jit_prepare(Compiler.jit);
- jit_callr(Compiler.jit,jit_R(0));
- jit_retval(Compiler.jit,jit_R(0));
- LoadSymPtrIntoReg("HCSetJmp",1);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(0));
- jit_putargi(Compiler.jit,1);
- jit_callr(Compiler.jit,jit_R(1));
- jit_retval(Compiler.jit,jit_R(0));
- op1=jit_bnei(Compiler.jit,NULL,jit_R(0),0);
- CompileAstWithBreakpoint(ast->try_block.body);
- PopIRValue;
- LoadSymPtrIntoReg("PopTryFrame",0);
- jit_prepare(Compiler.jit);
- jit_callr(Compiler.jit,jit_R(0));
- op2=jit_jmpi(Compiler.jit,NULL);
- jit_patch(Compiler.jit,op1);
+ lo=GetFreeIReg;
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,lo);
+ JIT_FUNC_CALL(Compiler.jit,0);
+ JIT_I64(Compiler.jit,&CallStackSize);
+ }
+ jit_rpnIf(Compiler.jit);
+ JIT_FUNC_CALL(Compiler.jit,1);
+ JIT_FUNC_CALL(Compiler.jit,0);
+ LoadSymPtr("EnterTry");
+ LoadSymPtr("HCSetJmp");
+ //t
+ op1=jit_rpnBodyStart(Compiler.jit);
if(Compiler.debug_mode) {
- jit_ldxi(Compiler.jit,jit_R(0),R_FP,lo,8);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(0));
- jit_call(Compiler.jit,&SetCallStackSize);
+ JIT_FUNC_CALL(Compiler.jit,1);
+ JIT_R(Compiler.jit,lo);
+ JIT_I64(Compiler.jit,&SetCallStackSize);
}
CompileAstWithBreakpoint(ast->try_block.cat);
- PopIRValue;
- LoadSymPtrIntoReg("ExitCatch",0);
- jit_prepare(Compiler.jit);
- jit_callr(Compiler.jit,jit_R(0));
- jit_patch(Compiler.jit,op2);
- PushIRInt(0);
+ JIT_FUNC_CALL(Compiler.jit,0);
+ LoadSymPtr("ExitCatch");
+ jit_rpnBodyEnd(Compiler.jit,op1);
+ //f
+ op1=jit_rpnBodyStart(Compiler.jit);
+ CompileAstWithBreakpoint(ast->try_block.body);
+ JIT_FUNC_CALL(Compiler.jit,0);
+ LoadSymPtr("PopTryFrame");
+ jit_rpnBodyEnd(Compiler.jit,op1);
break;
case AST_LASTCLASS:
//Is symbolic
break;
case AST_RANGE:
- to_patch=VectorNew;
- PushIRReg(GetType("I64i"),hi=GetFreeIReg);
- jit_movi(Compiler.jit,jit_R(hi),1);
- value_c=Compiler.stack;
cnt=MSize(ast->range.values)/sizeof(AST*);
+ if(cnt==2) {
+ idx=1;
+ if(IsF64(ast->range.values[idx-1]->type2)||IsF64(ast->range.values[idx]->type2)) {
+ switch(ast->range.types[idx-1]) {
+ case AST_LT:
+ op1=JIT_FLT(Compiler.jit);
+ break;
+ case AST_GT:
+ op1=JIT_FGT(Compiler.jit);
+ break;
+ case AST_LE:
+ op1=JIT_FLE(Compiler.jit);
+ break;
+ case AST_GE:
+ op1=JIT_FGE(Compiler.jit);
+ break;
+ }
+ } else if(!IsSigned(ast->range.values[idx-1]->type2)||!IsSigned(ast->range.values[idx]->type2)) {
+ //Types below 64bits are promoted so treat them as 64bit signed if small
+ if((ast->range.values[idx-1]->type2->sz==8&&!IsSigned(ast->range.values[idx-1]->type2))||(ast->range.values[idx]->type2->sz==8&&!IsSigned(ast->range.values[idx]->type2)))
+ ;
+ else
+ goto cmp_signed;
+ switch(ast->range.types[idx-1]) {
+ case AST_LT:
+ op1=JIT_LTU(Compiler.jit);
+ break;
+ case AST_GT:
+ op1=JIT_GTU(Compiler.jit);
+ break;
+ case AST_LE:
+ op1=JIT_LEU(Compiler.jit);
+ break;
+ case AST_GE:
+ op1=JIT_GEU(Compiler.jit);
+ break;
+ }
+ } else {
+ cmp_signed:
+ switch(ast->range.types[idx-1]) {
+ case AST_LT:
+ JIT_LTI(Compiler.jit);
+ break;
+ case AST_GT:
+ JIT_GTI(Compiler.jit);
+ break;
+ case AST_LE:
+ JIT_LEI(Compiler.jit);
+ break;
+ case AST_GE:
+ JIT_GEI(Compiler.jit);
+ break;
+ }
+ }
+ CompileAST(ast->range.values[0]);
+ CompileAST(ast->range.values[1]);
+ break;
+ }
+ //Check for floating point and if so,make a tempoary zone for the cloned flaoting point value
+ cnt=MSize(ast->range.values)/sizeof(AST*);
+ while(--cnt>=0) {
+ if(IsF64(AssignTypeToNode(ast->range.values[cnt]))) {
+ offset=JIT_ALLOCAI(Compiler.jit,16);
+ break;
+ }
+ }
+ to_patch=VectorNew;
+ hi=GetFreeIReg;
+ reg_a=GetFreeIReg;
+ reg_b=GetFreeIReg;
+ JIT_COMMAI(Compiler.jit);
+ op2=jit_rpnBodyStart(Compiler.jit);
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,hi);
+ JIT_I64(Compiler.jit,1);
+ if(IsF64(AssignTypeToNode(ast->range.values[0]))) {
+ JIT_FMOV(Compiler.jit);
+ JIT_FDEREF(Compiler.jit,offset);
+ JIT_RBP(Compiler.jit);
+ } else {
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,reg_a);
+ }
CompileAST(ast->range.values[0]);
op1=NULL;
+ cnt=MSize(ast->range.values)/sizeof(AST*);
for(idx=1;idx<cnt;idx++) {
- if(op1) jit_patch(Compiler.jit,op1);
- CompileAST(ast->range.values[idx]);
- if(IsF64(Compiler.stack->last->type2)||IsF64(Compiler.stack->type2)) {
- value_a=MoveToFReg(IRValueClone(Compiler.stack->last),0);
- value_b=MoveToFReg(IRValueClone(Compiler.stack),1);
- PopIRValue,PopIRValue;
+ jit_rpnIf(Compiler.jit);
+ is_flt_style=FALSE;
+ if(IsF64(ast->range.values[idx-1]->type2)||IsF64(ast->range.values[idx]->type2)) {
+ is_flt_style=TRUE;
switch(ast->range.types[idx-1]) {
case AST_LT:
- op1=jit_fbltr(Compiler.jit,NULL,jit_FR(value_a->reg),jit_FR(value_b->reg));
+ op1=JIT_FGT(Compiler.jit);
break;
case AST_GT:
- op1=jit_fbgtr(Compiler.jit,NULL,jit_FR(value_a->reg),jit_FR(value_b->reg));
+ op1=JIT_FLT(Compiler.jit);
break;
case AST_LE:
- op1=jit_fbler(Compiler.jit,NULL,jit_FR(value_a->reg),jit_FR(value_b->reg));
+ op1=JIT_FGE(Compiler.jit);
break;
case AST_GE:
- op1=jit_fbger(Compiler.jit,NULL,jit_FR(value_a->reg),jit_FR(value_b->reg));
+ op1=JIT_FLE(Compiler.jit);
break;
}
- Free(value_a);
- value_b->last=Compiler.stack;
- Compiler.stack=value_b;
- } else if(!IsSigned(Compiler.stack->last->type2)||!IsSigned(Compiler.stack->type2)) {
+ } else if(!IsSigned(ast->range.values[idx-1]->type2)||!IsSigned(ast->range.values[idx]->type2)) {
//Types below 64bits are promoted so treat them as 64bit signed if small
- if((Compiler.stack->last->type2->sz==8&&!IsSigned(Compiler.stack->last->type2))||(Compiler.stack->type2->sz==8&&!IsSigned(Compiler.stack->type2)))
+ if((ast->range.values[idx-1]->type2->sz==8&&!IsSigned(ast->range.values[idx-1]->type2))||(ast->range.values[idx]->type2->sz==8&&!IsSigned(ast->range.values[idx]->type2)))
;
else
- goto cmp_signed;
- value_a=MoveToReg(IRValueClone(Compiler.stack.last),0);
- value_b=MoveToReg(IRValueClone(Compiler.stack),1);
- PopIRValue,PopIRValue;
+ goto cmp_signed0;
switch(ast->range.types[idx-1]) {
case AST_LT:
- op1=jit_bltr_u(Compiler.jit,NULL,jit_R(value_a->reg),jit_R(value_b->reg));
+ op1=JIT_GTU(Compiler.jit);
break;
case AST_GT:
- op1=jit_bgtr_u(Compiler.jit,NULL,jit_R(value_a->reg),jit_R(value_b->reg));
+ op1=JIT_LTU(Compiler.jit);
break;
case AST_LE:
- op1=jit_bler_u(Compiler.jit,NULL,jit_R(value_a->reg),jit_R(value_b->reg));
+ op1=JIT_GEU(Compiler.jit);
break;
case AST_GE:
- op1=jit_bger_u(Compiler.jit,NULL,jit_R(value_a->reg),jit_R(value_b->reg));
+ op1=JIT_LEU(Compiler.jit);
break;
}
- Free(value_a);
- value_b->last=Compiler.stack;
- Compiler.stack=value_b;
} else {
- cmp_signed:
- value_a=MoveToReg(IRValueClone(Compiler.stack.last),0);
- value_b=MoveToReg(IRValueClone(Compiler.stack),1);
- PopIRValue,PopIRValue;
+ cmp_signed0:
switch(ast->range.types[idx-1]) {
case AST_LT:
- op1=jit_bltr(Compiler.jit,NULL,jit_R(value_a->reg),jit_R(value_b->reg));
+ op1=JIT_GTI(Compiler.jit);
break;
case AST_GT:
- op1=jit_bgtr(Compiler.jit,NULL,jit_R(value_a->reg),jit_R(value_b->reg));
+ op1=JIT_LTI(Compiler.jit);
break;
case AST_LE:
- op1=jit_bler(Compiler.jit,NULL,jit_R(value_a->reg),jit_R(value_b->reg));
+ op1=JIT_GEI(Compiler.jit);
break;
case AST_GE:
- op1=jit_bger(Compiler.jit,NULL,jit_R(value_a->reg),jit_R(value_b->reg));
+ op1=JIT_LEI(Compiler.jit);
break;
}
- Free(value_a);
- value_b->last=Compiler.stack;
- Compiler.stack=value_b;
}
- jit_movi(Compiler.jit,jit_R(hi),0);
- VectorPush(to_patch,jit_jmpi(Compiler.jit,NULL));
+ if(!is_flt_style) {
+ //conditon
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,reg_b);
+ CompileAST(ast->range.values[idx]);
+ JIT_R(Compiler.jit,reg_a);
+ //t
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,reg_a);
+ JIT_R(Compiler.jit,reg_b);
+ //f
+ op3=jit_rpnBodyStart(Compiler.jit);
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,hi);
+ JIT_I64(Compiler.jit,0);
+ VectorPush(to_patch,JIT_JMP(Compiler.jit,NULL));
+ jit_rpnBodyEnd(Compiler.jit,op3);
+ } else {
+ //conditon
+ JIT_FMOV(Compiler.jit);
+ JIT_FDEREF(Compiler.jit,offset+8);
+ JIT_RBP(Compiler.jit);
+ CompileAST(ast->range.values[idx]);
+ JIT_FDEREF(Compiler.jit,offset);
+ JIT_RBP(Compiler.jit);
+ //t
+ JIT_FMOV(Compiler.jit);
+ JIT_FDEREF(Compiler.jit,offset);
+ JIT_RBP(Compiler.jit);
+ JIT_FDEREF(Compiler.jit,offset+8);
+ JIT_RBP(Compiler.jit);
+ //f
+ op3=jit_rpnBodyStart(Compiler.jit);
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,hi);
+ JIT_I64(Compiler.jit,0);
+ VectorPush(to_patch,JIT_JMP(Compiler.jit,NULL));
+ jit_rpnBodyEnd(Compiler.jit,op3);
+
+ }
}
- jit_patch(Compiler.jit,op1);
while(to_patch->size) {
- op2=VectorPop(to_patch);
- jit_patch(Compiler.jit,op2);
+ op3=VectorPop(to_patch);
+ JIT_PATCH(Compiler.jit,op3);
}
- PopIRValue;
+ jit_rpnBodyEnd(Compiler.jit,op2);
+ JIT_R(Compiler.jit,hi);
VectorFree(to_patch);
break;
case AST_ASSIGN_MOD:
+ if(IsF64(ast->type2))
+ JIT_FASSIGN_MOD(Compiler.jit);
+ else
+ JIT_ASSIGN_MODI(Compiler.jit);
CompileAST(ast->binop.a,TRUE);
- value_a=IRValueClone(Compiler.stack);
CompileAST(ast->binop.b);
- value_b=IRValueClone(Compiler.stack);
- if(IsF64(value_a->type2)) {
- value_b=MoveToFReg(value_b,1);
- value_c=MoveToFReg(IRValueClone(value_a),0);
- Assign(value_c,value_a);
- LoadSymPtrIntoReg("FMod",0);
- jit_prepare(Compiler.jit);
- jit_fputargr(Compiler.jit,jit_FR(value_c->reg),8);
- jit_fputargr(Compiler.jit,jit_FR(value_b->reg),8);
- jit_callr(Compiler.jit,jit_R(0)) ;
- jit_fretval(Compiler.jit,jit_FR(value_b->reg),8);
- Assign(value_a,value_b);
- } else {
- value_c=MoveToReg(IRValueClone(value_a),0);
- if(FoldIRInt) {
- jit_modi(Compiler.jit,jit_R(value_c->reg),jit_R(value_c->reg),value_b->int);
- Assign(value_a,value_c);
- PopIRValue,PopIRValue;
- Free(value_b),Free(value_c);
- goto amod_end;
- }
- value_b=MoveToFReg(value_b,1);
- jit_modr(Compiler.jit,jit_R(value_b->reg),jit_R(value_c->reg),jit_R(value_b->reg));
- Assign(value_a,value_b);
- }
- PopIRValue,PopIRValue;
- Free(value_c),Free(value_b);
- amod_end:
- value_a->last=Compiler.stack;
- Compiler.stack=value_a;
- goto asn_end;
+ break;
case AST_NAME:
if(Compiler.asm_mode&&HashFind(ast->name,Compiler.imports)) {
if(var=HashFind(ast->name,Compiler.locals)) {
if(var->isReg) throw('Compile');
if(var->is_local_unlinked) {
- LoadSymPtrIntoReg(var->str,idx=GetFreeIReg);
- PushIRReg(var->hc_type,idx);
+ LoadSymPtr(var->str);
} else
- PushIRInt(var->frame_off);
+ JIT_I64(Compiler.jit,var->frame_off);
break;
} else if(func=var=HashFind(ast->name,Compiler.globals)) {
- LoadSymPtrIntoReg(var->str,idx=GetFreeIReg);
- PushIRReg(var->hc_type,idx);
+ LoadSymPtr(var->str);
break;
}
}
@@ -6622,86 +5275,53 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
"NOT A VAR\n";
throw('Compile');
}
- if(pass_by_ref) {
- if(var->is_local_unlinked) {
- LoadSymPtrIntoReg(var->str,idx=GetFreeIReg);
- PushIRReg(var->hc_type,idx);
- break;
- } else if(var->is_extern_ptr) {
- PushIRIndirX(var->hc_type,idx=GetFreeIReg,0);
- jit_movi(Compiler.jit,jit_R(idx),var->extern_ptr);
- } else if(var->is_static&&var->hc_type->type!=HTT_ARRAY_TYPE) {
- PushIRIndirX(var->hc_type,idx=GetFreeIReg,0);
- VectorPush(var->static_refs,jit_ref_data(Compiler.jit,jit_R(idx),NULL));
- } else if(var->is_static&&var->hc_type->type==HTT_ARRAY_TYPE) {
- PushIRReg(var->hc_type,idx=GetFreeIReg);
- VectorPush(var->static_refs,jit_ref_data(Compiler.jit,jit_R(idx),NULL));
- } else if(var->isReg) {
- if(IsF64(var->hc_type))
- PushIRFReg(var->hc_type,var->reg);
- else
- PushIRReg(var->hc_type,var->reg);
- } else if(var->hc_type->type!=HTT_ARRAY_TYPE) {
- PushIRIndirX(var->hc_type,idx=GetFreeIReg,var->frame_off);
- jit_movr(Compiler.jit,jit_R(idx),R_FP);
- } else {
- PushIRReg(var->hc_type,idx=GetFreeIReg);
- jit_addi(Compiler.jit,jit_R(idx),R_FP,var->frame_off);
- }
+ if(var->is_local_unlinked) {
+ LoadSymPtr(var->str);
break;
- } else {
- if(var->is_local_unlinked) {
- LoadSymPtrIntoReg(var->str,idx=GetFreeIReg);
- PushIRReg(var->hc_type,idx);
- break;
- } else if(var->is_extern_ptr) {
- if(IsF64(var->hc_type)) {
- PushIRFReg(var->hc_type,GetFreeFReg);
- } else {
- PushIRReg(var->hc_type,GetFreeIReg);
- }
- PushIRIndirX(var->hc_type,idx=GetFreeIReg,0);
- jit_movi(Compiler.jit,jit_R(idx),var->extern_ptr);
- } else if(var->is_static) {
- if(IsF64(var->hc_type)) {
- PushIRFReg(var->hc_type,GetFreeFReg);
- } else {
- PushIRReg(var->hc_type,GetFreeIReg);
- }
- if(var->hc_type->type!=HTT_ARRAY_TYPE)
- PushIRIndirX(var->hc_type,idx=GetFreeIReg,0);
- else
- PushIRReg(var->hc_type,idx=GetFreeIReg);
- VectorPush(var->static_refs,jit_ref_data(Compiler.jit,jit_R(idx),NULL));
- } else if(var->isReg) {
- if(IsF64(var->hc_type)) {
- PushIRFReg(var->hc_type,GetFreeFReg);
- PushIRFReg(var->hc_type,var->reg);
- } else {
- PushIRReg(var->hc_type,GetFreeIReg);
- PushIRReg(var->hc_type,var->reg);
- }
- } else if(var->hc_type->type!=HTT_ARRAY_TYPE) {
+ } else if(var->is_extern_ptr) {
+ if(!get_ptr) {
+ if(IsF64(var->hc_type))
+ JIT_FDEREF(Compiler.jit);
+ else if(IsInteger(var->hc_type)&&!IsSigned(var->hc_type))
+ JIT_UDEREF(Compiler.jit,,var->hc_type->sz);
+ else
+ JIT_DEREF(Compiler.jit,,var->hc_type->sz);
+ }
+ JIT_I64(Compiler.jit,var->extern_ptr);
+ } else if(var->is_static&&var->hc_type->type!=HTT_ARRAY_TYPE) {
+ if(!get_ptr) {
if(IsF64(var->hc_type))
- PushIRFReg(var->hc_type,GetFreeFReg);
- else if(IsInteger(var->hc_type)||IsPtrType(var->hc_type))
- PushIRReg(var->hc_type,GetFreeIReg);
- else {
- PushIRIndirX(var->hc_type,idx=GetFreeIReg,var->frame_off);
- jit_movr(Compiler.jit,jit_R(idx),R_FP);
- break;
- }
- PushIRIndirX(var->hc_type,idx=GetFreeIReg,var->frame_off);
- jit_movr(Compiler.jit,jit_R(idx),R_FP);
- } else {
- PushIRReg(var->hc_type,idx=GetFreeIReg);
- jit_addi(Compiler.jit,jit_R(idx),R_FP,var->frame_off);
- break;
- }
- Assign(Compiler.stack->last,Compiler.stack);
- PopIRValue;
- break;
+ JIT_FDEREF(Compiler.jit);
+ else if(IsInteger(var->hc_type)&&!IsSigned(var->hc_type))
+ JIT_UDEREF(Compiler.jit,,var->hc_type->sz);
+ else
+ JIT_DEREF(Compiler.jit,,var->hc_type->sz);
+
+ }
+ VectorPush(var->static_refs,JIT_REF_DATA(Compiler.jit,NULL));
+ } else if(var->is_static&&var->hc_type->type==HTT_ARRAY_TYPE) {
+ VectorPush(var->static_refs,JIT_REF_DATA(Compiler.jit,NULL));
+ } else if(var->isReg) {
+ JIT_R(Compiler.jit,var->reg);
+ } else if(var->hc_type->type!=HTT_ARRAY_TYPE) {
+ if(!get_ptr) {
+ if(IsF64(var->hc_type))
+ JIT_FDEREF(Compiler.jit);
+ else if(IsInteger(var->hc_type)&&!IsSigned(var->hc_type))
+ JIT_UDEREF_NO_TC(Compiler.jit,,var->hc_type->sz);
+ else
+ JIT_DEREF_NO_TC(Compiler.jit,,var->hc_type->sz);
+
+ }
+ JIT_ADDI(Compiler.jit);
+ JIT_I64(Compiler.jit,var->frame_off);
+ JIT_RBP(Compiler.jit);
+ } else {
+ JIT_ADDI(Compiler.jit);
+ JIT_I64(Compiler.jit,var->frame_off);
+ JIT_RBP(Compiler.jit);
}
+ break;
}
glob_var:
func=var=HashFind(ast->name,Compiler.globals);
@@ -6711,181 +5331,109 @@ U0 __CompileAST(AST *ast,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE)
}
if(var&&var->type==HTT_FUNC) {
if(dont_call_lone_name) {
- LoadSymPtrIntoReg(func->str,idx=GetFreeIReg);
- PushIRIndirX(func->hc_type,idx,0);
+ LoadSymPtr(func->str);
} else {
type1=func->hc_type;
+ idx2=MSize(type1->arg_types)/sizeof(CType*);
+ if(type1->has_vargs) idx2++;
+ if(IsF64(type1->ret_type))
+ JIT_FCALL(Compiler.jit,idx2);
+ else
+ JIT_FUNC_CALL(Compiler.jit,idx2);
+ if(type1->has_vargs)
+ JIT_I64(Compiler.jit,0);
cnt=MSize(type1->arg_types)/sizeof(AST*);
- while(--cnt>=0) {
- if(!type1->arg_values[cnt]) {
- "Expected dft\n";
- throw('Compile');
- }
- if(!Compiler.aot_mode) {
- if(IsF64(type1->arg_types[cnt]))
- PushIRFlt(type1->arg_values[cnt][0](F64));
- else
- PushIRInt(type1->arg_values[cnt][0](I64));
+ for(idx=cnt-1;idx>=0;--idx) {
+ if(Compiler.aot_mode) {
+ JIT_DEREF(Compiler.jit,,8);
+ LoadSymPtr(type1->aot_arg_names[idx]);
} else {
- if(IsF64(type1->arg_types[cnt])) {
- PushIRFReg(GetType("F64"),GetFreeFReg);
- LoadSymPtrIntoReg(type1->aot_arg_names[cnt],0);
- jit_fldr(Compiler.jit,jit_FR(Compiler.stack->reg),jit_R(0),8);
- } else {
- PushIRReg(type1->arg_types[cnt],GetFreeIReg);
- LoadSymPtrIntoReg(type1->aot_arg_names[cnt],0);
- jit_ldr(Compiler.jit,jit_R(Compiler.stack->reg),jit_R(0),8);
- }
- }
- }
- cnt=MSize(type1->arg_types)/sizeof(AST*);
- LoadSymPtrIntoReg(func->str,0);
- jit_prepare(Compiler.jit);
- cnt=MSize(type1->arg_types)/sizeof(AST*);
- while(--cnt>=0) {
- PopIRValue(&value_a);
- switch(value_a->type) {
- case IRV_INT:
- jit_putargi(Compiler.jit,value_a->int);
- break;
- case IRV_FLOAT:
- jit_fputargi(Compiler.jit,value_a->flt,8);
- break;
- case IRV_REG:
- jit_putargr(Compiler.jit,jit_R(value_a->reg));
- break;
- case IRV_FREG:
- jit_fputargr(Compiler.jit,jit_FR(value_a->reg),8);
- break;
+ JIT_I64(Compiler.jit,type1->arg_values[idx][0]);
}
- Free(value_a);
- }
- if(type1->has_vargs) {
- jit_putargi(Compiler.jit,0);
- jit_putargi(Compiler.jit,0);
- }
- jit_callr(Compiler.jit,jit_R(0));
- if(IsF64(func->hc_type->ret_type)) {
- PushIRFReg(func->hc_type->ret_type,idx=GetFreeFReg);
- jit_fretval(Compiler.jit,jit_FR(idx),8);
- } else {
- PushIRReg(func->hc_type->ret_type,idx=GetFreeIReg);
- jit_retval(Compiler.jit,jit_R(idx));
}
+ LoadSymPtr(func->str);
}
} else if(var&&var->type==HTT_VAR) {
- LoadSymPtrIntoReg(var->str,idx=GetFreeIReg);
- if(var->hc_type->type==HTT_ARRAY_TYPE) {
- PushIRReg(var->hc_type,idx);
- break;
- }
- PushIRIndirX(var->hc_type,idx,0);
- if(IsF64(var->hc_type)||IsInteger(var->hc_type)||IsPtrType(var->hc_type))
- if(!IsF64(var->hc_type)) {
- if(!pass_by_ref) {
- PopIRValue(&value_a);
- PushIRReg(var->hc_type,idx);
- Assign(Compiler.stack,value_a);
- Free(value_a);
- }
- } else if(!pass_by_ref) {
- PopIRValue(&value_a);
- PushIRFReg(var->hc_type,GetFreeFReg);
- Assign(Compiler.stack,value_a);
- Free(value_a);
- }
+ if(var->hc_type->type==HTT_ARRAY_TYPE)
+ get_ptr=TRUE;
+ if(!get_ptr) {
+ if(IsF64(var->hc_type))
+ JIT_FDEREF(Compiler.jit);
+ else if(IsInteger(var->hc_type)&&!IsSigned(var->hc_type))
+ JIT_UDEREF(Compiler.jit,,var->hc_type->sz);
+ else
+ JIT_DEREF(Compiler.jit,,var->hc_type->sz);
+
+ }
+ LoadSymPtr(var->str);
} else {
- //May be an unresolved label
- PushIRReg(GetType("I64"),idx=GetFreeIReg);
- LoadSymPtrIntoReg(ast->name,idx);
+ LoadSymPtr(ast->name);
}
break;
}
}
-U0 CompileAST(AST *a,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE) {
- if(Compiler.error_count) {
- PushIRInt(0);
+U0 CompileAST(AST *a,Bool pass_by_ref=FALSE,Bool dont_call_lone_name=FALSE,Bool get_ptr=FALSE) {
+ CRPN *st=NULL;
+ I64 avail_reg;
+ if(a->next) st=jit_rpnBodyStart(Compiler.jit);
+ if(Compiler.error_count)
return;
- }
loop:
- CIRValue *to_validate=Compiler.stack;
- __CompileAST(a,pass_by_ref,dont_call_lone_name);
+ avail_reg=Compiler.cur_tmp_reg;
+ __CompileAST(a,pass_by_ref,dont_call_lone_name,get_ptr);
+ Compiler.cur_tmp_reg=avail_reg;
if(a->type==AST_OPCODE) {
if(a->next&&a->next->type==AST_OPCODE) {
} else {
- jit_end_asm_blk(Compiler.jit);
+ JIT_ASM_TAINT_LABEL(JIT_LABEL(Compiler.jit));
}
} else if(a->type!=AST_OPCODE&&a->next&&a->next->type==AST_OPCODE) {
//If is a group of opcodes,taint at first
//taint at enter
- jit_taint_label(Compiler.jit,jit_get_label(Compiler.jit));
- }
- if(to_validate!=Compiler.stack->last) {
- "Fail @%d\n",a->type;
- throw('Compile');
+ JIT_ASM_TAINT_LABEL(JIT_LABEL(Compiler.jit));
}
if(a->next) {
- PopIRValue;
a=a->next;
goto loop;
}
+ if(st) jit_rpnBodyEnd(Compiler.jit,st);
}
//See jitlib.h
class _CBreakpoint {
U8 enabled;
U0 *jit_op;
CFunction *f;
+ I64 num;
U8 path[256];
_CBreakpoint *prev,*next;
};
class CBreakpoints:CHash {
_CBreakpoint *bps;
};
-class jit_debugger_regs {
- //Prefix with "_" to allow bootstrap compiler to not recognize them as registers
- I64 _RAX;
- I64 _RBX;
- I64 _RCX;
- I64 _RDX;
- I64 _RSI;
- I64 _RDI;
- I64 _RSP;
- I64 _RBP;
- I64 _R8;
- I64 _R9;
- I64 _R10;
- I64 _R11;
- I64 _R12;
- I64 _R13;
- I64 _R15;
- F64 _XMM0;
- F64 _XMM1;
- F64 _XMM2;
- F64 _XMM3;
- F64 _XMM4;
- F64 _XMM5;
- F64 _XMM6;
- F64 _XMM7;
- I64 _R14;
-};
-//See ext/myjit/myjit/jitlib.h for the C definition which is only put there for show.
-class jit_debugger_ctrl {
- #define JIT_DBG_STEP 1
- #define JIT_DBG_NEXT 2
- #define JIT_DBG_FIN 3
- I64 code;
- U0 *prev_stack_ptr;
- //Our silly debugger "enters" into functions,but we will need the last known RIP to compute which breakpoint we were at before entering a breakpoint.
- U0 *last_rip;
-};
class CDebugger {
jit_debugger_ctrl ctrl;
_CBreakpoint *cur_bp;
//Im am sorry,I actually tried to get SEH working on windows but im flabergasted
//So we will stick to a explicit call stack,it goes like this [func1,frame1,func2,func2,...]
CVector *call_stack;
+ CVector *enabled_bps;
} _Debugger;
-_Debugger.call_stack=VectorNew;
+I64 FunctionParents(U0 **ptrs,I64 max,CDebuggerRegs *regs) {
+ --max;
+ I64 top=_Debugger.call_stack->size-2,cnt=0;
+ *ptrs++=_Debugger.ctrl->last_rip;
+ for(;top>=0<max;top-=2) {
+ ptrs[--max,cnt++]=_Debugger.call_stack->data[top+2-1](U0**)[1];
+ }
+ return cnt;
+}
+I64 ParentFramePtrs(U0 **ptrs,I64 max,CDebuggerRegs *regs) {
+ --max;
+ I64 top=_Debugger.call_stack->size-2,cnt=0;
+ for(;top>=0<max;top-=2)
+ ptrs[--max,cnt++]=_Debugger.call_stack->data[top+1];
+ return cnt;
+}
CFunction *GetFunctionByPtr(U0 *ptr) {
I64 idx=Compiler.globals->mask+1;
U8 *bptr;
@@ -6895,7 +5443,7 @@ CFunction *GetFunctionByPtr(U0 *ptr) {
if(func->type==HTT_FUNC) {
if(func->jit) {
bptr=func->func_ptr;
- if(bptr<=ptr<=bptr+jit_bin_size(func->jit))
+ if(bptr<=ptr<=bptr+func->jit->buf_size)
return func;
} else if(func->is_aot) {
bptr=func->func_ptr;
@@ -6910,8 +5458,39 @@ CFunction *GetFunctionByPtr(U0 *ptr) {
_CBreakpoint *GetBreakpointByPtr(U0 *ptr) {
CFunction *func=GetFunctionByPtr(ptr);
if((!func)||func->is_aot) return NULL;
- return jit_get_breakpoint_by_ptr(func->jit,ptr);
+ return JIT_GetBreakpointByPtr(func->jit,ptr);
+}
+
+U0 Backtrace(I64 hl_at,I64 trim=0) {
+ CDebuggerRegs regs;
+ regs.RBP=_Debugger.call_stack->data[_Debugger.call_stack->size-1];
+ U0 *backtrace[0x100];
+ try {
+ I64 idx,stk_sz=FunctionParents(backtrace,0x100,&regs);
+ } catch {
+ Fs->catch_except=TRUE;
+ "CORRUPT STACK\n";
+ return;
+ }
+ CFunction *func;
+ _CBreakpoint *bp;
+ U8 chr;
+ for(idx=trim;idx<stk_sz;idx++) {
+ if(hl_at==idx-trim) chr='*';
+ else chr=' ';
+ func=GetFunctionByPtr(backtrace[idx]);
+ if(func) {
+ if(bp=GetBreakpointByPtr(backtrace[idx]))
+ "[%d] %c %s %s\n",idx-trim,chr,func->str,bp->path;
+ else
+ "[%d] %c %s ???\n",idx-trim,chr,func->str;
+ } else
+ "[%d] %c ???\n",idx-trim,chr;
+ next:
+ }
}
+_Debugger.call_stack=VectorNew;
+_Debugger.enabled_bps=VectorNew;
U8 *DbgSkipWhitespace(U8 *str) {
while(*str&&Bt(char_bmp_white_space,*str))
str++;
@@ -6949,34 +5528,6 @@ U0 ListLines(U8 *fn,I64 s,I64 e) {
en:
Free(ftext);
}
-I64 ParentFramePtrs(U0 **ptrs,I64 max,jit_debugger_regs *regs);
-I64 FunctionParents(U0 **ptrs,I64 max);
-U0 Backtrace(I64 hl_at,I64 trim=0) {
- U0 *backtrace[0x100];
- try {
- I64 idx,stk_sz=FunctionParents(backtrace,0x100);
- } catch {
- Fs->catch_except=TRUE;
- "CORRUPT STACK\n";
- return;
- }
- CFunction *func;
- _CBreakpoint *bp;
- U8 chr;
- for(idx=trim;idx<stk_sz;idx++) {
- if(hl_at==idx-trim) chr='*';
- else chr=' ';
- func=GetFunctionByPtr(backtrace[idx]);
- if(func) {
- if(bp=GetBreakpointByPtr(backtrace[idx]))
- "[%d] %c %s %s\n",idx-trim,chr,func->str,bp->path;
- else
- "[%d] %c %s ???\n",idx-trim,chr,func->str;
- } else
- "[%d] %c ???\n",idx-trim,chr;
- next:
- }
-}
U0 DebugPrint(U0 *ptr,CType *type) {
loop:
if(type->type==HTT_UNION&&type->base) {
@@ -6993,18 +5544,34 @@ U0 DebugPrint(U0 *ptr,CType *type) {
} else if(IsPtrType(type)) {
"%x",ptr(U0**)[0];
} else {
- switch(type->sz) {
- case 1:
- "%d",ptr(I8*)[0];
- break;
- case 2:
- "%d",ptr(I16*)[0];
- break;
- case 4:
- "%d",ptr(I32*)[0];
- break;
- case 8:
- "%d",ptr(I64*)[0];
+ if(IsSigned(type)) {
+ switch(type->sz) {
+ case 1:
+ "%d",ptr(I8*)[0];
+ break;
+ case 2:
+ "%d",ptr(I16*)[0];
+ break;
+ case 4:
+ "%d",ptr(I32*)[0];
+ break;
+ case 8:
+ "%d",ptr(I64*)[0];
+ }
+ } else {
+ switch(type->sz) {
+ case 1:
+ "%d",ptr(U8*)[0];
+ break;
+ case 2:
+ "%d",ptr(U16*)[0];
+ break;
+ case 4:
+ "%d",ptr(U32*)[0];
+ break;
+ case 8:
+ "%d",ptr(U64*)[0];
+ }
}
}
break;
@@ -7033,34 +5600,37 @@ U0 DebugPrint(U0 *ptr,CType *type) {
break;
}
}
-U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
+U0 DebuggerRoutine(CDebuggerRegs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
"Welcome to debugger land.\n";
U0 *backtrace[0x100];
U0 *base_ptrs[0x100];
static U8 list_fn[256];
static U8 last_command[1024];
+ static I64 bp_num;
static I64 list_ln;
Bool leave=FALSE;
CCompilerState *cstate;
- I64 stk_sz,stk_pos,com_len,bp_ln,idx,cidx;
+ I64 stk_sz,stk_pos,com_len,bp_ln,idx,cidx,idx2;
U8 *command,*o_command,*fn_end,*fmt,*bp_fn;
CFunction *cur_func;
CVariable *local_var,*new_var;
CType *expr_type;
CCmpCtrl *cc;
AST *debug_expr;
- CIRValue *debug_value;
_CBreakpoint *_bp;
CBreakpoints *bps;
U0 (*fptr)();
- stk_sz=FunctionParents(backtrace,0x100);
+ stk_sz=FunctionParents(backtrace,0x100,regs);
ParentFramePtrs(base_ptrs,0x100,regs);
cidx=0;
+ if(cidx)
for(idx=cidx;idx<stk_sz;idx++) {
backtrace[idx-cidx]=backtrace[idx];
base_ptrs[idx-cidx]=base_ptrs[idx];
}
stk_sz-=cidx,stk_pos=0;
+ if(!bp)
+ bp=GetBreakpointByPtr(backtrace[stk_pos]);
_Debugger.cur_bp=bp;
if(bp) {
fmt=list_fn;
@@ -7099,6 +5669,31 @@ U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
"exit\t--Exit debugger.\n"
"Press enter for last command.\n"
;
+ } else if(!StrNCmp(command,"listb",com_len)&&com_len==5) {
+ for(idx=0;idx!=_Debugger.enabled_bps->size;idx++) {
+ _bp=_Debugger.enabled_bps->data[idx](_CBreakpoint*);
+ "%d: %s\n",_bp->num,_bp->path;
+ }
+ } else if(!StrNCmp(command,"d",com_len)&&com_len==1) {
+ command=DbgSkipWhitespace(command+com_len);
+ if(*command) {
+ idx=Str2I64(command);
+ for(idx2=0;idx2!=_Debugger.enabled_bps->size;idx2++) {
+ if(idx==_Debugger.enabled_bps->data[idx2](_CBreakpoint*)->num) {
+ _Debugger.enabled_bps->data[idx2](_CBreakpoint*)->enabled=FALSE;
+ VectorRemove(_Debugger.enabled_bps,_Debugger.enabled_bps->data[idx2]);
+ break;
+ }
+ }
+ } else {
+ "Do you really want to delete all breakpoints?\n";
+ if(YorN) {
+ for(idx2=0;idx2!=_Debugger.enabled_bps->size;idx2++) {
+ _Debugger.enabled_bps->data[idx2](_CBreakpoint*)->enabled=FALSE;
+ }
+ _Debugger.enabled_bps->size=0;
+ }
+ }
} else if(!StrNCmp(command,"up",com_len)&&com_len==2) {
if(stk_pos+1>=stk_sz) {
"At topmost stack item.\n";
@@ -7138,6 +5733,9 @@ U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
list_ln=LIST_LINE_COUNT;
ListLines(list_fn,list_ln-LIST_LINE_COUNT,list_ln+LIST_LINE_COUNT);
list_ln+=2*LIST_LINE_COUNT+1;
+ //Copy "last" to last_command(which will contain the contents of o_command),not the file/line number
+ Free(o_command);
+ o_command=StrNew("list");
} else if(!StrNCmp(command,"b",com_len)&&com_len==1) {
bp_fn=NULL;
command=DbgSkipWhitespace(command+StrLen("b"));
@@ -7169,7 +5767,7 @@ U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
if(bp_fn) {
fmt=LexMatchFile(Compiler.cc,bp_fn);
Free(bp_fn);
- } else
+ } else
fmt=NULL;
if(fmt) {
bp_fn=MStrPrint("%s,%d",fmt,bp_ln);
@@ -7177,11 +5775,16 @@ U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
if(bps) {
"Match at %s\n",bp_fn;
for(_bp=bps->bps;_bp;_bp=_bp->next) {
+ _bp->num=++bp_num;
_bp->enabled=TRUE;
+ VectorPush(_Debugger.enabled_bps,_bp(I64));
}
+ Free(bp_fn);
+ goto found;
}
- Free(bp_fn);
}
+ "No breakpoint found for %s:%d\n",fmt,bp_ln;
+ found:
Free(fmt);
} else if(!StrNCmp(command,"s",com_len)&&com_len==1) {
_Debugger.ctrl->code=JIT_DBG_STEP;
@@ -7219,9 +5822,9 @@ U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
new_var->extern_ptr=base_ptrs[stk_pos](U8*)+local_var->frame_off;
} else {
if(stk_pos==0) {
- new_var->extern_ptr=jit_debugger_get_reg_ptr(cur_func->jit,regs,_Debugger.cur_bp->jit_op,jit_R(local_var->reg));
+ new_var->extern_ptr=JIT_GetVregPtr(cur_func->jit,regs,caller_ptr,local_var->reg);
} else {
- new_var->extern_ptr=jit_debugger_get_vreg_ptr_from_parent(cur_func->jit,base_ptrs[stk_pos],_Debugger.cur_bp->jit_op,jit_R(local_var->reg));
+ new_var->extern_ptr=JIT_GetVregPtrFromParent(cur_func->jit,backtrace[stk_pos],base_ptrs[stk_pos],local_var->reg);
}
if(new_var->extern_ptr==NULL)
new_var->is_opted_out=TRUE;
@@ -7233,51 +5836,39 @@ U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
}
//TODO free cc
cc=CmpCtrlNew(NULL);
- LexIncludeStr(cc,NULL,StrNew(command),FALSE);
- Lex(cc);
- debug_expr=ParseExpr(cc);
+ LexIncludeStr(cc,NULL,MStrPrint("%s;",command),FALSE);
try {
+ Lex(cc);
+ debug_expr=ParseExpr(cc);
expr_type=AssignTypeToNode(debug_expr);
+ if(expr_type->sz)
+ idx=JIT_ALLOCAI(Compiler.jit,expr_type->sz);
+ else
+ //Beware the sneaky weaky "U0"'s who have no size
+ idx=JIT_ALLOCAI(Compiler.jit,1);
+ if(IsF64(expr_type)) {
+ JIT_FMOV(Compiler.jit);
+ JIT_FDEREF(Compiler.jit);
+ } else
+ JIT_MOV(Compiler.jit),JIT_DEREF(Compiler.jit);
+ JIT_ADDI(Compiler.jit);
+ JIT_RBP(Compiler.jit);
+ JIT_I64(Compiler.jit,idx);
CompileAST(debug_expr);
- PopIRValue(&debug_value);
- switch(debug_value->type) {
- case IRV_INT:
- "%d\n",debug_value->int;
- break;
- case IRV_FLOAT:
- "%n\n",debug_value->flt;
- start:
- idx=jit_allocai(Compiler.jit,8);
- case IRV_FREG:
- jit_fstxi(Compiler.jit,idx,R_FP,jit_FR(debug_value->reg),8);
- break;
- case IRV_REG:
- jit_stxi(Compiler.jit,idx,R_FP,jit_R(debug_value->reg),8);
- break;
- end:
- jit_addi(Compiler.jit,jit_R(0),R_FP,idx);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(0));
- jit_putargi(Compiler.jit,expr_type);
- jit_call(Compiler.jit,&DebugPrint);
- break;
- case IRV_STR:
- "%s\n",debug_value->int;
- break;
- case IRV_INDIRX:
- jit_addi(Compiler.jit,jit_R(debug_value->indirx.reg),jit_R(debug_value->indirx.reg),debug_value->indirx.offset);
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(debug_value->indirx.reg));
- jit_putargi(Compiler.jit,expr_type);
- jit_call(Compiler.jit,&DebugPrint);
- }
- Free(debug_value);
+ //
+ JIT_FUNC_CALL(Compiler.jit,2);
+ JIT_I64(Compiler.jit,expr_type);
+ JIT_ADDI(Compiler.jit);
+ JIT_RBP(Compiler.jit);
+ JIT_I64(Compiler.jit,idx);
+ JIT_I64(Compiler.jit,&DebugPrint);
if(Compiler.debug_mode) {
- jit_prepare(Compiler.jit);
- jit_call(Compiler.jit,&LeaveFunc);
+ JIT_FUNC_CALL(Compiler.jit,0);
+ JIT_I64(Compiler.jit,&LeaveFunc);
}
- jit_reti(Compiler.jit,1);
- cur_func=CompilerEmitCode;
+ JIT_RETI(Compiler.jit);
+ JIT_I64(Compiler.jit,0);
+ cur_func=CompilerEmitCode(0);
if(cur_func) {
fptr=cur_func->func_ptr;
"=";
@@ -7304,21 +5895,7 @@ U0 DebuggerRoutine(jit_debugger_regs *regs,_CBreakpoint *bp,U8 *caller_ptr) {
Free(o_command);
goto loop;
}
-U0 CompileAstWithBreakpoint(AST *a) {
- if(Compiler.error_count) {
- PushIRInt(0);
- return;
- }
- if(!Compiler.debug_mode) {
- naked:
- CompileAST(a);
- return;
- }
- if(a->type==AST_OPCODE)
- goto naked;
- if(a->next&&a->next->type==AST_OPCODE)
- goto naked;
- re:
+U0 CreateBreakpointFor(AST *a) {
U8 *path_str=MStrPrint("%s,%d",a->fn,a->ln);
_CBreakpoint *bp=MAlloc(sizeof(_CBreakpoint));
CBreakpoints *tail;
@@ -7334,14 +5911,32 @@ U0 CompileAstWithBreakpoint(AST *a) {
HashAdd(tail,Compiler.breakpoints);
goto loop;
}
- jit_breakpoint(Compiler.jit,bp,&DebuggerRoutine,&_Debugger.ctrl);
- __CompileAST(a);
+ JIT_BREAKPOINT(Compiler.jit,&_Debugger.ctrl,bp,&DebuggerRoutine);
Free(path_str);
+}
+U0 CompileAstWithBreakpoint(AST *a) {
+ CRPN *op;
+ if(Compiler.error_count) {
+ return;
+ }
+ if(!Compiler.debug_mode) {
+ naked:
+ CompileAST(a);
+ return;
+ }
+ if(a->type==AST_OPCODE)
+ goto naked;
+ if(a->next&&a->next->type==AST_OPCODE)
+ goto naked;
+ op=jit_rpnBodyStart(Compiler.jit);
+ re:
+ CreateBreakpointFor(a);
+ __CompileAST(a);
if(a->next) {
- PopIRValue;
a=a->next;
goto re;
}
+ jit_rpnBodyEnd(Compiler.jit,op);
}
U0 Debugger() {
DebuggerRoutine(NULL,NULL,NULL);
@@ -7359,11 +5954,10 @@ U0 GlobalCompileASTTo(U8 *to,AST *ast) {
var->str=StrNew(to);
var->global_ptr=MAlloc(AssignTypeToNode(ast)->sz);
HashAdd(var,Compiler.globals);
+ JIT_MOV(Compiler.jit);
+ JIT_DEREF(Compiler.jit);
+ LoadSymPtr(to);
CompileAST(ast);
- PushIRIndirX(AssignTypeToNode(ast),reg=GetFreeIReg,0);
- LoadSymPtrIntoReg(to,reg);
- Assign(Compiler.stack,Compiler.stack->last);
- PopIRValue,PopIRValue;
if(replace) {
*GlobalCompiler=Compiler;
Compiler=old;
@@ -7587,7 +6181,7 @@ U0 FillInRelocations(CFunction *f) {
f->relocs=first;
}
U0 ApplyAsmPatches(CFunction *f);
-CFunction *CompilerEmitCode() {
+CFunction *CompilerEmitCode(I64 arity) {
if(Compiler. error_count) return NULL;
Bool has_exports=FALSE;
CFunction *ret;
@@ -7595,28 +6189,25 @@ CFunction *CompilerEmitCode() {
CCompStringRef *str_ref;
CVariable *var;
CLabel *label,*new_label;
- I64 idx=Compiler.cur_strings->mask+1;
+ I64 idx=Compiler.cur_strings->mask+1,idx2;
+ CRPN *patch_to;
U0 *pat;
- U8 *zeros;
idx=Compiler.locals->mask+1;
while(--idx>=0) {
for(var=Compiler.locals->body[idx];var;var=var->next) {
if(var->type==HTT_VAR&&var->is_static) {
- jit_code_align_fill(Compiler.jit,var->hc_type->align,0);
- while(var->static_refs->size) {
- pat=VectorPop(var->static_refs);
- jit_patch(Compiler.jit,pat);
- }
- jit_dump_ptr(Compiler.jit,&var->static_ptr);
- zeros=MAlloc(var->hc_type->sz);
- jit_data_bytes(Compiler.jit,MSize(zeros),zeros);
- Free(zeros);
+ JIT_ALIGN_FILL(Compiler.jit,var->hc_type->align,0);
+ patch_to=JIT_DUMP_PTR(Compiler.jit,&var->static_ptr);
+ while(var->static_refs->size)
+ JIT_PATCH(Compiler.jit,VectorPop(var->static_refs),patch_to);
+ for(idx2=var->hc_type->sz;idx2>0;idx2-=8)
+ JIT_DU64(Compiler.jit,0);
}
}
}
+ jit_rpnBodyEnd(Compiler.jit,FirstRPN(Compiler.jit->cur_rpn_start));
ret=MAlloc(sizeof(CFunction));
- jit_disable_optimization(Compiler.jit,0xff);
- jit_generate_code(Compiler.jit);
+ ret->func_ptr=JitEmitCode(Compiler.jit,arity);
//Run this after the label pointers are computed
idx=Compiler.labels->mask+1;
while(--idx>=0) {
@@ -7633,7 +6224,6 @@ CFunction *CompilerEmitCode() {
ret->type=HTT_FUNC;
ret->has_exports=has_exports;
ret->jit=Compiler.jit;
- ret->func_ptr=Compiler.func_ptr;
ret->relocs=Compiler.relocations;
ret->locals=Compiler.locals;
ret->labels=Compiler.labels;
@@ -7653,6 +6243,7 @@ CFunction *CompilerEmitCode() {
}
Compiler.cur_strings=HashTableNew(0x40);
}
+ //JIT_RemoveNonDebuggerInfo(ret->jit);
return ret;
}
F64 EvalASTF64(AST *ast) {
@@ -7664,7 +6255,7 @@ F64 EvalASTF64(AST *ast) {
CCompilerState *state=NewCompilerState;
Compiler.ret_type=HashFind("F64",Compiler.globals);
CompileAST(ret);
- CFunction *func=CompilerEmitCode;
+ CFunction *func=CompilerEmitCode(0);
if(func)
F64(*fptr)()=func->func_ptr;
else
@@ -7675,12 +6266,10 @@ F64 EvalASTF64(AST *ast) {
if(func) FreeFunction(func);
return v;
}
-I64 EvalAST(AST *ast) {
- AST *ret=MAlloc(sizeof(AST));
+I64 EvalAST(AST *ast,Bool no_eval=FALSE) {
+ AST *ret;
CHashTable *swap;
I64 v=0,en=PoopSetGCEnable(0),idx;
- ret->type=AST_RETURN;
- ret->unopArg=ast;
CCompilerState *state=NewCompilerState;
//We swap out the "new" and empty Compiler labels with the old ones,Global labels are used in global asm-blocks and need to be flushed to avoid wierdness
if(GlobalCompiler==state) {
@@ -7688,9 +6277,20 @@ I64 EvalAST(AST *ast) {
Compiler.labels=state->labels;
state->labels=swap;
}
- Compiler.ret_type=HashFind("I64i",Compiler.globals);
- CompileAST(ret);
- CFunction *func=CompilerEmitCode;
+ if(no_eval) {
+ CompileAST(ast);
+ if(Compiler.debug_mode) {
+ JIT_FUNC_CALL(Compiler.jit,0);
+ JIT_I64(Compiler.jit,&LeaveFunc);
+ }
+ } else {
+ ret=MAlloc(sizeof(AST));
+ ret->type=AST_RETURN;
+ ret->unopArg=ast;
+ Compiler.ret_type=HashFind("I64i",Compiler.globals);
+ CompileAST(ret);
+ }
+ CFunction *func=CompilerEmitCode(0);
if(func) {
I64(*fptr)()=func->func_ptr;
v=(*fptr)();
@@ -7699,7 +6299,7 @@ I64 EvalAST(AST *ast) {
RestoreCompilerState(state);
if(func) {
if(func->has_exports) {
- func->str=MStrPrint("asm.%x",GetUnique);
+ func->str=MStrPrint("asm.%x",GetUnique);
HashAdd(func,Compiler.globals);
} else
FreeFunction(func);
@@ -7723,7 +6323,7 @@ CFunction *CompileFunction(AST *at,CCmpCtrl *cc,CType *type,U8 *name,Bool inst_e
Compiler.ret_type=type->ret_type;
AST *body;
Compiler.in_func=TRUE;
- I64 idx,cnt,frame_off=0,align,freg,fp;
+ I64 idx,cnt,freg,fp;
cnt=MSize(type->arg_types)/sizeof(CType*);
for(idx=0;idx!=cnt;idx++) {
if(type->arg_names[idx]) {
@@ -7731,7 +6331,7 @@ CFunction *CompileFunction(AST *at,CCmpCtrl *cc,CType *type,U8 *name,Bool inst_e
arg->str=StrNew(type->arg_names[idx]);
arg->type=HTT_VAR;
arg->hc_type=type->arg_types[idx];
- if(IsF64(arg->hc_type)||IsInteger(arg->hc_type)||IsPtrType(arg->hc_type))
+ if(IsInteger(arg->hc_type)||IsPtrType(arg->hc_type))
arg->isReg=TRUE; //Can be turned false later.
HashAdd(arg,Compiler.locals);
}
@@ -7762,112 +6362,85 @@ CFunction *CompileFunction(AST *at,CCmpCtrl *cc,CType *type,U8 *name,Bool inst_e
}
if(cc->token!='{') ParserFail(cc,"Expected function body.");
body=ParseScope(cc,inst_eval);
- Compiler.first_avail_ireg=3;
- Compiler.first_avail_freg=2;
cnt=Compiler.locals->mask+1;
for(idx=0;idx!=cnt;idx++) {
arg=Compiler.locals->body[idx];
for(;arg;arg=arg->next) {
if(arg->type==HTT_VAR&&!(arg->link.type&LINK_STATIC)) {
if(arg->isReg&&!Compiler.force_noregs) {
- if(IsF64(arg->hc_type))
- arg->reg=Compiler.first_avail_freg++;
- else
- arg->reg=Compiler.first_avail_ireg++;
+ arg->reg=Compiler.first_avail_reg++;
} else {
arg->isReg=FALSE;
- align=arg->hc_type->align;
- frame_off+=(align-(frame_off%align))%align;
- arg->frame_off=frame_off;
- frame_off+=arg->hc_type->sz;
- }
- }
- }
- }
- Compiler.frame_off=jit_allocai(Compiler.jit,frame_off);
- cnt=Compiler.locals->mask+1;
- for(idx=0;idx!=cnt;idx++) {
- arg=Compiler.locals->body[idx];
- for(;arg;arg=arg->next) {
- if(arg->type==HTT_VAR&&!(arg->link.type&LINK_STATIC)) {
- if(!arg->isReg){
- arg->frame_off+=Compiler.frame_off;
+ arg->frame_off=JIT_ALLOCAI(Compiler.jit,arg->hc_type.sz);
}
}
}
}
cnt=MSize(type->arg_types)/sizeof(CType*);
for(idx=0;idx!=cnt;idx++) {
- if(IsF64(type->arg_types[idx])) {
- jit_declare_arg(Compiler.jit,JIT_FLOAT_NUM,8);
- } else if(IsSigned(type->arg_types[idx]))
- jit_declare_arg(Compiler.jit,JIT_SIGNED_NUM,8);
- else
- jit_declare_arg(Compiler.jit,JIT_UNSIGNED_NUM,8);
- }
- cnt=MSize(type->arg_types)/sizeof(CType*);
- for(idx=0;idx!=cnt;idx++) {
if(type->arg_names[idx]) {
arg=HashFind(type->arg_names[idx],Compiler.locals);
if(arg->isReg) {
- if(IsF64(type->arg_types[idx]))
- jit_getarg(Compiler.jit,jit_FR(arg->reg),idx);
- else
- jit_getarg(Compiler.jit,jit_R(arg->reg),idx);
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,arg->reg);
+ JIT_GETARGI(Compiler.jit,idx);
} else {
if(IsF64(type->arg_types[idx])) {
- jit_getarg(Compiler.jit,jit_FR(freg=GetFreeFReg),idx);
- PushIRFReg(HashFind("F64",Compiler.globals),freg);
+ JIT_FMOV(Compiler.jit);
+ JIT_FDEREF(Compiler.jit,arg->frame_off);
+ JIT_RBP(Compiler.jit);
+ JIT_GETARGF(Compiler.jit,idx);
} else {
- jit_getarg(Compiler.jit,jit_R(freg=GetFreeIReg),idx);
- PushIRReg(HashFind("I64i",Compiler.globals),freg);
+ JIT_MOV(Compiler.jit);
+ JIT_DEREF(Compiler.jit,arg->frame_off);
+ JIT_RBP(Compiler.jit);
+ JIT_GETARGI(Compiler.jit,idx);
}
- PushIRIndirX(arg->hc_type,fp=GetFreeIReg,arg->frame_off);
- jit_movr(Compiler.jit,jit_R(fp),R_FP);
- Assign(Compiler.stack,Compiler.stack->last);
- PopIRValue,PopIRValue;
}
}
}
if(type->has_vargs) {
- jit_declare_arg(Compiler.jit,JIT_SIGNED_NUM,8);
arg=HashFind("argc",Compiler.locals);
if(arg->isReg) {
- jit_getarg(Compiler.jit,jit_R(arg->reg),idx++);
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,arg->reg);
+ JIT_GETARGI(Compiler.jit,idx);
} else {
- jit_getarg(Compiler.jit,jit_R(freg=GetFreeIReg),idx++);
- PushIRReg(HashFind("I64i",Compiler.globals),freg);
- PushIRIndirX(arg->hc_type,fp=GetFreeIReg,arg->frame_off);
- jit_movr(Compiler.jit,jit_R(fp),R_FP);
- Assign(Compiler.stack,Compiler.stack->last);
- PopIRValue,PopIRValue;
- }
- jit_declare_arg(Compiler.jit,JIT_PTR,8);
+ JIT_GETARGI(Compiler.jit,cnt);
+ }
arg=HashFind("argv",Compiler.locals);
if(arg->isReg) {
- jit_getarg(Compiler.jit,jit_R(arg->reg),idx++);
+ JIT_MOV(Compiler.jit);
+ JIT_R(Compiler.jit,arg->reg);
} else {
- jit_getarg(Compiler.jit,jit_R(freg=GetFreeIReg),idx++);
- PushIRReg(HashFind("I64i",Compiler.globals),freg);
- PushIRIndirX(arg->hc_type,fp=GetFreeIReg,arg->frame_off);
- jit_movr(Compiler.jit,jit_R(fp),R_FP);
- Assign(Compiler.stack,Compiler.stack->last);
- PopIRValue,PopIRValue;
- }
- }
-
+ JIT_MOV(Compiler.jit);
+ JIT_DEREF(Compiler.jit,arg->frame_off);
+ JIT_RBP(Compiler.jit);
+ }
+ JIT_ADDI(Compiler.jit);
+ JIT_RBP(Compiler.jit);
+ //start of argv
+ //argc
+ //args
+ //...
+ //RETURN ADDRESS
+ //OLD RBP
+ //RBP
+ JIT_I64(Compiler.jit,16+8*(cnt+1));
+ }
+ Compiler.cur_tmp_reg=++Compiler.first_avail_reg;
CompileAstWithBreakpoint(body);
- PopIRValue;
if(Compiler.debug_mode) {
- jit_prepare(Compiler.jit);
- jit_call(Compiler.jit,&LeaveFunc);
+ JIT_FUNC_CALL(Compiler.jit,0);
+ JIT_I64(Compiler.jit,&LeaveFunc);
}
- jit_reti(Compiler.jit,0);
+ JIT_RETI(Compiler.jit);
+ JIT_I64(Compiler.jit,0);
idx=Compiler.asm_tainted_label_names.mask+1;
while(--idx>=0) {
for(tainted=Compiler.asm_tainted_label_names.body[idx];tainted;tainted=tainted->next) {
if(label=HashFind(tainted->str,Compiler.labels))
- jit_taint_label(Compiler.jit,label->op);
+ JIT_ASM_TAINT_LABEL(label->op);
}
}
@@ -7884,7 +6457,9 @@ CFunction *CompileFunction(AST *at,CCmpCtrl *cc,CType *type,U8 *name,Bool inst_e
}
}
FreeAST(body);
- ret=CompilerEmitCode;
+ cnt=MSize(type->arg_types)/sizeof(CType*);
+ if(type->has_vargs) cnt++; //argv is implicit
+ ret=CompilerEmitCode(cnt);
if(!ret) {
ret=HashFind(name,Compiler.globals);
if(ret) {
@@ -7904,7 +6479,7 @@ CFunction *CompileFunction(AST *at,CCmpCtrl *cc,CType *type,U8 *name,Bool inst_e
idx=Compiler.globals->mask+1;
while(--idx>=0) {
func=Compiler.globals->body[idx];
- for(;func;func=func->next) {
+ for(;func;func=func->next) {
if(func->type==HTT_FUNC)
FillInRelocations(func);
}
@@ -7921,22 +6496,6 @@ I64 SetCallStackSize(I64 sz) {
I64 CallStackSize() {
return _Debugger.call_stack->size/2;
}
-I64 FunctionParents(U0 **ptrs,I64 max) {
- --max;
- I64 top=_Debugger.call_stack->size-2,cnt=0;
- *ptrs++=_Debugger.ctrl->last_rip;
- for(;top>=0<max;top-=2)
- ptrs[--max,cnt++]=_Debugger.call_stack->data[top];
- return cnt;
-}
-I64 ParentFramePtrs(U0 **ptrs,I64 max,jit_debugger_regs *regs) {
- --max;
- I64 top=_Debugger.call_stack->size-2,cnt=0;
- if(regs) *ptrs++=regs->_RBP;
- for(;top>=0<max;top-=2)
- ptrs[--max,cnt++]=_Debugger.call_stack->data[top+1];
- return cnt;
-}
U0 EnterFunc(U0 *frame) {
VectorPush(_Debugger.call_stack,frame(U0**)[1]);
VectorPush(_Debugger.call_stack,frame);
@@ -7956,7 +6515,7 @@ AST *CompileX64Mode(AST *a,CReg **base,CReg **index,I64 *scale,CVector *offsets,
case AST_ADD:
binop_a=CompileX64Mode(a->binop.a,base,index,scale,offsets);
binop_b=CompileX64Mode(a->binop.b,base,index,scale,offsets);
- if(binop_a||binop_b) {
+ if(binop_a&&binop_b) {
FreeAST(binop_a),FreeAST(binop_b);
ret=MAlloc(sizeof(AST));
ret->type=AST_X64_MODE;
@@ -8011,6 +6570,10 @@ AST *CompileX64Mode(AST *a,CReg **base,CReg **index,I64 *scale,CVector *offsets,
} catch {
CatchIf('Parser','Lexer');
}
+ for(cnt=offsets->size-1;cnt>=0;cnt--) {
+ AssignTypeToNode(offsets->data[cnt]);
+ offsets->data[cnt](AST*)->type2=GetType("I64i");
+ }
return NULL;
}
U0 AsmInheritLocalsFromState(CCompilerState *state) {
@@ -8038,7 +6601,6 @@ AST *ParseX64Mode(CCmpCtrl *cc,COpcode *opc) {
CReg *seg=NULL,*base=NULL,*index=NULL;
AST *tmp,*tmp2,*offset,*ret,*sum;
CVector *offsets;
- CIRValue *ir_value;
CType *addr_type=NULL;
Bool is_indirect=FALSE;
if(cc->token==TK_IDENT&&GetType(cc->cur_str))
@@ -8113,58 +6675,40 @@ AST *ParseX64Mode(CCmpCtrl *cc,COpcode *opc) {
tmp->binop.b=offset;
ret->x64_mode_offset=tmp;
}
+ offset->type2=GetType("I64i");
}
if(!is_indirect) {
if(base)
ret->x64_mode=X64ModeReg(base);
else {
//See x64_mode_offsets;
- if(AsmReferencesNonLocals(ret->x64_mode_offset)) {
- max_width=0;
- for(;opc;opc=opc->next_op) {
- if(opc->flags&OPC_F_IB)
- max_width=MaxI64(max_width,1);
- else if(opc->flags&OPC_F_IW)
- max_width=MaxI64(max_width,2);
- else if(opc->flags&OPC_F_ID)
- max_width=MaxI64(max_width,4);
- else if(opc->flags&OPC_F_IQ)
- max_width=MaxI64(max_width,8);
- }
- switch (max_width) {
- case 1:
- ret->x64_mode=X64ModeImm(0xff);
- break;
- case 2:
- ret->x64_mode=X64ModeImm(0xffff);
- break;
- case 4:
- ret->x64_mode=X64ModeImm(0xffffFFFF);
- break;
- case 8:
- ret->x64_mode=X64ModeImm(0xffffFFFFffff);
- break;
- default:
- //???
- ret->x64_mode=X64ModeImm(0);
- }
- } else {
- cstate=NewCompilerState;
- AsmInheritLocalsFromState(cstate);
- Compiler.asm_mode=Compiler.in_func=TRUE;
- tmp=MAlloc(sizeof(AST));
- tmp->type=AST_RETURN;
- tmp->unopArg=ret->x64_mode_offset;
- Compiler.ret_type=GetType("I64i");
- CompileAST(tmp);
- patcher=CompilerEmitCode;
- I64 (*fptr)()=patcher->func_ptr;
- aconst=(*fptr)();
- FreeFunction(patcher);
- RestoreCompilerState(cstate);
- ret->x64_mode=X64ModeImm(aconst);
- FreeAST(tmp);
- ret->x64_mode_offset=NULL;
+ max_width=0;
+ for(;opc;opc=opc->next_op) {
+ if(opc->flags&OPC_F_IB)
+ max_width=MaxI64(max_width,1);
+ else if(opc->flags&OPC_F_IW)
+ max_width=MaxI64(max_width,2);
+ else if(opc->flags&OPC_F_ID)
+ max_width=MaxI64(max_width,4);
+ else if(opc->flags&OPC_F_IQ)
+ max_width=MaxI64(max_width,8);
+ }
+ switch (max_width) {
+ case 1:
+ ret->x64_mode=X64ModeImm(0x7f);
+ break;
+ case 2:
+ ret->x64_mode=X64ModeImm(0x7fff);
+ break;
+ case 4:
+ ret->x64_mode=X64ModeImm(0x7fffFFFF);
+ break;
+ case 8:
+ ret->x64_mode=X64ModeImm(0x7fffFFFFffff);
+ break;
+ default:
+ //???
+ ret->x64_mode=X64ModeImm(0);
}
}
} else {
@@ -8172,29 +6716,14 @@ AST *ParseX64Mode(CCmpCtrl *cc,COpcode *opc) {
r=addr_type->sz;
else
r=0;
- if((!base)&&!index)
+ if(!base&&!index)
base=HashFind("RIP",regs);
- if(ret->x64_mode_offset&&AsmReferencesNonLocals(ret->x64_mode_offset)) {
- ret->x64_mode=X64ModeMem(seg,scale,index,base,0x11223344,r);
- } else if(ret->x64_mode_offset&&!AsmReferencesNonLocals(ret->x64_mode_offset)) {
- cstate=NewCompilerState;
- AsmInheritLocalsFromState(cstate);
- Compiler.asm_mode=Compiler.in_func=TRUE;
- tmp=MAlloc(sizeof(AST));
- tmp->type=AST_RETURN;
- tmp->unopArg=ret->x64_mode_offset;
- Compiler.ret_type=GetType("I64i");
- CompileAST(tmp);
- patcher=CompilerEmitCode;
- fptr=patcher->func_ptr;
- aconst=(*fptr)();
- FreeFunction(patcher);
- RestoreCompilerState(cstate);
- ret->x64_mode=X64ModeMem(seg,scale,index,base,aconst,r);
- FreeAST(tmp);
- ret->x64_mode_offset=NULL;
- } else
- ret->x64_mode=X64ModeMem(seg,scale,index,base,0x0,r);
+ //If we are using an offset,assume the maximum width
+ if(ret->x64_mode_offset)
+ max_width=0x11223344;
+ else
+ max_width=0;
+ ret->x64_mode=X64ModeMem(seg,scale,index,base,max_width,r);
}
VectorFree(offsets);
Compiler.asm_mode=FALSE;
@@ -8225,7 +6754,10 @@ U0 ApplyAsmPatches(CFunction *f) {
patcher->ptr(U64*)[0]=value;
break;
}
- }
+ } else {
+ "UNPATCHED:%p\n",patcher; //TODO REMOVE
+ "%s\n",patcher->relocs->name;
+ }
if(fully_patched&&patcher->is_const) {
next=patcher->next_patch;
FreeFunction(patcher);
@@ -8260,7 +6792,7 @@ Bool PatchAsmPatcher(CFunction *parent,CAsmPatcher *patcher ) {
nvar->type=HTT_VAR;
if(var->is_static) {
nvar->global_ptr=var->static_ptr;
- } if(!var->isReg) {
+ } else if(!var->isReg) {
nvar->global_ptr=var->frame_off;
}
HashAdd(nvar,Compiler.globals);
@@ -8270,7 +6802,7 @@ Bool PatchAsmPatcher(CFunction *parent,CAsmPatcher *patcher ) {
idx=parent->labels->mask+1;
while(--idx>=0) {
for(lab=parent->labels->body[idx];lab;lab=lab->next) {
- if(lab->is_local) {
+ if(lab->is_local) {
StrScan(lab->str,LOCAL_LAB_FMT,&local_lab_name,&__local_scope);
if(patcher->label_scope!=__local_scope)
goto next;
@@ -8279,8 +6811,7 @@ Bool PatchAsmPatcher(CFunction *parent,CAsmPatcher *patcher ) {
nvar=MAlloc(sizeof(CVariable));
nvar->str=StrNew(local_lab_name);
nvar->type=HTT_VAR;
- nvar->extern_ptr=lab->ptr;
- nvar->is_extern_ptr=TRUE;
+ nvar->global_ptr=lab->ptr;
nvar->hc_type=GetType("U8i")+1;
HashAdd(nvar,Compiler.globals);
next:
@@ -8321,7 +6852,7 @@ U0 ImportLabelsFromStateAsVars(CCompilerState *state,I64 local_scope=-2) {
}
}
}
-U0 CompileAsmConst(AST *mode,I64 width,Bool is_rel=FALSE,I64 local_scope=-2) {
+CAsmPatcher *CompileAsmConst(AST *mode,I64 width,Bool is_rel=FALSE,I64 local_scope=-2,Bool eval_only=FALSE) {
AST *offset;
Bool old_asm_mode=Compiler.asm_mode;
CFunction *func;
@@ -8330,24 +6861,25 @@ U0 CompileAsmConst(AST *mode,I64 width,Bool is_rel=FALSE,I64 local_scope=-2) {
CVariable *var,*nvar;
CAsmPatcher *patcher;
CLabel *lab;
- CIRValue *ir_value;
I64 (*fptr)();
if(1) {
patcher=MAlloc(sizeof(CAsmPatcher));
- jit_dump_ptr(Compiler.jit,&patcher->ptr);
- switch(width) {
- case 1:
- jit_data_byte(Compiler.jit,0);
- break;
- case 2:
- jit_data_word(Compiler.jit,0);
- break;
- case 4:
- jit_data_dword(Compiler.jit,0);
- break;
- case 8:
- jit_data_qword(Compiler.jit,0);
- break;
+ if(!eval_only) {
+ JIT_DUMP_PTR(Compiler.jit,&patcher->ptr);
+ switch(width) {
+ case 1:
+ JIT_DU8(Compiler.jit,0);
+ break;
+ case 2:
+ JIT_DU16(Compiler.jit,0);
+ break;
+ case 4:
+ JIT_DU32(Compiler.jit,0);
+ break;
+ case 8:
+ JIT_DU64(Compiler.jit,0);
+ break;
+ }
}
patcher->is_const=!AsmReferencesNonLocals(mode,TRUE);
cstate=NewCompilerState;
@@ -8356,25 +6888,18 @@ U0 CompileAsmConst(AST *mode,I64 width,Bool is_rel=FALSE,I64 local_scope=-2) {
Compiler.asm_mode=TRUE;
Compiler.in_func=TRUE;
Compiler.imports=cstate->imports;
- PushIRReg(GetType("I64i"),r=GetFreeIReg);
try {
old_asm_mode=Compiler.asm_mode;
Compiler.asm_mode=TRUE;
AssignTypeToNode(mode);
+ JIT_RETI(Compiler.jit);
CompileAST(mode);
} catch {
Compiler.asm_mode=old_asm_mode;
CatchIf('Parser','Compile');
}
Compiler.asm_mode=old_asm_mode;
- Assign(Compiler.stack->last,Compiler.stack);
- if(Compiler.debug_mode) {
- jit_prepare(Compiler.jit);
- jit_call(Compiler.jit,&LeaveFunc);
- }
- jit_retr(Compiler.jit,jit_R(r));
- PopIRValue,PopIRValue;
- *patcher=*(func=CompilerEmitCode);
+ *patcher=*(func=CompilerEmitCode(0));
patcher->width=width;
patcher->is_rel=is_rel;
patcher->label_scope=local_scope;
@@ -8383,8 +6908,11 @@ U0 CompileAsmConst(AST *mode,I64 width,Bool is_rel=FALSE,I64 local_scope=-2) {
FillInRelocations(patcher);
RestoreCompilerState(cstate);
}
- patcher->next_patch=Compiler.asm_patches;
- Compiler.asm_patches=patcher;
+ if(!eval_only) {
+ patcher->next_patch=Compiler.asm_patches;
+ Compiler.asm_patches=patcher;
+ }
+ return patcher;
}
AST *ParseOpcode(CCmpCtrl *cc) {
I64 acnt,idx;
@@ -8656,7 +7184,7 @@ U0 REPL(U8 *init=NULL,I64 flags=PF_DEBUGGER,U8 *body=NULL) {
Lex(cc);
try {
while(ast=ParseStmt(cc)) {
- EvalAST(ast);
+ EvalAST(ast,TRUE);
FreeAST(ast);
}
} catch {
@@ -8673,7 +7201,7 @@ U0 REPL(U8 *init=NULL,I64 flags=PF_DEBUGGER,U8 *body=NULL) {
Compiler.error_count=0;
ast=ParseStmt(cc,TRUE);
if(ast) {
- EvalAST(ast);
+ EvalAST(ast,TRUE);
FreeAST(ast);
}
} catch {
@@ -8761,14 +7289,13 @@ U8 *LoadFunction(U8 *from,Bool verbose=FALSE,CFunction **dump_to=NULL) {
CRelocation *reloc;
CBinLabel blabel;
CCompString *comp_string;
- CLabel *label;
+ CLabel *label,*glabel;
CBinAsmPatch basm_patch;
CAsmPatcher *patcher;
- if(*from!=1) return from;
func=MAlloc(sizeof(CFunction));
statics=HashTableNew(0x10);
labels=HashTableNew(0x20);
- for(ptr=++from;*ptr;ptr++);
+ for(ptr=from;*ptr;ptr++);
U8 name[256];
StrNCpy(name,from,ptr-from+1);
from=ptr+1;
@@ -8825,6 +7352,7 @@ U8 *LoadFunction(U8 *from,Bool verbose=FALSE,CFunction **dump_to=NULL) {
label=MAlloc(sizeof(CLabel));
label->type=HTT_LABEL;
label->str=StrNew(from);
+ label->ptr=blabel.offset;
from+=StrLen(from)+1;
switch(blabel.type) {
case BIN_LABEL_LOCAL:
@@ -8860,6 +7388,20 @@ U8 *LoadFunction(U8 *from,Bool verbose=FALSE,CFunction **dump_to=NULL) {
func->relocs=reloc;
}
}
+ //
+ cnt=labels->mask+1;
+ while(--cnt>=0) {
+ for(label=labels->body[cnt];label;label=label->next) {
+ label->ptr(U8*)+=func->func_ptr(U8*);
+ "PTR:%s->%p\n",label->str,label->ptr;
+ if(label->is_exported) {
+ glabel=MAlloc(sizeof(CLabel));
+ *glabel=*label;
+ glabel->str=StrNew(label->str);
+ HashAdd(glabel,Compiler.globals);
+ }
+ }
+ }
Free(patches);
func->locals=statics;
func->type=HTT_FUNC;
@@ -8875,15 +7417,22 @@ U8 *LoadFunction(U8 *from,Bool verbose=FALSE,CFunction **dump_to=NULL) {
*patcher=*tfunc;
patcher->width=basm_patch.width;
patcher->is_rel=basm_patch.is_rel;
- patcher->ptr=basm_patch.offset+func->func_ptr;
+ patcher->ptr=basm_patch.offset+func->func_ptr(U8*);
patcher->label_scope=basm_patch.labelContext;
+ if(verbose) {
+ "%p\n",patcher;
+ "is_rel:%d\n",patcher->is_rel;
+ "width:%d\n",patcher->width;
+ "offset:%p\n",basm_patch.offset;
+ "ptr:%p(func starts at %p)\n",patcher->ptr,func->func_ptr;
+ "context:%p\n",patcher->label_scope;
+ }
Free(tfunc);
if(func->asm_patches)
- func->asm_patches->next_patch=patcher;
+ patcher->next_patch=func->asm_patches;
func->asm_patches=patcher;
}
- ApplyAsmPatches(func);
- //
+ //
cnt=MSize(strings)/sizeof(CBinString*);
while(--cnt>=0) {
CCompString *cs=MAlloc(sizeof(CCompString));
@@ -8893,10 +7442,11 @@ U8 *LoadFunction(U8 *from,Bool verbose=FALSE,CFunction **dump_to=NULL) {
HashAdd(cs,AOTStrings);
Free(strings[cnt]);
}
- Free(strings),Free(labels);
+ Free(strings);
if(!dump_to)
HashAdd(func,Compiler.globals);
if(dump_to) *dump_to=func;
+ "END\n";
return from;
}
I64 SerializeFunc(U8 *to,CFunction *func,Bool naked=FALSE) {
@@ -9005,7 +7555,7 @@ I64 SerializeFunc(U8 *to,CFunction *func,Bool naked=FALSE) {
}
//Function binary
if(!func->func_ptr) throw('BinMod');
- size=jit_bin_size(func->jit);
+ size=MSize(func->jit->buffer);
tmp=size;
to=WriteIfPresent(to,&tmp,8,&written);
to=WriteIfPresent(to,func->func_ptr,size,&written);
@@ -9109,7 +7659,7 @@ U0 LoadBinModule(U8 *fn,Bool verbose=FALSE) {
loop:
switch(*ptr) {
case 1:
- ptr=LoadFunction(ptr,verbose);
+ ptr=LoadFunction(ptr+1,verbose);
break;
case 0:
ptr=LoadVar(ptr,verbose);
@@ -9120,7 +7670,7 @@ U0 LoadBinModule(U8 *fn,Bool verbose=FALSE) {
LexIncludeStr(cc,fn,MemCpy(MAlloc(cnt-(ptr-bin)+1),ptr,cnt-(ptr-bin)),TRUE);
Lex(cc);
while(ast=ParseStmt(cc)) {
- EvalAST(ast);
+ EvalAST(ast,TRUE);
FreeAST(ast);
}
goto en;
@@ -9169,11 +7719,11 @@ U0 CompileBinModule(U8 *source,U8 *fn="A.BIN",U8 *header=NULL) {
while(cc->token) {
stmt=ParseStmt(cc);
CompileAST(stmt);
- PopIRValue;
FreeAST(stmt);
}
- jit_reti(Compiler.jit,0);
- CFunction *main=CompilerEmitCode;
+ JIT_RETI(Compiler.jit);
+ JIT_I64(Compiler.jit,0);
+ CFunction *main=CompilerEmitCode(0);
main->str=StrNew("@@Main");
HashAdd(main,Compiler.globals);
written=__CompileBinModule(NULL,header_text);
@@ -9263,32 +7813,12 @@ I64 JIT_Eval(U8 *text,U8 **unused) {
//TODO free cc
return ret;
}
-#ifdef BOUNDS_CHECK
-U0 BtOnOOB(U8 *ptr,I64 sz) {
- if(!WhineOnOutOfBounds(ptr,sz))
- Backtrace(-1,0);
-}
-U0 CompileBoundsCheck(I64 r,I64 sz,I64 off=0) {
- I64 tmp;
- if(Compiler.bounds_check_mode) {
- if(off) {
- tmp=2; //Unused register typeically used for function calls.
- jit_addi(Compiler.jit,jit_R(tmp),jit_R(r),off);
- } else
- tmp=r;
- jit_prepare(Compiler.jit);
- jit_putargr(Compiler.jit,jit_R(tmp));
- jit_putargi(Compiler.jit,sz);
- jit_call(Compiler.jit,&BtOnOOB);
- }
-}
-#else
-U0 CompileBoundsCheck(I64 r,I64 sz,I64 off=0){}
-#endif
#ifdef STAGE1
GC_Collect;
-RegisterRuntimeClasses(&GetType,&LoaderCreateTypeFwd,&LoaderAddMember,&LoaderCreateArrayType);
-CompileBinModule("#define BOUNDS_CHECK\n#define SIGNAL\n#define RUNTIME_C\n#include \"CODEGEN.HC\";","CG.BIN","HCRT/HCRT.HH");
+//RegisterRuntimeClasses(&GetType,&LoaderCreateTypeFwd,&LoaderAddMember,&LoaderCreateArrayType);
+//CompileBinModule("#define BOUNDS_CHECK\n#define SIGNAL\n#define RUNTIME_C\n#include \"PARSER.HC\"#include \"HolyEd/EDITOR.HC\";","REPL.BIN","HCRT/HCRT.HH");
+//CompileBinModule("#define BOUNDS_CHECK\n#define SIGNAL\n#include \"PARSER2.HC\";","HCRT_TOS.BIN","HCRT/HCRT.HH");
+CompileBinModule("#include \"HCRT/HCRT.HH\"\n#include \"PARSER2.HC\";","HCRT_TOS.BIN","HCRT/HCRT.HH");
#endif
//See rl.c
I64 __HCCompetions2(U8 *buf,U8 **dst) {
@@ -9473,7 +8003,7 @@ U0 WriteTagsAndErrsToFile(U8 *src,U8 *tags=NULL,U8 *errs=NULL) {
Bool ParseAndRun(CCmpCtrl *cc) {
AST *t=ParseStmt(cc);
if(t) {
- EvalAST(t);
+ EvalAST(t,TRUE);
FreeAST(t);
return TRUE;
}
diff --git a/README.MD b/README.MD
index 0bff59a..1a1f8f1 100755
--- a/README.MD
+++ b/README.MD
@@ -95,11 +95,12 @@ U0 Hi() {
}
}
```
-If you suspect the assembler is acting up,open in gdb and type `disas GetVariable("Func_with_asm_in_it").func.funcptr,+100` for a dissambly. I would love to fix any problems in the assembler. Also,make sure you follow the ABI for your OS when using assembler code. And **DONT JUMP INTO ASM BLOCKS FROM HolyC Code**. All registers are unloaded prior to entering an asm block and before any label that an asm block jumps to.
-
+Also,With this update, **THIS COMPILER CONTAINS AN FFI FOR TEMPLEOS ABI,AND THE COMPILER COMPILES TO TEMPLEOS ABI**. I do plan on porting the offical compiler to run on Linux/FreeBSD/Windows,but I will need time. Basically the TempleOS ABI needs 2 things if you are writting functions in assembly.
+ - The function will pass all arguments on the stack
+ - The function will pop the arguments passed to it using `RET1 8*argc` (vargs are popped off by the caller)
# Internals
-This compiler uses a modified myjit which runs under windows(new feature),linux, and FreeBSD(and probaly any other systemV ABI Unix). The main part of the Compiler is in compile.c. The compiler uses a value stack for temporary values(if they are on the stack on the same time they interfere). The grammar is in `HolyC.y`. The lexer uses a rope data structure provided by a patched `ext/mropes`. I plan on making a game with this compiler so I will add to the runtime as needed. If you want to add functions,look at `runtime.c`,but a functional text editor is provided in `HolyEd/EDITOR.HC`.
+The Compiler contains a runtime of functions in `HCRT/*.HC`. The 2 main important files are `PARSER2.HC` and `CODEGEN.HC`. I use a polish notation for the IR. The parser is recursive descent. I plan on making a game with this compiler so I will add to the runtime as needed. If you want to add functions,look at `runtime.c`,but a functional text editor is provided in `HolyEd/EDITOR.HC`. To build the runtime do `./3d_loader2 --noruntime FULL_UNTIME.HC -c HCRT_TOS.BIN --binheader HCRT/HCRT.HH`. (The binaries are not TempleOS compatible).
# Contributing
You can contribute by adding to the runtime(see `runtime.c` and `HCRT/`). Nice things would include:
@@ -110,19 +111,7 @@ You can contribute by adding to the runtime(see `runtime.c` and `HCRT/`). Nice
- Make a `Help` function.
# Future!!!
-I am writing a HolyC parser in HolyC to complement the HCRT/LEXER.HC(which the compiler uses). So bugfixes in the current parser would be nice but it a new parser will be rolled out soon.
-
-
-# Internals
-Im glad you asked ;) . The compiler used to be written in C but now it is bootstrapping. I ditched makefiles to allow for a `filelist.tcsh` to tell `builder.tcsh` where the files are so it can put them in a chroot and build it that way (using `tcsh make.tcsh`).
-
-The lexer is mostly unmodified from TempleOS in `HCRT/LEXER.HC`. The real epic sauce of the Compiler is in `PARSER.HC` which provides a debugger,compiler and REPL. The parser is a recursive descent parser. `ParseStmt` and it's friends have a argument named `instant_eval` which tell the compiler to not look for a next symbol when parsing(Which is useful for the REPL).
-
-Error checking is mostly done in `AssignTypeToNode`. But other error checks can be found in the parser. `ParserFail` will immediately fail and flush the input,but `ParserFail2` will fail and display a diagnostic where the `AST` passed points to. Be sure to `CatchIf('Parser','Lexer')` in try blocks to recover from a bad parse(Not everything should be fatal). If you are really unlucky `CompileAST` will throw an exception,which (if it does),please create an issue. I will try to fix it.
-
-`CompileAST` is the bread and butter of the Compiler. A set of bindings for `myjit` in `ext/myjit` are provided for the Compiler. This library has been modified with bug fixes,relocations and bodacious debugging capacities (see `jit_debugger_get_reg_ptr` and `jit_debugger_get_vreg_ptr_from_parent` more on them later). `__CompileAST` is mostly a gaint switch statement with most of the AST types. `CompileAST` is the frontend to `__CompileAST`. It has a buddy named `CompileAstWithBreakpoint` which does the debugger magic. `Assign` does some lifting for the compiler too.
-
-And the debugger(and bounds checker) are here too. `DebuggerRoutine` is aliased to `Debugger`,but you will step out of it for epicness( as `Debugger` is a function ,TODO make `Debugger` secretly trigger the next breakpoint ). The breakpoints are stored in `Compiler.breakpoints` which contain `CBreakpoints` which are a specialization of `CHash`. The reason there are multiple breakpoints in `CBreakpoints.bps` is that a single line may have multiple breakpoints at one source location. `jit_FunctionParents` and `GetFunctionByPtr` are your friend when getting a backtrace. And `jit_ParentFramePtrs` is usefull for getting the base pointers of the callers for the debugger(use `jit_debugger_get_reg_ptr` get a spilled registers location for the current function,and `jit_debugger_get_vreg_ptr_from_parent` when you have the parent's base pointer).
+I will port the offical compiler to run under other OS'es using this compiler.
# Credits
- http://myjit.sourceforge.net/index.htm
diff --git a/REPL.VBIN b/REPL.VBIN
deleted file mode 100644
index 7e9b5a0..0000000
--- a/REPL.VBIN
+++ /dev/null
Binary files differ
diff --git a/REPL.WBIN b/REPL.WBIN
deleted file mode 100644
index 1088d3c..0000000
--- a/REPL.WBIN
+++ /dev/null
Binary files differ
diff --git a/TOSJMP.yasm b/TOSJMP.yasm
new file mode 100644
index 0000000..054a40f
--- /dev/null
+++ b/TOSJMP.yasm
@@ -0,0 +1,51 @@
+GLOBAL STK_HCSetJmp
+GLOBAL STK_HCLongJmp
+USE64
+SECTION .text
+;
+; Push dst ptr to stack then call
+STK_HCSetJmp:
+ MOV RAX, [RSP+8]
+ MOV [RAX],RAX
+ MOV [RAX+8],RBX
+ MOV [RAX+16],RCX
+ MOV [RAX+24],RDX
+ MOV [RAX+32],RSI
+ MOV [RAX+40],RDI
+ LEA RBX,[RSP+16] ;RSP BEFORE CALL
+ MOV [RAX+48],RBX
+ MOV [RAX+56],RBP
+ MOV [RAX+64],R8
+ MOV [RAX+72],R9
+ MOV [RAX+80],R10
+ MOV [RAX+88],R11
+ MOV [RAX+96],R12
+ MOV [RAX+112],R13
+ MOV [RAX+120],R15
+ MOV RBX, [RSP]
+ MOV [RAX+192],RBX
+ MOV [RAX+200],R14
+ MOV RAX,0
+ RET
+
+;
+; Push pad pointer to stack before calling
+;
+STK_HCLongJmp:
+ MOV RAX,[RSP+8]
+ MOV RBX,[RAX+8]
+ MOV RCX,[RAX+16]
+ MOV RDX,[RAX+24]
+ MOV RSI,[RAX+32]
+ MOV RSP,[RAX+48]
+ MOV RBP,[RAX+56]
+ MOV R8,[RAX+64]
+ MOV R9,[RAX+72]
+ MOV R10,[RAX+80]
+ MOV R11,[RAX+88]
+ MOV R12,[RAX+96]
+ MOV R13,[RAX+112]
+ MOV R14,[RAX+200]
+ MOV R15,[RAX+120]
+ MOV RDI,[RAX+40]
+ JMP [RAX+192]
diff --git a/VECTOR.HC b/VECTOR.HC
index b4af993..6b6397c 100755
--- a/VECTOR.HC
+++ b/VECTOR.HC
@@ -1,3 +1,5 @@
+#ifndef VECTOR_H
+#define VECTOR_H
class CVector {
I64 *data;
I64 cap,size;
@@ -20,7 +22,10 @@ U0 VectorPush(CVector *vec,I64 v) {
vec->data[vec->size++]=v;
}
I64 VectorPop(CVector *vec) {
- if(vec->size==0) throw('Vector');
+ if(vec->size==0) {
+ "%s",1323;
+ throw('Vector');
+ }
return vec->data[--vec->size];
}
U0 VectorAdd(CVector *vec,I64 v) {
@@ -34,3 +39,14 @@ U0 VectorAddAll(CVector *vec,CVector *vec2) {
while(--iter>=0)
VectorAdd(vec,vec2->data[iter]);
}
+U0 VectorRemove(CVector *vec,I64 v) {
+ I64 idx;
+ for(idx=0;idx<vec->size;) {
+ if(vec->data[idx]==v)
+ vec->data[idx]=VectorPop(vec);
+ else
+ idx++;
+ }
+}
+#endif
+
diff --git a/aot.c b/aot.c
index 469b574..5360d06 100755
--- a/aot.c
+++ b/aot.c
@@ -382,8 +382,21 @@ void LoadAOTBin(FILE *f,int flags,char **header) {
FillInRelocations(map_get(&Loader.symbols,key),-100);
}
if(aaMain)
- ((void(*)())aaMain->value_ptr)(0);
+ FFI_CALL_TOS_0(aaMain->value_ptr);
if(header)
*header=header_text;
else TD_FREE(header);
}
+char *GetAOTFunctionNameByPtr(void *ptr) {
+ map_iter_t iter=map_iter(&Loader.symbols);
+ const char *key;
+ CSymbol *sym;
+ while(key=map_next(&Loader.symbols,&iter)) {
+ sym=map_get(&Loader.symbols,key);
+ if(sym->type==SYM_FUNC) {
+ if(sym->value_ptr<=ptr&&sym->value_ptr+sym->size>=ptr)
+ return key;
+ }
+ }
+ return NULL;
+}
diff --git a/asmtest.hc b/asmtest.hc
deleted file mode 100644
index ca04026..0000000
--- a/asmtest.hc
+++ /dev/null
@@ -1,114 +0,0 @@
-U0 HelloWorld() {
- "HELLO WORLD\n";
-}
-U0 Pile() {
- asm {
- PUSH 0x7f;
- PUSH 0x7fff;
- PUSH 0x7ffff;
- //PUSH R12u16; //32bit only
- PUSH R12u32; //Weird
- PUSH R12u64;
- //PUSH I16 [R12]; //32bit only
- PUSH I32 [R12]; //Weird
- PUSH I64 [R12];
- //
- MOV AL, I8 [0x1122334455];
- MOV AX, I16 [0x1122334455];
- MOV EAX, I32 [0x1122334455];
- MOV I8 [0x1122334455],AL;
- MOV I16 [0x1122334455],AX;
- MOV I32 [0x1122334455], EAX;
- MOV R9u8, I8 [RBX+4*RCX];
- MOV R9u16, I16 [RBX+4*RCX];
- MOV R9u32, I32 [RBX+4*RCX];
- MOV R9u64, I64 [RAX+4*RDX];
- MOV I8 [RBX+4*RCX], R9u8;
- MOV I16 [RBX+4*RCX], R9u16;
- MOV I32 [RBX+4*RCX], R9u32;
- MOV I64 [RAX+4*RDX], R9u64;
- MOV R9u16, CS;
- MOV CS, R10u16;
- MOV R12u8,0xff;
- MOV R12u16,0x7fff;
- MOV R12u32,0x11223344;
- MOV R12,0x1122334455;
- MOV I8 [R12], 0xff;
- MOV I16 [R12], 0x7fff;
- MOV I32 [R12], 0x11223344;
- MOV I64 [R12], 0x11223344;
- ADC AL, 0xff;
- ADC AX, 0x7fff;
- ADC EAX, 0x11223344;
- ADC I8 [R13],0x7f;
- ADC I16 [R13],0x7fff;
- ADC I32 [R13],0x7ffff;
- ADC I64 [R13],0x7ffff;
- ADC I8 [R13],R13u8;
- ADC I16 [R13],R13u16;
- ADC I32 [R13],R13u32;
- ADC I64 [R13],R13;
- ADC R13u8, I8 [R13];
- ADC R13u16, I16 [R13];
- ADC R13u32, I32 [R13];
- ADC R13, I64 [R13];
- NOP;
- NOP2;
- CMOVC RAX,I64 [RAX];
- MOV R12,10
- loop:
- IMPORT Hello;
- MOV RAX, Hello;
- CALL RAX;
- DEC R12;
- CMP R12,0;
- JNE loop;
- MOV RAX, I64 GS:[RAX];
- };
-}
-class ABC{I64i a,b,c;};
-U0 Dummy() {
- ABC x={0,0,0};
- asm {
- LEA RSI,I64 &x[RBP+ABC.b];
- MOV RAX,10;
- MOV I64 [RSI],RAX;
- };
- "\n\n\n\n%d\n",x.b;
-}
-U0 Dummy2() {
- I64 x=10;
-asm {
- C_HELLO::
- PUSH R12;
- MOV R12,10;
- @@Loop:
- MOV RAX,&HelloWorld;
- CALL RAX;
- DEC R12;
- CMP R12,0;
- JNE @@Loop;
- en:
- JMP @@Loop;
- @@Loop: //useless
- POP R12;
-
- RET;
-};
- x+=10;
-}
-_import C_HELLO U0 Hi();
-Dummy;
-Hi;
-U0 Stat() {
- static I64 soop;
- asm {
- IMPORT soop;
- MOV RSI,soop;
- MOV RAX,101;
- MOV I64 [RSI],RAX;
- };
- return soop;
-}
-"%d\n",Stat;
-
diff --git a/debuggerAsm.yasm b/debuggerAsm.yasm
index 86f3481..6926f82 100755
--- a/debuggerAsm.yasm
+++ b/debuggerAsm.yasm
@@ -1,6 +1,4 @@
-GLOBAL jit_DebugggerHit;
-GLOBAL jit_FunctionParents;
-GLOBAL jit_ParentFramePtrs;
+GLOBAL JIT_DebuggerHit;
USE64
SECTION .text
;ctl+8+8+8+8
@@ -8,7 +6,7 @@ SECTION .text
;routine+8+8
;RET+8
;RBP+0
-jit_DebugggerHit: PUSH RBP
+JIT_DebuggerHit: PUSH RBP
MOV RBP,RSP
PUSH RBX
MOV RAX, [RBP+8]
@@ -17,14 +15,14 @@ MOV [RBX+16], RAX ;jit_debugger_ctrl.last_rip
POP RBX
MOV RAX,QWORD [RSP+8+8+8]
CMP BYTE [RAX],0
-JNE jit_DebugggerHit.enter
+JNE JIT_DebuggerHit.enter
;JIT_DBG_STEP is 1
;JIT_DBG_NEXT is 2
;JIT_DBG_FIN is 3
MOV RAX,QWORD [RSP+8+8+8+8]
CMP RAX,0
-JNE jit_DebugggerHit.step_check
-JMP jit_DebugggerHit.exit_lab
+JNE JIT_DebuggerHit.step_check
+JMP JIT_DebuggerHit.exit_lab
.enter ;
SUB RSP,256+8;Align to 16 bytes
MOV [RSP+8],RBX
@@ -40,20 +38,13 @@ MOV [RSP+80],R10
MOV [RSP+88],R11
MOV [RSP+96],R12
MOV [RSP+112],R13
-MOV [RSP+200],R14
-MOV [RSP+120],R15
-MOVSD [RSP+128],XMM0
-MOVSD [RSP+136],XMM1
-MOVSD [RSP+144],XMM2
-MOVSD [RSP+152],XMM3
-MOVSD [RSP+160],XMM4
-MOVSD [RSP+168],XMM5
-MOVSD [RSP+176],XMM6
-MOVSD [RSP+184],XMM7
-MOV RDI,RSP
-MOV RSI,QWORD [RSP+256+8+8+8+8]
-MOV RAX,QWORD [RSP+256+8+8+8] ;Routine
-MOV RDX,QWORD [RSP+256+8+8] ;Return address
+MOV [RSP+120],R14
+MOV [RSP+128],R15
+MOV RAX,RSP
+PUSH QWORD [RBP+8] ;Return address
+PUSH QWORD [RBP+8+8+8] ;breakpoint
+PUSH RAX ;Registers
+MOV RAX, [RBP+8+8] ;Routine
CALL RAX
MOV RAX,[RSP]
MOV RBX,[RSP+8]
@@ -67,18 +58,10 @@ MOV R10,[RSP+80]
MOV R11,[RSP+88]
MOV R12,[RSP+96]
MOV R13,[RSP+112]
-MOV R14,[RSP+200]
-MOV R15,[RSP+120]
-MOVSD XMM0,[RSP+128]
-MOVSD XMM1,[RSP+136]
-MOVSD XMM2,[RSP+144]
-MOVSD XMM3,[RSP+152]
-MOVSD XMM4,[RSP+160]
-MOVSD XMM5,[RSP+168]
-MOVSD XMM6,[RSP+176]
-MOVSD XMM7,[RSP+184]
+MOV R14,[RSP+120]
+MOV R15,[RSP+128]
ADD RSP,256+8
-.exit_lab POP RBP
+.exit_lab LEAVE
RET
.step_check
;JIT_DBG_STEP is 1
@@ -86,54 +69,21 @@ RET
;JIT_DBG_FIN is 3
MOV RAX, [RAX]
CMP RAX,1
-JE jit_DebugggerHit.enter
+JE JIT_DebuggerHit.enter
CMP RAX,2
-JNE jit_DebugggerHit.next
+JNE JIT_DebuggerHit.next
MOV RAX,QWORD [RSP+8+8+8+8]
MOV RAX,[RAX+8]
;Check if is equal or greater than previous stack pointer
CMP RAX,[RBP]
-JBE jit_DebugggerHit.enter
+JBE JIT_DebuggerHit.enter
.next
CMP RAX,3
-JNE jit_DebugggerHit.exit_lab
+JNE JIT_DebuggerHit.exit_lab
;Check if is greater than previous stack pointer
MOV RAX,QWORD [RSP+8+8+8+8]
MOV RAX,[RAX+8]
CMP RAX,[RBP]
-JB jit_DebugggerHit.enter
-JMP jit_DebugggerHit.exit_lab
-jit_FunctionParents:
-PUSH RBP
-MOV RBP,RSP
-MOV RDX,RBP
-MOV RCX,RSI
-.loop MOV RAX,[RDX+8]
-MOV [RDI],RAX
-ADD RDI,8
-MOV RDX,[RDX]
-CMP RDX,0
-JE jit_FunctionParents.end
-LOOP jit_FunctionParents.loop
-.end MOV RAX,RSI
-SUB RAX,RCX
-POP RBP
-RET
-jit_ParentFramePtrs:
-PUSH RBP
-MOV RBP,RSP
-MOV RDX,RBP
-MOV RCX,RSI
-.loop
-MOV RDX,[RDX]
-MOV [RDI],RDX
-ADD RDI,8
-CMP RDX,0
-JE jit_ParentFramePtrs.end
-LOOP jit_ParentFramePtrs.loop
-.end MOV RAX,RSI
-SUB RAX,RCX
-POP RBP
-RET
-
+JB JIT_DebuggerHit.enter
+JMP JIT_DebuggerHit.exit_lab
SECTION .data
diff --git a/exceptLin.yasm b/exceptLin.yasm
index e095c06..26679f9 100755
--- a/exceptLin.yasm
+++ b/exceptLin.yasm
@@ -18,18 +18,10 @@ HCSetJmp:
MOV [RDI+88],R11
MOV [RDI+96],R12
MOV [RDI+112],R13
- MOV [RDI+120],R15
- MOVSD [RDI+128],XMM0
- MOVSD [RDI+136],XMM1
- MOVSD [RDI+144],XMM2
- MOVSD [RDI+152],XMM3
- MOVSD [RDI+160],XMM4
- MOVSD [RDI+168],XMM5
- MOVSD [RDI+176],XMM6
- MOVSD [RDI+184],XMM7
+ MOV [RDI+120],R14
+ MOV [RDI+128],R15
MOV RAX, [RSP]
- MOV [RDI+192],RAX
- MOV [RDI+200],R14
+ MOV [RDI+136],RAX
MOV RAX,0
RET
@@ -47,16 +39,33 @@ HCLongJmp:
MOV R11,[RDI+88]
MOV R12,[RDI+96]
MOV R13,[RDI+112]
- MOV R14,[RDI+200]
- MOV R15,[RDI+120]
- MOVSD XMM0,[RDI+128]
- MOVSD XMM1,[RDI+136]
- MOVSD XMM2,[RDI+144]
- MOVSD XMM3,[RDI+152]
- MOVSD XMM4,[RDI+160]
- MOVSD XMM5,[RDI+168]
- MOVSD XMM6,[RDI+176]
- MOVSD XMM7,[RDI+184]
+ MOV R14,[RDI+120]
+ MOV R15,[RDI+128]
MOV RAX,RDI
MOV RDI,[RDI+40]
- JMP [RAX+192]
+ JMP [RAX+136]
+
+GLOBAL TOS_HCSetJmp
+TOS_HCSetJmp:
+ MOV RAX,[RSP+8]
+ MOV [RAX],RAX
+ MOV [RAX+8],RBX
+ MOV [RAX+16],RCX
+ MOV [RAX+24],RDX
+ MOV [RAX+32],RSI
+ MOV [RAX+40],RDI
+ LEA RBX,[RSP+8]; RSP BEFORE CALL
+ MOV [RAX+48],RBX;
+ MOV [RAX+56],RBP
+ MOV [RAX+64],R8
+ MOV [RAX+72],R9
+ MOV [RAX+80],R10
+ MOV [RAX+88],R11
+ MOV [RAX+96],R12
+ MOV [RAX+112],R13
+ MOV [RAX+120],R14
+ MOV [RAX+128],R15
+ MOV RBX, [RSP]
+ MOV [RAX+136],RBX
+ MOV RAX,0
+ RET
diff --git a/exceptTOS.yasm b/exceptTOS.yasm
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/exceptTOS.yasm
@@ -0,0 +1 @@
+
diff --git a/exceptWin.yasm b/exceptWin.yasm
index 6061f42..c214a4c 100755
--- a/exceptWin.yasm
+++ b/exceptWin.yasm
@@ -3,14 +3,13 @@ GLOBAL HCLongJmp
USE64
SECTION .text
HCSetJmp:
- PUSH RAX ; Align stack to 16
MOV [RCX],RAX
MOV [RCX+8],RBX
MOV [RCX+16],RCX
MOV [RCX+24],RDX
MOV [RCX+32],RSI
MOV [RCX+40],RDI
- LEA RAX,[RSP+16]
+ LEA RAX,[RSP+8]
MOV [RCX+48],RAX ;RSP BEFORE CALL
MOV [RCX+56],RBP
MOV [RCX+64],R8
@@ -19,29 +18,18 @@ HCSetJmp:
MOV [RCX+88],R11
MOV [RCX+96],R12
MOV [RCX+112],R13
- MOV [RCX+120],R15
- MOVSD [RCX+128],XMM0
- MOVSD [RCX+136],XMM1
- MOVSD [RCX+144],XMM2
- MOVSD [RCX+152],XMM3
- MOVSD [RCX+160],XMM4
- MOVSD [RCX+168],XMM5
- MOVSD [RCX+176],XMM6
- MOVSD [RCX+184],XMM7
- MOV RAX, [RSP+8]
- MOV [RCX+192],RAX
- MOV [RCX+200],R14
- POP RAX
+ MOV [RCX+120],R14
+ MOV [RCX+128],R15
+ MOV RAX, [RSP]
+ MOV [RCX+136],RAX
MOV RAX,0
RET
HCLongJmp:
MOV RAX,[RCX]
MOV RBX,[RCX+8]
- ;MOV RCX,[RCX+16] Do this later
MOV RDX,[RCX+24]
MOV RSI,[RCX+32]
- MOV RDI,[RCX+40]
MOV RSP,[RCX+48]
MOV RBP,[RCX+56]
MOV R8,[RCX+64]
@@ -50,15 +38,34 @@ HCLongJmp:
MOV R11,[RCX+88]
MOV R12,[RCX+96]
MOV R13,[RCX+112]
- MOV R14,[RCX+200]
- MOV R15,[RCX+120]
- MOVSD XMM0,[RCX+128]
- MOVSD XMM1,[RCX+136]
- MOVSD XMM2,[RCX+144]
- MOVSD XMM3,[RCX+152]
- MOVSD XMM4,[RCX+160]
- MOVSD XMM5,[RCX+168]
- MOVSD XMM6,[RCX+176]
- MOVSD XMM7,[RCX+184]
- MOV RAX,1
- JMP [RCX+192]
+ MOV R14,[RCX+120]
+ MOV R15,[RCX+128]
+ MOV RDI,[RCX+40]
+ MOV RAX,RCX
+ MOV RCX,[RAX+16]
+ JMP [RAX+136]
+
+GLOBAL TOS_HCSetJmp
+TOS_HCSetJmp:
+ MOV RAX,[RSP+8]
+ MOV [RAX],RAX
+ MOV [RAX+8],RBX
+ MOV [RAX+16],RCX
+ MOV [RAX+24],RDX
+ MOV [RAX+32],RSI
+ MOV [RAX+40],RDI
+ LEA RBX,[RSP+8]; RSP BEFORE CALL
+ MOV [RAX+48],RBX;
+ MOV [RAX+56],RBP
+ MOV [RAX+64],R8
+ MOV [RAX+72],R9
+ MOV [RAX+80],R10
+ MOV [RAX+88],R11
+ MOV [RAX+96],R12
+ MOV [RAX+112],R13
+ MOV [RAX+120],R14
+ MOV [RAX+128],R15
+ MOV RBX, [RSP]
+ MOV [RAX+136],RBX
+ MOV RAX,0
+ RET
diff --git a/ext/myjit/LICENSE b/ext/myjit/LICENSE
deleted file mode 100755
index 65c5ca8..0000000
--- a/ext/myjit/LICENSE
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/ext/myjit/Makefile b/ext/myjit/Makefile
deleted file mode 100755
index 0c50cca..0000000
--- a/ext/myjit/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-all: demo1 demo2 demo3 myjit-disassembler
-
-demo1: demo1.c jitlib-core.o
- $(CC) -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 demo1.c
- $(CC) -o demo1 -g -Wall -std=c99 -pedantic demo1.o jitlib-core.o -ldl
-
-demo2: demo2.c jitlib-core.o
- $(CC) -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 demo2.c
- $(CC) -o demo2 -g -Wall -std=c99 -pedantic demo2.o jitlib-core.o -ldl
-
-demo3: demo3.c jitlib-core.o
- $(CC) -O2 -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 demo3.c
- $(CC) -O2 -o demo3 -g -Wall -std=c99 -pedantic demo3.o jitlib-core.o -ldl
-
-debug: debug.c jitlib-core.o
- $(CC) -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 debug.c
- $(CC) -o debug -g -Wall -std=c99 -pedantic debug.o jitlib-core.o -ldl
-
-myjit-disassembler:
- $(MAKE) -C disasm
- ln -s disasm/myjit-disasm .
-
-
-
-
-jitlib-core.o: myjit/jitlib.h myjit/jitlib-core.h myjit/jitlib-core.c myjit/jitlib-debug.c myjit/x86-codegen.h myjit/x86-specific.h myjit/reg-allocator.h myjit/flow-analysis.h myjit/set.h myjit/amd64-specific.h myjit/amd64-codegen.h myjit/sparc-codegen.h myjit/sparc-specific.h myjit/llrb.c myjit/reg-allocator.h myjit/rmap.h myjit/cpu-detect.h myjit/x86-common-stuff.c myjit/common86-specific.h myjit/common86-codegen.h myjit/sse2-specific.h myjit/code-check.c
- $(CC) -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 myjit/jitlib-core.c
-
-clean:
- rm -f demo1
- rm -f demo2
- rm -f demo3
- rm -f debug
- rm -f *.o
- rm -f myjit-disasm
diff --git a/ext/myjit/README b/ext/myjit/README
deleted file mode 100755
index 6c569b5..0000000
--- a/ext/myjit/README
+++ /dev/null
@@ -1 +0,0 @@
-see doc/README, doc/readme.htm doc/readme.pdf
diff --git a/ext/myjit/demo1 b/ext/myjit/demo1
deleted file mode 100755
index dec7206..0000000
--- a/ext/myjit/demo1
+++ /dev/null
Binary files differ
diff --git a/ext/myjit/demo1.c b/ext/myjit/demo1.c
deleted file mode 100755
index 4930d25..0000000
--- a/ext/myjit/demo1.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-// include the header file
-#include "myjit/jitlib.h"
-
-// pointer to a function accepting one argument of type long and returning long value
-typedef long (* plfl)(long);
-
-int main()
-{
- // we create a new instance of a compiler
- struct jit * p = jit_init();
-
- plfl foo;
-
- // the code generated by the compiler will be assigned to the function `foo'
- jit_prolog(p, &foo);
-
- // the first argument of the function is signed number of size `long'
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- // moves the first argument into the register R(0)
- jit_getarg(p, R(0), 0);
-
- // takes the value in R(0), increments it by one, and stores the result into the
- // register R(1)
- jit_addi(p, R(1), R(0), 1);
-
- // returns from the function and returns the value in register R(1)
- jit_retr(p, R(1));
-
- // compiles the above defined code
- jit_generate_code(p);
-
- // if you are interested, you can dump the machine code
- jit_dump_ops(p, JIT_DEBUG_CODE);
-
- // check
- printf("Check #1: %li\n", foo(1));
- printf("Check #2: %li\n", foo(100));
- printf("Check #3: %li\n", foo(255));
-
- // cleanup
- jit_free(p);
- return 0;
-}
diff --git a/ext/myjit/demo2 b/ext/myjit/demo2
deleted file mode 100755
index 02e3e20..0000000
--- a/ext/myjit/demo2
+++ /dev/null
Binary files differ
diff --git a/ext/myjit/demo2.c b/ext/myjit/demo2.c
deleted file mode 100755
index c161f90..0000000
--- a/ext/myjit/demo2.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-// include the header file
-#include "myjit/jitlib.h"
-
-// pointer to a function accepting one argument of type long and returning long value
-typedef long (* plfl)(long);
-
-int main()
-{
- // we create a new instance of a compiler
- struct jit * p = jit_init();
-
- plfl factorial;
-
- // the code generated by the compiler will be assigned to the function `foo'
- jit_prolog(p, &factorial);
-
- // first argument of the function
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- // moves the first argument into the register R(0)
- jit_getarg(p, R(0), 0);
-
- // register R(1) serves as an accumulator
- jit_movi(p, R(1), 1);
-
- // here starts the loop
- jit_label * loop = jit_get_label(p);
-
- // if the value of R(0) is lesser or equal than 0,
- // jump to the line jit_patch(jit, o);
- // an example of the forward declaration
- jit_op * o = jit_blei(p, JIT_FORWARD, R(0), 0);
-
- // multiplies the value of R(1) by R(0) and stores the result into the register R(1)
- jit_mulr(p, R(1), R(1), R(0));
-
- // decrements the value of R(0) by one
- jit_subi(p, R(0), R(0), 1);
-
- // jumps to the beginning of the loop
- jit_jmpi(p, loop);
-
- jit_patch(p, o);
-
- // returns the factorial
- jit_retr(p, R(1));
-
- // compiles the above defined code
- jit_generate_code(p);
- jit_dump_ops(p, JIT_DEBUG_CODE);
-
- // check
- printf("Check #1: 1! = %li\n", factorial(1));
- printf("Check #2: 5! = %li\n", factorial(5));
- printf("Check #3: 6! = %li\n", factorial(6));
-
- // cleanup
- jit_free(p);
- return 0;
-}
diff --git a/ext/myjit/demo3 b/ext/myjit/demo3
deleted file mode 100755
index 74227bc..0000000
--- a/ext/myjit/demo3
+++ /dev/null
Binary files differ
diff --git a/ext/myjit/demo3.c b/ext/myjit/demo3.c
deleted file mode 100755
index a4edb29..0000000
--- a/ext/myjit/demo3.c
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-// include the header file
-#include "myjit/jitlib.h"
-
-// pointer to a function accepting one argument of type unsigned short and returning long value
-typedef long (* plfus)(unsigned short);
-
-int main()
-{
- // we create a new instance of a compiler
- struct jit * p = jit_init();
-
- plfus fib;
-
- // label of the same function
- jit_label * fibfn = jit_get_label(p);
-
- // the code generated by the compiler will be assigned to the function `foo'
- jit_prolog(p, &fib);
-
- // the first argument of the fucntion is `unsigned short' number
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(short));
-
- // moves the first argument into the register R(0)
- jit_getarg(p, R(0), 0);
-
- jit_op * zero = jit_beqi(p, JIT_FORWARD, R(0), 0);
- jit_op * one = jit_beqi(p, JIT_FORWARD, R(0), 1);
-
- // calls the fib. function with the first argument having value R(0) - 1
- jit_subi(p, R(0), R(0), 1);
-
- // prepares function call
- jit_prepare(p);
-
- // passes an argument
- jit_putargr(p, R(0));
-
- // calls the functions
- jit_call(p, fibfn);
-
- // stores the result into R(1)
- jit_retval(p, R(1));
-
- // another call of fib. function
- jit_subi(p, R(0), R(0), 1);
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_call(p, fibfn);
-
- // stores the result into R(2)
- jit_retval(p, R(2));
-
- // sums values in R(1) and R(2)
- jit_addr(p, R(1), R(1), R(2));
-
- // jump to return
- jit_op * ret1 = jit_jmpi(p, JIT_FORWARD);
-
- // returns 0
- jit_patch(p, zero);
- jit_movi(p, R(1), 0);
- jit_op * ret2 = jit_jmpi(p, JIT_FORWARD);
-
-
- // returns 1
- jit_patch(p, one);
- jit_movi(p, R(1), 1);
-
-
- jit_patch(p, ret1);
- jit_patch(p, ret2);
-
- // returns the fibonacci number
- jit_retr(p, R(1));
-
- // compiles the above defined code
- jit_generate_code(p);
-
- // if you are interested, you can dump the machine code
- //jit_dump_ops(p, JIT_DEBUG_CODE);
-
- // or you can inspect how each operation is transformed
- // into a machine code
- jit_dump_ops(p, JIT_DEBUG_COMBINED);
-
- // check
- printf("Check #1: fib(1) = %li\n", fib(1));
- printf("Check #2: fib(5) = %li\n", fib(5));
- printf("Check #3: fib(30) = %li\n", fib(30));
-
- // cleanup
- jit_free(p);
- return 0;
-}
diff --git a/ext/myjit/disasm/Makefile b/ext/myjit/disasm/Makefile
deleted file mode 100755
index ab9c888..0000000
--- a/ext/myjit/disasm/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-all: myjit-disasm
-
-export CFLAGS = -g -std=c99 -Wall -pedantic -D_XOPEN_SOURCE=600 -O2
-
-myjit-disasm: myjit-disasm.o io.o udis86/decode.o udis86/itab.o udis86/syn.o udis86/syn-att.o udis86/syn-intel.o udis86/udis86.o sparc/sparc-dis.o
- $(MAKE) -C udis86
- $(MAKE) -C sparc
- $(CC) $(CFLAGS) -o myjit-disasm udis86/decode.o udis86/itab.o udis86/syn.o udis86/syn-att.o udis86/syn-intel.o udis86/udis86.o sparc/sparc-dis.o myjit-disasm.o io.o
-
-myjit-disasm.o: myjit-disasm.c
- $(CC) $(CFLAGS) -c myjit-disasm.c
-
-io.o: io.c io.h
- $(CC) $(CFLAGS) -c io.c
-
-clean:
- rm -f myjit-disasm
- rm -f *.o
- rm -f udis86/*.o
- rm -f sparc/*.o
diff --git a/ext/myjit/disasm/io.c b/ext/myjit/disasm/io.c
deleted file mode 100755
index 8d26c5a..0000000
--- a/ext/myjit/disasm/io.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * MyJIT Disassembler
- *
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "io.h"
-
-static unsigned char *ibuf;
-static int ibuf_capacity = 16;
-static int ibuf_size = 0;
-
-void output_color_normal()
-{
- printf("\033[0m");
-}
-
-void output_color_white()
-{
- printf("\033[1;37m");
-}
-
-void output_color_yellow()
-{
- printf("\033[0;33m");
-}
-
-void output_color_cyan()
-{
- printf("\033[1;36m");
-}
-
-static int output_print_bytes(unsigned char *data, int size)
-{
- int out = 0;
- for (int i = 0; (i < size) && (i < OUTPUT_BYTES_PER_LINE); i++) {
- printf("%02x ", data[i]);
- out++;
- }
- if (out < OUTPUT_BYTES_PER_LINE) {
- for (int i = out; i < OUTPUT_BYTES_PER_LINE; i++)
- printf(" ");
- }
- return out;
-}
-
-void output_code(unsigned long addr, unsigned char *data, int size, char *text)
-{
- printf(" %04lx: ", addr & 0xffff);
- int out = output_print_bytes(data, size);
- printf(" %s\n", text);
- while (out < size) {
- printf(" ");
- data += out;
- out += output_print_bytes(data, size - out);
- printf("\n");
- }
-}
-
-void input_init()
-{
- ibuf = malloc(ibuf_capacity);
-}
-
-void input_free()
-{
- free(ibuf);
-}
-
-void input_clear()
-{
- ibuf_size = 0;
-}
-
-unsigned char *input_buffer()
-{
- return ibuf;
-}
-
-int input_size()
-{
- return ibuf_size;
-}
-
-static inline void input_putchar(char c)
-{
- if ((ibuf_size + 1) == ibuf_capacity) {
- ibuf_capacity *= 2;
- ibuf = realloc(ibuf, ibuf_capacity);
- }
- ibuf[ibuf_size++] = c;
-}
-
-int input_read()
-{
- while (!feof(stdin)) {
- char c = getchar();
- if ((c == EOF) || (c == '\r') || (c == '\n')) break;
- input_putchar(c);
- }
- input_putchar('\0');
- if (!feof(stdin)) return 1;
- else return 0;
-}
-
-void input_convert()
-{
- int len = ibuf_size - 1;
- char clearbuf[len];
- int j = 0;
- for (int i = 0; i < len; i++) {
- char c = tolower(ibuf[i]);
- if ((c >= '0') && (c <= '9')) clearbuf[j++] = c - '0';
- if ((c >= 'a') && (c <= 'f')) clearbuf[j++] = c - 'a' + 10;
- }
- for (int i = 0; i < (j / 2); i++)
- ibuf[i] = clearbuf[i * 2] * 16 + clearbuf[i * 2 + 1];
- ibuf_size = j / 2;
-}
diff --git a/ext/myjit/disasm/io.h b/ext/myjit/disasm/io.h
deleted file mode 100755
index 2c316ce..0000000
--- a/ext/myjit/disasm/io.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * MyJIT Disassembler
- *
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define OUTPUT_BYTES_PER_LINE (8)
-
-void output_color_normal();
-void output_color_white();
-void output_color_yellow();
-void output_color_cyan();
-void output_code(unsigned long addr, unsigned char *data, int size, char *text);
-
-void input_init();
-void input_free();
-void input_clear();
-unsigned char *input_buffer();
-int input_size();
-int input_read();
-void input_convert();
diff --git a/ext/myjit/disasm/myjit-disasm b/ext/myjit/disasm/myjit-disasm
deleted file mode 100755
index 26974c1..0000000
--- a/ext/myjit/disasm/myjit-disasm
+++ /dev/null
Binary files differ
diff --git a/ext/myjit/disasm/myjit-disasm.c b/ext/myjit/disasm/myjit-disasm.c
deleted file mode 100755
index b472ba7..0000000
--- a/ext/myjit/disasm/myjit-disasm.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * MyJIT Disassembler
- *
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "io.h"
-
-#include "udis86/udis86.h"
-#include "sparc/sparc-dis.h"
-
-unsigned long global_addr;
-
-enum {
- AMD64,
- I386,
- SPARC,
- DATA,
- TEXT,
- COMMENT
-} global_disassm_mode = DATA;
-
-ud_t dis_amd64;
-ud_t dis_i386;
-spd_t dis_sparc;
-
-void disassm_amd64(unsigned char *buf, int len)
-{
- ud_set_input_buffer(&dis_amd64, buf, len);
- while (ud_disassemble(&dis_amd64)) {
- int len = ud_insn_len(&dis_amd64);
- output_code(global_addr, buf, len, (char *)ud_insn_asm(&dis_amd64));
- buf += len;
- global_addr += len;
- }
-}
-
-void disassm_i386(unsigned char *buf, int len)
-{
- ud_set_input_buffer(&dis_i386, buf, len);
- while (ud_disassemble(&dis_i386)) {
- int len = ud_insn_len(&dis_i386);
- output_code(global_addr, buf, len, (char *)ud_insn_asm(&dis_i386));
- buf += len;
- global_addr += len;
- }
-}
-
-void disassm_text(unsigned char *buf, int len)
-{
- output_color_white();
- for (int i = 0; i < len; i++)
- putchar(buf[i]);
- output_color_normal();
- printf("\n");
-}
-
-void disassm_comment(unsigned char *buf, int len)
-{
- output_color_cyan();
- for (int i = 0; i < len; i++)
- putchar(buf[i]);
- output_color_normal();
- printf("\n");
-}
-
-void disassm_data(unsigned char *buf, int len)
-{
- output_color_yellow();
- do {
- int out = 0;
- char text[OUTPUT_BYTES_PER_LINE + 1];
- for (int i = 0; i < OUTPUT_BYTES_PER_LINE; i++) {
- if (i < len) {
- out++;
- text[i] = (buf[i] < 32 ? '.' : buf[i]);
- }
- }
- text[out] = '\0';
- output_code(global_addr, buf, out, text);
-
- global_addr += out;
- buf += out;
- len -= out;
- } while (len > 0);
- output_color_normal();
-}
-
-void disassm_sparc(unsigned char *buf, int len)
-{
-/*
- while (len > 0) {
- output_code(global_addr, buf, 4, "not yet supported");
- buf += 4;
- global_addr += 4;
- len -= 4;
- }
- */
- spd_set_input_buffer(&dis_sparc, buf, len);
- while (spd_disassemble(&dis_sparc)) {
- int len = 4;
- output_code(global_addr, buf, len, (char *)spd_insn_asm(&dis_sparc));
- buf += len;
- global_addr += len;
- }
-
-}
-
-void disassm_directive(unsigned char *buf)
-{
- const char *xbuf = (const char *)buf;
- if (!strcmp(xbuf, ".text")) global_disassm_mode = TEXT;
- else if (!strcmp(xbuf, ".data")) global_disassm_mode = DATA;
- else if (!strcmp(xbuf, ".comment")) global_disassm_mode = COMMENT;
- else if (!strcmp(xbuf, ".amd64")) global_disassm_mode = AMD64;
- else if (!strcmp(xbuf, ".i386")) global_disassm_mode = I386;
- else if (!strcmp(xbuf, ".sparc")) global_disassm_mode = SPARC;
- else if (!strncmp(xbuf, ".addr=", 6)) {
- global_addr = strtol(xbuf + 6, NULL, 16);
- ud_set_pc(&dis_amd64, global_addr);
- ud_set_pc(&dis_i386, global_addr);
- spd_set_pc(&dis_sparc, global_addr);
- if (sizeof(void *) == 8) printf("%016lx:\n", global_addr);
- else printf("%016lx:\n", global_addr);
- }
- else if (!strcmp(xbuf, ".nl")) printf("\n");
- else printf("Unknown directive: %s\n", buf);
-}
-
-int main()
-{
- ud_init(&dis_i386);
- ud_init(&dis_amd64);
- ud_set_mode(&dis_i386, 32);
- ud_set_mode(&dis_amd64, 64);
- ud_set_syntax(&dis_i386, UD_SYN_INTEL);
- ud_set_syntax(&dis_amd64, UD_SYN_INTEL);
-
- spd_init(&dis_sparc);
-
- global_addr = 0x0;
- input_init();
-
- int input;
- do {
- input = input_read();
- if (input_size() - 1 > 0) {
- if (input_buffer()[0] == '.') disassm_directive(input_buffer());
- else {
- if ((global_disassm_mode != TEXT) && (global_disassm_mode != COMMENT)) input_convert();
- switch (global_disassm_mode) {
- case DATA: disassm_data(input_buffer(), input_size()); break;
- case TEXT: disassm_text(input_buffer(), input_size() - 1); break;
- case COMMENT: disassm_comment(input_buffer(), input_size() - 1); break;
- case AMD64: disassm_amd64(input_buffer(), input_size()); break;
- case I386: disassm_i386(input_buffer(), input_size()); break;
- case SPARC: disassm_sparc(input_buffer(), input_size()); break;
- }
- }
- }
- input_clear();
- } while (input);
- input_free();
- return 0;
-}
diff --git a/ext/myjit/disasm/sparc/Makefile b/ext/myjit/disasm/sparc/Makefile
deleted file mode 100755
index 99baa27..0000000
--- a/ext/myjit/disasm/sparc/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-all: sparc-dis.o
-
-#CFLAGS = -g -std=c99 -Wall -pedantic -D_XOPEN_SOURCE=600
-
-sparc-dis.o: sparc-dis.c sparc-dis.h
- $(CC) $(CFLAGS) -c sparc-dis.c
-
-clean:
- rm -f *.o
diff --git a/ext/myjit/disasm/sparc/sparc-dis.c b/ext/myjit/disasm/sparc/sparc-dis.c
deleted file mode 100755
index 7eaeee5..0000000
--- a/ext/myjit/disasm/sparc/sparc-dis.c
+++ /dev/null
@@ -1,568 +0,0 @@
-/*
- * MyJIT Disassembler
- *
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdarg.h>
-
-#include "sparc-dis.h"
-
-#define ABS(x) ((x) < 0 ? - (x) : x)
-
-#define SPARC_G0 (0)
-#define SPARC_O7 (15)
-#define SPARC_I7 (31)
-
-#define sparc_inst_op(inst) ((inst) >> 30)
-#define sparc_inst_op2(inst) (((inst) >> 22) & 0x7)
-#define sparc_inst_rd(inst) (((inst) >> 25) & 0x1f)
-#define sparc_inst_op3(inst) (((inst) >> 19) & 0x3f)
-#define sparc_inst_i(inst) (((inst) >> 13) & 0x1)
-#define sparc_inst_rs1(inst) (((inst) >> 14) & 0x1f)
-#define sparc_inst_rs2(inst) (((inst) >> 0) & 0x1f)
-#define sparc_inst_imm(inst) (((inst) >> 13) & 0x1)
-#define sparc_inst_imm11(inst) (((inst) >> 0) & 0x7ff)
-#define sparc_inst_imm13(inst) (((inst) >> 0) & 0x1fff)
-#define sparc_inst_imm22(inst) (((inst) >> 0) & 0x3fffff)
-#define sparc_inst_imm30(inst) (((inst) >> 0) & 0x3fffffff)
-#define sparc_inst_cond(inst) (((inst) >> 25) & 0xf)
-#define sparc_inst_a(inst) (((inst) >> 29) & 0x1)
-#define sparc_inst_opf(inst) (((inst) >> 5) & 0x1ff)
-#define sparc_inst_cond_format4(inst) (((inst) >> 14) & 0xf)
-
-typedef struct {
- int opc;
- void (*print_fn)(spd_t *, char *op_name, int is_imm, int rd, int rs1, int rs2, int simm13);
- char *op_name;
-} format3;
-
-#define DEFINE_FORMAT(_fmt_name) \
-static void _fmt_name(spd_t *dis, char *op_name, int is_imm, int rd, int rs1, int rs2, int simm13)
-
-#define NAME spd_out_name(dis, op_name);
-#define OPNAME(_x) spd_out_name(dis, (_x));
-#define REG(_r) spd_out_reg(dis, (_r));
-#define FREG(_r) spd_out_freg(dis, (_r));
-#define COMMA spd_out_comma(dis);
-#define MEM do { \
- if (is_imm) spd_out_mem_imm(dis, rs1, simm13); \
- else spd_out_mem_reg(dis, rs1, rs2);\
-} while(0);
-
-#define REG_OR_SIMM13 do { \
- if (is_imm) spd_out_simm(dis, simm13); \
- else spd_out_reg(dis, rs2); \
-} while(0);
-
-#define REG_OR_IMM13 do { \
- if (is_imm) spd_out_imm(dis, simm13); \
- else spd_out_reg(dis, rs2); \
-} while(0);
-
-
-#define INDIRECT_ADDR13 do{ \
- if (is_imm) spd_out_indirect_addr_imm(dis, rs1, simm13); \
- else spd_out_indirect_addr_reg(dis, rs1, rs2); \
-} while(0);
-
-static inline int sign_ext(int bits, int value)
-{
- if (value & (1 << (bits - 1))) return value | (-1 << (bits - 1));
- return value;
-}
-
-/*
- *
- * Output functions
- *
- */
-static int spd_out_printf(char *buf, const char *format, ...) {
- va_list ap;
- va_start(ap, format);
- int result = vsprintf(buf + strlen(buf), format, ap);
- va_end(ap);
- return result;
-}
-
-static void spd_out_name(spd_t *dis, char *opname)
-{
- memcpy(dis->out, opname, strlen(opname) + 1);
- strcat(dis->out, " ");
-}
-
-static void spd_out_addr(spd_t *dis, int addr)
-{
- spd_out_printf(dis->out, "%x <pc %s %i>",
- dis->pc + addr,
- addr < 0 ? "-" : "+",
- ABS(addr));
-}
-
-static void spd_out_comma(spd_t *dis)
-{
- strcat(dis->out, ", ");
-}
-
-static void spd_out_reg(spd_t *dis, int reg)
-{
- static char *regs[] = {
- "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
- "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",
- "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
- "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7"
- };
-
- strcat(dis->out, "%");
- strcat(dis->out, regs[reg]);
-}
-
-static void spd_out_imm(spd_t *dis, int imm)
-{
- spd_out_printf(dis->out, "0x%x", imm & 0x1ff);
-}
-
-static void spd_out_simm(spd_t *dis, int simm)
-{
- spd_out_printf(dis->out, "%i", simm);
-}
-
-static void spd_out_freg(spd_t *dis, int freg)
-{
- strcat(dis->out,"%");
- spd_out_printf(dis->out, "f%i", freg);
-}
-
-static void spd_out_indirect_addr_reg(spd_t *dis, int reg1, int reg2)
-{
- if (reg1 && reg2) {
- spd_out_reg(dis, reg1);
- strcat(dis->out, " + ");
- spd_out_reg(dis, reg2);
- } else if (reg1) spd_out_reg(dis, reg1);
- else spd_out_reg(dis, reg2);
-}
-
-static void spd_out_indirect_addr_imm(spd_t *dis, int reg1, int imm)
-{
- spd_out_reg(dis, reg1);
- if (imm > 0) {
- strcat(dis->out, " + ");
- spd_out_printf(dis->out, "%i", imm);
- }
- if (imm < 0) {
- strcat(dis->out, " - ");
- spd_out_printf(dis->out, "%i", -imm);
- }
-}
-
-
-static void spd_out_mem_reg(spd_t *dis, int reg1, int reg2)
-{
- strcat(dis->out, "[ ");
- spd_out_indirect_addr_reg(dis, reg1, reg2);
- strcat(dis->out, " ]");
-}
-
-static void spd_out_mem_imm(spd_t *dis, int reg1, int imm)
-{
- strcat(dis->out, "[ ");
- spd_out_indirect_addr_imm(dis, reg1, imm);
- strcat(dis->out, " ]");
-}
-
-/*
- *
- * Decoding
- *
- */
-
-static void decode_format1(spd_t *dis, uint32_t insn)
-{
- spd_out_name(dis, "call");
- spd_out_addr(dis, sparc_inst_imm30(insn) << 2);
-}
-
-static void decode_format2(spd_t *dis, uint32_t insn)
-{
-
- static char *bops[] = { "bn", "be", "ble", "bl", "bleu", "bcs", "bneg", "bvs",
- "ba", "bne", "bg", "bge", "bgu", "bcc", "bpos", "bvc" };
-
- static char *bfops[] = { "fbn", "fbne", "fblg", "fbul", "fbl", "fbug", "fbg", "fbu",
- "fba", "fbe", "fbue", "fbge", "fbuge", "fble", "fbule", "fbo" };
-
- int rd = sparc_inst_rd(insn);
- int op2 = sparc_inst_op2(insn);
- int imm22 = sparc_inst_imm22(insn);
- if (op2 == 0x04) {
- if (rd) {
- spd_out_name(dis, "sethi ");
- spd_out_printf(dis->out, "%%hi(0x%x)", imm22 << 10);
- spd_out_comma(dis);
- spd_out_reg(dis, rd);
- } else {
- spd_out_name(dis, "nop");
- }
- return;
- }
-
- if ((op2 == 0x02) || (op2 == 0x06)) {
-
- if (op2 == 0x02) spd_out_name(dis, bops[sparc_inst_cond(insn)]);
- if (op2 == 0x06) spd_out_name(dis, bfops[sparc_inst_cond(insn)]);
-
- if (sparc_inst_a(insn)) strcat(dis->out + strlen(dis->out) - 1, ",a ");
- spd_out_addr(dis, sign_ext(22, imm22) * 4);
- }
-}
-
-
-static void decode_format4(spd_t *dis, uint32_t insn)
-{
- static char *movops[] = { "movn", "move", "movle", "movl", "movleu", "movcs", "movneg", "movvs",
- "mova", "movne", "movg", "movge", "movgu", "movcc", "movpos", "movvc" };
-
- int rd = sparc_inst_rd(insn);
- int rs2 = sparc_inst_rs2(insn);
- int op3 = sparc_inst_op3(insn);
- int simm11 = sign_ext(11, sparc_inst_imm11(insn));
- int is_imm = sparc_inst_i(insn);
-
- if (op3 != 0x2c) return;
-
- spd_out_name(dis, movops[sparc_inst_cond_format4(insn)]);
-
- if (is_imm) spd_out_simm(dis, simm11);
- else spd_out_reg(dis, rs2);
-
- spd_out_comma(dis);
- spd_out_reg(dis, rd);
-}
-
-static int decode_synthetic_3_11(spd_t *dis, int op3, int is_imm, int rd, int rs1, int rs2, int simm13)
-{
- if (rd == SPARC_G0) {
- switch (op3) {
- case 0x04: OPNAME("clr"); MEM; return 1;
- case 0x05: OPNAME("clrb"); MEM; return 1;
- case 0x06: OPNAME("clrh"); MEM; return 1;
- }
- }
- return 0;
-}
-
-static int decode_synthetic_3_10(spd_t *dis, int op3, int is_imm, int rd, int rs1, int rs2, int simm13)
-{
- if ((op3 == 0x14 /* subcc */) && (rd == SPARC_G0)) { OPNAME("cmp") REG(rs1) COMMA REG_OR_SIMM13; return 1; }
- if ((op3 == 0x12 /* orcc */) && !is_imm && (rd == SPARC_G0) && (rs1 == SPARC_G0)) { OPNAME("tst"); REG(rs2); return 1; }
- if ((op3 == 0x07 /* xnor */) && !is_imm && (rs2 == SPARC_G0)) {
- OPNAME("not");
- if (rs1 != rd) { REG(rs1) COMMA };
- REG(rd);
- return 1;
- }
-
- if ((op3 == 0x04 /* sub */) && !is_imm && (rs2 == SPARC_G0)) {
- OPNAME("neg");
- if (rs1 != rd) { REG(rs1) COMMA };
- REG(rd);
- return 1;
- }
-
-
- if ((op3 == 0x02 /* or */) && !is_imm && (rs1 == SPARC_G0) && (rs2 == SPARC_G0)) { OPNAME("clr") REG(rd); return 1; };
- if ((op3 == 0x02 /* or */) && (rs1 == SPARC_G0)) { OPNAME("mov") REG_OR_SIMM13 COMMA REG(rd); return 1; };
-
- if ((rs1 == rd) && (is_imm)) {
- int match = 0;
- switch (op3) {
- case 0x00: OPNAME("inc"); match = 1; break;
- case 0x10: OPNAME("inccc"); match = 1; break;
- case 0x04: OPNAME("dec"); match = 1; break;
- case 0x14: OPNAME("deccc"); match = 1; break;
- }
- if (match) {
- if (simm13 != 1) {
- spd_out_simm(dis, simm13);
- spd_out_comma(dis);
- }
-
- REG(rd);
- return 1;
- }
- }
-
- if ((op3 == 0x3d /*restore */) && (!is_imm) && (rd == SPARC_G0) && (rs1 == SPARC_G0) && (rs2 == SPARC_G0)) {
- OPNAME("restore");
- return 1;
- }
-
- if ((op3 == 0x38 /* jmpl */) && (rd == SPARC_G0)) {
- if (is_imm && (simm13 == 8)) {
- if (rs1 == SPARC_I7) { OPNAME("ret"); return 1; }
- if (rs1 == SPARC_O7) { OPNAME("retl"); return 1; }
- }
- OPNAME("jmp"); INDIRECT_ADDR13;
- return 1;
- }
-
- if ((op3 == 0x38 /* jmpl */) && (rd == SPARC_O7)) { OPNAME("call"); INDIRECT_ADDR13; return 1; }
-
-
- if ((op3 == 0x28 /* rd */) && (rs1 == SPARC_G0)) {
- OPNAME("rd");
- strcat(dis->out, "%y");
- COMMA;
- REG(rd);
- return 1;
- }
-
- if ((op3 == 0x30 /* wr */) && (rd == SPARC_G0)) {
- OPNAME("wr");
- REG(rs1);
- COMMA;
- REG_OR_IMM13;
- COMMA;
- strcat(dis->out, "%y");
- return 1;
- }
-
-
- return 0;
-}
-
-DEFINE_FORMAT(fmt_load) { NAME MEM COMMA REG(rd) }
-DEFINE_FORMAT(fmt_load_float) { NAME MEM COMMA FREG(rd) }
-DEFINE_FORMAT(fmt_store) { NAME REG(rd) COMMA MEM }
-DEFINE_FORMAT(fmt_store_float) { NAME FREG(rd) COMMA MEM }
-DEFINE_FORMAT(fmt_logic) { NAME REG(rs1) COMMA REG_OR_IMM13 COMMA REG(rd) }
-DEFINE_FORMAT(fmt_arithmetics) { NAME REG(rs1) COMMA REG_OR_SIMM13 COMMA REG(rd) }
-DEFINE_FORMAT(fmt_jmpl) { NAME INDIRECT_ADDR13 COMMA REG(rd) }
-DEFINE_FORMAT(fmt_fcmp) { NAME FREG(rs1) COMMA FREG(rs2) }
-DEFINE_FORMAT(fmt_fop2) { NAME FREG(rs2) COMMA FREG(rd) }
-DEFINE_FORMAT(fmt_fop3) { NAME FREG(rs1) COMMA FREG(rs2) COMMA FREG(rd) }
-
-static format3 opcodes_3_11[] = {
- { .opc = 0x00, .print_fn = fmt_load, .op_name = "ld" },
- { .opc = 0x01, .print_fn = fmt_load, .op_name = "ldub" },
- { .opc = 0x02, .print_fn = fmt_load, .op_name = "lduh" },
- { .opc = 0x03, .print_fn = fmt_load, .op_name = "ldd" },
- { .opc = 0x09, .print_fn = fmt_load, .op_name = "ldsb" },
- { .opc = 0x0a, .print_fn = fmt_load, .op_name = "ldsh" },
- { .opc = 0x04, .print_fn = fmt_store, .op_name = "st" },
- { .opc = 0x05, .print_fn = fmt_store, .op_name = "stb" },
- { .opc = 0x06, .print_fn = fmt_store, .op_name = "sth" },
- { .opc = 0x07, .print_fn = fmt_store, .op_name = "std" },
- { .opc = 0x20, .print_fn = fmt_load_float, .op_name = "ldf" },
- { .opc = 0x23, .print_fn = fmt_load_float, .op_name = "lddf" },
- { .opc = 0x24, .print_fn = fmt_store_float, .op_name = "stf" },
- { .opc = 0x27, .print_fn = fmt_store_float, .op_name = "stdf" },
-};
-
-static format3 opcodes_3_10[] = {
- { .opc = 0x01, .print_fn = fmt_logic, .op_name = "and" },
- { .opc = 0x11, .print_fn = fmt_logic, .op_name = "andcc" },
- { .opc = 0x05, .print_fn = fmt_logic, .op_name = "andn" },
- { .opc = 0x15, .print_fn = fmt_logic, .op_name = "andncc" },
- { .opc = 0x02, .print_fn = fmt_logic, .op_name = "or" },
- { .opc = 0x12, .print_fn = fmt_logic, .op_name = "orcc" },
- { .opc = 0x16, .print_fn = fmt_logic, .op_name = "orn" },
- { .opc = 0x03, .print_fn = fmt_logic, .op_name = "xor" },
- { .opc = 0x13, .print_fn = fmt_logic, .op_name = "xorcc" },
- { .opc = 0x07, .print_fn = fmt_logic, .op_name = "xnor" },
- { .opc = 0x17, .print_fn = fmt_logic, .op_name = "xnorcc" },
- { .opc = 0x25, .print_fn = fmt_arithmetics, .op_name = "sll" },
- { .opc = 0x26, .print_fn = fmt_arithmetics, .op_name = "srl" },
- { .opc = 0x27, .print_fn = fmt_arithmetics, .op_name = "sra" },
-
- { .opc = 0x00, .print_fn = fmt_arithmetics, .op_name = "add" },
- { .opc = 0x10, .print_fn = fmt_arithmetics, .op_name = "addcc" },
- { .opc = 0x08, .print_fn = fmt_arithmetics, .op_name = "addx" },
- { .opc = 0x18, .print_fn = fmt_arithmetics, .op_name = "addxcc" },
-
- { .opc = 0x04, .print_fn = fmt_arithmetics, .op_name = "sub" },
- { .opc = 0x14, .print_fn = fmt_arithmetics, .op_name = "subcc" },
- { .opc = 0x0c, .print_fn = fmt_arithmetics, .op_name = "subx" },
- { .opc = 0x1c, .print_fn = fmt_arithmetics, .op_name = "subxcc" },
-
- { .opc = 0x0a, .print_fn = fmt_arithmetics, .op_name = "umul" },
- { .opc = 0x0b, .print_fn = fmt_arithmetics, .op_name = "smul" },
- { .opc = 0x1a, .print_fn = fmt_arithmetics, .op_name = "umulcc" },
- { .opc = 0x1b, .print_fn = fmt_arithmetics, .op_name = "smulcc" },
-
- { .opc = 0x0e, .print_fn = fmt_arithmetics, .op_name = "udiv" },
- { .opc = 0x0f, .print_fn = fmt_arithmetics, .op_name = "sdiv" },
- { .opc = 0x1e, .print_fn = fmt_arithmetics, .op_name = "udivcc" },
- { .opc = 0x1f, .print_fn = fmt_arithmetics, .op_name = "sdivcc" },
-
- { .opc = 0x3c, .print_fn = fmt_arithmetics, .op_name = "save" },
- { .opc = 0x3d, .print_fn = fmt_arithmetics, .op_name = "restore" },
-
- { .opc = 0x38, .print_fn = fmt_jmpl, .op_name = "jmpl" },
-};
-
-static format3 opcodes_3fop[] = {
- /* fop1 format */
- { .opc = 196, .print_fn = fmt_fop2, .op_name = "fitos" },
- { .opc = 200, .print_fn = fmt_fop2, .op_name = "fitod" },
- { .opc = 204, .print_fn = fmt_fop2, .op_name = "fitoq" },
- { .opc = 132, .print_fn = fmt_fop2, .op_name = "fxtos" },
- { .opc = 136, .print_fn = fmt_fop2, .op_name = "fxtod" },
- { .opc = 140, .print_fn = fmt_fop2, .op_name = "fxtoq" },
- { .opc = 209, .print_fn = fmt_fop2, .op_name = "fstoi" },
- { .opc = 210, .print_fn = fmt_fop2, .op_name = "fdtoi" },
- { .opc = 211, .print_fn = fmt_fop2, .op_name = "fqtoi" },
- { .opc = 201, .print_fn = fmt_fop2, .op_name = "fstod" },
- { .opc = 205, .print_fn = fmt_fop2, .op_name = "fstoq" },
- { .opc = 198, .print_fn = fmt_fop2, .op_name = "fdtos" },
- { .opc = 206, .print_fn = fmt_fop2, .op_name = "fdtoq" },
- { .opc = 199, .print_fn = fmt_fop2, .op_name = "fqtos" },
- { .opc = 203, .print_fn = fmt_fop2, .op_name = "fqtod" },
- { .opc = 1, .print_fn = fmt_fop2, .op_name = "fmovs" },
- { .opc = 2, .print_fn = fmt_fop2, .op_name = "fmovd" },
- { .opc = 5, .print_fn = fmt_fop2, .op_name = "fnegs" },
- { .opc = 6, .print_fn = fmt_fop2, .op_name = "fnegd" },
- { .opc = 9, .print_fn = fmt_fop2, .op_name = "fabss" },
- { .opc = 10, .print_fn = fmt_fop2, .op_name = "fabsd" },
- { .opc = 41, .print_fn = fmt_fop2, .op_name = "fsqrts" },
- { .opc = 42, .print_fn = fmt_fop2, .op_name = "fsqrtd" },
- { .opc = 43, .print_fn = fmt_fop2, .op_name = "fsqrtq" },
- { .opc = 65, .print_fn = fmt_fop3, .op_name = "fadds" },
- { .opc = 66, .print_fn = fmt_fop3, .op_name = "faddd" },
- { .opc = 67, .print_fn = fmt_fop3, .op_name = "faddq" },
- { .opc = 69, .print_fn = fmt_fop3, .op_name = "fsubs" },
- { .opc = 70, .print_fn = fmt_fop3, .op_name = "fsubd" },
- { .opc = 71, .print_fn = fmt_fop3, .op_name = "fsubq" },
- { .opc = 73, .print_fn = fmt_fop3, .op_name = "fmuls" },
- { .opc = 74, .print_fn = fmt_fop3, .op_name = "fmuld" },
- { .opc = 75, .print_fn = fmt_fop3, .op_name = "fmulq" },
- { .opc = 105, .print_fn = fmt_fop3, .op_name = "fsmuld" },
- { .opc = 111, .print_fn = fmt_fop3, .op_name = "fdmulq" },
- { .opc = 77, .print_fn = fmt_fop3, .op_name = "fdivs" },
- { .opc = 78, .print_fn = fmt_fop3, .op_name = "fdivd" },
- { .opc = 79, .print_fn = fmt_fop3, .op_name = "fdivq" },
-
- /* fop2 format */
- { .opc = 81, .print_fn = fmt_fcmp, .op_name = "fcmps" },
- { .opc = 82, .print_fn = fmt_fcmp, .op_name = "fcmpd" },
- { .opc = 83, .print_fn = fmt_fcmp, .op_name = "fcmpq" },
- { .opc = 85, .print_fn = fmt_fcmp, .op_name = "fcmpes" },
- { .opc = 86, .print_fn = fmt_fcmp, .op_name = "fcmped" },
- { .opc = 87, .print_fn = fmt_fcmp, .op_name = "fcmpeq" },
-};
-
-static void decode_format3(spd_t *dis, uint32_t insn)
-{
- int rd = sparc_inst_rd(insn);
- int rs1 = sparc_inst_rs1(insn);
- int rs2 = sparc_inst_rs2(insn);
- int op3 = sparc_inst_op3(insn);
- int is_imm = sparc_inst_i(insn);
- int imm13 = sparc_inst_imm13(insn);
- int simm13 = sign_ext(13, imm13);
-
- format3 *op_table;
- int op_table_size;
- int op;
-
- if (sparc_inst_op(insn) == 2) {
- if (decode_synthetic_3_10(dis, op3, is_imm, rd, rs1, rs2, simm13)) return;
- op_table = opcodes_3_10;
- op_table_size = sizeof(opcodes_3_10);
- op = op3;
- }
-
- if (sparc_inst_op(insn) == 3) {
- if (decode_synthetic_3_11(dis, op3, is_imm, rd, rs1, rs2, simm13)) return;
- op_table = opcodes_3_11;
- op_table_size = sizeof(opcodes_3_11);
- op = op3;
- }
-
- if ((sparc_inst_op(insn) == 2) && ((op3 == 0x34) || (op3 == 0x35))) {
- op_table = opcodes_3fop;
- op_table_size = sizeof(opcodes_3fop);
- op = sparc_inst_opf(insn);
- }
-
- if ((sparc_inst_op(insn) == 2) && (op3 == 0x2c)) {
- decode_format4(dis, insn);
- return;
- }
-
- for (int i = 0; i < op_table_size; i++)
- if (op_table[i].opc == op) {
- char *op_name = op_table[i].op_name;
- op_table[i].print_fn(dis, op_name, is_imm, rd, rs1, rs2, simm13);
- return;
- }
- // B.28 - rd y
- // B.29 - wr y
-}
-
-static void decode(spd_t *dis, uint32_t insn)
-{
- switch (sparc_inst_op(insn)) {
- case 1: decode_format1(dis, insn); break;
- case 0: decode_format2(dis, insn); break;
- default: decode_format3(dis, insn); break;
- }
-}
-
-/*
- *
- * Public API
- *
- */
-void spd_init(spd_t *dis)
-{
- dis->ibuf = NULL;
- dis->ibuf_index = 0;
- dis->ibuf_size = 0;
- dis->pc = 0;
-}
-
-void spd_set_input_buffer(spd_t *dis, unsigned char *buf, int len)
-{
- dis->ibuf = (uint32_t *) buf;
- dis->ibuf_index = 0;
- dis->ibuf_size = len / 4;
-}
-
-int spd_disassemble(spd_t *dis)
-{
- spd_out_name(dis, "???");
- if (dis->ibuf_index >= dis->ibuf_size) return 0;
- decode(dis, dis->ibuf[dis->ibuf_index]);
- dis->ibuf_index++;
- dis->pc += 4;
- return 1;
-}
-
-char *spd_insn_asm(spd_t *dis)
-{
- return dis->out;
-}
-
-void spd_set_pc(spd_t *dis, unsigned long pc)
-{
- dis->pc = pc;
-}
diff --git a/ext/myjit/disasm/sparc/sparc-dis.h b/ext/myjit/disasm/sparc/sparc-dis.h
deleted file mode 100755
index cafca49..0000000
--- a/ext/myjit/disasm/sparc/sparc-dis.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * MyJIT Disassembler
- *
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-
-typedef struct spd_t {
- unsigned long pc;
- uint32_t *ibuf;
- unsigned int ibuf_index;
- unsigned int ibuf_size;
- char out[1024];
-} spd_t;
-
-void spd_init(spd_t *);
-void spd_set_input_buffer(spd_t *, unsigned char *, int);
-int spd_disassemble(spd_t *);
-char *spd_insn_asm(spd_t *);
-void spd_set_pc(spd_t *, unsigned long);
diff --git a/ext/myjit/disasm/udis86/Makefile b/ext/myjit/disasm/udis86/Makefile
deleted file mode 100755
index eb55741..0000000
--- a/ext/myjit/disasm/udis86/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-all: decode.o itab.o syn.o syn-att.o syn-intel.o udis86.o
-
-#CFLAGS = -g -std=c99 -Wall -pedantic -D_XOPEN_SOURCE=600
-
-decode.o: decode.c udint.h types.h extern.h decode.h
- $(CC) $(CFLAGS) -c decode.c
-
-itab.o: itab.c decode.h
- $(CC) $(CFLAGS) -c itab.c
-
-syn.o: syn.c types.h decode.h syn.h udint.h
- $(CC) $(CFLAGS) -c syn.c
-
-syn-att.o: syn-att.c types.h extern.h decode.h itab.h syn.h udint.h
- $(CC) $(CFLAGS) -c syn-att.c
-
-syn-intel.o: syn-intel.c types.h extern.h decode.h itab.h syn.h udint.h
- $(CC) $(CFLAGS) -c syn-intel.c
-
-udis86.o: udis86.c udint.h extern.h decode.h
- $(CC) $(CFLAGS) -c udis86.c
-
-clean:
- rm -f *.o
diff --git a/ext/myjit/disasm/udis86/decode.c b/ext/myjit/disasm/udis86/decode.c
deleted file mode 100755
index 036b9ed..0000000
--- a/ext/myjit/disasm/udis86/decode.c
+++ /dev/null
@@ -1,1266 +0,0 @@
-/* udis86 - libudis86/decode.c
- *
- * Copyright (c) 2002-2009 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "udint.h"
-#include "types.h"
-#include "extern.h"
-#include "decode.h"
-
-#ifndef __UD_STANDALONE__
-# include <string.h>
-#endif /* __UD_STANDALONE__ */
-
-/* The max number of prefixes to an instruction */
-#define MAX_PREFIXES 15
-
-/* rex prefix bits */
-#define REX_W(r) ( ( 0xF & ( r ) ) >> 3 )
-#define REX_R(r) ( ( 0x7 & ( r ) ) >> 2 )
-#define REX_X(r) ( ( 0x3 & ( r ) ) >> 1 )
-#define REX_B(r) ( ( 0x1 & ( r ) ) >> 0 )
-#define REX_PFX_MASK(n) ( ( P_REXW(n) << 3 ) | \
- ( P_REXR(n) << 2 ) | \
- ( P_REXX(n) << 1 ) | \
- ( P_REXB(n) << 0 ) )
-
-/* scable-index-base bits */
-#define SIB_S(b) ( ( b ) >> 6 )
-#define SIB_I(b) ( ( ( b ) >> 3 ) & 7 )
-#define SIB_B(b) ( ( b ) & 7 )
-
-/* modrm bits */
-#define MODRM_REG(b) ( ( ( b ) >> 3 ) & 7 )
-#define MODRM_NNN(b) ( ( ( b ) >> 3 ) & 7 )
-#define MODRM_MOD(b) ( ( ( b ) >> 6 ) & 3 )
-#define MODRM_RM(b) ( ( b ) & 7 )
-
-static int decode_ext(struct ud *u, uint16_t ptr);
-static int decode_opcode(struct ud *u);
-
-enum reg_class { /* register classes */
- REGCLASS_GPR,
- REGCLASS_MMX,
- REGCLASS_CR,
- REGCLASS_DB,
- REGCLASS_SEG,
- REGCLASS_XMM
-};
-
- /*
- * inp_start
- * Should be called before each de-code operation.
- */
-static void
-inp_start(struct ud *u)
-{
- u->inp_ctr = 0;
-}
-
-static uint8_t
-inp_peek(struct ud *u)
-{
- if (u->inp_end == 0) {
- if (u->inp_buf != NULL) {
- if (u->inp_buf_index < u->inp_buf_size) {
- return u->inp_buf[u->inp_buf_index];
- }
- } else if (u->inp_peek != UD_EOI) {
- return u->inp_peek;
- } else {
- int c;
- if ((c = u->inp_hook(u)) != UD_EOI) {
- u->inp_peek = c;
- return u->inp_peek;
- }
- }
- }
- u->inp_end = 1;
- UDERR(u, "byte expected, eoi received\n");
- return 0;
-}
-
-static uint8_t
-inp_next(struct ud *u)
-{
- if (u->inp_end == 0) {
- if (u->inp_buf != NULL) {
- if (u->inp_buf_index < u->inp_buf_size) {
- u->inp_ctr++;
- return (u->inp_curr = u->inp_buf[u->inp_buf_index++]);
- }
- } else {
- int c = u->inp_peek;
- if (c != UD_EOI || (c = u->inp_hook(u)) != UD_EOI) {
- u->inp_peek = UD_EOI;
- u->inp_curr = c;
- u->inp_sess[u->inp_ctr++] = u->inp_curr;
- return u->inp_curr;
- }
- }
- }
- u->inp_end = 1;
- UDERR(u, "byte expected, eoi received\n");
- return 0;
-}
-
-static uint8_t
-inp_curr(struct ud *u)
-{
- return u->inp_curr;
-}
-
-
-/*
- * inp_uint8
- * int_uint16
- * int_uint32
- * int_uint64
- * Load little-endian values from input
- */
-static uint8_t
-inp_uint8(struct ud* u)
-{
- return inp_next(u);
-}
-
-static uint16_t
-inp_uint16(struct ud* u)
-{
- uint16_t r, ret;
-
- ret = inp_next(u);
- r = inp_next(u);
- return ret | (r << 8);
-}
-
-static uint32_t
-inp_uint32(struct ud* u)
-{
- uint32_t r, ret;
-
- ret = inp_next(u);
- r = inp_next(u);
- ret = ret | (r << 8);
- r = inp_next(u);
- ret = ret | (r << 16);
- r = inp_next(u);
- return ret | (r << 24);
-}
-
-static uint64_t
-inp_uint64(struct ud* u)
-{
- uint64_t r, ret;
-
- ret = inp_next(u);
- r = inp_next(u);
- ret = ret | (r << 8);
- r = inp_next(u);
- ret = ret | (r << 16);
- r = inp_next(u);
- ret = ret | (r << 24);
- r = inp_next(u);
- ret = ret | (r << 32);
- r = inp_next(u);
- ret = ret | (r << 40);
- r = inp_next(u);
- ret = ret | (r << 48);
- r = inp_next(u);
- return ret | (r << 56);
-}
-
-
-static UD_INLINE int
-eff_opr_mode(int dis_mode, int rex_w, int pfx_opr)
-{
- if (dis_mode == 64) {
- return rex_w ? 64 : (pfx_opr ? 16 : 32);
- } else if (dis_mode == 32) {
- return pfx_opr ? 16 : 32;
- } else {
- UD_ASSERT(dis_mode == 16);
- return pfx_opr ? 32 : 16;
- }
-}
-
-
-static UD_INLINE int
-eff_adr_mode(int dis_mode, int pfx_adr)
-{
- if (dis_mode == 64) {
- return pfx_adr ? 32 : 64;
- } else if (dis_mode == 32) {
- return pfx_adr ? 16 : 32;
- } else {
- UD_ASSERT(dis_mode == 16);
- return pfx_adr ? 32 : 16;
- }
-}
-
-
-/*
- * decode_prefixes
- *
- * Extracts instruction prefixes.
- */
-static int
-decode_prefixes(struct ud *u)
-{
- int done = 0;
- uint8_t curr = 0, last = 0;
- UD_RETURN_ON_ERROR(u);
-
- do {
- last = curr;
- curr = inp_next(u);
- UD_RETURN_ON_ERROR(u);
- if (u->inp_ctr == MAX_INSN_LENGTH) {
- UD_RETURN_WITH_ERROR(u, "max instruction length");
- }
-
- switch (curr)
- {
- case 0x2E:
- u->pfx_seg = UD_R_CS;
- break;
- case 0x36:
- u->pfx_seg = UD_R_SS;
- break;
- case 0x3E:
- u->pfx_seg = UD_R_DS;
- break;
- case 0x26:
- u->pfx_seg = UD_R_ES;
- break;
- case 0x64:
- u->pfx_seg = UD_R_FS;
- break;
- case 0x65:
- u->pfx_seg = UD_R_GS;
- break;
- case 0x67: /* adress-size override prefix */
- u->pfx_adr = 0x67;
- break;
- case 0xF0:
- u->pfx_lock = 0xF0;
- break;
- case 0x66:
- u->pfx_opr = 0x66;
- break;
- case 0xF2:
- u->pfx_str = 0xf2;
- break;
- case 0xF3:
- u->pfx_str = 0xf3;
- break;
- default:
- /* consume if rex */
- done = (u->dis_mode == 64 && (curr & 0xF0) == 0x40) ? 0 : 1;
- break;
- }
- } while (!done);
- /* rex prefixes in 64bit mode, must be the last prefix */
- if (u->dis_mode == 64 && (last & 0xF0) == 0x40) {
- u->pfx_rex = last;
- }
- return 0;
-}
-
-
-/*
- * vex_l, vex_w
- * Return the vex.L and vex.W bits
- */
-static UD_INLINE uint8_t
-vex_l(const struct ud *u)
-{
- UD_ASSERT(u->vex_op != 0);
- return ((u->vex_op == 0xc4 ? u->vex_b2 : u->vex_b1) >> 2) & 1;
-}
-
-static UD_INLINE uint8_t
-vex_w(const struct ud *u)
-{
- UD_ASSERT(u->vex_op != 0);
- return u->vex_op == 0xc4 ? ((u->vex_b2 >> 7) & 1) : 0;
-}
-
-
-static UD_INLINE uint8_t
-modrm(struct ud * u)
-{
- if ( !u->have_modrm ) {
- u->modrm = inp_next( u );
- u->modrm_offset = (uint8_t) (u->inp_ctr - 1);
- u->have_modrm = 1;
- }
- return u->modrm;
-}
-
-
-static unsigned int
-resolve_operand_size(const struct ud* u, ud_operand_size_t osize)
-{
- switch (osize) {
- case SZ_V:
- return u->opr_mode;
- case SZ_Z:
- return u->opr_mode == 16 ? 16 : 32;
- case SZ_Y:
- return u->opr_mode == 16 ? 32 : u->opr_mode;
- case SZ_RDQ:
- return u->dis_mode == 64 ? 64 : 32;
- case SZ_X:
- UD_ASSERT(u->vex_op != 0);
- return (P_VEXL(u->itab_entry->prefix) && vex_l(u)) ? SZ_QQ : SZ_DQ;
- default:
- return osize;
- }
-}
-
-
-static int resolve_mnemonic( struct ud* u )
-{
- /* resolve 3dnow weirdness. */
- if ( u->mnemonic == UD_I3dnow ) {
- u->mnemonic = ud_itab[ u->le->table[ inp_curr( u ) ] ].mnemonic;
- }
- /* SWAPGS is only valid in 64bits mode */
- if ( u->mnemonic == UD_Iswapgs && u->dis_mode != 64 ) {
- UDERR(u, "swapgs invalid in 64bits mode\n");
- return -1;
- }
-
- if (u->mnemonic == UD_Ixchg) {
- if ((u->operand[0].type == UD_OP_REG && u->operand[0].base == UD_R_AX &&
- u->operand[1].type == UD_OP_REG && u->operand[1].base == UD_R_AX) ||
- (u->operand[0].type == UD_OP_REG && u->operand[0].base == UD_R_EAX &&
- u->operand[1].type == UD_OP_REG && u->operand[1].base == UD_R_EAX)) {
- u->operand[0].type = UD_NONE;
- u->operand[1].type = UD_NONE;
- u->mnemonic = UD_Inop;
- }
- }
-
- if (u->mnemonic == UD_Inop && u->pfx_repe) {
- u->pfx_repe = 0;
- u->mnemonic = UD_Ipause;
- }
- return 0;
-}
-
-
-/* -----------------------------------------------------------------------------
- * decode_a()- Decodes operands of the type seg:offset
- * -----------------------------------------------------------------------------
- */
-static void
-decode_a(struct ud* u, struct ud_operand *op)
-{
- if (u->opr_mode == 16) {
- /* seg16:off16 */
- op->type = UD_OP_PTR;
- op->size = 32;
- op->lval.ptr.off = inp_uint16(u);
- op->lval.ptr.seg = inp_uint16(u);
- } else {
- /* seg16:off32 */
- op->type = UD_OP_PTR;
- op->size = 48;
- op->lval.ptr.off = inp_uint32(u);
- op->lval.ptr.seg = inp_uint16(u);
- }
-}
-
-/* -----------------------------------------------------------------------------
- * decode_gpr() - Returns decoded General Purpose Register
- * -----------------------------------------------------------------------------
- */
-static enum ud_type
-decode_gpr(register struct ud* u, unsigned int s, unsigned char rm)
-{
- switch (s) {
- case 64:
- return UD_R_RAX + rm;
- case 32:
- return UD_R_EAX + rm;
- case 16:
- return UD_R_AX + rm;
- case 8:
- if (u->dis_mode == 64 && u->pfx_rex) {
- if (rm >= 4)
- return UD_R_SPL + (rm-4);
- return UD_R_AL + rm;
- } else return UD_R_AL + rm;
- case 0:
- /* invalid size in case of a decode error */
- UD_ASSERT(u->error);
- return UD_NONE;
- default:
- UD_ASSERT(!"invalid operand size");
- return UD_NONE;
- }
-}
-
-static void
-decode_reg(struct ud *u,
- struct ud_operand *opr,
- int type,
- int num,
- int size)
-{
- int reg;
- size = resolve_operand_size(u, size);
- switch (type) {
- case REGCLASS_GPR : reg = decode_gpr(u, size, num); break;
- case REGCLASS_MMX : reg = UD_R_MM0 + (num & 7); break;
- case REGCLASS_XMM :
- reg = num + (size == SZ_QQ ? UD_R_YMM0 : UD_R_XMM0);
- break;
- case REGCLASS_CR : reg = UD_R_CR0 + num; break;
- case REGCLASS_DB : reg = UD_R_DR0 + num; break;
- case REGCLASS_SEG : {
- /*
- * Only 6 segment registers, anything else is an error.
- */
- if ((num & 7) > 5) {
- UDERR(u, "invalid segment register value\n");
- return;
- } else {
- reg = UD_R_ES + (num & 7);
- }
- break;
- }
- default:
- UD_ASSERT(!"invalid register type");
- return;
- }
- opr->type = UD_OP_REG;
- opr->base = reg;
- opr->size = size;
-}
-
-
-/*
- * decode_imm
- *
- * Decode Immediate values.
- */
-static void
-decode_imm(struct ud* u, unsigned int size, struct ud_operand *op)
-{
- op->size = resolve_operand_size(u, size);
- op->type = UD_OP_IMM;
-
- switch (op->size) {
- case 8: op->lval.sbyte = inp_uint8(u); break;
- case 16: op->lval.uword = inp_uint16(u); break;
- case 32: op->lval.udword = inp_uint32(u); break;
- case 64: op->lval.uqword = inp_uint64(u); break;
- default: return;
- }
-}
-
-
-/*
- * decode_mem_disp
- *
- * Decode mem address displacement.
- */
-static void
-decode_mem_disp(struct ud* u, unsigned int size, struct ud_operand *op)
-{
- switch (size) {
- case 8:
- op->offset = 8;
- op->lval.ubyte = inp_uint8(u);
- break;
- case 16:
- op->offset = 16;
- op->lval.uword = inp_uint16(u);
- break;
- case 32:
- op->offset = 32;
- op->lval.udword = inp_uint32(u);
- break;
- case 64:
- op->offset = 64;
- op->lval.uqword = inp_uint64(u);
- break;
- default:
- return;
- }
-}
-
-
-/*
- * decode_modrm_reg
- *
- * Decodes reg field of mod/rm byte
- *
- */
-static UD_INLINE void
-decode_modrm_reg(struct ud *u,
- struct ud_operand *operand,
- unsigned int type,
- unsigned int size)
-{
- uint8_t reg = (REX_R(u->_rex) << 3) | MODRM_REG(modrm(u));
- decode_reg(u, operand, type, reg, size);
-}
-
-
-/*
- * decode_modrm_rm
- *
- * Decodes rm field of mod/rm byte
- *
- */
-static void
-decode_modrm_rm(struct ud *u,
- struct ud_operand *op,
- unsigned char type, /* register type */
- unsigned int size) /* operand size */
-
-{
- size_t offset = 0;
- unsigned char mod, rm;
-
- /* get mod, r/m and reg fields */
- mod = MODRM_MOD(modrm(u));
- rm = (REX_B(u->_rex) << 3) | MODRM_RM(modrm(u));
-
- /*
- * If mod is 11b, then the modrm.rm specifies a register.
- *
- */
- if (mod == 3) {
- decode_reg(u, op, type, rm, size);
- return;
- }
-
- /*
- * !11b => Memory Address
- */
- op->type = UD_OP_MEM;
- op->size = resolve_operand_size(u, size);
-
- if (u->adr_mode == 64) {
- op->base = UD_R_RAX + rm;
- if (mod == 1) {
- offset = 8;
- } else if (mod == 2) {
- offset = 32;
- } else if (mod == 0 && (rm & 7) == 5) {
- op->base = UD_R_RIP;
- offset = 32;
- } else {
- offset = 0;
- }
- /*
- * Scale-Index-Base (SIB)
- */
- if ((rm & 7) == 4) {
- inp_next(u);
-
- op->base = UD_R_RAX + (SIB_B(inp_curr(u)) | (REX_B(u->_rex) << 3));
- op->index = UD_R_RAX + (SIB_I(inp_curr(u)) | (REX_X(u->_rex) << 3));
- /* special conditions for base reference */
- if (op->index == UD_R_RSP) {
- op->index = UD_NONE;
- op->scale = UD_NONE;
- } else {
- op->scale = (1 << SIB_S(inp_curr(u))) & ~1;
- }
-
- if (op->base == UD_R_RBP || op->base == UD_R_R13) {
- if (mod == 0) {
- op->base = UD_NONE;
- }
- if (mod == 1) {
- offset = 8;
- } else {
- offset = 32;
- }
- }
- } else {
- op->scale = UD_NONE;
- op->index = UD_NONE;
- }
- } else if (u->adr_mode == 32) {
- op->base = UD_R_EAX + rm;
- if (mod == 1) {
- offset = 8;
- } else if (mod == 2) {
- offset = 32;
- } else if (mod == 0 && rm == 5) {
- op->base = UD_NONE;
- offset = 32;
- } else {
- offset = 0;
- }
-
- /* Scale-Index-Base (SIB) */
- if ((rm & 7) == 4) {
- inp_next(u);
-
- op->scale = (1 << SIB_S(inp_curr(u))) & ~1;
- op->index = UD_R_EAX + (SIB_I(inp_curr(u)) | (REX_X(u->pfx_rex) << 3));
- op->base = UD_R_EAX + (SIB_B(inp_curr(u)) | (REX_B(u->pfx_rex) << 3));
-
- if (op->index == UD_R_ESP) {
- op->index = UD_NONE;
- op->scale = UD_NONE;
- }
-
- /* special condition for base reference */
- if (op->base == UD_R_EBP) {
- if (mod == 0) {
- op->base = UD_NONE;
- }
- if (mod == 1) {
- offset = 8;
- } else {
- offset = 32;
- }
- }
- } else {
- op->scale = UD_NONE;
- op->index = UD_NONE;
- }
- } else {
- const unsigned int bases[] = { UD_R_BX, UD_R_BX, UD_R_BP, UD_R_BP,
- UD_R_SI, UD_R_DI, UD_R_BP, UD_R_BX };
- const unsigned int indices[] = { UD_R_SI, UD_R_DI, UD_R_SI, UD_R_DI,
- UD_NONE, UD_NONE, UD_NONE, UD_NONE };
- op->base = bases[rm & 7];
- op->index = indices[rm & 7];
- op->scale = UD_NONE;
- if (mod == 0 && rm == 6) {
- offset = 16;
- op->base = UD_NONE;
- } else if (mod == 1) {
- offset = 8;
- } else if (mod == 2) {
- offset = 16;
- }
- }
-
- if (offset) {
- decode_mem_disp(u, offset, op);
- } else {
- op->offset = 0;
- }
-}
-
-
-/*
- * decode_moffset
- * Decode offset-only memory operand
- */
-static void
-decode_moffset(struct ud *u, unsigned int size, struct ud_operand *opr)
-{
- opr->type = UD_OP_MEM;
- opr->base = UD_NONE;
- opr->index = UD_NONE;
- opr->scale = UD_NONE;
- opr->size = resolve_operand_size(u, size);
- decode_mem_disp(u, u->adr_mode, opr);
-}
-
-
-static void
-decode_vex_vvvv(struct ud *u, struct ud_operand *opr, unsigned size)
-{
- uint8_t vvvv;
- UD_ASSERT(u->vex_op != 0);
- vvvv = ((u->vex_op == 0xc4 ? u->vex_b2 : u->vex_b1) >> 3) & 0xf;
- decode_reg(u, opr, REGCLASS_XMM, (0xf & ~vvvv), size);
-}
-
-
-/*
- * decode_vex_immreg
- * Decode source operand encoded in immediate byte [7:4]
- */
-static int
-decode_vex_immreg(struct ud *u, struct ud_operand *opr, unsigned size)
-{
- uint8_t imm = inp_next(u);
- uint8_t mask = u->dis_mode == 64 ? 0xf : 0x7;
- UD_RETURN_ON_ERROR(u);
- UD_ASSERT(u->vex_op != 0);
- decode_reg(u, opr, REGCLASS_XMM, mask & (imm >> 4), size);
- return 0;
-}
-
-
-/*
- * decode_operand
- *
- * Decodes a single operand.
- * Returns the type of the operand (UD_NONE if none)
- */
-static int
-decode_operand(struct ud *u,
- struct ud_operand *operand,
- enum ud_operand_code type,
- unsigned int size)
-{
- operand->type = UD_NONE;
- operand->_oprcode = type;
-
- switch (type) {
- case OP_A :
- decode_a(u, operand);
- break;
- case OP_MR:
- decode_modrm_rm(u, operand, REGCLASS_GPR,
- MODRM_MOD(modrm(u)) == 3 ?
- Mx_reg_size(size) : Mx_mem_size(size));
- break;
- case OP_F:
- u->br_far = 1;
- /* intended fall through */
- case OP_M:
- if (MODRM_MOD(modrm(u)) == 3) {
- UDERR(u, "expected modrm.mod != 3\n");
- }
- /* intended fall through */
- case OP_E:
- decode_modrm_rm(u, operand, REGCLASS_GPR, size);
- break;
- case OP_G:
- decode_modrm_reg(u, operand, REGCLASS_GPR, size);
- break;
- case OP_sI:
- case OP_I:
- decode_imm(u, size, operand);
- break;
- case OP_I1:
- operand->type = UD_OP_CONST;
- operand->lval.udword = 1;
- break;
- case OP_N:
- if (MODRM_MOD(modrm(u)) != 3) {
- UDERR(u, "expected modrm.mod == 3\n");
- }
- /* intended fall through */
- case OP_Q:
- decode_modrm_rm(u, operand, REGCLASS_MMX, size);
- break;
- case OP_P:
- decode_modrm_reg(u, operand, REGCLASS_MMX, size);
- break;
- case OP_U:
- if (MODRM_MOD(modrm(u)) != 3) {
- UDERR(u, "expected modrm.mod == 3\n");
- }
- /* intended fall through */
- case OP_W:
- decode_modrm_rm(u, operand, REGCLASS_XMM, size);
- break;
- case OP_V:
- decode_modrm_reg(u, operand, REGCLASS_XMM, size);
- break;
- case OP_H:
- decode_vex_vvvv(u, operand, size);
- break;
- case OP_MU:
- decode_modrm_rm(u, operand, REGCLASS_XMM,
- MODRM_MOD(modrm(u)) == 3 ?
- Mx_reg_size(size) : Mx_mem_size(size));
- break;
- case OP_S:
- decode_modrm_reg(u, operand, REGCLASS_SEG, size);
- break;
- case OP_O:
- decode_moffset(u, size, operand);
- break;
- case OP_R0:
- case OP_R1:
- case OP_R2:
- case OP_R3:
- case OP_R4:
- case OP_R5:
- case OP_R6:
- case OP_R7:
- decode_reg(u, operand, REGCLASS_GPR,
- (REX_B(u->_rex) << 3) | (type - OP_R0), size);
- break;
- case OP_AL:
- case OP_AX:
- case OP_eAX:
- case OP_rAX:
- decode_reg(u, operand, REGCLASS_GPR, 0, size);
- break;
- case OP_CL:
- case OP_CX:
- case OP_eCX:
- decode_reg(u, operand, REGCLASS_GPR, 1, size);
- break;
- case OP_DL:
- case OP_DX:
- case OP_eDX:
- decode_reg(u, operand, REGCLASS_GPR, 2, size);
- break;
- case OP_ES:
- case OP_CS:
- case OP_DS:
- case OP_SS:
- case OP_FS:
- case OP_GS:
- /* in 64bits mode, only fs and gs are allowed */
- if (u->dis_mode == 64) {
- if (type != OP_FS && type != OP_GS) {
- UDERR(u, "invalid segment register in 64bits\n");
- }
- }
- operand->type = UD_OP_REG;
- operand->base = (type - OP_ES) + UD_R_ES;
- operand->size = 16;
- break;
- case OP_J :
- decode_imm(u, size, operand);
- operand->type = UD_OP_JIMM;
- break ;
- case OP_R :
- if (MODRM_MOD(modrm(u)) != 3) {
- UDERR(u, "expected modrm.mod == 3\n");
- }
- decode_modrm_rm(u, operand, REGCLASS_GPR, size);
- break;
- case OP_C:
- decode_modrm_reg(u, operand, REGCLASS_CR, size);
- break;
- case OP_D:
- decode_modrm_reg(u, operand, REGCLASS_DB, size);
- break;
- case OP_I3 :
- operand->type = UD_OP_CONST;
- operand->lval.sbyte = 3;
- break;
- case OP_ST0:
- case OP_ST1:
- case OP_ST2:
- case OP_ST3:
- case OP_ST4:
- case OP_ST5:
- case OP_ST6:
- case OP_ST7:
- operand->type = UD_OP_REG;
- operand->base = (type - OP_ST0) + UD_R_ST0;
- operand->size = 80;
- break;
- case OP_L:
- decode_vex_immreg(u, operand, size);
- break;
- default :
- operand->type = UD_NONE;
- break;
- }
- return operand->type;
-}
-
-
-/*
- * decode_operands
- *
- * Disassemble upto 3 operands of the current instruction being
- * disassembled. By the end of the function, the operand fields
- * of the ud structure will have been filled.
- */
-static int
-decode_operands(struct ud* u)
-{
- decode_operand(u, &u->operand[0],
- u->itab_entry->operand1.type,
- u->itab_entry->operand1.size);
- if (u->operand[0].type != UD_NONE) {
- decode_operand(u, &u->operand[1],
- u->itab_entry->operand2.type,
- u->itab_entry->operand2.size);
- }
- if (u->operand[1].type != UD_NONE) {
- decode_operand(u, &u->operand[2],
- u->itab_entry->operand3.type,
- u->itab_entry->operand3.size);
- }
- if (u->operand[2].type != UD_NONE) {
- decode_operand(u, &u->operand[3],
- u->itab_entry->operand4.type,
- u->itab_entry->operand4.size);
- }
- return 0;
-}
-
-/* -----------------------------------------------------------------------------
- * clear_insn() - clear instruction structure
- * -----------------------------------------------------------------------------
- */
-static void
-clear_insn(register struct ud* u)
-{
- u->error = 0;
- u->pfx_seg = 0;
- u->pfx_opr = 0;
- u->pfx_adr = 0;
- u->pfx_lock = 0;
- u->pfx_repne = 0;
- u->pfx_rep = 0;
- u->pfx_repe = 0;
- u->pfx_rex = 0;
- u->pfx_str = 0;
- u->mnemonic = UD_Inone;
- u->itab_entry = NULL;
- u->have_modrm = 0;
- u->br_far = 0;
- u->vex_op = 0;
- u->_rex = 0;
- u->operand[0].type = UD_NONE;
- u->operand[1].type = UD_NONE;
- u->operand[2].type = UD_NONE;
- u->operand[3].type = UD_NONE;
-}
-
-
-static UD_INLINE int
-resolve_pfx_str(struct ud* u)
-{
- if (u->pfx_str == 0xf3) {
- if (P_STR(u->itab_entry->prefix)) {
- u->pfx_rep = 0xf3;
- } else {
- u->pfx_repe = 0xf3;
- }
- } else if (u->pfx_str == 0xf2) {
- u->pfx_repne = 0xf3;
- }
- return 0;
-}
-
-
-static int
-resolve_mode( struct ud* u )
-{
- int default64;
- /* if in error state, bail out */
- if ( u->error ) return -1;
-
- /* propagate prefix effects */
- if ( u->dis_mode == 64 ) { /* set 64bit-mode flags */
-
- /* Check validity of instruction m64 */
- if ( P_INV64( u->itab_entry->prefix ) ) {
- UDERR(u, "instruction invalid in 64bits\n");
- return -1;
- }
-
- /* compute effective rex based on,
- * - vex prefix (if any)
- * - rex prefix (if any, and not vex)
- * - allowed prefixes specified by the opcode map
- */
- if (u->vex_op == 0xc4) {
- /* vex has rex.rxb in 1's complement */
- u->_rex = ((~(u->vex_b1 >> 5) & 0x7) /* rex.0rxb */ |
- ((u->vex_b2 >> 4) & 0x8) /* rex.w000 */);
- } else if (u->vex_op == 0xc5) {
- /* vex has rex.r in 1's complement */
- u->_rex = (~(u->vex_b1 >> 5)) & 4;
- } else {
- UD_ASSERT(u->vex_op == 0);
- u->_rex = u->pfx_rex;
- }
- u->_rex &= REX_PFX_MASK(u->itab_entry->prefix);
-
- /* whether this instruction has a default operand size of
- * 64bit, also hardcoded into the opcode map.
- */
- default64 = P_DEF64( u->itab_entry->prefix );
- /* calculate effective operand size */
- if (REX_W(u->_rex)) {
- u->opr_mode = 64;
- } else if ( u->pfx_opr ) {
- u->opr_mode = 16;
- } else {
- /* unless the default opr size of instruction is 64,
- * the effective operand size in the absence of rex.w
- * prefix is 32.
- */
- u->opr_mode = default64 ? 64 : 32;
- }
-
- /* calculate effective address size */
- u->adr_mode = (u->pfx_adr) ? 32 : 64;
- } else if ( u->dis_mode == 32 ) { /* set 32bit-mode flags */
- u->opr_mode = ( u->pfx_opr ) ? 16 : 32;
- u->adr_mode = ( u->pfx_adr ) ? 16 : 32;
- } else if ( u->dis_mode == 16 ) { /* set 16bit-mode flags */
- u->opr_mode = ( u->pfx_opr ) ? 32 : 16;
- u->adr_mode = ( u->pfx_adr ) ? 32 : 16;
- }
-
- return 0;
-}
-
-
-static UD_INLINE int
-decode_insn(struct ud *u, uint16_t ptr)
-{
- UD_ASSERT((ptr & 0x8000) == 0);
- u->itab_entry = &ud_itab[ ptr ];
- u->mnemonic = u->itab_entry->mnemonic;
- return (resolve_pfx_str(u) == 0 &&
- resolve_mode(u) == 0 &&
- decode_operands(u) == 0 &&
- resolve_mnemonic(u) == 0) ? 0 : -1;
-}
-
-
-/*
- * decode_3dnow()
- *
- * Decoding 3dnow is a little tricky because of its strange opcode
- * structure. The final opcode disambiguation depends on the last
- * byte that comes after the operands have been decoded. Fortunately,
- * all 3dnow instructions have the same set of operand types. So we
- * go ahead and decode the instruction by picking an arbitrarily chosen
- * valid entry in the table, decode the operands, and read the final
- * byte to resolve the menmonic.
- */
-static UD_INLINE int
-decode_3dnow(struct ud* u)
-{
- uint16_t ptr;
- UD_ASSERT(u->le->type == UD_TAB__OPC_3DNOW);
- UD_ASSERT(u->le->table[0xc] != 0);
- decode_insn(u, u->le->table[0xc]);
- inp_next(u);
- if (u->error) {
- return -1;
- }
- ptr = u->le->table[inp_curr(u)];
- UD_ASSERT((ptr & 0x8000) == 0);
- u->mnemonic = ud_itab[ptr].mnemonic;
- return 0;
-}
-
-
-static int
-decode_ssepfx(struct ud *u)
-{
- uint8_t idx;
- uint8_t pfx;
-
- /*
- * String prefixes (f2, f3) take precedence over operand
- * size prefix (66).
- */
- pfx = u->pfx_str;
- if (pfx == 0) {
- pfx = u->pfx_opr;
- }
- idx = ((pfx & 0xf) + 1) / 2;
- if (u->le->table[idx] == 0) {
- idx = 0;
- }
- if (idx && u->le->table[idx] != 0) {
- /*
- * "Consume" the prefix as a part of the opcode, so it is no
- * longer exported as an instruction prefix.
- */
- u->pfx_str = 0;
- if (pfx == 0x66) {
- /*
- * consume "66" only if it was used for decoding, leaving
- * it to be used as an operands size override for some
- * simd instructions.
- */
- u->pfx_opr = 0;
- }
- }
- return decode_ext(u, u->le->table[idx]);
-}
-
-
-static int
-decode_vex(struct ud *u)
-{
- uint8_t index;
- if (u->dis_mode != 64 && MODRM_MOD(inp_peek(u)) != 0x3) {
- index = 0;
- } else {
- u->vex_op = inp_curr(u);
- u->vex_b1 = inp_next(u);
- if (u->vex_op == 0xc4) {
- uint8_t pp, m;
- /* 3-byte vex */
- u->vex_b2 = inp_next(u);
- UD_RETURN_ON_ERROR(u);
- m = u->vex_b1 & 0x1f;
- if (m == 0 || m > 3) {
- UD_RETURN_WITH_ERROR(u, "reserved vex.m-mmmm value");
- }
- pp = u->vex_b2 & 0x3;
- index = (pp << 2) | m;
- } else {
- /* 2-byte vex */
- UD_ASSERT(u->vex_op == 0xc5);
- index = 0x1 | ((u->vex_b1 & 0x3) << 2);
- }
- }
- return decode_ext(u, u->le->table[index]);
-}
-
-
-/*
- * decode_ext()
- *
- * Decode opcode extensions (if any)
- */
-static int
-decode_ext(struct ud *u, uint16_t ptr)
-{
- uint8_t idx = 0;
- if ((ptr & 0x8000) == 0) {
- return decode_insn(u, ptr);
- }
- u->le = &ud_lookup_table_list[(~0x8000 & ptr)];
- if (u->le->type == UD_TAB__OPC_3DNOW) {
- return decode_3dnow(u);
- }
-
- switch (u->le->type) {
- case UD_TAB__OPC_MOD:
- /* !11 = 0, 11 = 1 */
- idx = (MODRM_MOD(modrm(u)) + 1) / 4;
- break;
- /* disassembly mode/operand size/address size based tables.
- * 16 = 0,, 32 = 1, 64 = 2
- */
- case UD_TAB__OPC_MODE:
- idx = u->dis_mode != 64 ? 0 : 1;
- break;
- case UD_TAB__OPC_OSIZE:
- idx = eff_opr_mode(u->dis_mode, REX_W(u->pfx_rex), u->pfx_opr) / 32;
- break;
- case UD_TAB__OPC_ASIZE:
- idx = eff_adr_mode(u->dis_mode, u->pfx_adr) / 32;
- break;
- case UD_TAB__OPC_X87:
- idx = modrm(u) - 0xC0;
- break;
- case UD_TAB__OPC_VENDOR:
- if (u->vendor == UD_VENDOR_ANY) {
- /* choose a valid entry */
- idx = (u->le->table[idx] != 0) ? 0 : 1;
- } else if (u->vendor == UD_VENDOR_AMD) {
- idx = 0;
- } else {
- idx = 1;
- }
- break;
- case UD_TAB__OPC_RM:
- idx = MODRM_RM(modrm(u));
- break;
- case UD_TAB__OPC_REG:
- idx = MODRM_REG(modrm(u));
- break;
- case UD_TAB__OPC_SSE:
- return decode_ssepfx(u);
- case UD_TAB__OPC_VEX:
- return decode_vex(u);
- case UD_TAB__OPC_VEX_W:
- idx = vex_w(u);
- break;
- case UD_TAB__OPC_VEX_L:
- idx = vex_l(u);
- break;
- case UD_TAB__OPC_TABLE:
- inp_next(u);
- return decode_opcode(u);
- default:
- UD_ASSERT(!"not reached");
- break;
- }
-
- return decode_ext(u, u->le->table[idx]);
-}
-
-
-static int
-decode_opcode(struct ud *u)
-{
- uint16_t ptr;
- UD_ASSERT(u->le->type == UD_TAB__OPC_TABLE);
- UD_RETURN_ON_ERROR(u);
- ptr = u->le->table[inp_curr(u)];
- return decode_ext(u, ptr);
-}
-
-
-/* =============================================================================
- * ud_decode() - Instruction decoder. Returns the number of bytes decoded.
- * =============================================================================
- */
-unsigned int
-ud_decode(struct ud *u)
-{
- inp_start(u);
- clear_insn(u);
- u->le = &ud_lookup_table_list[0];
- u->error = decode_prefixes(u) == -1 ||
- decode_opcode(u) == -1 ||
- u->error;
- /* Handle decode error. */
- if (u->error) {
- /* clear out the decode data. */
- clear_insn(u);
- /* mark the sequence of bytes as invalid. */
- u->itab_entry = &ud_itab[0]; /* entry 0 is invalid */
- u->mnemonic = u->itab_entry->mnemonic;
- }
-
- /* maybe this stray segment override byte
- * should be spewed out?
- */
- if ( !P_SEG( u->itab_entry->prefix ) &&
- u->operand[0].type != UD_OP_MEM &&
- u->operand[1].type != UD_OP_MEM )
- u->pfx_seg = 0;
-
- u->insn_offset = u->pc; /* set offset of instruction */
- u->asm_buf_fill = 0; /* set translation buffer index to 0 */
- u->pc += u->inp_ctr; /* move program counter by bytes decoded */
-
- /* return number of bytes disassembled. */
- return u->inp_ctr;
-}
-
-/*
-vim: set ts=2 sw=2 expandtab
-*/
diff --git a/ext/myjit/disasm/udis86/decode.h b/ext/myjit/disasm/udis86/decode.h
deleted file mode 100755
index 3949c4e..0000000
--- a/ext/myjit/disasm/udis86/decode.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/* udis86 - libudis86/decode.h
- *
- * Copyright (c) 2002-2009 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef UD_DECODE_H
-#define UD_DECODE_H
-
-#include "types.h"
-#include "udint.h"
-#include "itab.h"
-
-#define MAX_INSN_LENGTH 15
-
-/* itab prefix bits */
-#define P_none ( 0 )
-
-#define P_inv64 ( 1 << 0 )
-#define P_INV64(n) ( ( n >> 0 ) & 1 )
-#define P_def64 ( 1 << 1 )
-#define P_DEF64(n) ( ( n >> 1 ) & 1 )
-
-#define P_oso ( 1 << 2 )
-#define P_OSO(n) ( ( n >> 2 ) & 1 )
-#define P_aso ( 1 << 3 )
-#define P_ASO(n) ( ( n >> 3 ) & 1 )
-
-#define P_rexb ( 1 << 4 )
-#define P_REXB(n) ( ( n >> 4 ) & 1 )
-#define P_rexw ( 1 << 5 )
-#define P_REXW(n) ( ( n >> 5 ) & 1 )
-#define P_rexr ( 1 << 6 )
-#define P_REXR(n) ( ( n >> 6 ) & 1 )
-#define P_rexx ( 1 << 7 )
-#define P_REXX(n) ( ( n >> 7 ) & 1 )
-
-#define P_seg ( 1 << 8 )
-#define P_SEG(n) ( ( n >> 8 ) & 1 )
-
-#define P_vexl ( 1 << 9 )
-#define P_VEXL(n) ( ( n >> 9 ) & 1 )
-#define P_vexw ( 1 << 10 )
-#define P_VEXW(n) ( ( n >> 10 ) & 1 )
-
-#define P_str ( 1 << 11 )
-#define P_STR(n) ( ( n >> 11 ) & 1 )
-#define P_strz ( 1 << 12 )
-#define P_STR_ZF(n) ( ( n >> 12 ) & 1 )
-
-/* operand type constants -- order is important! */
-
-enum ud_operand_code {
- OP_NONE,
-
- OP_A, OP_E, OP_M, OP_G,
- OP_I, OP_F,
-
- OP_R0, OP_R1, OP_R2, OP_R3,
- OP_R4, OP_R5, OP_R6, OP_R7,
-
- OP_AL, OP_CL, OP_DL,
- OP_AX, OP_CX, OP_DX,
- OP_eAX, OP_eCX, OP_eDX,
- OP_rAX, OP_rCX, OP_rDX,
-
- OP_ES, OP_CS, OP_SS, OP_DS,
- OP_FS, OP_GS,
-
- OP_ST0, OP_ST1, OP_ST2, OP_ST3,
- OP_ST4, OP_ST5, OP_ST6, OP_ST7,
-
- OP_J, OP_S, OP_O,
- OP_I1, OP_I3, OP_sI,
-
- OP_V, OP_W, OP_Q, OP_P,
- OP_U, OP_N, OP_MU, OP_H,
- OP_L,
-
- OP_R, OP_C, OP_D,
-
- OP_MR
-} UD_ATTR_PACKED;
-
-
-/*
- * Operand size constants
- *
- * Symbolic constants for various operand sizes. Some of these constants
- * are given a value equal to the width of the data (SZ_B == 8), such
- * that they maybe used interchangeably in the internals. Modifying them
- * will most certainly break things!
- */
-typedef uint16_t ud_operand_size_t;
-
-#define SZ_NA 0
-#define SZ_Z 1
-#define SZ_V 2
-#define SZ_Y 3
-#define SZ_X 4
-#define SZ_RDQ 7
-#define SZ_B 8
-#define SZ_W 16
-#define SZ_D 32
-#define SZ_Q 64
-#define SZ_T 80
-#define SZ_O 12
-#define SZ_DQ 128 /* double quad */
-#define SZ_QQ 256 /* quad quad */
-
-/*
- * Complex size types; that encode sizes for operands of type MR (memory or
- * register); for internal use only. Id space above 256.
- */
-#define SZ_BD ((SZ_B << 8) | SZ_D)
-#define SZ_BV ((SZ_B << 8) | SZ_V)
-#define SZ_WD ((SZ_W << 8) | SZ_D)
-#define SZ_WV ((SZ_W << 8) | SZ_V)
-#define SZ_WY ((SZ_W << 8) | SZ_Y)
-#define SZ_DY ((SZ_D << 8) | SZ_Y)
-#define SZ_WO ((SZ_W << 8) | SZ_O)
-#define SZ_DO ((SZ_D << 8) | SZ_O)
-#define SZ_QO ((SZ_Q << 8) | SZ_O)
-
-
-/* resolve complex size type.
- */
-static UD_INLINE ud_operand_size_t
-Mx_mem_size(ud_operand_size_t size)
-{
- return (size >> 8) & 0xff;
-}
-
-static UD_INLINE ud_operand_size_t
-Mx_reg_size(ud_operand_size_t size)
-{
- return size & 0xff;
-}
-
-/* A single operand of an entry in the instruction table.
- * (internal use only)
- */
-struct ud_itab_entry_operand
-{
- enum ud_operand_code type;
- ud_operand_size_t size;
-};
-
-
-/* A single entry in an instruction table.
- *(internal use only)
- */
-struct ud_itab_entry
-{
- enum ud_mnemonic_code mnemonic;
- struct ud_itab_entry_operand operand1;
- struct ud_itab_entry_operand operand2;
- struct ud_itab_entry_operand operand3;
- struct ud_itab_entry_operand operand4;
- uint32_t prefix;
-};
-
-struct ud_lookup_table_list_entry {
- const uint16_t *table;
- enum ud_table_type type;
- const char *meta;
-};
-
-extern struct ud_itab_entry ud_itab[];
-extern struct ud_lookup_table_list_entry ud_lookup_table_list[];
-
-#endif /* UD_DECODE_H */
-
-/* vim:cindent
- * vim:expandtab
- * vim:ts=4
- * vim:sw=4
- */
diff --git a/ext/myjit/disasm/udis86/extern.h b/ext/myjit/disasm/udis86/extern.h
deleted file mode 100755
index 883110b..0000000
--- a/ext/myjit/disasm/udis86/extern.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* udis86 - libudis86/extern.h
- *
- * Copyright (c) 2002-2009, 2013 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef UD_EXTERN_H
-#define UD_EXTERN_H
-
-#ifdef __cplusplus
-/* extern */ "C" {
-#endif
-
-#include "types.h"
-
-#if defined(_MSC_VER) && defined(_USRDLL)
-# ifdef LIBUDIS86_EXPORTS
-# define LIBUDIS86_DLLEXTERN __declspec(dllexport)
-# else
-# define LIBUDIS86_DLLEXTERN __declspec(dllimport)
-# endif
-#else
-# define LIBUDIS86_DLLEXTERN
-#endif
-
-/* ============================= PUBLIC API ================================= */
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_init(struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_mode(struct ud*, uint8_t);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_pc(struct ud*, uint64_t);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_input_hook(struct ud*, int (*)(struct ud*));
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_input_buffer(struct ud*, const uint8_t*, size_t);
-
-#ifndef __UD_STANDALONE__
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_input_file(struct ud*, FILE*);
-#endif /* __UD_STANDALONE__ */
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_vendor(struct ud*, unsigned);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_syntax(struct ud*, void (*)(struct ud*));
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_input_skip(struct ud*, size_t);
-
-/* extern */ LIBUDIS86_DLLEXTERN int ud_input_end(const struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN unsigned int ud_decode(struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN unsigned int ud_disassemble(struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_translate_intel(struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_translate_att(struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN const char* ud_insn_asm(const struct ud* u);
-
-/* extern */ LIBUDIS86_DLLEXTERN const uint8_t* ud_insn_ptr(const struct ud* u);
-
-/* extern */ LIBUDIS86_DLLEXTERN uint64_t ud_insn_off(const struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN const char* ud_insn_hex(struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN unsigned int ud_insn_len(const struct ud* u);
-
-/* extern */ LIBUDIS86_DLLEXTERN const struct ud_operand* ud_insn_opr(const struct ud *u, unsigned int n);
-
-/* extern */ LIBUDIS86_DLLEXTERN int ud_opr_is_sreg(const struct ud_operand *opr);
-
-/* extern */ LIBUDIS86_DLLEXTERN int ud_opr_is_gpr(const struct ud_operand *opr);
-
-/* extern */ LIBUDIS86_DLLEXTERN enum ud_mnemonic_code ud_insn_mnemonic(const struct ud *u);
-
-/* extern */ LIBUDIS86_DLLEXTERN const char* ud_lookup_mnemonic(enum ud_mnemonic_code c);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_user_opaque_data(struct ud*, void*);
-
-/* extern */ LIBUDIS86_DLLEXTERN void* ud_get_user_opaque_data(const struct ud*);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_asm_buffer(struct ud *u, char *buf, size_t size);
-
-/* extern */ LIBUDIS86_DLLEXTERN void ud_set_sym_resolver(struct ud *u,
- const char* (*resolver)(struct ud*,
- uint64_t addr,
- int64_t *offset));
-
-/* ========================================================================== */
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* UD_EXTERN_H */
diff --git a/ext/myjit/disasm/udis86/itab.c b/ext/myjit/disasm/udis86/itab.c
deleted file mode 100755
index 953f3e5..0000000
--- a/ext/myjit/disasm/udis86/itab.c
+++ /dev/null
@@ -1,5946 +0,0 @@
-/* itab.c -- generated by udis86:scripts/ud_itab.py, do no edit */
-#include "decode.h"
-
-#define GROUP(n) (0x8000 | (n))
-#define INVALID 0
-
-
-const uint16_t ud_itab__0[] = {
- /* 0 */ 15, 16, 17, 18,
- /* 4 */ 19, 20, GROUP(1), GROUP(2),
- /* 8 */ 964, 965, 966, 967,
- /* c */ 968, 969, GROUP(3), GROUP(4),
- /* 10 */ 5, 6, 7, 8,
- /* 14 */ 9, 10, GROUP(284), GROUP(285),
- /* 18 */ 1336, 1337, 1338, 1339,
- /* 1c */ 1340, 1341, GROUP(286), GROUP(287),
- /* 20 */ 49, 50, 51, 52,
- /* 24 */ 53, 54, INVALID, GROUP(288),
- /* 28 */ 1407, 1408, 1409, 1410,
- /* 2c */ 1411, 1412, INVALID, GROUP(289),
- /* 30 */ 1487, 1488, 1489, 1490,
- /* 34 */ 1491, 1492, INVALID, GROUP(290),
- /* 38 */ 100, 101, 102, 103,
- /* 3c */ 104, 105, INVALID, GROUP(291),
- /* 40 */ 699, 700, 701, 702,
- /* 44 */ 703, 704, 705, 706,
- /* 48 */ 175, 176, 177, 178,
- /* 4c */ 179, 180, 181, 182,
- /* 50 */ 1246, 1247, 1248, 1249,
- /* 54 */ 1250, 1251, 1252, 1253,
- /* 58 */ 1101, 1102, 1103, 1104,
- /* 5c */ 1105, 1106, 1107, 1108,
- /* 60 */ GROUP(292), GROUP(295), GROUP(298), GROUP(299),
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ 1254, 697, 1256, 698,
- /* 6c */ 709, GROUP(300), 982, GROUP(301),
- /* 70 */ 726, 728, 730, 732,
- /* 74 */ 734, 736, 738, 740,
- /* 78 */ 742, 744, 746, 748,
- /* 7c */ 750, 752, 754, 756,
- /* 80 */ GROUP(302), GROUP(303), GROUP(304), GROUP(313),
- /* 84 */ 1433, 1434, 1475, 1476,
- /* 88 */ 828, 829, 830, 831,
- /* 8c */ 832, 770, 833, GROUP(314),
- /* 90 */ 1477, 1478, 1479, 1480,
- /* 94 */ 1481, 1482, 1483, 1484,
- /* 98 */ GROUP(315), GROUP(316), GROUP(317), 1470,
- /* 9c */ GROUP(318), GROUP(322), 1310, 766,
- /* a0 */ 834, 835, 836, 837,
- /* a4 */ 922, GROUP(326), 114, GROUP(327),
- /* a8 */ 1435, 1436, 1402, GROUP(328),
- /* ac */ 790, GROUP(329), 1346, GROUP(330),
- /* b0 */ 838, 839, 840, 841,
- /* b4 */ 842, 843, 844, 845,
- /* b8 */ 846, 847, 848, 849,
- /* bc */ 850, 851, 852, 853,
- /* c0 */ GROUP(331), GROUP(332), 1301, 1302,
- /* c4 */ GROUP(333), GROUP(403), GROUP(405), GROUP(406),
- /* c8 */ 200, 776, 1303, 1304,
- /* cc */ 713, 714, GROUP(407), GROUP(408),
- /* d0 */ GROUP(409), GROUP(410), GROUP(411), GROUP(412),
- /* d4 */ GROUP(413), GROUP(414), GROUP(415), 1486,
- /* d8 */ GROUP(416), GROUP(419), GROUP(422), GROUP(425),
- /* dc */ GROUP(428), GROUP(431), GROUP(434), GROUP(437),
- /* e0 */ 794, 795, 796, GROUP(440),
- /* e4 */ 690, 691, 978, 979,
- /* e8 */ 72, 763, GROUP(441), 765,
- /* ec */ 692, 693, 980, 981,
- /* f0 */ 789, 712, 1299, 1300,
- /* f4 */ 687, 83, GROUP(442), GROUP(443),
- /* f8 */ 77, 1395, 81, 1398,
- /* fc */ 78, 1396, GROUP(444), GROUP(445),
-};
-
-static const uint16_t ud_itab__1[] = {
- /* 0 */ 1240, INVALID,
-};
-
-static const uint16_t ud_itab__2[] = {
- /* 0 */ 1096, INVALID,
-};
-
-static const uint16_t ud_itab__3[] = {
- /* 0 */ 1241, INVALID,
-};
-
-static const uint16_t ud_itab__4[] = {
- /* 0 */ GROUP(5), GROUP(6), 767, 797,
- /* 4 */ INVALID, 1426, 82, 1431,
- /* 8 */ 716, 1471, INVALID, 1444,
- /* c */ INVALID, GROUP(27), 430, GROUP(28),
- /* 10 */ GROUP(29), GROUP(30), GROUP(31), GROUP(34),
- /* 14 */ GROUP(35), GROUP(36), GROUP(37), GROUP(40),
- /* 18 */ GROUP(41), 955, 956, 957,
- /* 1c */ 958, 959, 960, 961,
- /* 20 */ 854, 855, 856, 857,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ GROUP(42), GROUP(43), GROUP(44), GROUP(45),
- /* 2c */ GROUP(46), GROUP(47), GROUP(48), GROUP(49),
- /* 30 */ 1472, 1297, 1295, 1296,
- /* 34 */ GROUP(50), GROUP(52), INVALID, 1514,
- /* 38 */ GROUP(54), INVALID, GROUP(116), INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
- /* 40 */ 84, 85, 86, 87,
- /* 44 */ 88, 89, 90, 91,
- /* 48 */ 92, 93, 94, 95,
- /* 4c */ 96, 97, 98, 99,
- /* 50 */ GROUP(143), GROUP(144), GROUP(145), GROUP(146),
- /* 54 */ GROUP(147), GROUP(148), GROUP(149), GROUP(150),
- /* 58 */ GROUP(151), GROUP(152), GROUP(153), GROUP(154),
- /* 5c */ GROUP(155), GROUP(156), GROUP(157), GROUP(158),
- /* 60 */ GROUP(159), GROUP(160), GROUP(161), GROUP(162),
- /* 64 */ GROUP(163), GROUP(164), GROUP(165), GROUP(166),
- /* 68 */ GROUP(167), GROUP(168), GROUP(169), GROUP(170),
- /* 6c */ GROUP(171), GROUP(172), GROUP(173), GROUP(176),
- /* 70 */ GROUP(177), GROUP(178), GROUP(182), GROUP(186),
- /* 74 */ GROUP(191), GROUP(192), GROUP(193), 199,
- /* 78 */ GROUP(194), GROUP(195), INVALID, INVALID,
- /* 7c */ GROUP(196), GROUP(197), GROUP(198), GROUP(201),
- /* 80 */ 727, 729, 731, 733,
- /* 84 */ 735, 737, 739, 741,
- /* 88 */ 743, 745, 747, 749,
- /* 8c */ 751, 753, 755, 757,
- /* 90 */ 1350, 1351, 1352, 1353,
- /* 94 */ 1354, 1355, 1356, 1357,
- /* 98 */ 1358, 1359, 1360, 1361,
- /* 9c */ 1362, 1363, 1364, 1365,
- /* a0 */ 1245, 1100, 131, 1670,
- /* a4 */ 1375, 1376, GROUP(202), GROUP(207),
- /* a8 */ 1244, 1099, 1305, 1675,
- /* ac */ 1377, 1378, GROUP(215), 694,
- /* b0 */ 122, 123, 775, 1673,
- /* b4 */ 772, 773, 940, 941,
- /* b8 */ GROUP(221), INVALID, GROUP(222), 1671,
- /* bc */ 1659, 1660, 930, 931,
- /* c0 */ 1473, 1474, GROUP(223), 904,
- /* c4 */ GROUP(224), GROUP(225), GROUP(226), GROUP(227),
- /* c8 */ 1661, 1662, 1663, 1664,
- /* cc */ 1665, 1666, 1667, 1668,
- /* d0 */ GROUP(236), GROUP(237), GROUP(238), GROUP(239),
- /* d4 */ GROUP(240), GROUP(241), GROUP(242), GROUP(243),
- /* d8 */ GROUP(244), GROUP(245), GROUP(246), GROUP(247),
- /* dc */ GROUP(248), GROUP(249), GROUP(250), GROUP(251),
- /* e0 */ GROUP(252), GROUP(253), GROUP(254), GROUP(255),
- /* e4 */ GROUP(256), GROUP(257), GROUP(258), GROUP(259),
- /* e8 */ GROUP(260), GROUP(261), GROUP(262), GROUP(263),
- /* ec */ GROUP(264), GROUP(265), GROUP(266), GROUP(267),
- /* f0 */ GROUP(268), GROUP(269), GROUP(270), GROUP(271),
- /* f4 */ GROUP(272), GROUP(273), GROUP(274), GROUP(275),
- /* f8 */ GROUP(277), GROUP(278), GROUP(279), GROUP(280),
- /* fc */ GROUP(281), GROUP(282), GROUP(283), INVALID,
-};
-
-static const uint16_t ud_itab__5[] = {
- /* 0 */ 1384, 1406, 786, 798,
- /* 4 */ 1453, 1454, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__6[] = {
- /* 0 */ GROUP(7), GROUP(8),
-};
-
-static const uint16_t ud_itab__7[] = {
- /* 0 */ 1374, 1383, 785, 774,
- /* 4 */ 1385, INVALID, 787, 719,
-};
-
-static const uint16_t ud_itab__8[] = {
- /* 0 */ GROUP(9), GROUP(14), GROUP(15), GROUP(16),
- /* 4 */ 1386, INVALID, 788, GROUP(25),
-};
-
-static const uint16_t ud_itab__9[] = {
- /* 0 */ INVALID, GROUP(10), GROUP(11), GROUP(12),
- /* 4 */ GROUP(13), INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__10[] = {
- /* 0 */ INVALID, 1455, INVALID,
-};
-
-static const uint16_t ud_itab__11[] = {
- /* 0 */ INVALID, 1461, INVALID,
-};
-
-static const uint16_t ud_itab__12[] = {
- /* 0 */ INVALID, 1462, INVALID,
-};
-
-static const uint16_t ud_itab__13[] = {
- /* 0 */ INVALID, 1463, INVALID,
-};
-
-static const uint16_t ud_itab__14[] = {
- /* 0 */ 824, 952, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__15[] = {
- /* 0 */ 1485, 1508, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__16[] = {
- /* 0 */ GROUP(17), GROUP(18), GROUP(19), GROUP(20),
- /* 4 */ GROUP(21), GROUP(22), GROUP(23), GROUP(24),
-};
-
-static const uint16_t ud_itab__17[] = {
- /* 0 */ 1466, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__18[] = {
- /* 0 */ 1467, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__19[] = {
- /* 0 */ 1468, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__20[] = {
- /* 0 */ 1469, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__21[] = {
- /* 0 */ 1397, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__22[] = {
- /* 0 */ 80, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__23[] = {
- /* 0 */ 1399, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__24[] = {
- /* 0 */ 720, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__25[] = {
- /* 0 */ 1425, GROUP(26), INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__26[] = {
- /* 0 */ 1298, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__27[] = {
- /* 0 */ 1119, 1120, 1121, 1122,
- /* 4 */ 1123, 1124, 1125, 1126,
-};
-
-static const uint16_t ud_itab__28[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
- /* 8 */ INVALID, INVALID, INVALID, INVALID,
- /* c */ 1216, 1217, INVALID, INVALID,
- /* 10 */ INVALID, INVALID, INVALID, INVALID,
- /* 14 */ INVALID, INVALID, INVALID, INVALID,
- /* 18 */ INVALID, INVALID, INVALID, INVALID,
- /* 1c */ 1218, 1219, INVALID, INVALID,
- /* 20 */ INVALID, INVALID, INVALID, INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ INVALID, INVALID, INVALID, INVALID,
- /* 2c */ INVALID, INVALID, INVALID, INVALID,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
- /* 40 */ INVALID, INVALID, INVALID, INVALID,
- /* 44 */ INVALID, INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, INVALID, INVALID,
- /* 4c */ INVALID, INVALID, INVALID, INVALID,
- /* 50 */ INVALID, INVALID, INVALID, INVALID,
- /* 54 */ INVALID, INVALID, INVALID, INVALID,
- /* 58 */ INVALID, INVALID, INVALID, INVALID,
- /* 5c */ INVALID, INVALID, INVALID, INVALID,
- /* 60 */ INVALID, INVALID, INVALID, INVALID,
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ INVALID, INVALID, INVALID, INVALID,
- /* 6c */ INVALID, INVALID, INVALID, INVALID,
- /* 70 */ INVALID, INVALID, INVALID, INVALID,
- /* 74 */ INVALID, INVALID, INVALID, INVALID,
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ INVALID, INVALID, INVALID, INVALID,
- /* 80 */ INVALID, INVALID, INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, 1220, INVALID,
- /* 8c */ INVALID, INVALID, 1221, INVALID,
- /* 90 */ 1222, INVALID, INVALID, INVALID,
- /* 94 */ 1223, INVALID, 1224, 1225,
- /* 98 */ INVALID, INVALID, 1226, INVALID,
- /* 9c */ INVALID, INVALID, 1227, INVALID,
- /* a0 */ 1228, INVALID, INVALID, INVALID,
- /* a4 */ 1229, INVALID, 1230, 1231,
- /* a8 */ INVALID, INVALID, 1232, INVALID,
- /* ac */ INVALID, INVALID, 1233, INVALID,
- /* b0 */ 1234, INVALID, INVALID, INVALID,
- /* b4 */ 1235, INVALID, 1236, 1237,
- /* b8 */ INVALID, INVALID, INVALID, 1238,
- /* bc */ INVALID, INVALID, INVALID, 1239,
- /* c0 */ INVALID, INVALID, INVALID, INVALID,
- /* c4 */ INVALID, INVALID, INVALID, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ INVALID, INVALID, INVALID, INVALID,
- /* d4 */ INVALID, INVALID, INVALID, INVALID,
- /* d8 */ INVALID, INVALID, INVALID, INVALID,
- /* dc */ INVALID, INVALID, INVALID, INVALID,
- /* e0 */ INVALID, INVALID, INVALID, INVALID,
- /* e4 */ INVALID, INVALID, INVALID, INVALID,
- /* e8 */ INVALID, INVALID, INVALID, INVALID,
- /* ec */ INVALID, INVALID, INVALID, INVALID,
- /* f0 */ INVALID, INVALID, INVALID, INVALID,
- /* f4 */ INVALID, INVALID, INVALID, INVALID,
- /* f8 */ INVALID, INVALID, INVALID, INVALID,
- /* fc */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__29[] = {
- /* 0 */ 936, 925, 928, 932,
-};
-
-static const uint16_t ud_itab__30[] = {
- /* 0 */ 938, 926, 929, 934,
-};
-
-static const uint16_t ud_itab__31[] = {
- /* 0 */ GROUP(32), GROUP(33),
-};
-
-static const uint16_t ud_itab__32[] = {
- /* 0 */ 892, 1563, 1571, 888,
-};
-
-static const uint16_t ud_itab__33[] = {
- /* 0 */ 896, 1561, 1569, INVALID,
-};
-
-static const uint16_t ud_itab__34[] = {
- /* 0 */ 894, INVALID, INVALID, 890,
-};
-
-static const uint16_t ud_itab__35[] = {
- /* 0 */ 1449, INVALID, INVALID, 1451,
-};
-
-static const uint16_t ud_itab__36[] = {
- /* 0 */ 1447, INVALID, INVALID, 1445,
-};
-
-static const uint16_t ud_itab__37[] = {
- /* 0 */ GROUP(38), GROUP(39),
-};
-
-static const uint16_t ud_itab__38[] = {
- /* 0 */ 882, INVALID, 1567, 878,
-};
-
-static const uint16_t ud_itab__39[] = {
- /* 0 */ 886, INVALID, 1565, INVALID,
-};
-
-static const uint16_t ud_itab__40[] = {
- /* 0 */ 884, INVALID, INVALID, 880,
-};
-
-static const uint16_t ud_itab__41[] = {
- /* 0 */ 1127, 1128, 1129, 1130,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__42[] = {
- /* 0 */ 862, INVALID, INVALID, 858,
-};
-
-static const uint16_t ud_itab__43[] = {
- /* 0 */ 864, INVALID, INVALID, 860,
-};
-
-static const uint16_t ud_itab__44[] = {
- /* 0 */ 141, 152, 154, 142,
-};
-
-static const uint16_t ud_itab__45[] = {
- /* 0 */ 907, INVALID, INVALID, 905,
-};
-
-static const uint16_t ud_itab__46[] = {
- /* 0 */ 165, 166, 168, 162,
-};
-
-static const uint16_t ud_itab__47[] = {
- /* 0 */ 147, 148, 158, 138,
-};
-
-static const uint16_t ud_itab__48[] = {
- /* 0 */ 1442, INVALID, INVALID, 1440,
-};
-
-static const uint16_t ud_itab__49[] = {
- /* 0 */ 129, INVALID, INVALID, 127,
-};
-
-static const uint16_t ud_itab__50[] = {
- /* 0 */ 1427, GROUP(51),
-};
-
-static const uint16_t ud_itab__51[] = {
- /* 0 */ INVALID, 1428, INVALID,
-};
-
-static const uint16_t ud_itab__52[] = {
- /* 0 */ 1429, GROUP(53),
-};
-
-static const uint16_t ud_itab__53[] = {
- /* 0 */ INVALID, 1430, INVALID,
-};
-
-static const uint16_t ud_itab__54[] = {
- /* 0 */ GROUP(67), GROUP(68), GROUP(63), GROUP(64),
- /* 4 */ GROUP(65), GROUP(66), GROUP(86), GROUP(90),
- /* 8 */ GROUP(69), GROUP(70), GROUP(71), GROUP(72),
- /* c */ INVALID, INVALID, INVALID, INVALID,
- /* 10 */ GROUP(73), INVALID, INVALID, INVALID,
- /* 14 */ GROUP(75), GROUP(76), INVALID, GROUP(77),
- /* 18 */ INVALID, INVALID, INVALID, INVALID,
- /* 1c */ GROUP(78), GROUP(79), GROUP(80), INVALID,
- /* 20 */ GROUP(81), GROUP(82), GROUP(83), GROUP(84),
- /* 24 */ GROUP(85), GROUP(108), INVALID, INVALID,
- /* 28 */ GROUP(87), GROUP(88), GROUP(89), GROUP(74),
- /* 2c */ INVALID, INVALID, INVALID, INVALID,
- /* 30 */ GROUP(91), GROUP(92), GROUP(93), GROUP(94),
- /* 34 */ GROUP(95), GROUP(96), INVALID, GROUP(97),
- /* 38 */ GROUP(98), GROUP(99), GROUP(100), GROUP(101),
- /* 3c */ GROUP(102), GROUP(103), GROUP(104), GROUP(105),
- /* 40 */ GROUP(106), GROUP(107), INVALID, INVALID,
- /* 44 */ INVALID, INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, INVALID, INVALID,
- /* 4c */ INVALID, INVALID, INVALID, INVALID,
- /* 50 */ INVALID, INVALID, INVALID, INVALID,
- /* 54 */ INVALID, INVALID, INVALID, INVALID,
- /* 58 */ INVALID, INVALID, INVALID, INVALID,
- /* 5c */ INVALID, INVALID, INVALID, INVALID,
- /* 60 */ INVALID, INVALID, INVALID, INVALID,
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ INVALID, INVALID, INVALID, INVALID,
- /* 6c */ INVALID, INVALID, INVALID, INVALID,
- /* 70 */ INVALID, INVALID, INVALID, INVALID,
- /* 74 */ INVALID, INVALID, INVALID, INVALID,
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ INVALID, INVALID, INVALID, INVALID,
- /* 80 */ GROUP(55), GROUP(59), INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, INVALID, INVALID,
- /* 8c */ INVALID, INVALID, INVALID, INVALID,
- /* 90 */ INVALID, INVALID, INVALID, INVALID,
- /* 94 */ INVALID, INVALID, INVALID, INVALID,
- /* 98 */ INVALID, INVALID, INVALID, INVALID,
- /* 9c */ INVALID, INVALID, INVALID, INVALID,
- /* a0 */ INVALID, INVALID, INVALID, INVALID,
- /* a4 */ INVALID, INVALID, INVALID, INVALID,
- /* a8 */ INVALID, INVALID, INVALID, INVALID,
- /* ac */ INVALID, INVALID, INVALID, INVALID,
- /* b0 */ INVALID, INVALID, INVALID, INVALID,
- /* b4 */ INVALID, INVALID, INVALID, INVALID,
- /* b8 */ INVALID, INVALID, INVALID, INVALID,
- /* bc */ INVALID, INVALID, INVALID, INVALID,
- /* c0 */ INVALID, INVALID, INVALID, INVALID,
- /* c4 */ INVALID, INVALID, INVALID, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ INVALID, INVALID, INVALID, INVALID,
- /* d4 */ INVALID, INVALID, INVALID, INVALID,
- /* d8 */ INVALID, INVALID, INVALID, GROUP(109),
- /* dc */ GROUP(110), GROUP(111), GROUP(112), GROUP(113),
- /* e0 */ INVALID, INVALID, INVALID, INVALID,
- /* e4 */ INVALID, INVALID, INVALID, INVALID,
- /* e8 */ INVALID, INVALID, INVALID, INVALID,
- /* ec */ INVALID, INVALID, INVALID, INVALID,
- /* f0 */ GROUP(114), GROUP(115), INVALID, INVALID,
- /* f4 */ INVALID, INVALID, INVALID, INVALID,
- /* f8 */ INVALID, INVALID, INVALID, INVALID,
- /* fc */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__55[] = {
- /* 0 */ INVALID, INVALID, INVALID, GROUP(56),
-};
-
-static const uint16_t ud_itab__56[] = {
- /* 0 */ GROUP(57), GROUP(58),
-};
-
-static const uint16_t ud_itab__57[] = {
- /* 0 */ INVALID, 717, INVALID,
-};
-
-static const uint16_t ud_itab__58[] = {
- /* 0 */ INVALID, 718, INVALID,
-};
-
-static const uint16_t ud_itab__59[] = {
- /* 0 */ INVALID, INVALID, INVALID, GROUP(60),
-};
-
-static const uint16_t ud_itab__60[] = {
- /* 0 */ GROUP(61), GROUP(62),
-};
-
-static const uint16_t ud_itab__61[] = {
- /* 0 */ INVALID, 721, INVALID,
-};
-
-static const uint16_t ud_itab__62[] = {
- /* 0 */ INVALID, 722, INVALID,
-};
-
-static const uint16_t ud_itab__63[] = {
- /* 0 */ 1588, INVALID, INVALID, 1589,
-};
-
-static const uint16_t ud_itab__64[] = {
- /* 0 */ 1591, INVALID, INVALID, 1592,
-};
-
-static const uint16_t ud_itab__65[] = {
- /* 0 */ 1594, INVALID, INVALID, 1595,
-};
-
-static const uint16_t ud_itab__66[] = {
- /* 0 */ 1597, INVALID, INVALID, 1598,
-};
-
-static const uint16_t ud_itab__67[] = {
- /* 0 */ 1582, INVALID, INVALID, 1583,
-};
-
-static const uint16_t ud_itab__68[] = {
- /* 0 */ 1585, INVALID, INVALID, 1586,
-};
-
-static const uint16_t ud_itab__69[] = {
- /* 0 */ 1606, INVALID, INVALID, 1607,
-};
-
-static const uint16_t ud_itab__70[] = {
- /* 0 */ 1612, INVALID, INVALID, 1613,
-};
-
-static const uint16_t ud_itab__71[] = {
- /* 0 */ 1609, INVALID, INVALID, 1610,
-};
-
-static const uint16_t ud_itab__72[] = {
- /* 0 */ 1615, INVALID, INVALID, 1616,
-};
-
-static const uint16_t ud_itab__73[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1621,
-};
-
-static const uint16_t ud_itab__74[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1683,
-};
-
-static const uint16_t ud_itab__75[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1657,
-};
-
-static const uint16_t ud_itab__76[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1656,
-};
-
-static const uint16_t ud_itab__77[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1711,
-};
-
-static const uint16_t ud_itab__78[] = {
- /* 0 */ 1573, INVALID, INVALID, 1574,
-};
-
-static const uint16_t ud_itab__79[] = {
- /* 0 */ 1576, INVALID, INVALID, 1577,
-};
-
-static const uint16_t ud_itab__80[] = {
- /* 0 */ 1579, INVALID, INVALID, 1580,
-};
-
-static const uint16_t ud_itab__81[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1685,
-};
-
-static const uint16_t ud_itab__82[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1687,
-};
-
-static const uint16_t ud_itab__83[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1689,
-};
-
-static const uint16_t ud_itab__84[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1691,
-};
-
-static const uint16_t ud_itab__85[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1693,
-};
-
-static const uint16_t ud_itab__86[] = {
- /* 0 */ 1600, INVALID, INVALID, 1601,
-};
-
-static const uint16_t ud_itab__87[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1622,
-};
-
-static const uint16_t ud_itab__88[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1708,
-};
-
-static const uint16_t ud_itab__89[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1681,
-};
-
-static const uint16_t ud_itab__90[] = {
- /* 0 */ 1603, INVALID, INVALID, 1604,
-};
-
-static const uint16_t ud_itab__91[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1696,
-};
-
-static const uint16_t ud_itab__92[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1698,
-};
-
-static const uint16_t ud_itab__93[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1700,
-};
-
-static const uint16_t ud_itab__94[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1702,
-};
-
-static const uint16_t ud_itab__95[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1704,
-};
-
-static const uint16_t ud_itab__96[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1706,
-};
-
-static const uint16_t ud_itab__97[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1717,
-};
-
-static const uint16_t ud_itab__98[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1624,
-};
-
-static const uint16_t ud_itab__99[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1626,
-};
-
-static const uint16_t ud_itab__100[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1628,
-};
-
-static const uint16_t ud_itab__101[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1630,
-};
-
-static const uint16_t ud_itab__102[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1632,
-};
-
-static const uint16_t ud_itab__103[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1634,
-};
-
-static const uint16_t ud_itab__104[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1638,
-};
-
-static const uint16_t ud_itab__105[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1636,
-};
-
-static const uint16_t ud_itab__106[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1640,
-};
-
-static const uint16_t ud_itab__107[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1642,
-};
-
-static const uint16_t ud_itab__108[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1695,
-};
-
-static const uint16_t ud_itab__109[] = {
- /* 0 */ INVALID, INVALID, INVALID, 45,
-};
-
-static const uint16_t ud_itab__110[] = {
- /* 0 */ INVALID, INVALID, INVALID, 41,
-};
-
-static const uint16_t ud_itab__111[] = {
- /* 0 */ INVALID, INVALID, INVALID, 43,
-};
-
-static const uint16_t ud_itab__112[] = {
- /* 0 */ INVALID, INVALID, INVALID, 37,
-};
-
-static const uint16_t ud_itab__113[] = {
- /* 0 */ INVALID, INVALID, INVALID, 39,
-};
-
-static const uint16_t ud_itab__114[] = {
- /* 0 */ 1723, 1725, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__115[] = {
- /* 0 */ 1724, 1726, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__116[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
- /* 8 */ GROUP(117), GROUP(118), GROUP(119), GROUP(120),
- /* c */ GROUP(121), GROUP(122), GROUP(123), GROUP(124),
- /* 10 */ INVALID, INVALID, INVALID, INVALID,
- /* 14 */ GROUP(125), GROUP(126), GROUP(127), GROUP(129),
- /* 18 */ INVALID, INVALID, INVALID, INVALID,
- /* 1c */ INVALID, INVALID, INVALID, INVALID,
- /* 20 */ GROUP(130), GROUP(131), GROUP(132), INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ INVALID, INVALID, INVALID, INVALID,
- /* 2c */ INVALID, INVALID, INVALID, INVALID,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
- /* 40 */ GROUP(134), GROUP(135), GROUP(136), INVALID,
- /* 44 */ GROUP(137), INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, INVALID, INVALID,
- /* 4c */ INVALID, INVALID, INVALID, INVALID,
- /* 50 */ INVALID, INVALID, INVALID, INVALID,
- /* 54 */ INVALID, INVALID, INVALID, INVALID,
- /* 58 */ INVALID, INVALID, INVALID, INVALID,
- /* 5c */ INVALID, INVALID, INVALID, INVALID,
- /* 60 */ GROUP(139), GROUP(140), GROUP(141), GROUP(142),
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ INVALID, INVALID, INVALID, INVALID,
- /* 6c */ INVALID, INVALID, INVALID, INVALID,
- /* 70 */ INVALID, INVALID, INVALID, INVALID,
- /* 74 */ INVALID, INVALID, INVALID, INVALID,
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ INVALID, INVALID, INVALID, INVALID,
- /* 80 */ INVALID, INVALID, INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, INVALID, INVALID,
- /* 8c */ INVALID, INVALID, INVALID, INVALID,
- /* 90 */ INVALID, INVALID, INVALID, INVALID,
- /* 94 */ INVALID, INVALID, INVALID, INVALID,
- /* 98 */ INVALID, INVALID, INVALID, INVALID,
- /* 9c */ INVALID, INVALID, INVALID, INVALID,
- /* a0 */ INVALID, INVALID, INVALID, INVALID,
- /* a4 */ INVALID, INVALID, INVALID, INVALID,
- /* a8 */ INVALID, INVALID, INVALID, INVALID,
- /* ac */ INVALID, INVALID, INVALID, INVALID,
- /* b0 */ INVALID, INVALID, INVALID, INVALID,
- /* b4 */ INVALID, INVALID, INVALID, INVALID,
- /* b8 */ INVALID, INVALID, INVALID, INVALID,
- /* bc */ INVALID, INVALID, INVALID, INVALID,
- /* c0 */ INVALID, INVALID, INVALID, INVALID,
- /* c4 */ INVALID, INVALID, INVALID, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ INVALID, INVALID, INVALID, INVALID,
- /* d4 */ INVALID, INVALID, INVALID, INVALID,
- /* d8 */ INVALID, INVALID, INVALID, INVALID,
- /* dc */ INVALID, INVALID, INVALID, GROUP(138),
- /* e0 */ INVALID, INVALID, INVALID, INVALID,
- /* e4 */ INVALID, INVALID, INVALID, INVALID,
- /* e8 */ INVALID, INVALID, INVALID, INVALID,
- /* ec */ INVALID, INVALID, INVALID, INVALID,
- /* f0 */ INVALID, INVALID, INVALID, INVALID,
- /* f4 */ INVALID, INVALID, INVALID, INVALID,
- /* f8 */ INVALID, INVALID, INVALID, INVALID,
- /* fc */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__117[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1644,
-};
-
-static const uint16_t ud_itab__118[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1646,
-};
-
-static const uint16_t ud_itab__119[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1648,
-};
-
-static const uint16_t ud_itab__120[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1650,
-};
-
-static const uint16_t ud_itab__121[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1654,
-};
-
-static const uint16_t ud_itab__122[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1652,
-};
-
-static const uint16_t ud_itab__123[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1677,
-};
-
-static const uint16_t ud_itab__124[] = {
- /* 0 */ 1618, INVALID, INVALID, 1619,
-};
-
-static const uint16_t ud_itab__125[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1045,
-};
-
-static const uint16_t ud_itab__126[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1056,
-};
-
-static const uint16_t ud_itab__127[] = {
- /* 0 */ INVALID, INVALID, INVALID, GROUP(128),
-};
-
-static const uint16_t ud_itab__128[] = {
- /* 0 */ 1047, 1049, 1051,
-};
-
-static const uint16_t ud_itab__129[] = {
- /* 0 */ INVALID, INVALID, INVALID, 201,
-};
-
-static const uint16_t ud_itab__130[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1058,
-};
-
-static const uint16_t ud_itab__131[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1557,
-};
-
-static const uint16_t ud_itab__132[] = {
- /* 0 */ INVALID, INVALID, INVALID, GROUP(133),
-};
-
-static const uint16_t ud_itab__133[] = {
- /* 0 */ 1062, 1063, 1064,
-};
-
-static const uint16_t ud_itab__134[] = {
- /* 0 */ INVALID, INVALID, INVALID, 197,
-};
-
-static const uint16_t ud_itab__135[] = {
- /* 0 */ INVALID, INVALID, INVALID, 195,
-};
-
-static const uint16_t ud_itab__136[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1679,
-};
-
-static const uint16_t ud_itab__137[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1512,
-};
-
-static const uint16_t ud_itab__138[] = {
- /* 0 */ INVALID, INVALID, INVALID, 47,
-};
-
-static const uint16_t ud_itab__139[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1715,
-};
-
-static const uint16_t ud_itab__140[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1713,
-};
-
-static const uint16_t ud_itab__141[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1721,
-};
-
-static const uint16_t ud_itab__142[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1719,
-};
-
-static const uint16_t ud_itab__143[] = {
- /* 0 */ 900, INVALID, INVALID, 898,
-};
-
-static const uint16_t ud_itab__144[] = {
- /* 0 */ 1387, 1391, 1393, 1389,
-};
-
-static const uint16_t ud_itab__145[] = {
- /* 0 */ 1306, INVALID, 1308, INVALID,
-};
-
-static const uint16_t ud_itab__146[] = {
- /* 0 */ 1291, INVALID, 1293, INVALID,
-};
-
-static const uint16_t ud_itab__147[] = {
- /* 0 */ 61, INVALID, INVALID, 59,
-};
-
-static const uint16_t ud_itab__148[] = {
- /* 0 */ 65, INVALID, INVALID, 63,
-};
-
-static const uint16_t ud_itab__149[] = {
- /* 0 */ 976, INVALID, INVALID, 974,
-};
-
-static const uint16_t ud_itab__150[] = {
- /* 0 */ 1499, INVALID, INVALID, 1497,
-};
-
-static const uint16_t ud_itab__151[] = {
- /* 0 */ 27, 29, 31, 25,
-};
-
-static const uint16_t ud_itab__152[] = {
- /* 0 */ 946, 948, 950, 944,
-};
-
-static const uint16_t ud_itab__153[] = {
- /* 0 */ 145, 150, 156, 139,
-};
-
-static const uint16_t ud_itab__154[] = {
- /* 0 */ 134, INVALID, 163, 143,
-};
-
-static const uint16_t ud_itab__155[] = {
- /* 0 */ 1419, 1421, 1423, 1417,
-};
-
-static const uint16_t ud_itab__156[] = {
- /* 0 */ 818, 820, 822, 816,
-};
-
-static const uint16_t ud_itab__157[] = {
- /* 0 */ 189, 191, 193, 187,
-};
-
-static const uint16_t ud_itab__158[] = {
- /* 0 */ 802, 804, 806, 800,
-};
-
-static const uint16_t ud_itab__159[] = {
- /* 0 */ 1209, INVALID, INVALID, 1207,
-};
-
-static const uint16_t ud_itab__160[] = {
- /* 0 */ 1212, INVALID, INVALID, 1210,
-};
-
-static const uint16_t ud_itab__161[] = {
- /* 0 */ 1215, INVALID, INVALID, 1213,
-};
-
-static const uint16_t ud_itab__162[] = {
- /* 0 */ 987, INVALID, INVALID, 985,
-};
-
-static const uint16_t ud_itab__163[] = {
- /* 0 */ 1038, INVALID, INVALID, 1036,
-};
-
-static const uint16_t ud_itab__164[] = {
- /* 0 */ 1041, INVALID, INVALID, 1039,
-};
-
-static const uint16_t ud_itab__165[] = {
- /* 0 */ 1044, INVALID, INVALID, 1042,
-};
-
-static const uint16_t ud_itab__166[] = {
- /* 0 */ 993, INVALID, INVALID, 991,
-};
-
-static const uint16_t ud_itab__167[] = {
- /* 0 */ 1200, INVALID, INVALID, 1198,
-};
-
-static const uint16_t ud_itab__168[] = {
- /* 0 */ 1203, INVALID, INVALID, 1201,
-};
-
-static const uint16_t ud_itab__169[] = {
- /* 0 */ 1206, INVALID, INVALID, 1204,
-};
-
-static const uint16_t ud_itab__170[] = {
- /* 0 */ 990, INVALID, INVALID, 988,
-};
-
-static const uint16_t ud_itab__171[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1547,
-};
-
-static const uint16_t ud_itab__172[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1545,
-};
-
-static const uint16_t ud_itab__173[] = {
- /* 0 */ GROUP(174), INVALID, INVALID, GROUP(175),
-};
-
-static const uint16_t ud_itab__174[] = {
- /* 0 */ 866, 867, 910,
-};
-
-static const uint16_t ud_itab__175[] = {
- /* 0 */ 868, 870, 911,
-};
-
-static const uint16_t ud_itab__176[] = {
- /* 0 */ 920, INVALID, 1522, 1517,
-};
-
-static const uint16_t ud_itab__177[] = {
- /* 0 */ 1134, 1537, 1535, 1539,
-};
-
-static const uint16_t ud_itab__178[] = {
- /* 0 */ INVALID, INVALID, GROUP(179), INVALID,
- /* 4 */ GROUP(180), INVALID, GROUP(181), INVALID,
-};
-
-static const uint16_t ud_itab__179[] = {
- /* 0 */ 1159, INVALID, INVALID, 1163,
-};
-
-static const uint16_t ud_itab__180[] = {
- /* 0 */ 1152, INVALID, INVALID, 1150,
-};
-
-static const uint16_t ud_itab__181[] = {
- /* 0 */ 1138, INVALID, INVALID, 1137,
-};
-
-static const uint16_t ud_itab__182[] = {
- /* 0 */ INVALID, INVALID, GROUP(183), INVALID,
- /* 4 */ GROUP(184), INVALID, GROUP(185), INVALID,
-};
-
-static const uint16_t ud_itab__183[] = {
- /* 0 */ 1165, INVALID, INVALID, 1169,
-};
-
-static const uint16_t ud_itab__184[] = {
- /* 0 */ 1153, INVALID, INVALID, 1157,
-};
-
-static const uint16_t ud_itab__185[] = {
- /* 0 */ 1142, INVALID, INVALID, 1141,
-};
-
-static const uint16_t ud_itab__186[] = {
- /* 0 */ INVALID, INVALID, GROUP(187), GROUP(188),
- /* 4 */ INVALID, INVALID, GROUP(189), GROUP(190),
-};
-
-static const uint16_t ud_itab__187[] = {
- /* 0 */ 1171, INVALID, INVALID, 1175,
-};
-
-static const uint16_t ud_itab__188[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1543,
-};
-
-static const uint16_t ud_itab__189[] = {
- /* 0 */ 1146, INVALID, INVALID, 1145,
-};
-
-static const uint16_t ud_itab__190[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1541,
-};
-
-static const uint16_t ud_itab__191[] = {
- /* 0 */ 1027, INVALID, INVALID, 1028,
-};
-
-static const uint16_t ud_itab__192[] = {
- /* 0 */ 1030, INVALID, INVALID, 1031,
-};
-
-static const uint16_t ud_itab__193[] = {
- /* 0 */ 1033, INVALID, INVALID, 1034,
-};
-
-static const uint16_t ud_itab__194[] = {
- /* 0 */ INVALID, 1464, INVALID,
-};
-
-static const uint16_t ud_itab__195[] = {
- /* 0 */ INVALID, 1465, INVALID,
-};
-
-static const uint16_t ud_itab__196[] = {
- /* 0 */ INVALID, 1551, INVALID, 1549,
-};
-
-static const uint16_t ud_itab__197[] = {
- /* 0 */ INVALID, 1555, INVALID, 1553,
-};
-
-static const uint16_t ud_itab__198[] = {
- /* 0 */ GROUP(199), INVALID, 916, GROUP(200),
-};
-
-static const uint16_t ud_itab__199[] = {
- /* 0 */ 872, 873, 913,
-};
-
-static const uint16_t ud_itab__200[] = {
- /* 0 */ 874, 876, 914,
-};
-
-static const uint16_t ud_itab__201[] = {
- /* 0 */ 921, INVALID, 1524, 1515,
-};
-
-static const uint16_t ud_itab__202[] = {
- /* 0 */ INVALID, GROUP(203),
-};
-
-static const uint16_t ud_itab__203[] = {
- /* 0 */ GROUP(204), GROUP(205), GROUP(206), INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__204[] = {
- /* 0 */ 825, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__205[] = {
- /* 0 */ 1509, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__206[] = {
- /* 0 */ 1510, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__207[] = {
- /* 0 */ INVALID, GROUP(208),
-};
-
-static const uint16_t ud_itab__208[] = {
- /* 0 */ GROUP(209), GROUP(210), GROUP(211), GROUP(212),
- /* 4 */ GROUP(213), GROUP(214), INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__209[] = {
- /* 0 */ 1511, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__210[] = {
- /* 0 */ 1501, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__211[] = {
- /* 0 */ 1502, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__212[] = {
- /* 0 */ 1503, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__213[] = {
- /* 0 */ 1504, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__214[] = {
- /* 0 */ 1505, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__215[] = {
- /* 0 */ GROUP(216), GROUP(217),
-};
-
-static const uint16_t ud_itab__216[] = {
- /* 0 */ 683, 682, 768, 1400,
- /* 4 */ 1507, 1506, INVALID, 79,
-};
-
-static const uint16_t ud_itab__217[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, GROUP(218), GROUP(219), GROUP(220),
-};
-
-static const uint16_t ud_itab__218[] = {
- /* 0 */ 777, 778, 779, 780,
- /* 4 */ 781, 782, 783, 784,
-};
-
-static const uint16_t ud_itab__219[] = {
- /* 0 */ 808, 809, 810, 811,
- /* 4 */ 812, 813, 814, 815,
-};
-
-static const uint16_t ud_itab__220[] = {
- /* 0 */ 1366, 1367, 1368, 1369,
- /* 4 */ 1370, 1371, 1372, 1373,
-};
-
-static const uint16_t ud_itab__221[] = {
- /* 0 */ INVALID, INVALID, 1710, INVALID,
-};
-
-static const uint16_t ud_itab__222[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ 1669, 1676, 1674, 1672,
-};
-
-static const uint16_t ud_itab__223[] = {
- /* 0 */ 112, 117, 120, 110,
-};
-
-static const uint16_t ud_itab__224[] = {
- /* 0 */ 1059, INVALID, INVALID, 1060,
-};
-
-static const uint16_t ud_itab__225[] = {
- /* 0 */ 1055, INVALID, INVALID, 1053,
-};
-
-static const uint16_t ud_itab__226[] = {
- /* 0 */ 1381, INVALID, INVALID, 1379,
-};
-
-static const uint16_t ud_itab__227[] = {
- /* 0 */ GROUP(228), GROUP(235),
-};
-
-static const uint16_t ud_itab__228[] = {
- /* 0 */ INVALID, GROUP(229), INVALID, INVALID,
- /* 4 */ INVALID, INVALID, GROUP(230), GROUP(234),
-};
-
-static const uint16_t ud_itab__229[] = {
- /* 0 */ 124, 125, 126,
-};
-
-static const uint16_t ud_itab__230[] = {
- /* 0 */ GROUP(231), INVALID, GROUP(232), GROUP(233),
-};
-
-static const uint16_t ud_itab__231[] = {
- /* 0 */ INVALID, 1459, INVALID,
-};
-
-static const uint16_t ud_itab__232[] = {
- /* 0 */ INVALID, 1458, INVALID,
-};
-
-static const uint16_t ud_itab__233[] = {
- /* 0 */ INVALID, 1457, INVALID,
-};
-
-static const uint16_t ud_itab__234[] = {
- /* 0 */ INVALID, 1460, INVALID,
-};
-
-static const uint16_t ud_itab__235[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, 1456, INVALID,
-};
-
-static const uint16_t ud_itab__236[] = {
- /* 0 */ INVALID, 35, INVALID, 33,
-};
-
-static const uint16_t ud_itab__237[] = {
- /* 0 */ 1160, INVALID, INVALID, 1161,
-};
-
-static const uint16_t ud_itab__238[] = {
- /* 0 */ 1166, INVALID, INVALID, 1167,
-};
-
-static const uint16_t ud_itab__239[] = {
- /* 0 */ 1172, INVALID, INVALID, 1173,
-};
-
-static const uint16_t ud_itab__240[] = {
- /* 0 */ 1527, INVALID, INVALID, 1528,
-};
-
-static const uint16_t ud_itab__241[] = {
- /* 0 */ 1093, INVALID, INVALID, 1094,
-};
-
-static const uint16_t ud_itab__242[] = {
- /* 0 */ INVALID, 1521, 1526, 918,
-};
-
-static const uint16_t ud_itab__243[] = {
- /* 0 */ 1086, INVALID, INVALID, 1084,
-};
-
-static const uint16_t ud_itab__244[] = {
- /* 0 */ 1192, INVALID, INVALID, 1193,
-};
-
-static const uint16_t ud_itab__245[] = {
- /* 0 */ 1195, INVALID, INVALID, 1196,
-};
-
-static const uint16_t ud_itab__246[] = {
- /* 0 */ 1083, INVALID, INVALID, 1081,
-};
-
-static const uint16_t ud_itab__247[] = {
- /* 0 */ 1017, INVALID, INVALID, 1015,
-};
-
-static const uint16_t ud_itab__248[] = {
- /* 0 */ 1009, INVALID, INVALID, 1010,
-};
-
-static const uint16_t ud_itab__249[] = {
- /* 0 */ 1012, INVALID, INVALID, 1013,
-};
-
-static const uint16_t ud_itab__250[] = {
- /* 0 */ 1075, INVALID, INVALID, 1076,
-};
-
-static const uint16_t ud_itab__251[] = {
- /* 0 */ 1020, INVALID, INVALID, 1018,
-};
-
-static const uint16_t ud_itab__252[] = {
- /* 0 */ 1023, INVALID, INVALID, 1021,
-};
-
-static const uint16_t ud_itab__253[] = {
- /* 0 */ 1147, INVALID, INVALID, 1148,
-};
-
-static const uint16_t ud_itab__254[] = {
- /* 0 */ 1156, INVALID, INVALID, 1154,
-};
-
-static const uint16_t ud_itab__255[] = {
- /* 0 */ 1026, INVALID, INVALID, 1024,
-};
-
-static const uint16_t ud_itab__256[] = {
- /* 0 */ 1087, INVALID, INVALID, 1088,
-};
-
-static const uint16_t ud_itab__257[] = {
- /* 0 */ 1092, INVALID, INVALID, 1090,
-};
-
-static const uint16_t ud_itab__258[] = {
- /* 0 */ INVALID, 136, 132, 160,
-};
-
-static const uint16_t ud_itab__259[] = {
- /* 0 */ 909, INVALID, INVALID, 902,
-};
-
-static const uint16_t ud_itab__260[] = {
- /* 0 */ 1186, INVALID, INVALID, 1187,
-};
-
-static const uint16_t ud_itab__261[] = {
- /* 0 */ 1189, INVALID, INVALID, 1190,
-};
-
-static const uint16_t ud_itab__262[] = {
- /* 0 */ 1080, INVALID, INVALID, 1078,
-};
-
-static const uint16_t ud_itab__263[] = {
- /* 0 */ 1118, INVALID, INVALID, 1116,
-};
-
-static const uint16_t ud_itab__264[] = {
- /* 0 */ 1003, INVALID, INVALID, 1004,
-};
-
-static const uint16_t ud_itab__265[] = {
- /* 0 */ 1006, INVALID, INVALID, 1007,
-};
-
-static const uint16_t ud_itab__266[] = {
- /* 0 */ 1074, INVALID, INVALID, 1072,
-};
-
-static const uint16_t ud_itab__267[] = {
- /* 0 */ 1266, INVALID, INVALID, 1264,
-};
-
-static const uint16_t ud_itab__268[] = {
- /* 0 */ INVALID, 1559, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__269[] = {
- /* 0 */ 1136, INVALID, INVALID, 1135,
-};
-
-static const uint16_t ud_itab__270[] = {
- /* 0 */ 1140, INVALID, INVALID, 1139,
-};
-
-static const uint16_t ud_itab__271[] = {
- /* 0 */ 1144, INVALID, INVALID, 1143,
-};
-
-static const uint16_t ud_itab__272[] = {
- /* 0 */ 1533, INVALID, INVALID, 1534,
-};
-
-static const uint16_t ud_itab__273[] = {
- /* 0 */ 1069, INVALID, INVALID, 1070,
-};
-
-static const uint16_t ud_itab__274[] = {
- /* 0 */ 1133, INVALID, INVALID, 1131,
-};
-
-static const uint16_t ud_itab__275[] = {
- /* 0 */ INVALID, GROUP(276),
-};
-
-static const uint16_t ud_itab__276[] = {
- /* 0 */ 799, INVALID, INVALID, 1519,
-};
-
-static const uint16_t ud_itab__277[] = {
- /* 0 */ 1179, INVALID, INVALID, 1177,
-};
-
-static const uint16_t ud_itab__278[] = {
- /* 0 */ 1182, INVALID, INVALID, 1180,
-};
-
-static const uint16_t ud_itab__279[] = {
- /* 0 */ 1183, INVALID, INVALID, 1184,
-};
-
-static const uint16_t ud_itab__280[] = {
- /* 0 */ 1532, INVALID, INVALID, 1530,
-};
-
-static const uint16_t ud_itab__281[] = {
- /* 0 */ 996, INVALID, INVALID, 994,
-};
-
-static const uint16_t ud_itab__282[] = {
- /* 0 */ 997, INVALID, INVALID, 998,
-};
-
-static const uint16_t ud_itab__283[] = {
- /* 0 */ 1000, INVALID, INVALID, 1001,
-};
-
-static const uint16_t ud_itab__284[] = {
- /* 0 */ 1242, INVALID,
-};
-
-static const uint16_t ud_itab__285[] = {
- /* 0 */ 1097, INVALID,
-};
-
-static const uint16_t ud_itab__286[] = {
- /* 0 */ 1243, INVALID,
-};
-
-static const uint16_t ud_itab__287[] = {
- /* 0 */ 1098, INVALID,
-};
-
-static const uint16_t ud_itab__288[] = {
- /* 0 */ 173, INVALID,
-};
-
-static const uint16_t ud_itab__289[] = {
- /* 0 */ 174, INVALID,
-};
-
-static const uint16_t ud_itab__290[] = {
- /* 0 */ 1, INVALID,
-};
-
-static const uint16_t ud_itab__291[] = {
- /* 0 */ 4, INVALID,
-};
-
-static const uint16_t ud_itab__292[] = {
- /* 0 */ GROUP(293), GROUP(294), INVALID,
-};
-
-static const uint16_t ud_itab__293[] = {
- /* 0 */ 1257, INVALID,
-};
-
-static const uint16_t ud_itab__294[] = {
- /* 0 */ 1258, INVALID,
-};
-
-static const uint16_t ud_itab__295[] = {
- /* 0 */ GROUP(296), GROUP(297), INVALID,
-};
-
-static const uint16_t ud_itab__296[] = {
- /* 0 */ 1110, INVALID,
-};
-
-static const uint16_t ud_itab__297[] = {
- /* 0 */ 1111, INVALID,
-};
-
-static const uint16_t ud_itab__298[] = {
- /* 0 */ 1658, INVALID,
-};
-
-static const uint16_t ud_itab__299[] = {
- /* 0 */ 67, 68,
-};
-
-static const uint16_t ud_itab__300[] = {
- /* 0 */ 710, 711, INVALID,
-};
-
-static const uint16_t ud_itab__301[] = {
- /* 0 */ 983, 984, INVALID,
-};
-
-static const uint16_t ud_itab__302[] = {
- /* 0 */ 21, 970, 11, 1342,
- /* 4 */ 55, 1413, 1493, 106,
-};
-
-static const uint16_t ud_itab__303[] = {
- /* 0 */ 23, 971, 13, 1343,
- /* 4 */ 57, 1414, 1494, 108,
-};
-
-static const uint16_t ud_itab__304[] = {
- /* 0 */ GROUP(305), GROUP(306), GROUP(307), GROUP(308),
- /* 4 */ GROUP(309), GROUP(310), GROUP(311), GROUP(312),
-};
-
-static const uint16_t ud_itab__305[] = {
- /* 0 */ 22, INVALID,
-};
-
-static const uint16_t ud_itab__306[] = {
- /* 0 */ 972, INVALID,
-};
-
-static const uint16_t ud_itab__307[] = {
- /* 0 */ 12, INVALID,
-};
-
-static const uint16_t ud_itab__308[] = {
- /* 0 */ 1344, INVALID,
-};
-
-static const uint16_t ud_itab__309[] = {
- /* 0 */ 56, INVALID,
-};
-
-static const uint16_t ud_itab__310[] = {
- /* 0 */ 1415, INVALID,
-};
-
-static const uint16_t ud_itab__311[] = {
- /* 0 */ 1495, INVALID,
-};
-
-static const uint16_t ud_itab__312[] = {
- /* 0 */ 107, INVALID,
-};
-
-static const uint16_t ud_itab__313[] = {
- /* 0 */ 24, 973, 14, 1345,
- /* 4 */ 58, 1416, 1496, 109,
-};
-
-static const uint16_t ud_itab__314[] = {
- /* 0 */ 1109, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__315[] = {
- /* 0 */ 74, 75, 76,
-};
-
-static const uint16_t ud_itab__316[] = {
- /* 0 */ 170, 171, 172,
-};
-
-static const uint16_t ud_itab__317[] = {
- /* 0 */ 73, INVALID,
-};
-
-static const uint16_t ud_itab__318[] = {
- /* 0 */ GROUP(319), GROUP(320), GROUP(321),
-};
-
-static const uint16_t ud_itab__319[] = {
- /* 0 */ 1259, 1260,
-};
-
-static const uint16_t ud_itab__320[] = {
- /* 0 */ 1261, 1262,
-};
-
-static const uint16_t ud_itab__321[] = {
- /* 0 */ INVALID, 1263,
-};
-
-static const uint16_t ud_itab__322[] = {
- /* 0 */ GROUP(323), GROUP(324), GROUP(325),
-};
-
-static const uint16_t ud_itab__323[] = {
- /* 0 */ 1112, INVALID,
-};
-
-static const uint16_t ud_itab__324[] = {
- /* 0 */ 1113, 1114,
-};
-
-static const uint16_t ud_itab__325[] = {
- /* 0 */ INVALID, 1115,
-};
-
-static const uint16_t ud_itab__326[] = {
- /* 0 */ 923, 924, 927,
-};
-
-static const uint16_t ud_itab__327[] = {
- /* 0 */ 115, 116, 119,
-};
-
-static const uint16_t ud_itab__328[] = {
- /* 0 */ 1403, 1404, 1405,
-};
-
-static const uint16_t ud_itab__329[] = {
- /* 0 */ 791, 792, 793,
-};
-
-static const uint16_t ud_itab__330[] = {
- /* 0 */ 1347, 1348, 1349,
-};
-
-static const uint16_t ud_itab__331[] = {
- /* 0 */ 1279, 1286, 1267, 1275,
- /* 4 */ 1327, 1334, 1318, 1313,
-};
-
-static const uint16_t ud_itab__332[] = {
- /* 0 */ 1284, 1287, 1268, 1274,
- /* 4 */ 1323, 1330, 1319, 1315,
-};
-
-static const uint16_t ud_itab__333[] = {
- /* 0 */ GROUP(334), GROUP(335), INVALID, INVALID,
- /* 4 */ INVALID, GROUP(341), GROUP(357), GROUP(369),
- /* 8 */ INVALID, GROUP(394), INVALID, INVALID,
- /* c */ INVALID, GROUP(399), INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__334[] = {
- /* 0 */ 771, INVALID,
-};
-
-static const uint16_t ud_itab__335[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
- /* 8 */ INVALID, INVALID, INVALID, INVALID,
- /* c */ INVALID, INVALID, INVALID, INVALID,
- /* 10 */ 937, 939, GROUP(336), 895,
- /* 14 */ 1450, 1448, GROUP(337), 885,
- /* 18 */ INVALID, INVALID, INVALID, INVALID,
- /* 1c */ INVALID, INVALID, INVALID, INVALID,
- /* 20 */ INVALID, INVALID, INVALID, INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ 863, 865, INVALID, 908,
- /* 2c */ INVALID, INVALID, 1443, 130,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
- /* 40 */ INVALID, INVALID, INVALID, INVALID,
- /* 44 */ INVALID, INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, INVALID, INVALID,
- /* 4c */ INVALID, INVALID, INVALID, INVALID,
- /* 50 */ 901, 1388, 1307, 1292,
- /* 54 */ 62, 66, 977, 1500,
- /* 58 */ 28, 947, 146, 135,
- /* 5c */ 1420, 819, 190, 803,
- /* 60 */ INVALID, INVALID, INVALID, INVALID,
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ INVALID, INVALID, INVALID, INVALID,
- /* 6c */ INVALID, INVALID, INVALID, INVALID,
- /* 70 */ INVALID, INVALID, INVALID, INVALID,
- /* 74 */ INVALID, INVALID, INVALID, GROUP(340),
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ INVALID, INVALID, INVALID, INVALID,
- /* 80 */ INVALID, INVALID, INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, INVALID, INVALID,
- /* 8c */ INVALID, INVALID, INVALID, INVALID,
- /* 90 */ INVALID, INVALID, INVALID, INVALID,
- /* 94 */ INVALID, INVALID, INVALID, INVALID,
- /* 98 */ INVALID, INVALID, INVALID, INVALID,
- /* 9c */ INVALID, INVALID, INVALID, INVALID,
- /* a0 */ INVALID, INVALID, INVALID, INVALID,
- /* a4 */ INVALID, INVALID, INVALID, INVALID,
- /* a8 */ INVALID, INVALID, INVALID, INVALID,
- /* ac */ INVALID, INVALID, GROUP(338), INVALID,
- /* b0 */ INVALID, INVALID, INVALID, INVALID,
- /* b4 */ INVALID, INVALID, INVALID, INVALID,
- /* b8 */ INVALID, INVALID, INVALID, INVALID,
- /* bc */ INVALID, INVALID, INVALID, INVALID,
- /* c0 */ INVALID, INVALID, 113, INVALID,
- /* c4 */ INVALID, INVALID, 1382, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ INVALID, INVALID, INVALID, INVALID,
- /* d4 */ INVALID, INVALID, INVALID, INVALID,
- /* d8 */ INVALID, INVALID, INVALID, INVALID,
- /* dc */ INVALID, INVALID, INVALID, INVALID,
- /* e0 */ INVALID, INVALID, INVALID, INVALID,
- /* e4 */ INVALID, INVALID, INVALID, INVALID,
- /* e8 */ INVALID, INVALID, INVALID, INVALID,
- /* ec */ INVALID, INVALID, INVALID, INVALID,
- /* f0 */ INVALID, INVALID, INVALID, INVALID,
- /* f4 */ INVALID, INVALID, INVALID, INVALID,
- /* f8 */ INVALID, INVALID, INVALID, INVALID,
- /* fc */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__336[] = {
- /* 0 */ 893, 897,
-};
-
-static const uint16_t ud_itab__337[] = {
- /* 0 */ 883, 887,
-};
-
-static const uint16_t ud_itab__338[] = {
- /* 0 */ GROUP(339), INVALID,
-};
-
-static const uint16_t ud_itab__339[] = {
- /* 0 */ INVALID, INVALID, INVALID, 1401,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__340[] = {
- /* 0 */ 1742, 1743,
-};
-
-static const uint16_t ud_itab__341[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
- /* 8 */ INVALID, INVALID, INVALID, INVALID,
- /* c */ INVALID, INVALID, INVALID, INVALID,
- /* 10 */ 933, 935, GROUP(342), 891,
- /* 14 */ 1452, 1446, GROUP(343), 881,
- /* 18 */ INVALID, INVALID, INVALID, INVALID,
- /* 1c */ INVALID, INVALID, INVALID, INVALID,
- /* 20 */ INVALID, INVALID, INVALID, INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ 859, 861, INVALID, 906,
- /* 2c */ INVALID, INVALID, 1441, 128,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
- /* 40 */ INVALID, INVALID, INVALID, INVALID,
- /* 44 */ INVALID, INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, INVALID, INVALID,
- /* 4c */ INVALID, INVALID, INVALID, INVALID,
- /* 50 */ 899, 1390, INVALID, INVALID,
- /* 54 */ 60, 64, 975, 1498,
- /* 58 */ 26, 945, 140, 144,
- /* 5c */ 1418, 817, 188, 801,
- /* 60 */ 1208, 1211, 1214, 986,
- /* 64 */ 1037, 1040, 1043, 992,
- /* 68 */ 1199, 1202, 1205, 989,
- /* 6c */ 1548, 1546, GROUP(344), 1518,
- /* 70 */ 1540, GROUP(345), GROUP(347), GROUP(349),
- /* 74 */ 1029, 1032, 1035, INVALID,
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ 1550, 1554, GROUP(351), 1516,
- /* 80 */ INVALID, INVALID, INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, INVALID, INVALID,
- /* 8c */ INVALID, INVALID, INVALID, INVALID,
- /* 90 */ INVALID, INVALID, INVALID, INVALID,
- /* 94 */ INVALID, INVALID, INVALID, INVALID,
- /* 98 */ INVALID, INVALID, INVALID, INVALID,
- /* 9c */ INVALID, INVALID, INVALID, INVALID,
- /* a0 */ INVALID, INVALID, INVALID, INVALID,
- /* a4 */ INVALID, INVALID, INVALID, INVALID,
- /* a8 */ INVALID, INVALID, INVALID, INVALID,
- /* ac */ INVALID, INVALID, INVALID, INVALID,
- /* b0 */ INVALID, INVALID, INVALID, INVALID,
- /* b4 */ INVALID, INVALID, INVALID, INVALID,
- /* b8 */ INVALID, INVALID, INVALID, INVALID,
- /* bc */ INVALID, INVALID, INVALID, INVALID,
- /* c0 */ INVALID, INVALID, 111, INVALID,
- /* c4 */ 1061, 1054, 1380, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ 34, 1162, 1168, 1174,
- /* d4 */ 1529, 1095, 919, GROUP(352),
- /* d8 */ 1194, 1197, 1082, 1016,
- /* dc */ 1011, 1014, 1077, 1019,
- /* e0 */ 1022, 1149, 1155, 1025,
- /* e4 */ 1089, 1091, 161, 903,
- /* e8 */ 1188, 1191, 1079, 1117,
- /* ec */ 1005, 1008, 1073, 1265,
- /* f0 */ INVALID, GROUP(353), GROUP(354), GROUP(355),
- /* f4 */ INVALID, 1071, 1132, GROUP(356),
- /* f8 */ 1178, 1181, 1185, 1531,
- /* fc */ 995, 999, 1002, INVALID,
-};
-
-static const uint16_t ud_itab__342[] = {
- /* 0 */ 889, INVALID,
-};
-
-static const uint16_t ud_itab__343[] = {
- /* 0 */ 879, INVALID,
-};
-
-static const uint16_t ud_itab__344[] = {
- /* 0 */ 869, 871, 912,
-};
-
-static const uint16_t ud_itab__345[] = {
- /* 0 */ INVALID, INVALID, 1164, INVALID,
- /* 4 */ 1151, INVALID, GROUP(346), INVALID,
-};
-
-static const uint16_t ud_itab__346[] = {
- /* 0 */ 1756, INVALID,
-};
-
-static const uint16_t ud_itab__347[] = {
- /* 0 */ INVALID, INVALID, 1170, INVALID,
- /* 4 */ 1158, INVALID, GROUP(348), INVALID,
-};
-
-static const uint16_t ud_itab__348[] = {
- /* 0 */ 1758, INVALID,
-};
-
-static const uint16_t ud_itab__349[] = {
- /* 0 */ INVALID, INVALID, 1176, 1544,
- /* 4 */ INVALID, INVALID, GROUP(350), 1542,
-};
-
-static const uint16_t ud_itab__350[] = {
- /* 0 */ 1760, INVALID,
-};
-
-static const uint16_t ud_itab__351[] = {
- /* 0 */ 875, 877, 915,
-};
-
-static const uint16_t ud_itab__352[] = {
- /* 0 */ 1085, INVALID,
-};
-
-static const uint16_t ud_itab__353[] = {
- /* 0 */ 1755, INVALID,
-};
-
-static const uint16_t ud_itab__354[] = {
- /* 0 */ 1757, INVALID,
-};
-
-static const uint16_t ud_itab__355[] = {
- /* 0 */ 1759, INVALID,
-};
-
-static const uint16_t ud_itab__356[] = {
- /* 0 */ INVALID, 1520,
-};
-
-static const uint16_t ud_itab__357[] = {
- /* 0 */ 1584, 1587, 1590, 1593,
- /* 4 */ 1596, 1599, 1602, 1605,
- /* 8 */ 1608, 1614, 1611, 1617,
- /* c */ GROUP(358), GROUP(359), GROUP(360), GROUP(361),
- /* 10 */ INVALID, INVALID, INVALID, INVALID,
- /* 14 */ INVALID, INVALID, INVALID, 1712,
- /* 18 */ GROUP(362), GROUP(363), INVALID, INVALID,
- /* 1c */ 1575, 1578, 1581, INVALID,
- /* 20 */ 1686, 1688, 1690, 1692,
- /* 24 */ 1694, INVALID, INVALID, INVALID,
- /* 28 */ 1623, 1709, 1682, 1684,
- /* 2c */ GROUP(365), GROUP(366), GROUP(367), GROUP(368),
- /* 30 */ 1697, 1699, 1701, 1703,
- /* 34 */ 1705, 1707, INVALID, 1718,
- /* 38 */ 1625, 1627, 1629, 1631,
- /* 3c */ 1633, 1635, 1639, 1637,
- /* 40 */ 1641, 1643, INVALID, INVALID,
- /* 44 */ INVALID, INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, INVALID, INVALID,
- /* 4c */ INVALID, INVALID, INVALID, INVALID,
- /* 50 */ INVALID, INVALID, INVALID, INVALID,
- /* 54 */ INVALID, INVALID, INVALID, INVALID,
- /* 58 */ INVALID, INVALID, INVALID, INVALID,
- /* 5c */ INVALID, INVALID, INVALID, INVALID,
- /* 60 */ INVALID, INVALID, INVALID, INVALID,
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ INVALID, INVALID, INVALID, INVALID,
- /* 6c */ INVALID, INVALID, INVALID, INVALID,
- /* 70 */ INVALID, INVALID, INVALID, INVALID,
- /* 74 */ INVALID, INVALID, INVALID, INVALID,
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ INVALID, INVALID, INVALID, INVALID,
- /* 80 */ INVALID, INVALID, INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, INVALID, INVALID,
- /* 8c */ INVALID, INVALID, INVALID, INVALID,
- /* 90 */ INVALID, INVALID, INVALID, INVALID,
- /* 94 */ INVALID, INVALID, INVALID, INVALID,
- /* 98 */ INVALID, INVALID, INVALID, INVALID,
- /* 9c */ INVALID, INVALID, INVALID, INVALID,
- /* a0 */ INVALID, INVALID, INVALID, INVALID,
- /* a4 */ INVALID, INVALID, INVALID, INVALID,
- /* a8 */ INVALID, INVALID, INVALID, INVALID,
- /* ac */ INVALID, INVALID, INVALID, INVALID,
- /* b0 */ INVALID, INVALID, INVALID, INVALID,
- /* b4 */ INVALID, INVALID, INVALID, INVALID,
- /* b8 */ INVALID, INVALID, INVALID, INVALID,
- /* bc */ INVALID, INVALID, INVALID, INVALID,
- /* c0 */ INVALID, INVALID, INVALID, INVALID,
- /* c4 */ INVALID, INVALID, INVALID, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ INVALID, INVALID, INVALID, INVALID,
- /* d4 */ INVALID, INVALID, INVALID, INVALID,
- /* d8 */ INVALID, INVALID, INVALID, 46,
- /* dc */ 42, 44, 38, 40,
- /* e0 */ INVALID, INVALID, INVALID, INVALID,
- /* e4 */ INVALID, INVALID, INVALID, INVALID,
- /* e8 */ INVALID, INVALID, INVALID, INVALID,
- /* ec */ INVALID, INVALID, INVALID, INVALID,
- /* f0 */ INVALID, INVALID, INVALID, INVALID,
- /* f4 */ INVALID, INVALID, INVALID, INVALID,
- /* f8 */ INVALID, INVALID, INVALID, INVALID,
- /* fc */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__358[] = {
- /* 0 */ 1737, INVALID,
-};
-
-static const uint16_t ud_itab__359[] = {
- /* 0 */ 1735, INVALID,
-};
-
-static const uint16_t ud_itab__360[] = {
- /* 0 */ 1740, INVALID,
-};
-
-static const uint16_t ud_itab__361[] = {
- /* 0 */ 1741, INVALID,
-};
-
-static const uint16_t ud_itab__362[] = {
- /* 0 */ 1727, INVALID,
-};
-
-static const uint16_t ud_itab__363[] = {
- /* 0 */ GROUP(364), INVALID,
-};
-
-static const uint16_t ud_itab__364[] = {
- /* 0 */ INVALID, 1728,
-};
-
-static const uint16_t ud_itab__365[] = {
- /* 0 */ 1731, INVALID,
-};
-
-static const uint16_t ud_itab__366[] = {
- /* 0 */ 1733, INVALID,
-};
-
-static const uint16_t ud_itab__367[] = {
- /* 0 */ 1732, INVALID,
-};
-
-static const uint16_t ud_itab__368[] = {
- /* 0 */ 1734, INVALID,
-};
-
-static const uint16_t ud_itab__369[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ GROUP(370), GROUP(371), GROUP(372), INVALID,
- /* 8 */ 1645, 1647, 1649, 1651,
- /* c */ 1655, 1653, 1678, 1620,
- /* 10 */ INVALID, INVALID, INVALID, INVALID,
- /* 14 */ GROUP(374), 1057, GROUP(375), 202,
- /* 18 */ GROUP(379), GROUP(381), INVALID, INVALID,
- /* 1c */ INVALID, INVALID, INVALID, INVALID,
- /* 20 */ GROUP(383), 1558, GROUP(385), INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ INVALID, INVALID, INVALID, INVALID,
- /* 2c */ INVALID, INVALID, INVALID, INVALID,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
- /* 40 */ 198, 196, 1680, INVALID,
- /* 44 */ 1513, INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, GROUP(391), GROUP(392),
- /* 4c */ GROUP(393), INVALID, INVALID, INVALID,
- /* 50 */ INVALID, INVALID, INVALID, INVALID,
- /* 54 */ INVALID, INVALID, INVALID, INVALID,
- /* 58 */ INVALID, INVALID, INVALID, INVALID,
- /* 5c */ INVALID, INVALID, INVALID, INVALID,
- /* 60 */ 1716, 1714, 1722, 1720,
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ INVALID, INVALID, INVALID, INVALID,
- /* 6c */ INVALID, INVALID, INVALID, INVALID,
- /* 70 */ INVALID, INVALID, INVALID, INVALID,
- /* 74 */ INVALID, INVALID, INVALID, INVALID,
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ INVALID, INVALID, INVALID, INVALID,
- /* 80 */ INVALID, INVALID, INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, INVALID, INVALID,
- /* 8c */ INVALID, INVALID, INVALID, INVALID,
- /* 90 */ INVALID, INVALID, INVALID, INVALID,
- /* 94 */ INVALID, INVALID, INVALID, INVALID,
- /* 98 */ INVALID, INVALID, INVALID, INVALID,
- /* 9c */ INVALID, INVALID, INVALID, INVALID,
- /* a0 */ INVALID, INVALID, INVALID, INVALID,
- /* a4 */ INVALID, INVALID, INVALID, INVALID,
- /* a8 */ INVALID, INVALID, INVALID, INVALID,
- /* ac */ INVALID, INVALID, INVALID, INVALID,
- /* b0 */ INVALID, INVALID, INVALID, INVALID,
- /* b4 */ INVALID, INVALID, INVALID, INVALID,
- /* b8 */ INVALID, INVALID, INVALID, INVALID,
- /* bc */ INVALID, INVALID, INVALID, INVALID,
- /* c0 */ INVALID, INVALID, INVALID, INVALID,
- /* c4 */ INVALID, INVALID, INVALID, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ INVALID, INVALID, INVALID, INVALID,
- /* d4 */ INVALID, INVALID, INVALID, INVALID,
- /* d8 */ INVALID, INVALID, INVALID, INVALID,
- /* dc */ INVALID, INVALID, INVALID, 48,
- /* e0 */ INVALID, INVALID, INVALID, INVALID,
- /* e4 */ INVALID, INVALID, INVALID, INVALID,
- /* e8 */ INVALID, INVALID, INVALID, INVALID,
- /* ec */ INVALID, INVALID, INVALID, INVALID,
- /* f0 */ INVALID, INVALID, INVALID, INVALID,
- /* f4 */ INVALID, INVALID, INVALID, INVALID,
- /* f8 */ INVALID, INVALID, INVALID, INVALID,
- /* fc */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__370[] = {
- /* 0 */ 1738, INVALID,
-};
-
-static const uint16_t ud_itab__371[] = {
- /* 0 */ 1736, INVALID,
-};
-
-static const uint16_t ud_itab__372[] = {
- /* 0 */ GROUP(373), INVALID,
-};
-
-static const uint16_t ud_itab__373[] = {
- /* 0 */ INVALID, 1739,
-};
-
-static const uint16_t ud_itab__374[] = {
- /* 0 */ 1046, INVALID,
-};
-
-static const uint16_t ud_itab__375[] = {
- /* 0 */ GROUP(376), GROUP(377), GROUP(378),
-};
-
-static const uint16_t ud_itab__376[] = {
- /* 0 */ 1048, INVALID,
-};
-
-static const uint16_t ud_itab__377[] = {
- /* 0 */ 1050, INVALID,
-};
-
-static const uint16_t ud_itab__378[] = {
- /* 0 */ INVALID, 1052,
-};
-
-static const uint16_t ud_itab__379[] = {
- /* 0 */ GROUP(380), INVALID,
-};
-
-static const uint16_t ud_itab__380[] = {
- /* 0 */ INVALID, 1730,
-};
-
-static const uint16_t ud_itab__381[] = {
- /* 0 */ GROUP(382), INVALID,
-};
-
-static const uint16_t ud_itab__382[] = {
- /* 0 */ INVALID, 1729,
-};
-
-static const uint16_t ud_itab__383[] = {
- /* 0 */ GROUP(384), INVALID,
-};
-
-static const uint16_t ud_itab__384[] = {
- /* 0 */ 1065, INVALID,
-};
-
-static const uint16_t ud_itab__385[] = {
- /* 0 */ GROUP(386), GROUP(388),
-};
-
-static const uint16_t ud_itab__386[] = {
- /* 0 */ GROUP(387), INVALID,
-};
-
-static const uint16_t ud_itab__387[] = {
- /* 0 */ 1066, INVALID,
-};
-
-static const uint16_t ud_itab__388[] = {
- /* 0 */ GROUP(389), GROUP(390),
-};
-
-static const uint16_t ud_itab__389[] = {
- /* 0 */ 1067, INVALID,
-};
-
-static const uint16_t ud_itab__390[] = {
- /* 0 */ 1068, INVALID,
-};
-
-static const uint16_t ud_itab__391[] = {
- /* 0 */ 1745, INVALID,
-};
-
-static const uint16_t ud_itab__392[] = {
- /* 0 */ 1744, INVALID,
-};
-
-static const uint16_t ud_itab__393[] = {
- /* 0 */ 1754, INVALID,
-};
-
-static const uint16_t ud_itab__394[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
- /* 8 */ INVALID, INVALID, INVALID, INVALID,
- /* c */ INVALID, INVALID, INVALID, INVALID,
- /* 10 */ GROUP(395), GROUP(396), GROUP(397), INVALID,
- /* 14 */ INVALID, INVALID, GROUP(398), INVALID,
- /* 18 */ INVALID, INVALID, INVALID, INVALID,
- /* 1c */ INVALID, INVALID, INVALID, INVALID,
- /* 20 */ INVALID, INVALID, INVALID, INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ INVALID, INVALID, 155, INVALID,
- /* 2c */ 169, 159, INVALID, INVALID,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
- /* 40 */ INVALID, INVALID, INVALID, INVALID,
- /* 44 */ INVALID, INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, INVALID, INVALID,
- /* 4c */ INVALID, INVALID, INVALID, INVALID,
- /* 50 */ INVALID, 1394, 1309, 1294,
- /* 54 */ INVALID, INVALID, INVALID, INVALID,
- /* 58 */ 32, 951, 157, 164,
- /* 5c */ 1424, 823, 194, 807,
- /* 60 */ INVALID, INVALID, INVALID, INVALID,
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ INVALID, INVALID, INVALID, INVALID,
- /* 6c */ INVALID, INVALID, INVALID, 1523,
- /* 70 */ 1536, INVALID, INVALID, INVALID,
- /* 74 */ INVALID, INVALID, INVALID, INVALID,
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ INVALID, INVALID, 917, 1525,
- /* 80 */ INVALID, INVALID, INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, INVALID, INVALID,
- /* 8c */ INVALID, INVALID, INVALID, INVALID,
- /* 90 */ INVALID, INVALID, INVALID, INVALID,
- /* 94 */ INVALID, INVALID, INVALID, INVALID,
- /* 98 */ INVALID, INVALID, INVALID, INVALID,
- /* 9c */ INVALID, INVALID, INVALID, INVALID,
- /* a0 */ INVALID, INVALID, INVALID, INVALID,
- /* a4 */ INVALID, INVALID, INVALID, INVALID,
- /* a8 */ INVALID, INVALID, INVALID, INVALID,
- /* ac */ INVALID, INVALID, INVALID, INVALID,
- /* b0 */ INVALID, INVALID, INVALID, INVALID,
- /* b4 */ INVALID, INVALID, INVALID, INVALID,
- /* b8 */ INVALID, INVALID, INVALID, INVALID,
- /* bc */ INVALID, INVALID, INVALID, INVALID,
- /* c0 */ INVALID, INVALID, 121, INVALID,
- /* c4 */ INVALID, INVALID, INVALID, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ INVALID, INVALID, INVALID, INVALID,
- /* d4 */ INVALID, INVALID, INVALID, INVALID,
- /* d8 */ INVALID, INVALID, INVALID, INVALID,
- /* dc */ INVALID, INVALID, INVALID, INVALID,
- /* e0 */ INVALID, INVALID, INVALID, INVALID,
- /* e4 */ INVALID, INVALID, 133, INVALID,
- /* e8 */ INVALID, INVALID, INVALID, INVALID,
- /* ec */ INVALID, INVALID, INVALID, INVALID,
- /* f0 */ INVALID, INVALID, INVALID, INVALID,
- /* f4 */ INVALID, INVALID, INVALID, INVALID,
- /* f8 */ INVALID, INVALID, INVALID, INVALID,
- /* fc */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__395[] = {
- /* 0 */ 1751, 1750,
-};
-
-static const uint16_t ud_itab__396[] = {
- /* 0 */ 1753, 1752,
-};
-
-static const uint16_t ud_itab__397[] = {
- /* 0 */ 1572, 1570,
-};
-
-static const uint16_t ud_itab__398[] = {
- /* 0 */ 1568, 1566,
-};
-
-static const uint16_t ud_itab__399[] = {
- /* 0 */ INVALID, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
- /* 8 */ INVALID, INVALID, INVALID, INVALID,
- /* c */ INVALID, INVALID, INVALID, INVALID,
- /* 10 */ GROUP(402), GROUP(400), GROUP(401), INVALID,
- /* 14 */ INVALID, INVALID, INVALID, INVALID,
- /* 18 */ INVALID, INVALID, INVALID, INVALID,
- /* 1c */ INVALID, INVALID, INVALID, INVALID,
- /* 20 */ INVALID, INVALID, INVALID, INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ INVALID, INVALID, 153, INVALID,
- /* 2c */ 167, 149, INVALID, INVALID,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
- /* 40 */ INVALID, INVALID, INVALID, INVALID,
- /* 44 */ INVALID, INVALID, INVALID, INVALID,
- /* 48 */ INVALID, INVALID, INVALID, INVALID,
- /* 4c */ INVALID, INVALID, INVALID, INVALID,
- /* 50 */ INVALID, 1392, INVALID, INVALID,
- /* 54 */ INVALID, INVALID, INVALID, INVALID,
- /* 58 */ 30, 949, 151, INVALID,
- /* 5c */ 1422, 821, 192, 805,
- /* 60 */ INVALID, INVALID, INVALID, INVALID,
- /* 64 */ INVALID, INVALID, INVALID, INVALID,
- /* 68 */ INVALID, INVALID, INVALID, INVALID,
- /* 6c */ INVALID, INVALID, INVALID, INVALID,
- /* 70 */ 1538, INVALID, INVALID, INVALID,
- /* 74 */ INVALID, INVALID, INVALID, INVALID,
- /* 78 */ INVALID, INVALID, INVALID, INVALID,
- /* 7c */ 1552, 1556, INVALID, INVALID,
- /* 80 */ INVALID, INVALID, INVALID, INVALID,
- /* 84 */ INVALID, INVALID, INVALID, INVALID,
- /* 88 */ INVALID, INVALID, INVALID, INVALID,
- /* 8c */ INVALID, INVALID, INVALID, INVALID,
- /* 90 */ INVALID, INVALID, INVALID, INVALID,
- /* 94 */ INVALID, INVALID, INVALID, INVALID,
- /* 98 */ INVALID, INVALID, INVALID, INVALID,
- /* 9c */ INVALID, INVALID, INVALID, INVALID,
- /* a0 */ INVALID, INVALID, INVALID, INVALID,
- /* a4 */ INVALID, INVALID, INVALID, INVALID,
- /* a8 */ INVALID, INVALID, INVALID, INVALID,
- /* ac */ INVALID, INVALID, INVALID, INVALID,
- /* b0 */ INVALID, INVALID, INVALID, INVALID,
- /* b4 */ INVALID, INVALID, INVALID, INVALID,
- /* b8 */ INVALID, INVALID, INVALID, INVALID,
- /* bc */ INVALID, INVALID, INVALID, INVALID,
- /* c0 */ INVALID, INVALID, 118, INVALID,
- /* c4 */ INVALID, INVALID, INVALID, INVALID,
- /* c8 */ INVALID, INVALID, INVALID, INVALID,
- /* cc */ INVALID, INVALID, INVALID, INVALID,
- /* d0 */ 36, INVALID, INVALID, INVALID,
- /* d4 */ INVALID, INVALID, INVALID, INVALID,
- /* d8 */ INVALID, INVALID, INVALID, INVALID,
- /* dc */ INVALID, INVALID, INVALID, INVALID,
- /* e0 */ INVALID, INVALID, INVALID, INVALID,
- /* e4 */ INVALID, INVALID, 137, INVALID,
- /* e8 */ INVALID, INVALID, INVALID, INVALID,
- /* ec */ INVALID, INVALID, INVALID, INVALID,
- /* f0 */ 1560, INVALID, INVALID, INVALID,
- /* f4 */ INVALID, INVALID, INVALID, INVALID,
- /* f8 */ INVALID, INVALID, INVALID, INVALID,
- /* fc */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__400[] = {
- /* 0 */ 1749, 1748,
-};
-
-static const uint16_t ud_itab__401[] = {
- /* 0 */ 1564, 1562,
-};
-
-static const uint16_t ud_itab__402[] = {
- /* 0 */ 1747, 1746,
-};
-
-static const uint16_t ud_itab__403[] = {
- /* 0 */ GROUP(404), GROUP(335), INVALID, INVALID,
- /* 4 */ INVALID, GROUP(341), GROUP(357), GROUP(369),
- /* 8 */ INVALID, GROUP(394), INVALID, INVALID,
- /* c */ INVALID, GROUP(399), INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__404[] = {
- /* 0 */ 769, INVALID,
-};
-
-static const uint16_t ud_itab__405[] = {
- /* 0 */ 826, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__406[] = {
- /* 0 */ 827, INVALID, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__407[] = {
- /* 0 */ 715, INVALID,
-};
-
-static const uint16_t ud_itab__408[] = {
- /* 0 */ 723, 724, 725,
-};
-
-static const uint16_t ud_itab__409[] = {
- /* 0 */ 1280, 1285, 1269, 1273,
- /* 4 */ 1326, 1333, 1320, 1314,
-};
-
-static const uint16_t ud_itab__410[] = {
- /* 0 */ 1281, 1288, 1272, 1276,
- /* 4 */ 1325, 1332, 1329, 1312,
-};
-
-static const uint16_t ud_itab__411[] = {
- /* 0 */ 1282, 1289, 1270, 1277,
- /* 4 */ 1324, 1331, 1321, 1316,
-};
-
-static const uint16_t ud_itab__412[] = {
- /* 0 */ 1283, 1290, 1271, 1278,
- /* 4 */ 1328, 1335, 1322, 1317,
-};
-
-static const uint16_t ud_itab__413[] = {
- /* 0 */ 3, INVALID,
-};
-
-static const uint16_t ud_itab__414[] = {
- /* 0 */ 2, INVALID,
-};
-
-static const uint16_t ud_itab__415[] = {
- /* 0 */ 1311, INVALID,
-};
-
-static const uint16_t ud_itab__416[] = {
- /* 0 */ GROUP(417), GROUP(418),
-};
-
-static const uint16_t ud_itab__417[] = {
- /* 0 */ 206, 503, 307, 357,
- /* 4 */ 587, 630, 387, 413,
-};
-
-static const uint16_t ud_itab__418[] = {
- /* 0 */ 215, 216, 217, 218,
- /* 4 */ 219, 220, 221, 222,
- /* 8 */ 504, 505, 506, 507,
- /* c */ 508, 509, 510, 511,
- /* 10 */ 309, 310, 311, 312,
- /* 14 */ 313, 314, 315, 316,
- /* 18 */ 359, 360, 361, 362,
- /* 1c */ 363, 364, 365, 366,
- /* 20 */ 589, 590, 591, 592,
- /* 24 */ 593, 594, 595, 596,
- /* 28 */ 614, 615, 616, 617,
- /* 2c */ 618, 619, 620, 621,
- /* 30 */ 388, 389, 390, 391,
- /* 34 */ 392, 393, 394, 395,
- /* 38 */ 414, 415, 416, 417,
- /* 3c */ 418, 419, 420, 421,
-};
-
-static const uint16_t ud_itab__419[] = {
- /* 0 */ GROUP(420), GROUP(421),
-};
-
-static const uint16_t ud_itab__420[] = {
- /* 0 */ 476, INVALID, 573, 540,
- /* 4 */ 493, 492, 584, 583,
-};
-
-static const uint16_t ud_itab__421[] = {
- /* 0 */ 477, 478, 479, 480,
- /* 4 */ 481, 482, 483, 484,
- /* 8 */ 658, 659, 660, 661,
- /* c */ 662, 663, 664, 665,
- /* 10 */ 522, INVALID, INVALID, INVALID,
- /* 14 */ INVALID, INVALID, INVALID, INVALID,
- /* 18 */ 549, 550, 551, 552,
- /* 1c */ 553, 554, 555, 556,
- /* 20 */ 233, 204, INVALID, INVALID,
- /* 24 */ 639, 657, INVALID, INVALID,
- /* 28 */ 485, 486, 487, 488,
- /* 2c */ 489, 490, 491, INVALID,
- /* 30 */ 203, 685, 529, 526,
- /* 34 */ 684, 528, 377, 454,
- /* 38 */ 527, 686, 537, 536,
- /* 3c */ 530, 534, 535, 376,
-};
-
-static const uint16_t ud_itab__422[] = {
- /* 0 */ GROUP(423), GROUP(424),
-};
-
-static const uint16_t ud_itab__423[] = {
- /* 0 */ 456, 520, 448, 450,
- /* 4 */ 462, 464, 460, 458,
-};
-
-static const uint16_t ud_itab__424[] = {
- /* 0 */ 235, 236, 237, 238,
- /* 4 */ 239, 240, 241, 242,
- /* 8 */ 243, 244, 245, 246,
- /* c */ 247, 248, 249, 250,
- /* 10 */ 251, 252, 253, 254,
- /* 14 */ 255, 256, 257, 258,
- /* 18 */ 259, 260, 261, 262,
- /* 1c */ 263, 264, 265, 266,
- /* 20 */ INVALID, INVALID, INVALID, INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ INVALID, 656, INVALID, INVALID,
- /* 2c */ INVALID, INVALID, INVALID, INVALID,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__425[] = {
- /* 0 */ GROUP(426), GROUP(427),
-};
-
-static const uint16_t ud_itab__426[] = {
- /* 0 */ 453, 471, 467, 470,
- /* 4 */ INVALID, 474, INVALID, 538,
-};
-
-static const uint16_t ud_itab__427[] = {
- /* 0 */ 267, 268, 269, 270,
- /* 4 */ 271, 272, 273, 274,
- /* 8 */ 275, 276, 277, 278,
- /* c */ 279, 280, 281, 282,
- /* 10 */ 283, 284, 285, 286,
- /* 14 */ 287, 288, 289, 290,
- /* 18 */ 291, 292, 293, 294,
- /* 1c */ 295, 296, 297, 298,
- /* 20 */ 524, 523, 234, 455,
- /* 24 */ 525, 532, INVALID, INVALID,
- /* 28 */ 299, 300, 301, 302,
- /* 2c */ 303, 304, 305, 306,
- /* 30 */ 333, 334, 335, 336,
- /* 34 */ 337, 338, 339, 340,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__428[] = {
- /* 0 */ GROUP(429), GROUP(430),
-};
-
-static const uint16_t ud_itab__429[] = {
- /* 0 */ 205, 494, 308, 358,
- /* 4 */ 588, 613, 378, 404,
-};
-
-static const uint16_t ud_itab__430[] = {
- /* 0 */ 207, 208, 209, 210,
- /* 4 */ 211, 212, 213, 214,
- /* 8 */ 495, 496, 497, 498,
- /* c */ 499, 500, 501, 502,
- /* 10 */ 317, 318, 319, 320,
- /* 14 */ 321, 322, 323, 324,
- /* 18 */ 325, 326, 327, 328,
- /* 1c */ 329, 330, 331, 332,
- /* 20 */ 622, 623, 624, 625,
- /* 24 */ 626, 627, 628, 629,
- /* 28 */ 597, 598, 599, 600,
- /* 2c */ 601, 602, 603, 604,
- /* 30 */ 405, 406, 407, 408,
- /* 34 */ 409, 410, 411, 412,
- /* 38 */ 379, 380, 381, 382,
- /* 3c */ 383, 384, 385, 386,
-};
-
-static const uint16_t ud_itab__431[] = {
- /* 0 */ GROUP(432), GROUP(433),
-};
-
-static const uint16_t ud_itab__432[] = {
- /* 0 */ 475, 472, 574, 539,
- /* 4 */ 531, INVALID, 533, 585,
-};
-
-static const uint16_t ud_itab__433[] = {
- /* 0 */ 431, 432, 433, 434,
- /* 4 */ 435, 436, 437, 438,
- /* 8 */ 666, 667, 668, 669,
- /* c */ 670, 671, 672, 673,
- /* 10 */ 575, 576, 577, 578,
- /* 14 */ 579, 580, 581, 582,
- /* 18 */ 541, 542, 543, 544,
- /* 1c */ 545, 546, 547, 548,
- /* 20 */ 640, 641, 642, 643,
- /* 24 */ 644, 645, 646, 647,
- /* 28 */ 648, 649, 650, 651,
- /* 2c */ 652, 653, 654, 655,
- /* 30 */ INVALID, INVALID, INVALID, INVALID,
- /* 34 */ INVALID, INVALID, INVALID, INVALID,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__434[] = {
- /* 0 */ GROUP(435), GROUP(436),
-};
-
-static const uint16_t ud_itab__435[] = {
- /* 0 */ 457, 521, 447, 449,
- /* 4 */ 463, 465, 461, 459,
-};
-
-static const uint16_t ud_itab__436[] = {
- /* 0 */ 223, 224, 225, 226,
- /* 4 */ 227, 228, 229, 230,
- /* 8 */ 512, 513, 514, 515,
- /* c */ 516, 517, 518, 519,
- /* 10 */ 367, 368, 369, 370,
- /* 14 */ 371, 372, 373, 374,
- /* 18 */ INVALID, 375, INVALID, INVALID,
- /* 1c */ INVALID, INVALID, INVALID, INVALID,
- /* 20 */ 631, 632, 633, 634,
- /* 24 */ 635, 636, 637, 638,
- /* 28 */ 605, 606, 607, 608,
- /* 2c */ 609, 610, 611, 612,
- /* 30 */ 422, 423, 424, 425,
- /* 34 */ 426, 427, 428, 429,
- /* 38 */ 396, 397, 398, 399,
- /* 3c */ 400, 401, 402, 403,
-};
-
-static const uint16_t ud_itab__437[] = {
- /* 0 */ GROUP(438), GROUP(439),
-};
-
-static const uint16_t ud_itab__438[] = {
- /* 0 */ 451, 473, 466, 468,
- /* 4 */ 231, 452, 232, 469,
-};
-
-static const uint16_t ud_itab__439[] = {
- /* 0 */ 439, 440, 441, 442,
- /* 4 */ 443, 444, 445, 446,
- /* 8 */ 674, 675, 676, 677,
- /* c */ 678, 679, 680, 681,
- /* 10 */ 557, 558, 559, 560,
- /* 14 */ 561, 562, 563, 564,
- /* 18 */ 565, 566, 567, 568,
- /* 1c */ 569, 570, 571, 572,
- /* 20 */ 586, INVALID, INVALID, INVALID,
- /* 24 */ INVALID, INVALID, INVALID, INVALID,
- /* 28 */ 341, 342, 343, 344,
- /* 2c */ 345, 346, 347, 348,
- /* 30 */ 349, 350, 351, 352,
- /* 34 */ 353, 354, 355, 356,
- /* 38 */ INVALID, INVALID, INVALID, INVALID,
- /* 3c */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__440[] = {
- /* 0 */ 758, 759, 760,
-};
-
-static const uint16_t ud_itab__441[] = {
- /* 0 */ 764, INVALID,
-};
-
-static const uint16_t ud_itab__442[] = {
- /* 0 */ 1432, 1437, 962, 953,
- /* 4 */ 942, 695, 186, 689,
-};
-
-static const uint16_t ud_itab__443[] = {
- /* 0 */ 1438, 1439, 963, 954,
- /* 4 */ 943, 696, 185, 688,
-};
-
-static const uint16_t ud_itab__444[] = {
- /* 0 */ 708, 183, INVALID, INVALID,
- /* 4 */ INVALID, INVALID, INVALID, INVALID,
-};
-
-static const uint16_t ud_itab__445[] = {
- /* 0 */ 707, 184, GROUP(446), 71,
- /* 4 */ 761, 762, 1255, INVALID,
-};
-
-static const uint16_t ud_itab__446[] = {
- /* 0 */ 69, 70,
-};
-
-
-struct ud_lookup_table_list_entry ud_lookup_table_list[] = {
- /* 000 */ { ud_itab__0, UD_TAB__OPC_TABLE, "opctbl" },
- /* 001 */ { ud_itab__1, UD_TAB__OPC_MODE, "/m" },
- /* 002 */ { ud_itab__2, UD_TAB__OPC_MODE, "/m" },
- /* 003 */ { ud_itab__3, UD_TAB__OPC_MODE, "/m" },
- /* 004 */ { ud_itab__4, UD_TAB__OPC_TABLE, "opctbl" },
- /* 005 */ { ud_itab__5, UD_TAB__OPC_REG, "/reg" },
- /* 006 */ { ud_itab__6, UD_TAB__OPC_MOD, "/mod" },
- /* 007 */ { ud_itab__7, UD_TAB__OPC_REG, "/reg" },
- /* 008 */ { ud_itab__8, UD_TAB__OPC_REG, "/reg" },
- /* 009 */ { ud_itab__9, UD_TAB__OPC_RM, "/rm" },
- /* 010 */ { ud_itab__10, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 011 */ { ud_itab__11, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 012 */ { ud_itab__12, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 013 */ { ud_itab__13, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 014 */ { ud_itab__14, UD_TAB__OPC_RM, "/rm" },
- /* 015 */ { ud_itab__15, UD_TAB__OPC_RM, "/rm" },
- /* 016 */ { ud_itab__16, UD_TAB__OPC_RM, "/rm" },
- /* 017 */ { ud_itab__17, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 018 */ { ud_itab__18, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 019 */ { ud_itab__19, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 020 */ { ud_itab__20, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 021 */ { ud_itab__21, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 022 */ { ud_itab__22, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 023 */ { ud_itab__23, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 024 */ { ud_itab__24, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 025 */ { ud_itab__25, UD_TAB__OPC_RM, "/rm" },
- /* 026 */ { ud_itab__26, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 027 */ { ud_itab__27, UD_TAB__OPC_REG, "/reg" },
- /* 028 */ { ud_itab__28, UD_TAB__OPC_3DNOW, "/3dnow" },
- /* 029 */ { ud_itab__29, UD_TAB__OPC_SSE, "/sse" },
- /* 030 */ { ud_itab__30, UD_TAB__OPC_SSE, "/sse" },
- /* 031 */ { ud_itab__31, UD_TAB__OPC_MOD, "/mod" },
- /* 032 */ { ud_itab__32, UD_TAB__OPC_SSE, "/sse" },
- /* 033 */ { ud_itab__33, UD_TAB__OPC_SSE, "/sse" },
- /* 034 */ { ud_itab__34, UD_TAB__OPC_SSE, "/sse" },
- /* 035 */ { ud_itab__35, UD_TAB__OPC_SSE, "/sse" },
- /* 036 */ { ud_itab__36, UD_TAB__OPC_SSE, "/sse" },
- /* 037 */ { ud_itab__37, UD_TAB__OPC_MOD, "/mod" },
- /* 038 */ { ud_itab__38, UD_TAB__OPC_SSE, "/sse" },
- /* 039 */ { ud_itab__39, UD_TAB__OPC_SSE, "/sse" },
- /* 040 */ { ud_itab__40, UD_TAB__OPC_SSE, "/sse" },
- /* 041 */ { ud_itab__41, UD_TAB__OPC_REG, "/reg" },
- /* 042 */ { ud_itab__42, UD_TAB__OPC_SSE, "/sse" },
- /* 043 */ { ud_itab__43, UD_TAB__OPC_SSE, "/sse" },
- /* 044 */ { ud_itab__44, UD_TAB__OPC_SSE, "/sse" },
- /* 045 */ { ud_itab__45, UD_TAB__OPC_SSE, "/sse" },
- /* 046 */ { ud_itab__46, UD_TAB__OPC_SSE, "/sse" },
- /* 047 */ { ud_itab__47, UD_TAB__OPC_SSE, "/sse" },
- /* 048 */ { ud_itab__48, UD_TAB__OPC_SSE, "/sse" },
- /* 049 */ { ud_itab__49, UD_TAB__OPC_SSE, "/sse" },
- /* 050 */ { ud_itab__50, UD_TAB__OPC_MODE, "/m" },
- /* 051 */ { ud_itab__51, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 052 */ { ud_itab__52, UD_TAB__OPC_MODE, "/m" },
- /* 053 */ { ud_itab__53, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 054 */ { ud_itab__54, UD_TAB__OPC_TABLE, "opctbl" },
- /* 055 */ { ud_itab__55, UD_TAB__OPC_SSE, "/sse" },
- /* 056 */ { ud_itab__56, UD_TAB__OPC_MODE, "/m" },
- /* 057 */ { ud_itab__57, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 058 */ { ud_itab__58, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 059 */ { ud_itab__59, UD_TAB__OPC_SSE, "/sse" },
- /* 060 */ { ud_itab__60, UD_TAB__OPC_MODE, "/m" },
- /* 061 */ { ud_itab__61, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 062 */ { ud_itab__62, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 063 */ { ud_itab__63, UD_TAB__OPC_SSE, "/sse" },
- /* 064 */ { ud_itab__64, UD_TAB__OPC_SSE, "/sse" },
- /* 065 */ { ud_itab__65, UD_TAB__OPC_SSE, "/sse" },
- /* 066 */ { ud_itab__66, UD_TAB__OPC_SSE, "/sse" },
- /* 067 */ { ud_itab__67, UD_TAB__OPC_SSE, "/sse" },
- /* 068 */ { ud_itab__68, UD_TAB__OPC_SSE, "/sse" },
- /* 069 */ { ud_itab__69, UD_TAB__OPC_SSE, "/sse" },
- /* 070 */ { ud_itab__70, UD_TAB__OPC_SSE, "/sse" },
- /* 071 */ { ud_itab__71, UD_TAB__OPC_SSE, "/sse" },
- /* 072 */ { ud_itab__72, UD_TAB__OPC_SSE, "/sse" },
- /* 073 */ { ud_itab__73, UD_TAB__OPC_SSE, "/sse" },
- /* 074 */ { ud_itab__74, UD_TAB__OPC_SSE, "/sse" },
- /* 075 */ { ud_itab__75, UD_TAB__OPC_SSE, "/sse" },
- /* 076 */ { ud_itab__76, UD_TAB__OPC_SSE, "/sse" },
- /* 077 */ { ud_itab__77, UD_TAB__OPC_SSE, "/sse" },
- /* 078 */ { ud_itab__78, UD_TAB__OPC_SSE, "/sse" },
- /* 079 */ { ud_itab__79, UD_TAB__OPC_SSE, "/sse" },
- /* 080 */ { ud_itab__80, UD_TAB__OPC_SSE, "/sse" },
- /* 081 */ { ud_itab__81, UD_TAB__OPC_SSE, "/sse" },
- /* 082 */ { ud_itab__82, UD_TAB__OPC_SSE, "/sse" },
- /* 083 */ { ud_itab__83, UD_TAB__OPC_SSE, "/sse" },
- /* 084 */ { ud_itab__84, UD_TAB__OPC_SSE, "/sse" },
- /* 085 */ { ud_itab__85, UD_TAB__OPC_SSE, "/sse" },
- /* 086 */ { ud_itab__86, UD_TAB__OPC_SSE, "/sse" },
- /* 087 */ { ud_itab__87, UD_TAB__OPC_SSE, "/sse" },
- /* 088 */ { ud_itab__88, UD_TAB__OPC_SSE, "/sse" },
- /* 089 */ { ud_itab__89, UD_TAB__OPC_SSE, "/sse" },
- /* 090 */ { ud_itab__90, UD_TAB__OPC_SSE, "/sse" },
- /* 091 */ { ud_itab__91, UD_TAB__OPC_SSE, "/sse" },
- /* 092 */ { ud_itab__92, UD_TAB__OPC_SSE, "/sse" },
- /* 093 */ { ud_itab__93, UD_TAB__OPC_SSE, "/sse" },
- /* 094 */ { ud_itab__94, UD_TAB__OPC_SSE, "/sse" },
- /* 095 */ { ud_itab__95, UD_TAB__OPC_SSE, "/sse" },
- /* 096 */ { ud_itab__96, UD_TAB__OPC_SSE, "/sse" },
- /* 097 */ { ud_itab__97, UD_TAB__OPC_SSE, "/sse" },
- /* 098 */ { ud_itab__98, UD_TAB__OPC_SSE, "/sse" },
- /* 099 */ { ud_itab__99, UD_TAB__OPC_SSE, "/sse" },
- /* 100 */ { ud_itab__100, UD_TAB__OPC_SSE, "/sse" },
- /* 101 */ { ud_itab__101, UD_TAB__OPC_SSE, "/sse" },
- /* 102 */ { ud_itab__102, UD_TAB__OPC_SSE, "/sse" },
- /* 103 */ { ud_itab__103, UD_TAB__OPC_SSE, "/sse" },
- /* 104 */ { ud_itab__104, UD_TAB__OPC_SSE, "/sse" },
- /* 105 */ { ud_itab__105, UD_TAB__OPC_SSE, "/sse" },
- /* 106 */ { ud_itab__106, UD_TAB__OPC_SSE, "/sse" },
- /* 107 */ { ud_itab__107, UD_TAB__OPC_SSE, "/sse" },
- /* 108 */ { ud_itab__108, UD_TAB__OPC_SSE, "/sse" },
- /* 109 */ { ud_itab__109, UD_TAB__OPC_SSE, "/sse" },
- /* 110 */ { ud_itab__110, UD_TAB__OPC_SSE, "/sse" },
- /* 111 */ { ud_itab__111, UD_TAB__OPC_SSE, "/sse" },
- /* 112 */ { ud_itab__112, UD_TAB__OPC_SSE, "/sse" },
- /* 113 */ { ud_itab__113, UD_TAB__OPC_SSE, "/sse" },
- /* 114 */ { ud_itab__114, UD_TAB__OPC_SSE, "/sse" },
- /* 115 */ { ud_itab__115, UD_TAB__OPC_SSE, "/sse" },
- /* 116 */ { ud_itab__116, UD_TAB__OPC_TABLE, "opctbl" },
- /* 117 */ { ud_itab__117, UD_TAB__OPC_SSE, "/sse" },
- /* 118 */ { ud_itab__118, UD_TAB__OPC_SSE, "/sse" },
- /* 119 */ { ud_itab__119, UD_TAB__OPC_SSE, "/sse" },
- /* 120 */ { ud_itab__120, UD_TAB__OPC_SSE, "/sse" },
- /* 121 */ { ud_itab__121, UD_TAB__OPC_SSE, "/sse" },
- /* 122 */ { ud_itab__122, UD_TAB__OPC_SSE, "/sse" },
- /* 123 */ { ud_itab__123, UD_TAB__OPC_SSE, "/sse" },
- /* 124 */ { ud_itab__124, UD_TAB__OPC_SSE, "/sse" },
- /* 125 */ { ud_itab__125, UD_TAB__OPC_SSE, "/sse" },
- /* 126 */ { ud_itab__126, UD_TAB__OPC_SSE, "/sse" },
- /* 127 */ { ud_itab__127, UD_TAB__OPC_SSE, "/sse" },
- /* 128 */ { ud_itab__128, UD_TAB__OPC_OSIZE, "/o" },
- /* 129 */ { ud_itab__129, UD_TAB__OPC_SSE, "/sse" },
- /* 130 */ { ud_itab__130, UD_TAB__OPC_SSE, "/sse" },
- /* 131 */ { ud_itab__131, UD_TAB__OPC_SSE, "/sse" },
- /* 132 */ { ud_itab__132, UD_TAB__OPC_SSE, "/sse" },
- /* 133 */ { ud_itab__133, UD_TAB__OPC_OSIZE, "/o" },
- /* 134 */ { ud_itab__134, UD_TAB__OPC_SSE, "/sse" },
- /* 135 */ { ud_itab__135, UD_TAB__OPC_SSE, "/sse" },
- /* 136 */ { ud_itab__136, UD_TAB__OPC_SSE, "/sse" },
- /* 137 */ { ud_itab__137, UD_TAB__OPC_SSE, "/sse" },
- /* 138 */ { ud_itab__138, UD_TAB__OPC_SSE, "/sse" },
- /* 139 */ { ud_itab__139, UD_TAB__OPC_SSE, "/sse" },
- /* 140 */ { ud_itab__140, UD_TAB__OPC_SSE, "/sse" },
- /* 141 */ { ud_itab__141, UD_TAB__OPC_SSE, "/sse" },
- /* 142 */ { ud_itab__142, UD_TAB__OPC_SSE, "/sse" },
- /* 143 */ { ud_itab__143, UD_TAB__OPC_SSE, "/sse" },
- /* 144 */ { ud_itab__144, UD_TAB__OPC_SSE, "/sse" },
- /* 145 */ { ud_itab__145, UD_TAB__OPC_SSE, "/sse" },
- /* 146 */ { ud_itab__146, UD_TAB__OPC_SSE, "/sse" },
- /* 147 */ { ud_itab__147, UD_TAB__OPC_SSE, "/sse" },
- /* 148 */ { ud_itab__148, UD_TAB__OPC_SSE, "/sse" },
- /* 149 */ { ud_itab__149, UD_TAB__OPC_SSE, "/sse" },
- /* 150 */ { ud_itab__150, UD_TAB__OPC_SSE, "/sse" },
- /* 151 */ { ud_itab__151, UD_TAB__OPC_SSE, "/sse" },
- /* 152 */ { ud_itab__152, UD_TAB__OPC_SSE, "/sse" },
- /* 153 */ { ud_itab__153, UD_TAB__OPC_SSE, "/sse" },
- /* 154 */ { ud_itab__154, UD_TAB__OPC_SSE, "/sse" },
- /* 155 */ { ud_itab__155, UD_TAB__OPC_SSE, "/sse" },
- /* 156 */ { ud_itab__156, UD_TAB__OPC_SSE, "/sse" },
- /* 157 */ { ud_itab__157, UD_TAB__OPC_SSE, "/sse" },
- /* 158 */ { ud_itab__158, UD_TAB__OPC_SSE, "/sse" },
- /* 159 */ { ud_itab__159, UD_TAB__OPC_SSE, "/sse" },
- /* 160 */ { ud_itab__160, UD_TAB__OPC_SSE, "/sse" },
- /* 161 */ { ud_itab__161, UD_TAB__OPC_SSE, "/sse" },
- /* 162 */ { ud_itab__162, UD_TAB__OPC_SSE, "/sse" },
- /* 163 */ { ud_itab__163, UD_TAB__OPC_SSE, "/sse" },
- /* 164 */ { ud_itab__164, UD_TAB__OPC_SSE, "/sse" },
- /* 165 */ { ud_itab__165, UD_TAB__OPC_SSE, "/sse" },
- /* 166 */ { ud_itab__166, UD_TAB__OPC_SSE, "/sse" },
- /* 167 */ { ud_itab__167, UD_TAB__OPC_SSE, "/sse" },
- /* 168 */ { ud_itab__168, UD_TAB__OPC_SSE, "/sse" },
- /* 169 */ { ud_itab__169, UD_TAB__OPC_SSE, "/sse" },
- /* 170 */ { ud_itab__170, UD_TAB__OPC_SSE, "/sse" },
- /* 171 */ { ud_itab__171, UD_TAB__OPC_SSE, "/sse" },
- /* 172 */ { ud_itab__172, UD_TAB__OPC_SSE, "/sse" },
- /* 173 */ { ud_itab__173, UD_TAB__OPC_SSE, "/sse" },
- /* 174 */ { ud_itab__174, UD_TAB__OPC_OSIZE, "/o" },
- /* 175 */ { ud_itab__175, UD_TAB__OPC_OSIZE, "/o" },
- /* 176 */ { ud_itab__176, UD_TAB__OPC_SSE, "/sse" },
- /* 177 */ { ud_itab__177, UD_TAB__OPC_SSE, "/sse" },
- /* 178 */ { ud_itab__178, UD_TAB__OPC_REG, "/reg" },
- /* 179 */ { ud_itab__179, UD_TAB__OPC_SSE, "/sse" },
- /* 180 */ { ud_itab__180, UD_TAB__OPC_SSE, "/sse" },
- /* 181 */ { ud_itab__181, UD_TAB__OPC_SSE, "/sse" },
- /* 182 */ { ud_itab__182, UD_TAB__OPC_REG, "/reg" },
- /* 183 */ { ud_itab__183, UD_TAB__OPC_SSE, "/sse" },
- /* 184 */ { ud_itab__184, UD_TAB__OPC_SSE, "/sse" },
- /* 185 */ { ud_itab__185, UD_TAB__OPC_SSE, "/sse" },
- /* 186 */ { ud_itab__186, UD_TAB__OPC_REG, "/reg" },
- /* 187 */ { ud_itab__187, UD_TAB__OPC_SSE, "/sse" },
- /* 188 */ { ud_itab__188, UD_TAB__OPC_SSE, "/sse" },
- /* 189 */ { ud_itab__189, UD_TAB__OPC_SSE, "/sse" },
- /* 190 */ { ud_itab__190, UD_TAB__OPC_SSE, "/sse" },
- /* 191 */ { ud_itab__191, UD_TAB__OPC_SSE, "/sse" },
- /* 192 */ { ud_itab__192, UD_TAB__OPC_SSE, "/sse" },
- /* 193 */ { ud_itab__193, UD_TAB__OPC_SSE, "/sse" },
- /* 194 */ { ud_itab__194, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 195 */ { ud_itab__195, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 196 */ { ud_itab__196, UD_TAB__OPC_SSE, "/sse" },
- /* 197 */ { ud_itab__197, UD_TAB__OPC_SSE, "/sse" },
- /* 198 */ { ud_itab__198, UD_TAB__OPC_SSE, "/sse" },
- /* 199 */ { ud_itab__199, UD_TAB__OPC_OSIZE, "/o" },
- /* 200 */ { ud_itab__200, UD_TAB__OPC_OSIZE, "/o" },
- /* 201 */ { ud_itab__201, UD_TAB__OPC_SSE, "/sse" },
- /* 202 */ { ud_itab__202, UD_TAB__OPC_MOD, "/mod" },
- /* 203 */ { ud_itab__203, UD_TAB__OPC_REG, "/reg" },
- /* 204 */ { ud_itab__204, UD_TAB__OPC_RM, "/rm" },
- /* 205 */ { ud_itab__205, UD_TAB__OPC_RM, "/rm" },
- /* 206 */ { ud_itab__206, UD_TAB__OPC_RM, "/rm" },
- /* 207 */ { ud_itab__207, UD_TAB__OPC_MOD, "/mod" },
- /* 208 */ { ud_itab__208, UD_TAB__OPC_REG, "/reg" },
- /* 209 */ { ud_itab__209, UD_TAB__OPC_RM, "/rm" },
- /* 210 */ { ud_itab__210, UD_TAB__OPC_RM, "/rm" },
- /* 211 */ { ud_itab__211, UD_TAB__OPC_RM, "/rm" },
- /* 212 */ { ud_itab__212, UD_TAB__OPC_RM, "/rm" },
- /* 213 */ { ud_itab__213, UD_TAB__OPC_RM, "/rm" },
- /* 214 */ { ud_itab__214, UD_TAB__OPC_RM, "/rm" },
- /* 215 */ { ud_itab__215, UD_TAB__OPC_MOD, "/mod" },
- /* 216 */ { ud_itab__216, UD_TAB__OPC_REG, "/reg" },
- /* 217 */ { ud_itab__217, UD_TAB__OPC_REG, "/reg" },
- /* 218 */ { ud_itab__218, UD_TAB__OPC_RM, "/rm" },
- /* 219 */ { ud_itab__219, UD_TAB__OPC_RM, "/rm" },
- /* 220 */ { ud_itab__220, UD_TAB__OPC_RM, "/rm" },
- /* 221 */ { ud_itab__221, UD_TAB__OPC_SSE, "/sse" },
- /* 222 */ { ud_itab__222, UD_TAB__OPC_REG, "/reg" },
- /* 223 */ { ud_itab__223, UD_TAB__OPC_SSE, "/sse" },
- /* 224 */ { ud_itab__224, UD_TAB__OPC_SSE, "/sse" },
- /* 225 */ { ud_itab__225, UD_TAB__OPC_SSE, "/sse" },
- /* 226 */ { ud_itab__226, UD_TAB__OPC_SSE, "/sse" },
- /* 227 */ { ud_itab__227, UD_TAB__OPC_MOD, "/mod" },
- /* 228 */ { ud_itab__228, UD_TAB__OPC_REG, "/reg" },
- /* 229 */ { ud_itab__229, UD_TAB__OPC_OSIZE, "/o" },
- /* 230 */ { ud_itab__230, UD_TAB__OPC_SSE, "/sse" },
- /* 231 */ { ud_itab__231, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 232 */ { ud_itab__232, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 233 */ { ud_itab__233, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 234 */ { ud_itab__234, UD_TAB__OPC_VENDOR, "/vendor" },
- /* 235 */ { ud_itab__235, UD_TAB__OPC_REG, "/reg" },
- /* 236 */ { ud_itab__236, UD_TAB__OPC_SSE, "/sse" },
- /* 237 */ { ud_itab__237, UD_TAB__OPC_SSE, "/sse" },
- /* 238 */ { ud_itab__238, UD_TAB__OPC_SSE, "/sse" },
- /* 239 */ { ud_itab__239, UD_TAB__OPC_SSE, "/sse" },
- /* 240 */ { ud_itab__240, UD_TAB__OPC_SSE, "/sse" },
- /* 241 */ { ud_itab__241, UD_TAB__OPC_SSE, "/sse" },
- /* 242 */ { ud_itab__242, UD_TAB__OPC_SSE, "/sse" },
- /* 243 */ { ud_itab__243, UD_TAB__OPC_SSE, "/sse" },
- /* 244 */ { ud_itab__244, UD_TAB__OPC_SSE, "/sse" },
- /* 245 */ { ud_itab__245, UD_TAB__OPC_SSE, "/sse" },
- /* 246 */ { ud_itab__246, UD_TAB__OPC_SSE, "/sse" },
- /* 247 */ { ud_itab__247, UD_TAB__OPC_SSE, "/sse" },
- /* 248 */ { ud_itab__248, UD_TAB__OPC_SSE, "/sse" },
- /* 249 */ { ud_itab__249, UD_TAB__OPC_SSE, "/sse" },
- /* 250 */ { ud_itab__250, UD_TAB__OPC_SSE, "/sse" },
- /* 251 */ { ud_itab__251, UD_TAB__OPC_SSE, "/sse" },
- /* 252 */ { ud_itab__252, UD_TAB__OPC_SSE, "/sse" },
- /* 253 */ { ud_itab__253, UD_TAB__OPC_SSE, "/sse" },
- /* 254 */ { ud_itab__254, UD_TAB__OPC_SSE, "/sse" },
- /* 255 */ { ud_itab__255, UD_TAB__OPC_SSE, "/sse" },
- /* 256 */ { ud_itab__256, UD_TAB__OPC_SSE, "/sse" },
- /* 257 */ { ud_itab__257, UD_TAB__OPC_SSE, "/sse" },
- /* 258 */ { ud_itab__258, UD_TAB__OPC_SSE, "/sse" },
- /* 259 */ { ud_itab__259, UD_TAB__OPC_SSE, "/sse" },
- /* 260 */ { ud_itab__260, UD_TAB__OPC_SSE, "/sse" },
- /* 261 */ { ud_itab__261, UD_TAB__OPC_SSE, "/sse" },
- /* 262 */ { ud_itab__262, UD_TAB__OPC_SSE, "/sse" },
- /* 263 */ { ud_itab__263, UD_TAB__OPC_SSE, "/sse" },
- /* 264 */ { ud_itab__264, UD_TAB__OPC_SSE, "/sse" },
- /* 265 */ { ud_itab__265, UD_TAB__OPC_SSE, "/sse" },
- /* 266 */ { ud_itab__266, UD_TAB__OPC_SSE, "/sse" },
- /* 267 */ { ud_itab__267, UD_TAB__OPC_SSE, "/sse" },
- /* 268 */ { ud_itab__268, UD_TAB__OPC_SSE, "/sse" },
- /* 269 */ { ud_itab__269, UD_TAB__OPC_SSE, "/sse" },
- /* 270 */ { ud_itab__270, UD_TAB__OPC_SSE, "/sse" },
- /* 271 */ { ud_itab__271, UD_TAB__OPC_SSE, "/sse" },
- /* 272 */ { ud_itab__272, UD_TAB__OPC_SSE, "/sse" },
- /* 273 */ { ud_itab__273, UD_TAB__OPC_SSE, "/sse" },
- /* 274 */ { ud_itab__274, UD_TAB__OPC_SSE, "/sse" },
- /* 275 */ { ud_itab__275, UD_TAB__OPC_MOD, "/mod" },
- /* 276 */ { ud_itab__276, UD_TAB__OPC_SSE, "/sse" },
- /* 277 */ { ud_itab__277, UD_TAB__OPC_SSE, "/sse" },
- /* 278 */ { ud_itab__278, UD_TAB__OPC_SSE, "/sse" },
- /* 279 */ { ud_itab__279, UD_TAB__OPC_SSE, "/sse" },
- /* 280 */ { ud_itab__280, UD_TAB__OPC_SSE, "/sse" },
- /* 281 */ { ud_itab__281, UD_TAB__OPC_SSE, "/sse" },
- /* 282 */ { ud_itab__282, UD_TAB__OPC_SSE, "/sse" },
- /* 283 */ { ud_itab__283, UD_TAB__OPC_SSE, "/sse" },
- /* 284 */ { ud_itab__284, UD_TAB__OPC_MODE, "/m" },
- /* 285 */ { ud_itab__285, UD_TAB__OPC_MODE, "/m" },
- /* 286 */ { ud_itab__286, UD_TAB__OPC_MODE, "/m" },
- /* 287 */ { ud_itab__287, UD_TAB__OPC_MODE, "/m" },
- /* 288 */ { ud_itab__288, UD_TAB__OPC_MODE, "/m" },
- /* 289 */ { ud_itab__289, UD_TAB__OPC_MODE, "/m" },
- /* 290 */ { ud_itab__290, UD_TAB__OPC_MODE, "/m" },
- /* 291 */ { ud_itab__291, UD_TAB__OPC_MODE, "/m" },
- /* 292 */ { ud_itab__292, UD_TAB__OPC_OSIZE, "/o" },
- /* 293 */ { ud_itab__293, UD_TAB__OPC_MODE, "/m" },
- /* 294 */ { ud_itab__294, UD_TAB__OPC_MODE, "/m" },
- /* 295 */ { ud_itab__295, UD_TAB__OPC_OSIZE, "/o" },
- /* 296 */ { ud_itab__296, UD_TAB__OPC_MODE, "/m" },
- /* 297 */ { ud_itab__297, UD_TAB__OPC_MODE, "/m" },
- /* 298 */ { ud_itab__298, UD_TAB__OPC_MODE, "/m" },
- /* 299 */ { ud_itab__299, UD_TAB__OPC_MODE, "/m" },
- /* 300 */ { ud_itab__300, UD_TAB__OPC_OSIZE, "/o" },
- /* 301 */ { ud_itab__301, UD_TAB__OPC_OSIZE, "/o" },
- /* 302 */ { ud_itab__302, UD_TAB__OPC_REG, "/reg" },
- /* 303 */ { ud_itab__303, UD_TAB__OPC_REG, "/reg" },
- /* 304 */ { ud_itab__304, UD_TAB__OPC_REG, "/reg" },
- /* 305 */ { ud_itab__305, UD_TAB__OPC_MODE, "/m" },
- /* 306 */ { ud_itab__306, UD_TAB__OPC_MODE, "/m" },
- /* 307 */ { ud_itab__307, UD_TAB__OPC_MODE, "/m" },
- /* 308 */ { ud_itab__308, UD_TAB__OPC_MODE, "/m" },
- /* 309 */ { ud_itab__309, UD_TAB__OPC_MODE, "/m" },
- /* 310 */ { ud_itab__310, UD_TAB__OPC_MODE, "/m" },
- /* 311 */ { ud_itab__311, UD_TAB__OPC_MODE, "/m" },
- /* 312 */ { ud_itab__312, UD_TAB__OPC_MODE, "/m" },
- /* 313 */ { ud_itab__313, UD_TAB__OPC_REG, "/reg" },
- /* 314 */ { ud_itab__314, UD_TAB__OPC_REG, "/reg" },
- /* 315 */ { ud_itab__315, UD_TAB__OPC_OSIZE, "/o" },
- /* 316 */ { ud_itab__316, UD_TAB__OPC_OSIZE, "/o" },
- /* 317 */ { ud_itab__317, UD_TAB__OPC_MODE, "/m" },
- /* 318 */ { ud_itab__318, UD_TAB__OPC_OSIZE, "/o" },
- /* 319 */ { ud_itab__319, UD_TAB__OPC_MODE, "/m" },
- /* 320 */ { ud_itab__320, UD_TAB__OPC_MODE, "/m" },
- /* 321 */ { ud_itab__321, UD_TAB__OPC_MODE, "/m" },
- /* 322 */ { ud_itab__322, UD_TAB__OPC_OSIZE, "/o" },
- /* 323 */ { ud_itab__323, UD_TAB__OPC_MODE, "/m" },
- /* 324 */ { ud_itab__324, UD_TAB__OPC_MODE, "/m" },
- /* 325 */ { ud_itab__325, UD_TAB__OPC_MODE, "/m" },
- /* 326 */ { ud_itab__326, UD_TAB__OPC_OSIZE, "/o" },
- /* 327 */ { ud_itab__327, UD_TAB__OPC_OSIZE, "/o" },
- /* 328 */ { ud_itab__328, UD_TAB__OPC_OSIZE, "/o" },
- /* 329 */ { ud_itab__329, UD_TAB__OPC_OSIZE, "/o" },
- /* 330 */ { ud_itab__330, UD_TAB__OPC_OSIZE, "/o" },
- /* 331 */ { ud_itab__331, UD_TAB__OPC_REG, "/reg" },
- /* 332 */ { ud_itab__332, UD_TAB__OPC_REG, "/reg" },
- /* 333 */ { ud_itab__333, UD_TAB__OPC_VEX, "/vex" },
- /* 334 */ { ud_itab__334, UD_TAB__OPC_MODE, "/m" },
- /* 335 */ { ud_itab__335, UD_TAB__OPC_TABLE, "opctbl" },
- /* 336 */ { ud_itab__336, UD_TAB__OPC_MOD, "/mod" },
- /* 337 */ { ud_itab__337, UD_TAB__OPC_MOD, "/mod" },
- /* 338 */ { ud_itab__338, UD_TAB__OPC_MOD, "/mod" },
- /* 339 */ { ud_itab__339, UD_TAB__OPC_REG, "/reg" },
- /* 340 */ { ud_itab__340, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 341 */ { ud_itab__341, UD_TAB__OPC_TABLE, "opctbl" },
- /* 342 */ { ud_itab__342, UD_TAB__OPC_MOD, "/mod" },
- /* 343 */ { ud_itab__343, UD_TAB__OPC_MOD, "/mod" },
- /* 344 */ { ud_itab__344, UD_TAB__OPC_OSIZE, "/o" },
- /* 345 */ { ud_itab__345, UD_TAB__OPC_REG, "/reg" },
- /* 346 */ { ud_itab__346, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 347 */ { ud_itab__347, UD_TAB__OPC_REG, "/reg" },
- /* 348 */ { ud_itab__348, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 349 */ { ud_itab__349, UD_TAB__OPC_REG, "/reg" },
- /* 350 */ { ud_itab__350, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 351 */ { ud_itab__351, UD_TAB__OPC_OSIZE, "/o" },
- /* 352 */ { ud_itab__352, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 353 */ { ud_itab__353, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 354 */ { ud_itab__354, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 355 */ { ud_itab__355, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 356 */ { ud_itab__356, UD_TAB__OPC_MOD, "/mod" },
- /* 357 */ { ud_itab__357, UD_TAB__OPC_TABLE, "opctbl" },
- /* 358 */ { ud_itab__358, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 359 */ { ud_itab__359, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 360 */ { ud_itab__360, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 361 */ { ud_itab__361, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 362 */ { ud_itab__362, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 363 */ { ud_itab__363, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 364 */ { ud_itab__364, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 365 */ { ud_itab__365, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 366 */ { ud_itab__366, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 367 */ { ud_itab__367, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 368 */ { ud_itab__368, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 369 */ { ud_itab__369, UD_TAB__OPC_TABLE, "opctbl" },
- /* 370 */ { ud_itab__370, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 371 */ { ud_itab__371, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 372 */ { ud_itab__372, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 373 */ { ud_itab__373, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 374 */ { ud_itab__374, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 375 */ { ud_itab__375, UD_TAB__OPC_OSIZE, "/o" },
- /* 376 */ { ud_itab__376, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 377 */ { ud_itab__377, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 378 */ { ud_itab__378, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 379 */ { ud_itab__379, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 380 */ { ud_itab__380, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 381 */ { ud_itab__381, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 382 */ { ud_itab__382, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 383 */ { ud_itab__383, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 384 */ { ud_itab__384, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 385 */ { ud_itab__385, UD_TAB__OPC_MODE, "/m" },
- /* 386 */ { ud_itab__386, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 387 */ { ud_itab__387, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 388 */ { ud_itab__388, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 389 */ { ud_itab__389, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 390 */ { ud_itab__390, UD_TAB__OPC_VEX_L, "/vexl" },
- /* 391 */ { ud_itab__391, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 392 */ { ud_itab__392, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 393 */ { ud_itab__393, UD_TAB__OPC_VEX_W, "/vexw" },
- /* 394 */ { ud_itab__394, UD_TAB__OPC_TABLE, "opctbl" },
- /* 395 */ { ud_itab__395, UD_TAB__OPC_MOD, "/mod" },
- /* 396 */ { ud_itab__396, UD_TAB__OPC_MOD, "/mod" },
- /* 397 */ { ud_itab__397, UD_TAB__OPC_MOD, "/mod" },
- /* 398 */ { ud_itab__398, UD_TAB__OPC_MOD, "/mod" },
- /* 399 */ { ud_itab__399, UD_TAB__OPC_TABLE, "opctbl" },
- /* 400 */ { ud_itab__400, UD_TAB__OPC_MOD, "/mod" },
- /* 401 */ { ud_itab__401, UD_TAB__OPC_MOD, "/mod" },
- /* 402 */ { ud_itab__402, UD_TAB__OPC_MOD, "/mod" },
- /* 403 */ { ud_itab__403, UD_TAB__OPC_VEX, "/vex" },
- /* 404 */ { ud_itab__404, UD_TAB__OPC_MODE, "/m" },
- /* 405 */ { ud_itab__405, UD_TAB__OPC_REG, "/reg" },
- /* 406 */ { ud_itab__406, UD_TAB__OPC_REG, "/reg" },
- /* 407 */ { ud_itab__407, UD_TAB__OPC_MODE, "/m" },
- /* 408 */ { ud_itab__408, UD_TAB__OPC_OSIZE, "/o" },
- /* 409 */ { ud_itab__409, UD_TAB__OPC_REG, "/reg" },
- /* 410 */ { ud_itab__410, UD_TAB__OPC_REG, "/reg" },
- /* 411 */ { ud_itab__411, UD_TAB__OPC_REG, "/reg" },
- /* 412 */ { ud_itab__412, UD_TAB__OPC_REG, "/reg" },
- /* 413 */ { ud_itab__413, UD_TAB__OPC_MODE, "/m" },
- /* 414 */ { ud_itab__414, UD_TAB__OPC_MODE, "/m" },
- /* 415 */ { ud_itab__415, UD_TAB__OPC_MODE, "/m" },
- /* 416 */ { ud_itab__416, UD_TAB__OPC_MOD, "/mod" },
- /* 417 */ { ud_itab__417, UD_TAB__OPC_REG, "/reg" },
- /* 418 */ { ud_itab__418, UD_TAB__OPC_X87, "/x87" },
- /* 419 */ { ud_itab__419, UD_TAB__OPC_MOD, "/mod" },
- /* 420 */ { ud_itab__420, UD_TAB__OPC_REG, "/reg" },
- /* 421 */ { ud_itab__421, UD_TAB__OPC_X87, "/x87" },
- /* 422 */ { ud_itab__422, UD_TAB__OPC_MOD, "/mod" },
- /* 423 */ { ud_itab__423, UD_TAB__OPC_REG, "/reg" },
- /* 424 */ { ud_itab__424, UD_TAB__OPC_X87, "/x87" },
- /* 425 */ { ud_itab__425, UD_TAB__OPC_MOD, "/mod" },
- /* 426 */ { ud_itab__426, UD_TAB__OPC_REG, "/reg" },
- /* 427 */ { ud_itab__427, UD_TAB__OPC_X87, "/x87" },
- /* 428 */ { ud_itab__428, UD_TAB__OPC_MOD, "/mod" },
- /* 429 */ { ud_itab__429, UD_TAB__OPC_REG, "/reg" },
- /* 430 */ { ud_itab__430, UD_TAB__OPC_X87, "/x87" },
- /* 431 */ { ud_itab__431, UD_TAB__OPC_MOD, "/mod" },
- /* 432 */ { ud_itab__432, UD_TAB__OPC_REG, "/reg" },
- /* 433 */ { ud_itab__433, UD_TAB__OPC_X87, "/x87" },
- /* 434 */ { ud_itab__434, UD_TAB__OPC_MOD, "/mod" },
- /* 435 */ { ud_itab__435, UD_TAB__OPC_REG, "/reg" },
- /* 436 */ { ud_itab__436, UD_TAB__OPC_X87, "/x87" },
- /* 437 */ { ud_itab__437, UD_TAB__OPC_MOD, "/mod" },
- /* 438 */ { ud_itab__438, UD_TAB__OPC_REG, "/reg" },
- /* 439 */ { ud_itab__439, UD_TAB__OPC_X87, "/x87" },
- /* 440 */ { ud_itab__440, UD_TAB__OPC_ASIZE, "/a" },
- /* 441 */ { ud_itab__441, UD_TAB__OPC_MODE, "/m" },
- /* 442 */ { ud_itab__442, UD_TAB__OPC_REG, "/reg" },
- /* 443 */ { ud_itab__443, UD_TAB__OPC_REG, "/reg" },
- /* 444 */ { ud_itab__444, UD_TAB__OPC_REG, "/reg" },
- /* 445 */ { ud_itab__445, UD_TAB__OPC_REG, "/reg" },
- /* 446 */ { ud_itab__446, UD_TAB__OPC_MODE, "/m" },
-};
-
-/* itab entry operand definitions (for readability) */
-#define O_AL { OP_AL, SZ_B }
-#define O_AX { OP_AX, SZ_W }
-#define O_Av { OP_A, SZ_V }
-#define O_C { OP_C, SZ_NA }
-#define O_CL { OP_CL, SZ_B }
-#define O_CS { OP_CS, SZ_NA }
-#define O_CX { OP_CX, SZ_W }
-#define O_D { OP_D, SZ_NA }
-#define O_DL { OP_DL, SZ_B }
-#define O_DS { OP_DS, SZ_NA }
-#define O_DX { OP_DX, SZ_W }
-#define O_E { OP_E, SZ_NA }
-#define O_ES { OP_ES, SZ_NA }
-#define O_Eb { OP_E, SZ_B }
-#define O_Ed { OP_E, SZ_D }
-#define O_Eq { OP_E, SZ_Q }
-#define O_Ev { OP_E, SZ_V }
-#define O_Ew { OP_E, SZ_W }
-#define O_Ey { OP_E, SZ_Y }
-#define O_Ez { OP_E, SZ_Z }
-#define O_FS { OP_FS, SZ_NA }
-#define O_Fv { OP_F, SZ_V }
-#define O_G { OP_G, SZ_NA }
-#define O_GS { OP_GS, SZ_NA }
-#define O_Gb { OP_G, SZ_B }
-#define O_Gd { OP_G, SZ_D }
-#define O_Gq { OP_G, SZ_Q }
-#define O_Gv { OP_G, SZ_V }
-#define O_Gw { OP_G, SZ_W }
-#define O_Gy { OP_G, SZ_Y }
-#define O_Gz { OP_G, SZ_Z }
-#define O_H { OP_H, SZ_X }
-#define O_Hqq { OP_H, SZ_QQ }
-#define O_Hx { OP_H, SZ_X }
-#define O_I1 { OP_I1, SZ_NA }
-#define O_I3 { OP_I3, SZ_NA }
-#define O_Ib { OP_I, SZ_B }
-#define O_Iv { OP_I, SZ_V }
-#define O_Iw { OP_I, SZ_W }
-#define O_Iz { OP_I, SZ_Z }
-#define O_Jb { OP_J, SZ_B }
-#define O_Jv { OP_J, SZ_V }
-#define O_Jz { OP_J, SZ_Z }
-#define O_L { OP_L, SZ_O }
-#define O_Lx { OP_L, SZ_X }
-#define O_M { OP_M, SZ_NA }
-#define O_Mb { OP_M, SZ_B }
-#define O_MbRd { OP_MR, SZ_BD }
-#define O_MbRv { OP_MR, SZ_BV }
-#define O_Md { OP_M, SZ_D }
-#define O_MdRy { OP_MR, SZ_DY }
-#define O_MdU { OP_MU, SZ_DO }
-#define O_Mdq { OP_M, SZ_DQ }
-#define O_Mo { OP_M, SZ_O }
-#define O_Mq { OP_M, SZ_Q }
-#define O_MqU { OP_MU, SZ_QO }
-#define O_Ms { OP_M, SZ_W }
-#define O_Mt { OP_M, SZ_T }
-#define O_Mv { OP_M, SZ_V }
-#define O_Mw { OP_M, SZ_W }
-#define O_MwRd { OP_MR, SZ_WD }
-#define O_MwRv { OP_MR, SZ_WV }
-#define O_MwRy { OP_MR, SZ_WY }
-#define O_MwU { OP_MU, SZ_WO }
-#define O_N { OP_N, SZ_Q }
-#define O_NONE { OP_NONE, SZ_NA }
-#define O_Ob { OP_O, SZ_B }
-#define O_Ov { OP_O, SZ_V }
-#define O_Ow { OP_O, SZ_W }
-#define O_P { OP_P, SZ_Q }
-#define O_Q { OP_Q, SZ_Q }
-#define O_R { OP_R, SZ_RDQ }
-#define O_R0b { OP_R0, SZ_B }
-#define O_R0v { OP_R0, SZ_V }
-#define O_R0w { OP_R0, SZ_W }
-#define O_R0y { OP_R0, SZ_Y }
-#define O_R0z { OP_R0, SZ_Z }
-#define O_R1b { OP_R1, SZ_B }
-#define O_R1v { OP_R1, SZ_V }
-#define O_R1w { OP_R1, SZ_W }
-#define O_R1y { OP_R1, SZ_Y }
-#define O_R1z { OP_R1, SZ_Z }
-#define O_R2b { OP_R2, SZ_B }
-#define O_R2v { OP_R2, SZ_V }
-#define O_R2w { OP_R2, SZ_W }
-#define O_R2y { OP_R2, SZ_Y }
-#define O_R2z { OP_R2, SZ_Z }
-#define O_R3b { OP_R3, SZ_B }
-#define O_R3v { OP_R3, SZ_V }
-#define O_R3w { OP_R3, SZ_W }
-#define O_R3y { OP_R3, SZ_Y }
-#define O_R3z { OP_R3, SZ_Z }
-#define O_R4b { OP_R4, SZ_B }
-#define O_R4v { OP_R4, SZ_V }
-#define O_R4w { OP_R4, SZ_W }
-#define O_R4y { OP_R4, SZ_Y }
-#define O_R4z { OP_R4, SZ_Z }
-#define O_R5b { OP_R5, SZ_B }
-#define O_R5v { OP_R5, SZ_V }
-#define O_R5w { OP_R5, SZ_W }
-#define O_R5y { OP_R5, SZ_Y }
-#define O_R5z { OP_R5, SZ_Z }
-#define O_R6b { OP_R6, SZ_B }
-#define O_R6v { OP_R6, SZ_V }
-#define O_R6w { OP_R6, SZ_W }
-#define O_R6y { OP_R6, SZ_Y }
-#define O_R6z { OP_R6, SZ_Z }
-#define O_R7b { OP_R7, SZ_B }
-#define O_R7v { OP_R7, SZ_V }
-#define O_R7w { OP_R7, SZ_W }
-#define O_R7y { OP_R7, SZ_Y }
-#define O_R7z { OP_R7, SZ_Z }
-#define O_S { OP_S, SZ_W }
-#define O_SS { OP_SS, SZ_NA }
-#define O_ST0 { OP_ST0, SZ_NA }
-#define O_ST1 { OP_ST1, SZ_NA }
-#define O_ST2 { OP_ST2, SZ_NA }
-#define O_ST3 { OP_ST3, SZ_NA }
-#define O_ST4 { OP_ST4, SZ_NA }
-#define O_ST5 { OP_ST5, SZ_NA }
-#define O_ST6 { OP_ST6, SZ_NA }
-#define O_ST7 { OP_ST7, SZ_NA }
-#define O_U { OP_U, SZ_O }
-#define O_Ux { OP_U, SZ_X }
-#define O_V { OP_V, SZ_DQ }
-#define O_Vdq { OP_V, SZ_DQ }
-#define O_Vqq { OP_V, SZ_QQ }
-#define O_Vsd { OP_V, SZ_Q }
-#define O_Vx { OP_V, SZ_X }
-#define O_W { OP_W, SZ_DQ }
-#define O_Wdq { OP_W, SZ_DQ }
-#define O_Wqq { OP_W, SZ_QQ }
-#define O_Wsd { OP_W, SZ_Q }
-#define O_Wx { OP_W, SZ_X }
-#define O_eAX { OP_eAX, SZ_Z }
-#define O_eCX { OP_eCX, SZ_Z }
-#define O_eDX { OP_eDX, SZ_Z }
-#define O_rAX { OP_rAX, SZ_V }
-#define O_rCX { OP_rCX, SZ_V }
-#define O_rDX { OP_rDX, SZ_V }
-#define O_sIb { OP_sI, SZ_B }
-#define O_sIv { OP_sI, SZ_V }
-#define O_sIz { OP_sI, SZ_Z }
-
-struct ud_itab_entry ud_itab[] = {
- /* 0000 */ { UD_Iinvalid, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0001 */ { UD_Iaaa, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0002 */ { UD_Iaad, O_Ib, O_NONE, O_NONE, O_NONE, P_none },
- /* 0003 */ { UD_Iaam, O_Ib, O_NONE, O_NONE, O_NONE, P_none },
- /* 0004 */ { UD_Iaas, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0005 */ { UD_Iadc, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0006 */ { UD_Iadc, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0007 */ { UD_Iadc, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0008 */ { UD_Iadc, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0009 */ { UD_Iadc, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 0010 */ { UD_Iadc, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0011 */ { UD_Iadc, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0012 */ { UD_Iadc, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 },
- /* 0013 */ { UD_Iadc, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0014 */ { UD_Iadc, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0015 */ { UD_Iadd, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0016 */ { UD_Iadd, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0017 */ { UD_Iadd, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0018 */ { UD_Iadd, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0019 */ { UD_Iadd, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 0020 */ { UD_Iadd, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0021 */ { UD_Iadd, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0022 */ { UD_Iadd, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 },
- /* 0023 */ { UD_Iadd, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0024 */ { UD_Iadd, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0025 */ { UD_Iaddpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0026 */ { UD_Ivaddpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0027 */ { UD_Iaddps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0028 */ { UD_Ivaddps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0029 */ { UD_Iaddsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0030 */ { UD_Ivaddsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0031 */ { UD_Iaddss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0032 */ { UD_Ivaddss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0033 */ { UD_Iaddsubpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0034 */ { UD_Ivaddsubpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0035 */ { UD_Iaddsubps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0036 */ { UD_Ivaddsubps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0037 */ { UD_Iaesdec, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0038 */ { UD_Ivaesdec, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0039 */ { UD_Iaesdeclast, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0040 */ { UD_Ivaesdeclast, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0041 */ { UD_Iaesenc, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0042 */ { UD_Ivaesenc, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0043 */ { UD_Iaesenclast, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0044 */ { UD_Ivaesenclast, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0045 */ { UD_Iaesimc, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0046 */ { UD_Ivaesimc, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0047 */ { UD_Iaeskeygenassist, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0048 */ { UD_Ivaeskeygenassist, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0049 */ { UD_Iand, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0050 */ { UD_Iand, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0051 */ { UD_Iand, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0052 */ { UD_Iand, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0053 */ { UD_Iand, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 0054 */ { UD_Iand, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0055 */ { UD_Iand, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0056 */ { UD_Iand, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 },
- /* 0057 */ { UD_Iand, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0058 */ { UD_Iand, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0059 */ { UD_Iandpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0060 */ { UD_Ivandpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0061 */ { UD_Iandps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0062 */ { UD_Ivandps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0063 */ { UD_Iandnpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0064 */ { UD_Ivandnpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0065 */ { UD_Iandnps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0066 */ { UD_Ivandnps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0067 */ { UD_Iarpl, O_Ew, O_Gw, O_NONE, O_NONE, P_aso },
- /* 0068 */ { UD_Imovsxd, O_Gq, O_Ed, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexx|P_rexr|P_rexb },
- /* 0069 */ { UD_Icall, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0070 */ { UD_Icall, O_Eq, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 0071 */ { UD_Icall, O_Fv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0072 */ { UD_Icall, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0073 */ { UD_Icall, O_Av, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0074 */ { UD_Icbw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0075 */ { UD_Icwde, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0076 */ { UD_Icdqe, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0077 */ { UD_Iclc, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0078 */ { UD_Icld, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0079 */ { UD_Iclflush, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0080 */ { UD_Iclgi, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0081 */ { UD_Icli, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0082 */ { UD_Iclts, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0083 */ { UD_Icmc, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0084 */ { UD_Icmovo, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0085 */ { UD_Icmovno, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0086 */ { UD_Icmovb, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0087 */ { UD_Icmovae, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0088 */ { UD_Icmovz, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0089 */ { UD_Icmovnz, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0090 */ { UD_Icmovbe, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0091 */ { UD_Icmova, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0092 */ { UD_Icmovs, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0093 */ { UD_Icmovns, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0094 */ { UD_Icmovp, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0095 */ { UD_Icmovnp, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0096 */ { UD_Icmovl, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0097 */ { UD_Icmovge, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0098 */ { UD_Icmovle, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0099 */ { UD_Icmovg, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0100 */ { UD_Icmp, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0101 */ { UD_Icmp, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0102 */ { UD_Icmp, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0103 */ { UD_Icmp, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0104 */ { UD_Icmp, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 0105 */ { UD_Icmp, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0106 */ { UD_Icmp, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0107 */ { UD_Icmp, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 },
- /* 0108 */ { UD_Icmp, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0109 */ { UD_Icmp, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0110 */ { UD_Icmppd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0111 */ { UD_Ivcmppd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0112 */ { UD_Icmpps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0113 */ { UD_Ivcmpps, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0114 */ { UD_Icmpsb, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_seg },
- /* 0115 */ { UD_Icmpsw, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw|P_seg },
- /* 0116 */ { UD_Icmpsd, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw|P_seg },
- /* 0117 */ { UD_Icmpsd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0118 */ { UD_Ivcmpsd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0119 */ { UD_Icmpsq, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw|P_seg },
- /* 0120 */ { UD_Icmpss, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0121 */ { UD_Ivcmpss, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0122 */ { UD_Icmpxchg, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0123 */ { UD_Icmpxchg, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0124 */ { UD_Icmpxchg8b, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0125 */ { UD_Icmpxchg8b, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0126 */ { UD_Icmpxchg16b, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0127 */ { UD_Icomisd, O_Vsd, O_Wsd, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0128 */ { UD_Ivcomisd, O_Vsd, O_Wsd, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0129 */ { UD_Icomiss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0130 */ { UD_Ivcomiss, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0131 */ { UD_Icpuid, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0132 */ { UD_Icvtdq2pd, O_V, O_Wdq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0133 */ { UD_Ivcvtdq2pd, O_Vx, O_Wdq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0134 */ { UD_Icvtdq2ps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0135 */ { UD_Ivcvtdq2ps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0136 */ { UD_Icvtpd2dq, O_Vdq, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0137 */ { UD_Ivcvtpd2dq, O_Vdq, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0138 */ { UD_Icvtpd2pi, O_P, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0139 */ { UD_Icvtpd2ps, O_Vdq, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0140 */ { UD_Ivcvtpd2ps, O_Vdq, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0141 */ { UD_Icvtpi2ps, O_V, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0142 */ { UD_Icvtpi2pd, O_V, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0143 */ { UD_Icvtps2dq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0144 */ { UD_Ivcvtps2dq, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0145 */ { UD_Icvtps2pd, O_V, O_Wdq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0146 */ { UD_Ivcvtps2pd, O_Vx, O_Wdq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0147 */ { UD_Icvtps2pi, O_P, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0148 */ { UD_Icvtsd2si, O_Gy, O_MqU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0149 */ { UD_Ivcvtsd2si, O_Gy, O_MqU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0150 */ { UD_Icvtsd2ss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0151 */ { UD_Ivcvtsd2ss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0152 */ { UD_Icvtsi2sd, O_V, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0153 */ { UD_Ivcvtsi2sd, O_Vx, O_Hx, O_Ey, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0154 */ { UD_Icvtsi2ss, O_V, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0155 */ { UD_Ivcvtsi2ss, O_Vx, O_Hx, O_Ey, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0156 */ { UD_Icvtss2sd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0157 */ { UD_Ivcvtss2sd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0158 */ { UD_Icvtss2si, O_Gy, O_MdU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0159 */ { UD_Ivcvtss2si, O_Gy, O_MdU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0160 */ { UD_Icvttpd2dq, O_Vdq, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0161 */ { UD_Ivcvttpd2dq, O_Vdq, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0162 */ { UD_Icvttpd2pi, O_P, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0163 */ { UD_Icvttps2dq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0164 */ { UD_Ivcvttps2dq, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0165 */ { UD_Icvttps2pi, O_P, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0166 */ { UD_Icvttsd2si, O_Gy, O_MqU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0167 */ { UD_Ivcvttsd2si, O_Gy, O_MqU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0168 */ { UD_Icvttss2si, O_Gy, O_MdU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0169 */ { UD_Ivcvttss2si, O_Gy, O_MdU, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0170 */ { UD_Icwd, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0171 */ { UD_Icdq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0172 */ { UD_Icqo, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0173 */ { UD_Idaa, O_NONE, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 0174 */ { UD_Idas, O_NONE, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 0175 */ { UD_Idec, O_R0z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0176 */ { UD_Idec, O_R1z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0177 */ { UD_Idec, O_R2z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0178 */ { UD_Idec, O_R3z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0179 */ { UD_Idec, O_R4z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0180 */ { UD_Idec, O_R5z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0181 */ { UD_Idec, O_R6z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0182 */ { UD_Idec, O_R7z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0183 */ { UD_Idec, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0184 */ { UD_Idec, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0185 */ { UD_Idiv, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0186 */ { UD_Idiv, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0187 */ { UD_Idivpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0188 */ { UD_Ivdivpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0189 */ { UD_Idivps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0190 */ { UD_Ivdivps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0191 */ { UD_Idivsd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0192 */ { UD_Ivdivsd, O_Vx, O_Hx, O_MqU, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0193 */ { UD_Idivss, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0194 */ { UD_Ivdivss, O_Vx, O_Hx, O_MdU, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0195 */ { UD_Idppd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0196 */ { UD_Ivdppd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0197 */ { UD_Idpps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0198 */ { UD_Ivdpps, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0199 */ { UD_Iemms, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0200 */ { UD_Ienter, O_Iw, O_Ib, O_NONE, O_NONE, P_def64 },
- /* 0201 */ { UD_Iextractps, O_MdRy, O_V, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 0202 */ { UD_Ivextractps, O_MdRy, O_Vx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 0203 */ { UD_If2xm1, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0204 */ { UD_Ifabs, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0205 */ { UD_Ifadd, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0206 */ { UD_Ifadd, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0207 */ { UD_Ifadd, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0208 */ { UD_Ifadd, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0209 */ { UD_Ifadd, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0210 */ { UD_Ifadd, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0211 */ { UD_Ifadd, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0212 */ { UD_Ifadd, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0213 */ { UD_Ifadd, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0214 */ { UD_Ifadd, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0215 */ { UD_Ifadd, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0216 */ { UD_Ifadd, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0217 */ { UD_Ifadd, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0218 */ { UD_Ifadd, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0219 */ { UD_Ifadd, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0220 */ { UD_Ifadd, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0221 */ { UD_Ifadd, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0222 */ { UD_Ifadd, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0223 */ { UD_Ifaddp, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0224 */ { UD_Ifaddp, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0225 */ { UD_Ifaddp, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0226 */ { UD_Ifaddp, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0227 */ { UD_Ifaddp, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0228 */ { UD_Ifaddp, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0229 */ { UD_Ifaddp, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0230 */ { UD_Ifaddp, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0231 */ { UD_Ifbld, O_Mt, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0232 */ { UD_Ifbstp, O_Mt, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0233 */ { UD_Ifchs, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0234 */ { UD_Ifclex, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0235 */ { UD_Ifcmovb, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0236 */ { UD_Ifcmovb, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0237 */ { UD_Ifcmovb, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0238 */ { UD_Ifcmovb, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0239 */ { UD_Ifcmovb, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0240 */ { UD_Ifcmovb, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0241 */ { UD_Ifcmovb, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0242 */ { UD_Ifcmovb, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0243 */ { UD_Ifcmove, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0244 */ { UD_Ifcmove, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0245 */ { UD_Ifcmove, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0246 */ { UD_Ifcmove, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0247 */ { UD_Ifcmove, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0248 */ { UD_Ifcmove, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0249 */ { UD_Ifcmove, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0250 */ { UD_Ifcmove, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0251 */ { UD_Ifcmovbe, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0252 */ { UD_Ifcmovbe, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0253 */ { UD_Ifcmovbe, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0254 */ { UD_Ifcmovbe, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0255 */ { UD_Ifcmovbe, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0256 */ { UD_Ifcmovbe, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0257 */ { UD_Ifcmovbe, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0258 */ { UD_Ifcmovbe, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0259 */ { UD_Ifcmovu, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0260 */ { UD_Ifcmovu, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0261 */ { UD_Ifcmovu, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0262 */ { UD_Ifcmovu, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0263 */ { UD_Ifcmovu, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0264 */ { UD_Ifcmovu, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0265 */ { UD_Ifcmovu, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0266 */ { UD_Ifcmovu, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0267 */ { UD_Ifcmovnb, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0268 */ { UD_Ifcmovnb, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0269 */ { UD_Ifcmovnb, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0270 */ { UD_Ifcmovnb, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0271 */ { UD_Ifcmovnb, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0272 */ { UD_Ifcmovnb, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0273 */ { UD_Ifcmovnb, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0274 */ { UD_Ifcmovnb, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0275 */ { UD_Ifcmovne, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0276 */ { UD_Ifcmovne, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0277 */ { UD_Ifcmovne, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0278 */ { UD_Ifcmovne, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0279 */ { UD_Ifcmovne, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0280 */ { UD_Ifcmovne, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0281 */ { UD_Ifcmovne, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0282 */ { UD_Ifcmovne, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0283 */ { UD_Ifcmovnbe, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0284 */ { UD_Ifcmovnbe, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0285 */ { UD_Ifcmovnbe, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0286 */ { UD_Ifcmovnbe, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0287 */ { UD_Ifcmovnbe, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0288 */ { UD_Ifcmovnbe, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0289 */ { UD_Ifcmovnbe, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0290 */ { UD_Ifcmovnbe, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0291 */ { UD_Ifcmovnu, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0292 */ { UD_Ifcmovnu, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0293 */ { UD_Ifcmovnu, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0294 */ { UD_Ifcmovnu, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0295 */ { UD_Ifcmovnu, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0296 */ { UD_Ifcmovnu, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0297 */ { UD_Ifcmovnu, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0298 */ { UD_Ifcmovnu, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0299 */ { UD_Ifucomi, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0300 */ { UD_Ifucomi, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0301 */ { UD_Ifucomi, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0302 */ { UD_Ifucomi, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0303 */ { UD_Ifucomi, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0304 */ { UD_Ifucomi, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0305 */ { UD_Ifucomi, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0306 */ { UD_Ifucomi, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0307 */ { UD_Ifcom, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0308 */ { UD_Ifcom, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0309 */ { UD_Ifcom, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0310 */ { UD_Ifcom, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0311 */ { UD_Ifcom, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0312 */ { UD_Ifcom, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0313 */ { UD_Ifcom, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0314 */ { UD_Ifcom, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0315 */ { UD_Ifcom, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0316 */ { UD_Ifcom, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0317 */ { UD_Ifcom2, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0318 */ { UD_Ifcom2, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0319 */ { UD_Ifcom2, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0320 */ { UD_Ifcom2, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0321 */ { UD_Ifcom2, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0322 */ { UD_Ifcom2, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0323 */ { UD_Ifcom2, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0324 */ { UD_Ifcom2, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0325 */ { UD_Ifcomp3, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0326 */ { UD_Ifcomp3, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0327 */ { UD_Ifcomp3, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0328 */ { UD_Ifcomp3, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0329 */ { UD_Ifcomp3, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0330 */ { UD_Ifcomp3, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0331 */ { UD_Ifcomp3, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0332 */ { UD_Ifcomp3, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0333 */ { UD_Ifcomi, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0334 */ { UD_Ifcomi, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0335 */ { UD_Ifcomi, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0336 */ { UD_Ifcomi, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0337 */ { UD_Ifcomi, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0338 */ { UD_Ifcomi, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0339 */ { UD_Ifcomi, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0340 */ { UD_Ifcomi, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0341 */ { UD_Ifucomip, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0342 */ { UD_Ifucomip, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0343 */ { UD_Ifucomip, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0344 */ { UD_Ifucomip, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0345 */ { UD_Ifucomip, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0346 */ { UD_Ifucomip, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0347 */ { UD_Ifucomip, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0348 */ { UD_Ifucomip, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0349 */ { UD_Ifcomip, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0350 */ { UD_Ifcomip, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0351 */ { UD_Ifcomip, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0352 */ { UD_Ifcomip, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0353 */ { UD_Ifcomip, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0354 */ { UD_Ifcomip, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0355 */ { UD_Ifcomip, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0356 */ { UD_Ifcomip, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0357 */ { UD_Ifcomp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0358 */ { UD_Ifcomp, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0359 */ { UD_Ifcomp, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0360 */ { UD_Ifcomp, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0361 */ { UD_Ifcomp, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0362 */ { UD_Ifcomp, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0363 */ { UD_Ifcomp, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0364 */ { UD_Ifcomp, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0365 */ { UD_Ifcomp, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0366 */ { UD_Ifcomp, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0367 */ { UD_Ifcomp5, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0368 */ { UD_Ifcomp5, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0369 */ { UD_Ifcomp5, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0370 */ { UD_Ifcomp5, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0371 */ { UD_Ifcomp5, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0372 */ { UD_Ifcomp5, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0373 */ { UD_Ifcomp5, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0374 */ { UD_Ifcomp5, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0375 */ { UD_Ifcompp, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0376 */ { UD_Ifcos, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0377 */ { UD_Ifdecstp, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0378 */ { UD_Ifdiv, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0379 */ { UD_Ifdiv, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0380 */ { UD_Ifdiv, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0381 */ { UD_Ifdiv, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0382 */ { UD_Ifdiv, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0383 */ { UD_Ifdiv, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0384 */ { UD_Ifdiv, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0385 */ { UD_Ifdiv, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0386 */ { UD_Ifdiv, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0387 */ { UD_Ifdiv, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0388 */ { UD_Ifdiv, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0389 */ { UD_Ifdiv, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0390 */ { UD_Ifdiv, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0391 */ { UD_Ifdiv, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0392 */ { UD_Ifdiv, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0393 */ { UD_Ifdiv, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0394 */ { UD_Ifdiv, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0395 */ { UD_Ifdiv, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0396 */ { UD_Ifdivp, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0397 */ { UD_Ifdivp, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0398 */ { UD_Ifdivp, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0399 */ { UD_Ifdivp, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0400 */ { UD_Ifdivp, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0401 */ { UD_Ifdivp, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0402 */ { UD_Ifdivp, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0403 */ { UD_Ifdivp, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0404 */ { UD_Ifdivr, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0405 */ { UD_Ifdivr, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0406 */ { UD_Ifdivr, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0407 */ { UD_Ifdivr, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0408 */ { UD_Ifdivr, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0409 */ { UD_Ifdivr, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0410 */ { UD_Ifdivr, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0411 */ { UD_Ifdivr, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0412 */ { UD_Ifdivr, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0413 */ { UD_Ifdivr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0414 */ { UD_Ifdivr, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0415 */ { UD_Ifdivr, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0416 */ { UD_Ifdivr, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0417 */ { UD_Ifdivr, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0418 */ { UD_Ifdivr, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0419 */ { UD_Ifdivr, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0420 */ { UD_Ifdivr, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0421 */ { UD_Ifdivr, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0422 */ { UD_Ifdivrp, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0423 */ { UD_Ifdivrp, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0424 */ { UD_Ifdivrp, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0425 */ { UD_Ifdivrp, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0426 */ { UD_Ifdivrp, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0427 */ { UD_Ifdivrp, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0428 */ { UD_Ifdivrp, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0429 */ { UD_Ifdivrp, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0430 */ { UD_Ifemms, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0431 */ { UD_Iffree, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0432 */ { UD_Iffree, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0433 */ { UD_Iffree, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0434 */ { UD_Iffree, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0435 */ { UD_Iffree, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0436 */ { UD_Iffree, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0437 */ { UD_Iffree, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0438 */ { UD_Iffree, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0439 */ { UD_Iffreep, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0440 */ { UD_Iffreep, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0441 */ { UD_Iffreep, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0442 */ { UD_Iffreep, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0443 */ { UD_Iffreep, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0444 */ { UD_Iffreep, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0445 */ { UD_Iffreep, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0446 */ { UD_Iffreep, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0447 */ { UD_Ificom, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0448 */ { UD_Ificom, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0449 */ { UD_Ificomp, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0450 */ { UD_Ificomp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0451 */ { UD_Ifild, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0452 */ { UD_Ifild, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0453 */ { UD_Ifild, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0454 */ { UD_Ifincstp, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0455 */ { UD_Ifninit, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0456 */ { UD_Ifiadd, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0457 */ { UD_Ifiadd, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0458 */ { UD_Ifidivr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0459 */ { UD_Ifidivr, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0460 */ { UD_Ifidiv, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0461 */ { UD_Ifidiv, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0462 */ { UD_Ifisub, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0463 */ { UD_Ifisub, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0464 */ { UD_Ifisubr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0465 */ { UD_Ifisubr, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0466 */ { UD_Ifist, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0467 */ { UD_Ifist, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0468 */ { UD_Ifistp, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0469 */ { UD_Ifistp, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0470 */ { UD_Ifistp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0471 */ { UD_Ifisttp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0472 */ { UD_Ifisttp, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0473 */ { UD_Ifisttp, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0474 */ { UD_Ifld, O_Mt, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0475 */ { UD_Ifld, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0476 */ { UD_Ifld, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0477 */ { UD_Ifld, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0478 */ { UD_Ifld, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0479 */ { UD_Ifld, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0480 */ { UD_Ifld, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0481 */ { UD_Ifld, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0482 */ { UD_Ifld, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0483 */ { UD_Ifld, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0484 */ { UD_Ifld, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0485 */ { UD_Ifld1, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0486 */ { UD_Ifldl2t, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0487 */ { UD_Ifldl2e, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0488 */ { UD_Ifldpi, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0489 */ { UD_Ifldlg2, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0490 */ { UD_Ifldln2, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0491 */ { UD_Ifldz, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0492 */ { UD_Ifldcw, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0493 */ { UD_Ifldenv, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0494 */ { UD_Ifmul, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0495 */ { UD_Ifmul, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0496 */ { UD_Ifmul, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0497 */ { UD_Ifmul, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0498 */ { UD_Ifmul, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0499 */ { UD_Ifmul, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0500 */ { UD_Ifmul, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0501 */ { UD_Ifmul, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0502 */ { UD_Ifmul, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0503 */ { UD_Ifmul, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0504 */ { UD_Ifmul, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0505 */ { UD_Ifmul, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0506 */ { UD_Ifmul, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0507 */ { UD_Ifmul, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0508 */ { UD_Ifmul, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0509 */ { UD_Ifmul, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0510 */ { UD_Ifmul, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0511 */ { UD_Ifmul, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0512 */ { UD_Ifmulp, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0513 */ { UD_Ifmulp, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0514 */ { UD_Ifmulp, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0515 */ { UD_Ifmulp, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0516 */ { UD_Ifmulp, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0517 */ { UD_Ifmulp, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0518 */ { UD_Ifmulp, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0519 */ { UD_Ifmulp, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0520 */ { UD_Ifimul, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0521 */ { UD_Ifimul, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0522 */ { UD_Ifnop, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0523 */ { UD_Ifndisi, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0524 */ { UD_Ifneni, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0525 */ { UD_Ifnsetpm, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0526 */ { UD_Ifpatan, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0527 */ { UD_Ifprem, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0528 */ { UD_Ifprem1, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0529 */ { UD_Ifptan, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0530 */ { UD_Ifrndint, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0531 */ { UD_Ifrstor, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0532 */ { UD_Ifrstpm, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0533 */ { UD_Ifnsave, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0534 */ { UD_Ifscale, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0535 */ { UD_Ifsin, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0536 */ { UD_Ifsincos, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0537 */ { UD_Ifsqrt, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0538 */ { UD_Ifstp, O_Mt, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0539 */ { UD_Ifstp, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0540 */ { UD_Ifstp, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0541 */ { UD_Ifstp, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0542 */ { UD_Ifstp, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0543 */ { UD_Ifstp, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0544 */ { UD_Ifstp, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0545 */ { UD_Ifstp, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0546 */ { UD_Ifstp, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0547 */ { UD_Ifstp, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0548 */ { UD_Ifstp, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0549 */ { UD_Ifstp1, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0550 */ { UD_Ifstp1, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0551 */ { UD_Ifstp1, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0552 */ { UD_Ifstp1, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0553 */ { UD_Ifstp1, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0554 */ { UD_Ifstp1, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0555 */ { UD_Ifstp1, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0556 */ { UD_Ifstp1, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0557 */ { UD_Ifstp8, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0558 */ { UD_Ifstp8, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0559 */ { UD_Ifstp8, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0560 */ { UD_Ifstp8, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0561 */ { UD_Ifstp8, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0562 */ { UD_Ifstp8, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0563 */ { UD_Ifstp8, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0564 */ { UD_Ifstp8, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0565 */ { UD_Ifstp9, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0566 */ { UD_Ifstp9, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0567 */ { UD_Ifstp9, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0568 */ { UD_Ifstp9, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0569 */ { UD_Ifstp9, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0570 */ { UD_Ifstp9, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0571 */ { UD_Ifstp9, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0572 */ { UD_Ifstp9, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0573 */ { UD_Ifst, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0574 */ { UD_Ifst, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0575 */ { UD_Ifst, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0576 */ { UD_Ifst, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0577 */ { UD_Ifst, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0578 */ { UD_Ifst, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0579 */ { UD_Ifst, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0580 */ { UD_Ifst, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0581 */ { UD_Ifst, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0582 */ { UD_Ifst, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0583 */ { UD_Ifnstcw, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0584 */ { UD_Ifnstenv, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0585 */ { UD_Ifnstsw, O_Mw, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0586 */ { UD_Ifnstsw, O_AX, O_NONE, O_NONE, O_NONE, P_none },
- /* 0587 */ { UD_Ifsub, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0588 */ { UD_Ifsub, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0589 */ { UD_Ifsub, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0590 */ { UD_Ifsub, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0591 */ { UD_Ifsub, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0592 */ { UD_Ifsub, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0593 */ { UD_Ifsub, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0594 */ { UD_Ifsub, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0595 */ { UD_Ifsub, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0596 */ { UD_Ifsub, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0597 */ { UD_Ifsub, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0598 */ { UD_Ifsub, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0599 */ { UD_Ifsub, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0600 */ { UD_Ifsub, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0601 */ { UD_Ifsub, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0602 */ { UD_Ifsub, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0603 */ { UD_Ifsub, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0604 */ { UD_Ifsub, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0605 */ { UD_Ifsubp, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0606 */ { UD_Ifsubp, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0607 */ { UD_Ifsubp, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0608 */ { UD_Ifsubp, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0609 */ { UD_Ifsubp, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0610 */ { UD_Ifsubp, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0611 */ { UD_Ifsubp, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0612 */ { UD_Ifsubp, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0613 */ { UD_Ifsubr, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0614 */ { UD_Ifsubr, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0615 */ { UD_Ifsubr, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0616 */ { UD_Ifsubr, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0617 */ { UD_Ifsubr, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0618 */ { UD_Ifsubr, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0619 */ { UD_Ifsubr, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0620 */ { UD_Ifsubr, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0621 */ { UD_Ifsubr, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0622 */ { UD_Ifsubr, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0623 */ { UD_Ifsubr, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0624 */ { UD_Ifsubr, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0625 */ { UD_Ifsubr, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0626 */ { UD_Ifsubr, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0627 */ { UD_Ifsubr, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0628 */ { UD_Ifsubr, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0629 */ { UD_Ifsubr, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0630 */ { UD_Ifsubr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0631 */ { UD_Ifsubrp, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0632 */ { UD_Ifsubrp, O_ST1, O_ST0, O_NONE, O_NONE, P_none },
- /* 0633 */ { UD_Ifsubrp, O_ST2, O_ST0, O_NONE, O_NONE, P_none },
- /* 0634 */ { UD_Ifsubrp, O_ST3, O_ST0, O_NONE, O_NONE, P_none },
- /* 0635 */ { UD_Ifsubrp, O_ST4, O_ST0, O_NONE, O_NONE, P_none },
- /* 0636 */ { UD_Ifsubrp, O_ST5, O_ST0, O_NONE, O_NONE, P_none },
- /* 0637 */ { UD_Ifsubrp, O_ST6, O_ST0, O_NONE, O_NONE, P_none },
- /* 0638 */ { UD_Ifsubrp, O_ST7, O_ST0, O_NONE, O_NONE, P_none },
- /* 0639 */ { UD_Iftst, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0640 */ { UD_Ifucom, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0641 */ { UD_Ifucom, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0642 */ { UD_Ifucom, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0643 */ { UD_Ifucom, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0644 */ { UD_Ifucom, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0645 */ { UD_Ifucom, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0646 */ { UD_Ifucom, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0647 */ { UD_Ifucom, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0648 */ { UD_Ifucomp, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0649 */ { UD_Ifucomp, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0650 */ { UD_Ifucomp, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0651 */ { UD_Ifucomp, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0652 */ { UD_Ifucomp, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0653 */ { UD_Ifucomp, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0654 */ { UD_Ifucomp, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0655 */ { UD_Ifucomp, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0656 */ { UD_Ifucompp, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0657 */ { UD_Ifxam, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0658 */ { UD_Ifxch, O_ST0, O_ST0, O_NONE, O_NONE, P_none },
- /* 0659 */ { UD_Ifxch, O_ST0, O_ST1, O_NONE, O_NONE, P_none },
- /* 0660 */ { UD_Ifxch, O_ST0, O_ST2, O_NONE, O_NONE, P_none },
- /* 0661 */ { UD_Ifxch, O_ST0, O_ST3, O_NONE, O_NONE, P_none },
- /* 0662 */ { UD_Ifxch, O_ST0, O_ST4, O_NONE, O_NONE, P_none },
- /* 0663 */ { UD_Ifxch, O_ST0, O_ST5, O_NONE, O_NONE, P_none },
- /* 0664 */ { UD_Ifxch, O_ST0, O_ST6, O_NONE, O_NONE, P_none },
- /* 0665 */ { UD_Ifxch, O_ST0, O_ST7, O_NONE, O_NONE, P_none },
- /* 0666 */ { UD_Ifxch4, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0667 */ { UD_Ifxch4, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0668 */ { UD_Ifxch4, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0669 */ { UD_Ifxch4, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0670 */ { UD_Ifxch4, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0671 */ { UD_Ifxch4, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0672 */ { UD_Ifxch4, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0673 */ { UD_Ifxch4, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0674 */ { UD_Ifxch7, O_ST0, O_NONE, O_NONE, O_NONE, P_none },
- /* 0675 */ { UD_Ifxch7, O_ST1, O_NONE, O_NONE, O_NONE, P_none },
- /* 0676 */ { UD_Ifxch7, O_ST2, O_NONE, O_NONE, O_NONE, P_none },
- /* 0677 */ { UD_Ifxch7, O_ST3, O_NONE, O_NONE, O_NONE, P_none },
- /* 0678 */ { UD_Ifxch7, O_ST4, O_NONE, O_NONE, O_NONE, P_none },
- /* 0679 */ { UD_Ifxch7, O_ST5, O_NONE, O_NONE, O_NONE, P_none },
- /* 0680 */ { UD_Ifxch7, O_ST6, O_NONE, O_NONE, O_NONE, P_none },
- /* 0681 */ { UD_Ifxch7, O_ST7, O_NONE, O_NONE, O_NONE, P_none },
- /* 0682 */ { UD_Ifxrstor, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0683 */ { UD_Ifxsave, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0684 */ { UD_Ifxtract, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0685 */ { UD_Ifyl2x, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0686 */ { UD_Ifyl2xp1, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0687 */ { UD_Ihlt, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0688 */ { UD_Iidiv, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0689 */ { UD_Iidiv, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0690 */ { UD_Iin, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 0691 */ { UD_Iin, O_eAX, O_Ib, O_NONE, O_NONE, P_oso },
- /* 0692 */ { UD_Iin, O_AL, O_DX, O_NONE, O_NONE, P_none },
- /* 0693 */ { UD_Iin, O_eAX, O_DX, O_NONE, O_NONE, P_oso },
- /* 0694 */ { UD_Iimul, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0695 */ { UD_Iimul, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0696 */ { UD_Iimul, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0697 */ { UD_Iimul, O_Gv, O_Ev, O_Iz, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0698 */ { UD_Iimul, O_Gv, O_Ev, O_sIb, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0699 */ { UD_Iinc, O_R0z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0700 */ { UD_Iinc, O_R1z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0701 */ { UD_Iinc, O_R2z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0702 */ { UD_Iinc, O_R3z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0703 */ { UD_Iinc, O_R4z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0704 */ { UD_Iinc, O_R5z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0705 */ { UD_Iinc, O_R6z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0706 */ { UD_Iinc, O_R7z, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0707 */ { UD_Iinc, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0708 */ { UD_Iinc, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0709 */ { UD_Iinsb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg },
- /* 0710 */ { UD_Iinsw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_oso|P_seg },
- /* 0711 */ { UD_Iinsd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_oso|P_seg },
- /* 0712 */ { UD_Iint1, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0713 */ { UD_Iint3, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0714 */ { UD_Iint, O_Ib, O_NONE, O_NONE, O_NONE, P_none },
- /* 0715 */ { UD_Iinto, O_NONE, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 0716 */ { UD_Iinvd, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0717 */ { UD_Iinvept, O_Gd, O_Mo, O_NONE, O_NONE, P_none },
- /* 0718 */ { UD_Iinvept, O_Gq, O_Mo, O_NONE, O_NONE, P_none },
- /* 0719 */ { UD_Iinvlpg, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0720 */ { UD_Iinvlpga, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0721 */ { UD_Iinvvpid, O_Gd, O_Mo, O_NONE, O_NONE, P_none },
- /* 0722 */ { UD_Iinvvpid, O_Gq, O_Mo, O_NONE, O_NONE, P_none },
- /* 0723 */ { UD_Iiretw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0724 */ { UD_Iiretd, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0725 */ { UD_Iiretq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0726 */ { UD_Ijo, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0727 */ { UD_Ijo, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0728 */ { UD_Ijno, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0729 */ { UD_Ijno, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0730 */ { UD_Ijb, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0731 */ { UD_Ijb, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0732 */ { UD_Ijae, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0733 */ { UD_Ijae, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0734 */ { UD_Ijz, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0735 */ { UD_Ijz, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0736 */ { UD_Ijnz, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0737 */ { UD_Ijnz, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0738 */ { UD_Ijbe, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0739 */ { UD_Ijbe, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0740 */ { UD_Ija, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0741 */ { UD_Ija, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0742 */ { UD_Ijs, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0743 */ { UD_Ijs, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0744 */ { UD_Ijns, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0745 */ { UD_Ijns, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0746 */ { UD_Ijp, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0747 */ { UD_Ijp, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0748 */ { UD_Ijnp, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0749 */ { UD_Ijnp, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0750 */ { UD_Ijl, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0751 */ { UD_Ijl, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0752 */ { UD_Ijge, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0753 */ { UD_Ijge, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0754 */ { UD_Ijle, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0755 */ { UD_Ijle, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0756 */ { UD_Ijg, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0757 */ { UD_Ijg, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0758 */ { UD_Ijcxz, O_Jb, O_NONE, O_NONE, O_NONE, P_aso },
- /* 0759 */ { UD_Ijecxz, O_Jb, O_NONE, O_NONE, O_NONE, P_aso },
- /* 0760 */ { UD_Ijrcxz, O_Jb, O_NONE, O_NONE, O_NONE, P_aso },
- /* 0761 */ { UD_Ijmp, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 0762 */ { UD_Ijmp, O_Fv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0763 */ { UD_Ijmp, O_Jz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 0764 */ { UD_Ijmp, O_Av, O_NONE, O_NONE, O_NONE, P_oso },
- /* 0765 */ { UD_Ijmp, O_Jb, O_NONE, O_NONE, O_NONE, P_def64 },
- /* 0766 */ { UD_Ilahf, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0767 */ { UD_Ilar, O_Gv, O_Ew, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0768 */ { UD_Ildmxcsr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0769 */ { UD_Ilds, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso },
- /* 0770 */ { UD_Ilea, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0771 */ { UD_Iles, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso },
- /* 0772 */ { UD_Ilfs, O_Gz, O_M, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0773 */ { UD_Ilgs, O_Gz, O_M, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0774 */ { UD_Ilidt, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0775 */ { UD_Ilss, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0776 */ { UD_Ileave, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0777 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0778 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0779 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0780 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0781 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0782 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0783 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0784 */ { UD_Ilfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0785 */ { UD_Ilgdt, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0786 */ { UD_Illdt, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0787 */ { UD_Ilmsw, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0788 */ { UD_Ilmsw, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0789 */ { UD_Ilock, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0790 */ { UD_Ilodsb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg },
- /* 0791 */ { UD_Ilodsw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 0792 */ { UD_Ilodsd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 0793 */ { UD_Ilodsq, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 0794 */ { UD_Iloopne, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0795 */ { UD_Iloope, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0796 */ { UD_Iloop, O_Jb, O_NONE, O_NONE, O_NONE, P_none },
- /* 0797 */ { UD_Ilsl, O_Gv, O_Ew, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0798 */ { UD_Iltr, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0799 */ { UD_Imaskmovq, O_P, O_N, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0800 */ { UD_Imaxpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0801 */ { UD_Ivmaxpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0802 */ { UD_Imaxps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0803 */ { UD_Ivmaxps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0804 */ { UD_Imaxsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0805 */ { UD_Ivmaxsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0806 */ { UD_Imaxss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0807 */ { UD_Ivmaxss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0808 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0809 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0810 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0811 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0812 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0813 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0814 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0815 */ { UD_Imfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0816 */ { UD_Iminpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0817 */ { UD_Ivminpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0818 */ { UD_Iminps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0819 */ { UD_Ivminps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0820 */ { UD_Iminsd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0821 */ { UD_Ivminsd, O_Vx, O_Hx, O_MqU, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0822 */ { UD_Iminss, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0823 */ { UD_Ivminss, O_Vx, O_Hx, O_MdU, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0824 */ { UD_Imonitor, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0825 */ { UD_Imontmul, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0826 */ { UD_Imov, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0827 */ { UD_Imov, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0828 */ { UD_Imov, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0829 */ { UD_Imov, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0830 */ { UD_Imov, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0831 */ { UD_Imov, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0832 */ { UD_Imov, O_MwRv, O_S, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0833 */ { UD_Imov, O_S, O_MwRv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0834 */ { UD_Imov, O_AL, O_Ob, O_NONE, O_NONE, P_none },
- /* 0835 */ { UD_Imov, O_rAX, O_Ov, O_NONE, O_NONE, P_aso|P_oso|P_rexw },
- /* 0836 */ { UD_Imov, O_Ob, O_AL, O_NONE, O_NONE, P_none },
- /* 0837 */ { UD_Imov, O_Ov, O_rAX, O_NONE, O_NONE, P_aso|P_oso|P_rexw },
- /* 0838 */ { UD_Imov, O_R0b, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 0839 */ { UD_Imov, O_R1b, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 0840 */ { UD_Imov, O_R2b, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 0841 */ { UD_Imov, O_R3b, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 0842 */ { UD_Imov, O_R4b, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 0843 */ { UD_Imov, O_R5b, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 0844 */ { UD_Imov, O_R6b, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 0845 */ { UD_Imov, O_R7b, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 0846 */ { UD_Imov, O_R0v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 0847 */ { UD_Imov, O_R1v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 0848 */ { UD_Imov, O_R2v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 0849 */ { UD_Imov, O_R3v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 0850 */ { UD_Imov, O_R4v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 0851 */ { UD_Imov, O_R5v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 0852 */ { UD_Imov, O_R6v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 0853 */ { UD_Imov, O_R7v, O_Iv, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 0854 */ { UD_Imov, O_R, O_C, O_NONE, O_NONE, P_rexr|P_rexw|P_rexb },
- /* 0855 */ { UD_Imov, O_R, O_D, O_NONE, O_NONE, P_rexr|P_rexw|P_rexb },
- /* 0856 */ { UD_Imov, O_C, O_R, O_NONE, O_NONE, P_rexr|P_rexw|P_rexb },
- /* 0857 */ { UD_Imov, O_D, O_R, O_NONE, O_NONE, P_rexr|P_rexw|P_rexb },
- /* 0858 */ { UD_Imovapd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0859 */ { UD_Ivmovapd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0860 */ { UD_Imovapd, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0861 */ { UD_Ivmovapd, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0862 */ { UD_Imovaps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0863 */ { UD_Ivmovaps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0864 */ { UD_Imovaps, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0865 */ { UD_Ivmovaps, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0866 */ { UD_Imovd, O_P, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0867 */ { UD_Imovd, O_P, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0868 */ { UD_Imovd, O_V, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0869 */ { UD_Ivmovd, O_Vx, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0870 */ { UD_Imovd, O_V, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0871 */ { UD_Ivmovd, O_Vx, O_Ey, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0872 */ { UD_Imovd, O_Ey, O_P, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0873 */ { UD_Imovd, O_Ey, O_P, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0874 */ { UD_Imovd, O_Ey, O_V, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0875 */ { UD_Ivmovd, O_Ey, O_Vx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0876 */ { UD_Imovd, O_Ey, O_V, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0877 */ { UD_Ivmovd, O_Ey, O_Vx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0878 */ { UD_Imovhpd, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0879 */ { UD_Ivmovhpd, O_Vx, O_Hx, O_M, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0880 */ { UD_Imovhpd, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0881 */ { UD_Ivmovhpd, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0882 */ { UD_Imovhps, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0883 */ { UD_Ivmovhps, O_Vx, O_Hx, O_M, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0884 */ { UD_Imovhps, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0885 */ { UD_Ivmovhps, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0886 */ { UD_Imovlhps, O_V, O_U, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0887 */ { UD_Ivmovlhps, O_Vx, O_Hx, O_Ux, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0888 */ { UD_Imovlpd, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0889 */ { UD_Ivmovlpd, O_Vx, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0890 */ { UD_Imovlpd, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0891 */ { UD_Ivmovlpd, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0892 */ { UD_Imovlps, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0893 */ { UD_Ivmovlps, O_Vx, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0894 */ { UD_Imovlps, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0895 */ { UD_Ivmovlps, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0896 */ { UD_Imovhlps, O_V, O_U, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0897 */ { UD_Ivmovhlps, O_Vx, O_Ux, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0898 */ { UD_Imovmskpd, O_Gd, O_U, O_NONE, O_NONE, P_oso|P_rexr|P_rexb },
- /* 0899 */ { UD_Ivmovmskpd, O_Gd, O_Ux, O_NONE, O_NONE, P_oso|P_rexr|P_rexb|P_vexl },
- /* 0900 */ { UD_Imovmskps, O_Gd, O_U, O_NONE, O_NONE, P_oso|P_rexr|P_rexb },
- /* 0901 */ { UD_Ivmovmskps, O_Gd, O_Ux, O_NONE, O_NONE, P_oso|P_rexr|P_rexb },
- /* 0902 */ { UD_Imovntdq, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0903 */ { UD_Ivmovntdq, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0904 */ { UD_Imovnti, O_M, O_Gy, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0905 */ { UD_Imovntpd, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0906 */ { UD_Ivmovntpd, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0907 */ { UD_Imovntps, O_M, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0908 */ { UD_Ivmovntps, O_M, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0909 */ { UD_Imovntq, O_M, O_P, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0910 */ { UD_Imovq, O_P, O_Eq, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0911 */ { UD_Imovq, O_V, O_Eq, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0912 */ { UD_Ivmovq, O_Vx, O_Eq, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0913 */ { UD_Imovq, O_Eq, O_P, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0914 */ { UD_Imovq, O_Eq, O_V, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0915 */ { UD_Ivmovq, O_Eq, O_Vx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0916 */ { UD_Imovq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0917 */ { UD_Ivmovq, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0918 */ { UD_Imovq, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0919 */ { UD_Ivmovq, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0920 */ { UD_Imovq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0921 */ { UD_Imovq, O_Q, O_P, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0922 */ { UD_Imovsb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg },
- /* 0923 */ { UD_Imovsw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 0924 */ { UD_Imovsd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 0925 */ { UD_Imovsd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0926 */ { UD_Imovsd, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0927 */ { UD_Imovsq, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 0928 */ { UD_Imovss, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0929 */ { UD_Imovss, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0930 */ { UD_Imovsx, O_Gv, O_Eb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0931 */ { UD_Imovsx, O_Gy, O_Ew, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0932 */ { UD_Imovupd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0933 */ { UD_Ivmovupd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0934 */ { UD_Imovupd, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0935 */ { UD_Ivmovupd, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0936 */ { UD_Imovups, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0937 */ { UD_Ivmovups, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0938 */ { UD_Imovups, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0939 */ { UD_Ivmovups, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0940 */ { UD_Imovzx, O_Gv, O_Eb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0941 */ { UD_Imovzx, O_Gy, O_Ew, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0942 */ { UD_Imul, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0943 */ { UD_Imul, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0944 */ { UD_Imulpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0945 */ { UD_Ivmulpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0946 */ { UD_Imulps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0947 */ { UD_Ivmulps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0948 */ { UD_Imulsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0949 */ { UD_Ivmulsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0950 */ { UD_Imulss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0951 */ { UD_Ivmulss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0952 */ { UD_Imwait, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 0953 */ { UD_Ineg, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0954 */ { UD_Ineg, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0955 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0956 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0957 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0958 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0959 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0960 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0961 */ { UD_Inop, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0962 */ { UD_Inot, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0963 */ { UD_Inot, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0964 */ { UD_Ior, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0965 */ { UD_Ior, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0966 */ { UD_Ior, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0967 */ { UD_Ior, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0968 */ { UD_Ior, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 0969 */ { UD_Ior, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 0970 */ { UD_Ior, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0971 */ { UD_Ior, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0972 */ { UD_Ior, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0973 */ { UD_Ior, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 0974 */ { UD_Iorpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0975 */ { UD_Ivorpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0976 */ { UD_Iorps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0977 */ { UD_Ivorps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0978 */ { UD_Iout, O_Ib, O_AL, O_NONE, O_NONE, P_none },
- /* 0979 */ { UD_Iout, O_Ib, O_eAX, O_NONE, O_NONE, P_oso },
- /* 0980 */ { UD_Iout, O_DX, O_AL, O_NONE, O_NONE, P_none },
- /* 0981 */ { UD_Iout, O_DX, O_eAX, O_NONE, O_NONE, P_oso },
- /* 0982 */ { UD_Ioutsb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg },
- /* 0983 */ { UD_Ioutsw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_oso|P_seg },
- /* 0984 */ { UD_Ioutsd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_oso|P_seg },
- /* 0985 */ { UD_Ipacksswb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0986 */ { UD_Ivpacksswb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0987 */ { UD_Ipacksswb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0988 */ { UD_Ipackssdw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0989 */ { UD_Ivpackssdw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0990 */ { UD_Ipackssdw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0991 */ { UD_Ipackuswb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0992 */ { UD_Ivpackuswb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0993 */ { UD_Ipackuswb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0994 */ { UD_Ipaddb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0995 */ { UD_Ivpaddb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 0996 */ { UD_Ipaddb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0997 */ { UD_Ipaddw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0998 */ { UD_Ipaddw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 0999 */ { UD_Ivpaddw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1000 */ { UD_Ipaddd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1001 */ { UD_Ipaddd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1002 */ { UD_Ivpaddd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1003 */ { UD_Ipaddsb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1004 */ { UD_Ipaddsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1005 */ { UD_Ivpaddsb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1006 */ { UD_Ipaddsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1007 */ { UD_Ipaddsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1008 */ { UD_Ivpaddsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1009 */ { UD_Ipaddusb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1010 */ { UD_Ipaddusb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1011 */ { UD_Ivpaddusb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1012 */ { UD_Ipaddusw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1013 */ { UD_Ipaddusw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1014 */ { UD_Ivpaddusw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1015 */ { UD_Ipand, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1016 */ { UD_Ivpand, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1017 */ { UD_Ipand, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1018 */ { UD_Ipandn, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1019 */ { UD_Ivpandn, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1020 */ { UD_Ipandn, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1021 */ { UD_Ipavgb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1022 */ { UD_Ivpavgb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1023 */ { UD_Ipavgb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1024 */ { UD_Ipavgw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1025 */ { UD_Ivpavgw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1026 */ { UD_Ipavgw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1027 */ { UD_Ipcmpeqb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1028 */ { UD_Ipcmpeqb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1029 */ { UD_Ivpcmpeqb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1030 */ { UD_Ipcmpeqw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1031 */ { UD_Ipcmpeqw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1032 */ { UD_Ivpcmpeqw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1033 */ { UD_Ipcmpeqd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1034 */ { UD_Ipcmpeqd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1035 */ { UD_Ivpcmpeqd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1036 */ { UD_Ipcmpgtb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1037 */ { UD_Ivpcmpgtb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1038 */ { UD_Ipcmpgtb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1039 */ { UD_Ipcmpgtw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1040 */ { UD_Ivpcmpgtw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1041 */ { UD_Ipcmpgtw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1042 */ { UD_Ipcmpgtd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1043 */ { UD_Ivpcmpgtd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1044 */ { UD_Ipcmpgtd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1045 */ { UD_Ipextrb, O_MbRv, O_V, O_Ib, O_NONE, P_aso|P_rexx|P_rexr|P_rexb|P_def64 },
- /* 1046 */ { UD_Ivpextrb, O_MbRv, O_Vx, O_Ib, O_NONE, P_aso|P_rexx|P_rexr|P_rexb|P_def64 },
- /* 1047 */ { UD_Ipextrd, O_Ed, O_V, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexw|P_rexb },
- /* 1048 */ { UD_Ivpextrd, O_Ed, O_Vx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexw|P_rexb },
- /* 1049 */ { UD_Ipextrd, O_Ed, O_V, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexw|P_rexb },
- /* 1050 */ { UD_Ivpextrd, O_Ed, O_Vx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexw|P_rexb },
- /* 1051 */ { UD_Ipextrq, O_Eq, O_V, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexb|P_def64 },
- /* 1052 */ { UD_Ivpextrq, O_Eq, O_Vx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexb|P_def64 },
- /* 1053 */ { UD_Ipextrw, O_Gd, O_U, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexb },
- /* 1054 */ { UD_Ivpextrw, O_Gd, O_Ux, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexb },
- /* 1055 */ { UD_Ipextrw, O_Gd, O_N, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1056 */ { UD_Ipextrw, O_MwRd, O_V, O_Ib, O_NONE, P_aso|P_rexw|P_rexx|P_rexr|P_rexb },
- /* 1057 */ { UD_Ivpextrw, O_MwRd, O_Vx, O_Ib, O_NONE, P_aso|P_rexw|P_rexx|P_rexr|P_rexb },
- /* 1058 */ { UD_Ipinsrb, O_V, O_MbRd, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1059 */ { UD_Ipinsrw, O_P, O_MwRy, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 1060 */ { UD_Ipinsrw, O_V, O_MwRy, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 1061 */ { UD_Ivpinsrw, O_Vx, O_MwRy, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 1062 */ { UD_Ipinsrd, O_V, O_Ed, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1063 */ { UD_Ipinsrd, O_V, O_Ed, O_Ib, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1064 */ { UD_Ipinsrq, O_V, O_Eq, O_Ib, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1065 */ { UD_Ivpinsrb, O_V, O_H, O_MbRd, O_Ib, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1066 */ { UD_Ivpinsrd, O_V, O_H, O_Ed, O_Ib, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1067 */ { UD_Ivpinsrd, O_V, O_H, O_Ed, O_Ib, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1068 */ { UD_Ivpinsrq, O_V, O_H, O_Eq, O_Ib, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1069 */ { UD_Ipmaddwd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1070 */ { UD_Ipmaddwd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1071 */ { UD_Ivpmaddwd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1072 */ { UD_Ipmaxsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1073 */ { UD_Ivpmaxsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1074 */ { UD_Ipmaxsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1075 */ { UD_Ipmaxub, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1076 */ { UD_Ipmaxub, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1077 */ { UD_Ivpmaxub, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1078 */ { UD_Ipminsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1079 */ { UD_Ivpminsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1080 */ { UD_Ipminsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1081 */ { UD_Ipminub, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1082 */ { UD_Ivpminub, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1083 */ { UD_Ipminub, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1084 */ { UD_Ipmovmskb, O_Gd, O_U, O_NONE, O_NONE, P_oso|P_rexr|P_rexw|P_rexb },
- /* 1085 */ { UD_Ivpmovmskb, O_Gd, O_Ux, O_NONE, O_NONE, P_oso|P_rexr|P_rexw|P_rexb },
- /* 1086 */ { UD_Ipmovmskb, O_Gd, O_N, O_NONE, O_NONE, P_oso|P_rexr|P_rexw|P_rexb },
- /* 1087 */ { UD_Ipmulhuw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1088 */ { UD_Ipmulhuw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1089 */ { UD_Ivpmulhuw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1090 */ { UD_Ipmulhw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1091 */ { UD_Ivpmulhw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1092 */ { UD_Ipmulhw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1093 */ { UD_Ipmullw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1094 */ { UD_Ipmullw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1095 */ { UD_Ivpmullw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1096 */ { UD_Ipop, O_ES, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 1097 */ { UD_Ipop, O_SS, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 1098 */ { UD_Ipop, O_DS, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 1099 */ { UD_Ipop, O_GS, O_NONE, O_NONE, O_NONE, P_none },
- /* 1100 */ { UD_Ipop, O_FS, O_NONE, O_NONE, O_NONE, P_none },
- /* 1101 */ { UD_Ipop, O_R0v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1102 */ { UD_Ipop, O_R1v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1103 */ { UD_Ipop, O_R2v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1104 */ { UD_Ipop, O_R3v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1105 */ { UD_Ipop, O_R4v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1106 */ { UD_Ipop, O_R5v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1107 */ { UD_Ipop, O_R6v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1108 */ { UD_Ipop, O_R7v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1109 */ { UD_Ipop, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 1110 */ { UD_Ipopa, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_inv64 },
- /* 1111 */ { UD_Ipopad, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_inv64 },
- /* 1112 */ { UD_Ipopfw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso },
- /* 1113 */ { UD_Ipopfd, O_NONE, O_NONE, O_NONE, O_NONE, P_oso },
- /* 1114 */ { UD_Ipopfq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 1115 */ { UD_Ipopfq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 1116 */ { UD_Ipor, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1117 */ { UD_Ivpor, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1118 */ { UD_Ipor, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1119 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1120 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1121 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1122 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1123 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1124 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1125 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1126 */ { UD_Iprefetch, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1127 */ { UD_Iprefetchnta, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1128 */ { UD_Iprefetcht0, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1129 */ { UD_Iprefetcht1, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1130 */ { UD_Iprefetcht2, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1131 */ { UD_Ipsadbw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1132 */ { UD_Ivpsadbw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1133 */ { UD_Ipsadbw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1134 */ { UD_Ipshufw, O_P, O_Q, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1135 */ { UD_Ipsllw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1136 */ { UD_Ipsllw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1137 */ { UD_Ipsllw, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1138 */ { UD_Ipsllw, O_N, O_Ib, O_NONE, O_NONE, P_none },
- /* 1139 */ { UD_Ipslld, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1140 */ { UD_Ipslld, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1141 */ { UD_Ipslld, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1142 */ { UD_Ipslld, O_N, O_Ib, O_NONE, O_NONE, P_none },
- /* 1143 */ { UD_Ipsllq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1144 */ { UD_Ipsllq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1145 */ { UD_Ipsllq, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1146 */ { UD_Ipsllq, O_N, O_Ib, O_NONE, O_NONE, P_none },
- /* 1147 */ { UD_Ipsraw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1148 */ { UD_Ipsraw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1149 */ { UD_Ivpsraw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1150 */ { UD_Ipsraw, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1151 */ { UD_Ivpsraw, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb },
- /* 1152 */ { UD_Ipsraw, O_N, O_Ib, O_NONE, O_NONE, P_none },
- /* 1153 */ { UD_Ipsrad, O_N, O_Ib, O_NONE, O_NONE, P_none },
- /* 1154 */ { UD_Ipsrad, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1155 */ { UD_Ivpsrad, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1156 */ { UD_Ipsrad, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1157 */ { UD_Ipsrad, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1158 */ { UD_Ivpsrad, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb },
- /* 1159 */ { UD_Ipsrlw, O_N, O_Ib, O_NONE, O_NONE, P_none },
- /* 1160 */ { UD_Ipsrlw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1161 */ { UD_Ipsrlw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1162 */ { UD_Ivpsrlw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1163 */ { UD_Ipsrlw, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1164 */ { UD_Ivpsrlw, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb },
- /* 1165 */ { UD_Ipsrld, O_N, O_Ib, O_NONE, O_NONE, P_none },
- /* 1166 */ { UD_Ipsrld, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1167 */ { UD_Ipsrld, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1168 */ { UD_Ivpsrld, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1169 */ { UD_Ipsrld, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1170 */ { UD_Ivpsrld, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb },
- /* 1171 */ { UD_Ipsrlq, O_N, O_Ib, O_NONE, O_NONE, P_none },
- /* 1172 */ { UD_Ipsrlq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1173 */ { UD_Ipsrlq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1174 */ { UD_Ivpsrlq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1175 */ { UD_Ipsrlq, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1176 */ { UD_Ivpsrlq, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb },
- /* 1177 */ { UD_Ipsubb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1178 */ { UD_Ivpsubb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1179 */ { UD_Ipsubb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1180 */ { UD_Ipsubw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1181 */ { UD_Ivpsubw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1182 */ { UD_Ipsubw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1183 */ { UD_Ipsubd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1184 */ { UD_Ipsubd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1185 */ { UD_Ivpsubd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1186 */ { UD_Ipsubsb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1187 */ { UD_Ipsubsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1188 */ { UD_Ivpsubsb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1189 */ { UD_Ipsubsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1190 */ { UD_Ipsubsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1191 */ { UD_Ivpsubsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1192 */ { UD_Ipsubusb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1193 */ { UD_Ipsubusb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1194 */ { UD_Ivpsubusb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1195 */ { UD_Ipsubusw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1196 */ { UD_Ipsubusw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1197 */ { UD_Ivpsubusw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1198 */ { UD_Ipunpckhbw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1199 */ { UD_Ivpunpckhbw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1200 */ { UD_Ipunpckhbw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1201 */ { UD_Ipunpckhwd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1202 */ { UD_Ivpunpckhwd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1203 */ { UD_Ipunpckhwd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1204 */ { UD_Ipunpckhdq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1205 */ { UD_Ivpunpckhdq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1206 */ { UD_Ipunpckhdq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1207 */ { UD_Ipunpcklbw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1208 */ { UD_Ivpunpcklbw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1209 */ { UD_Ipunpcklbw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1210 */ { UD_Ipunpcklwd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1211 */ { UD_Ivpunpcklwd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1212 */ { UD_Ipunpcklwd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1213 */ { UD_Ipunpckldq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1214 */ { UD_Ivpunpckldq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1215 */ { UD_Ipunpckldq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1216 */ { UD_Ipi2fw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1217 */ { UD_Ipi2fd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1218 */ { UD_Ipf2iw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1219 */ { UD_Ipf2id, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1220 */ { UD_Ipfnacc, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1221 */ { UD_Ipfpnacc, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1222 */ { UD_Ipfcmpge, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1223 */ { UD_Ipfmin, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1224 */ { UD_Ipfrcp, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1225 */ { UD_Ipfrsqrt, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1226 */ { UD_Ipfsub, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1227 */ { UD_Ipfadd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1228 */ { UD_Ipfcmpgt, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1229 */ { UD_Ipfmax, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1230 */ { UD_Ipfrcpit1, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1231 */ { UD_Ipfrsqit1, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1232 */ { UD_Ipfsubr, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1233 */ { UD_Ipfacc, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1234 */ { UD_Ipfcmpeq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1235 */ { UD_Ipfmul, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1236 */ { UD_Ipfrcpit2, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1237 */ { UD_Ipmulhrw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1238 */ { UD_Ipswapd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1239 */ { UD_Ipavgusb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1240 */ { UD_Ipush, O_ES, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 1241 */ { UD_Ipush, O_CS, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 1242 */ { UD_Ipush, O_SS, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 1243 */ { UD_Ipush, O_DS, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 1244 */ { UD_Ipush, O_GS, O_NONE, O_NONE, O_NONE, P_none },
- /* 1245 */ { UD_Ipush, O_FS, O_NONE, O_NONE, O_NONE, P_none },
- /* 1246 */ { UD_Ipush, O_R0v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1247 */ { UD_Ipush, O_R1v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1248 */ { UD_Ipush, O_R2v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1249 */ { UD_Ipush, O_R3v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1250 */ { UD_Ipush, O_R4v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1251 */ { UD_Ipush, O_R5v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1252 */ { UD_Ipush, O_R6v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1253 */ { UD_Ipush, O_R7v, O_NONE, O_NONE, O_NONE, P_oso|P_rexb|P_def64 },
- /* 1254 */ { UD_Ipush, O_sIz, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 1255 */ { UD_Ipush, O_Ev, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 1256 */ { UD_Ipush, O_sIb, O_NONE, O_NONE, O_NONE, P_oso|P_def64 },
- /* 1257 */ { UD_Ipusha, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_inv64 },
- /* 1258 */ { UD_Ipushad, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_inv64 },
- /* 1259 */ { UD_Ipushfw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso },
- /* 1260 */ { UD_Ipushfw, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_def64 },
- /* 1261 */ { UD_Ipushfd, O_NONE, O_NONE, O_NONE, O_NONE, P_oso },
- /* 1262 */ { UD_Ipushfq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_def64 },
- /* 1263 */ { UD_Ipushfq, O_NONE, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_def64 },
- /* 1264 */ { UD_Ipxor, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1265 */ { UD_Ivpxor, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1266 */ { UD_Ipxor, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1267 */ { UD_Ircl, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1268 */ { UD_Ircl, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1269 */ { UD_Ircl, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1270 */ { UD_Ircl, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1271 */ { UD_Ircl, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1272 */ { UD_Ircl, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1273 */ { UD_Ircr, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1274 */ { UD_Ircr, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1275 */ { UD_Ircr, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1276 */ { UD_Ircr, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1277 */ { UD_Ircr, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1278 */ { UD_Ircr, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1279 */ { UD_Irol, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1280 */ { UD_Irol, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1281 */ { UD_Irol, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1282 */ { UD_Irol, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1283 */ { UD_Irol, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1284 */ { UD_Irol, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1285 */ { UD_Iror, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1286 */ { UD_Iror, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1287 */ { UD_Iror, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1288 */ { UD_Iror, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1289 */ { UD_Iror, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1290 */ { UD_Iror, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1291 */ { UD_Ircpps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1292 */ { UD_Ivrcpps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1293 */ { UD_Ircpss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1294 */ { UD_Ivrcpss, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1295 */ { UD_Irdmsr, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1296 */ { UD_Irdpmc, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1297 */ { UD_Irdtsc, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1298 */ { UD_Irdtscp, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1299 */ { UD_Irepne, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1300 */ { UD_Irep, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1301 */ { UD_Iret, O_Iw, O_NONE, O_NONE, O_NONE, P_none },
- /* 1302 */ { UD_Iret, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1303 */ { UD_Iretf, O_Iw, O_NONE, O_NONE, O_NONE, P_none },
- /* 1304 */ { UD_Iretf, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1305 */ { UD_Irsm, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1306 */ { UD_Irsqrtps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1307 */ { UD_Ivrsqrtps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1308 */ { UD_Irsqrtss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1309 */ { UD_Ivrsqrtss, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1310 */ { UD_Isahf, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1311 */ { UD_Isalc, O_NONE, O_NONE, O_NONE, O_NONE, P_inv64 },
- /* 1312 */ { UD_Isar, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1313 */ { UD_Isar, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1314 */ { UD_Isar, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1315 */ { UD_Isar, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1316 */ { UD_Isar, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1317 */ { UD_Isar, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1318 */ { UD_Ishl, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1319 */ { UD_Ishl, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1320 */ { UD_Ishl, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1321 */ { UD_Ishl, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1322 */ { UD_Ishl, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1323 */ { UD_Ishl, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1324 */ { UD_Ishl, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1325 */ { UD_Ishl, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1326 */ { UD_Ishl, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1327 */ { UD_Ishl, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1328 */ { UD_Ishl, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1329 */ { UD_Ishl, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1330 */ { UD_Ishr, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1331 */ { UD_Ishr, O_Eb, O_CL, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1332 */ { UD_Ishr, O_Ev, O_I1, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1333 */ { UD_Ishr, O_Eb, O_I1, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1334 */ { UD_Ishr, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1335 */ { UD_Ishr, O_Ev, O_CL, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1336 */ { UD_Isbb, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1337 */ { UD_Isbb, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1338 */ { UD_Isbb, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1339 */ { UD_Isbb, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1340 */ { UD_Isbb, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 1341 */ { UD_Isbb, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 1342 */ { UD_Isbb, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1343 */ { UD_Isbb, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1344 */ { UD_Isbb, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 },
- /* 1345 */ { UD_Isbb, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1346 */ { UD_Iscasb, O_NONE, O_NONE, O_NONE, O_NONE, P_strz },
- /* 1347 */ { UD_Iscasw, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw },
- /* 1348 */ { UD_Iscasd, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw },
- /* 1349 */ { UD_Iscasq, O_NONE, O_NONE, O_NONE, O_NONE, P_strz|P_oso|P_rexw },
- /* 1350 */ { UD_Iseto, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1351 */ { UD_Isetno, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1352 */ { UD_Isetb, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1353 */ { UD_Isetae, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1354 */ { UD_Isetz, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1355 */ { UD_Isetnz, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1356 */ { UD_Isetbe, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1357 */ { UD_Iseta, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1358 */ { UD_Isets, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1359 */ { UD_Isetns, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1360 */ { UD_Isetp, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1361 */ { UD_Isetnp, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1362 */ { UD_Isetl, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1363 */ { UD_Isetge, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1364 */ { UD_Isetle, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1365 */ { UD_Isetg, O_Eb, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1366 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1367 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1368 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1369 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1370 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1371 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1372 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1373 */ { UD_Isfence, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1374 */ { UD_Isgdt, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1375 */ { UD_Ishld, O_Ev, O_Gv, O_Ib, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1376 */ { UD_Ishld, O_Ev, O_Gv, O_CL, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1377 */ { UD_Ishrd, O_Ev, O_Gv, O_Ib, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1378 */ { UD_Ishrd, O_Ev, O_Gv, O_CL, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1379 */ { UD_Ishufpd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1380 */ { UD_Ivshufpd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1381 */ { UD_Ishufps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1382 */ { UD_Ivshufps, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1383 */ { UD_Isidt, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1384 */ { UD_Isldt, O_MwRv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1385 */ { UD_Ismsw, O_MwRv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1386 */ { UD_Ismsw, O_MwRv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1387 */ { UD_Isqrtps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1388 */ { UD_Ivsqrtps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1389 */ { UD_Isqrtpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1390 */ { UD_Ivsqrtpd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1391 */ { UD_Isqrtsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1392 */ { UD_Ivsqrtsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1393 */ { UD_Isqrtss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1394 */ { UD_Ivsqrtss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1395 */ { UD_Istc, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1396 */ { UD_Istd, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1397 */ { UD_Istgi, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1398 */ { UD_Isti, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1399 */ { UD_Iskinit, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1400 */ { UD_Istmxcsr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1401 */ { UD_Ivstmxcsr, O_Md, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1402 */ { UD_Istosb, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg },
- /* 1403 */ { UD_Istosw, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 1404 */ { UD_Istosd, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 1405 */ { UD_Istosq, O_NONE, O_NONE, O_NONE, O_NONE, P_str|P_seg|P_oso|P_rexw },
- /* 1406 */ { UD_Istr, O_MwRv, O_NONE, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1407 */ { UD_Isub, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1408 */ { UD_Isub, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1409 */ { UD_Isub, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1410 */ { UD_Isub, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1411 */ { UD_Isub, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 1412 */ { UD_Isub, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 1413 */ { UD_Isub, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1414 */ { UD_Isub, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1415 */ { UD_Isub, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 },
- /* 1416 */ { UD_Isub, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1417 */ { UD_Isubpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1418 */ { UD_Ivsubpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1419 */ { UD_Isubps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1420 */ { UD_Ivsubps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1421 */ { UD_Isubsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1422 */ { UD_Ivsubsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1423 */ { UD_Isubss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1424 */ { UD_Ivsubss, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1425 */ { UD_Iswapgs, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1426 */ { UD_Isyscall, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1427 */ { UD_Isysenter, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1428 */ { UD_Isysenter, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1429 */ { UD_Isysexit, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1430 */ { UD_Isysexit, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1431 */ { UD_Isysret, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1432 */ { UD_Itest, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1433 */ { UD_Itest, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1434 */ { UD_Itest, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1435 */ { UD_Itest, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 1436 */ { UD_Itest, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 1437 */ { UD_Itest, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1438 */ { UD_Itest, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1439 */ { UD_Itest, O_Ev, O_Iz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1440 */ { UD_Iucomisd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1441 */ { UD_Ivucomisd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1442 */ { UD_Iucomiss, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1443 */ { UD_Ivucomiss, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1444 */ { UD_Iud2, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1445 */ { UD_Iunpckhpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1446 */ { UD_Ivunpckhpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1447 */ { UD_Iunpckhps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1448 */ { UD_Ivunpckhps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1449 */ { UD_Iunpcklps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1450 */ { UD_Ivunpcklps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1451 */ { UD_Iunpcklpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1452 */ { UD_Ivunpcklpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1453 */ { UD_Iverr, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1454 */ { UD_Iverw, O_Ew, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1455 */ { UD_Ivmcall, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1456 */ { UD_Irdrand, O_R, O_NONE, O_NONE, O_NONE, P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1457 */ { UD_Ivmclear, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1458 */ { UD_Ivmxon, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1459 */ { UD_Ivmptrld, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1460 */ { UD_Ivmptrst, O_Mq, O_NONE, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1461 */ { UD_Ivmlaunch, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1462 */ { UD_Ivmresume, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1463 */ { UD_Ivmxoff, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1464 */ { UD_Ivmread, O_Ey, O_Gy, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 1465 */ { UD_Ivmwrite, O_Gy, O_Ey, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_def64 },
- /* 1466 */ { UD_Ivmrun, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1467 */ { UD_Ivmmcall, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1468 */ { UD_Ivmload, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1469 */ { UD_Ivmsave, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1470 */ { UD_Iwait, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1471 */ { UD_Iwbinvd, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1472 */ { UD_Iwrmsr, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1473 */ { UD_Ixadd, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexx|P_rexb },
- /* 1474 */ { UD_Ixadd, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1475 */ { UD_Ixchg, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1476 */ { UD_Ixchg, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1477 */ { UD_Ixchg, O_R0v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1478 */ { UD_Ixchg, O_R1v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1479 */ { UD_Ixchg, O_R2v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1480 */ { UD_Ixchg, O_R3v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1481 */ { UD_Ixchg, O_R4v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1482 */ { UD_Ixchg, O_R5v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1483 */ { UD_Ixchg, O_R6v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1484 */ { UD_Ixchg, O_R7v, O_rAX, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1485 */ { UD_Ixgetbv, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1486 */ { UD_Ixlatb, O_NONE, O_NONE, O_NONE, O_NONE, P_rexw|P_seg },
- /* 1487 */ { UD_Ixor, O_Eb, O_Gb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1488 */ { UD_Ixor, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1489 */ { UD_Ixor, O_Gb, O_Eb, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1490 */ { UD_Ixor, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1491 */ { UD_Ixor, O_AL, O_Ib, O_NONE, O_NONE, P_none },
- /* 1492 */ { UD_Ixor, O_rAX, O_sIz, O_NONE, O_NONE, P_oso|P_rexw },
- /* 1493 */ { UD_Ixor, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1494 */ { UD_Ixor, O_Ev, O_sIz, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1495 */ { UD_Ixor, O_Eb, O_Ib, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_inv64 },
- /* 1496 */ { UD_Ixor, O_Ev, O_sIb, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1497 */ { UD_Ixorpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1498 */ { UD_Ivxorpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1499 */ { UD_Ixorps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1500 */ { UD_Ivxorps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1501 */ { UD_Ixcryptecb, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1502 */ { UD_Ixcryptcbc, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1503 */ { UD_Ixcryptctr, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1504 */ { UD_Ixcryptcfb, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1505 */ { UD_Ixcryptofb, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1506 */ { UD_Ixrstor, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1507 */ { UD_Ixsave, O_M, O_NONE, O_NONE, O_NONE, P_aso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1508 */ { UD_Ixsetbv, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1509 */ { UD_Ixsha1, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1510 */ { UD_Ixsha256, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1511 */ { UD_Ixstore, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1512 */ { UD_Ipclmulqdq, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1513 */ { UD_Ivpclmulqdq, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1514 */ { UD_Igetsec, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1515 */ { UD_Imovdqa, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1516 */ { UD_Ivmovdqa, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1517 */ { UD_Imovdqa, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1518 */ { UD_Ivmovdqa, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1519 */ { UD_Imaskmovdqu, O_V, O_U, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1520 */ { UD_Ivmaskmovdqu, O_Vx, O_Ux, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1521 */ { UD_Imovdq2q, O_P, O_U, O_NONE, O_NONE, P_aso|P_rexb },
- /* 1522 */ { UD_Imovdqu, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1523 */ { UD_Ivmovdqu, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1524 */ { UD_Imovdqu, O_W, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1525 */ { UD_Ivmovdqu, O_Wx, O_Vx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1526 */ { UD_Imovq2dq, O_V, O_N, O_NONE, O_NONE, P_aso|P_rexr },
- /* 1527 */ { UD_Ipaddq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1528 */ { UD_Ipaddq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1529 */ { UD_Ivpaddq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1530 */ { UD_Ipsubq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1531 */ { UD_Ivpsubq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1532 */ { UD_Ipsubq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1533 */ { UD_Ipmuludq, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1534 */ { UD_Ipmuludq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1535 */ { UD_Ipshufhw, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1536 */ { UD_Ivpshufhw, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1537 */ { UD_Ipshuflw, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1538 */ { UD_Ivpshuflw, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1539 */ { UD_Ipshufd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1540 */ { UD_Ivpshufd, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1541 */ { UD_Ipslldq, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1542 */ { UD_Ivpslldq, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb },
- /* 1543 */ { UD_Ipsrldq, O_U, O_Ib, O_NONE, O_NONE, P_rexb },
- /* 1544 */ { UD_Ivpsrldq, O_Hx, O_Ux, O_Ib, O_NONE, P_rexb },
- /* 1545 */ { UD_Ipunpckhqdq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1546 */ { UD_Ivpunpckhqdq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1547 */ { UD_Ipunpcklqdq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1548 */ { UD_Ivpunpcklqdq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1549 */ { UD_Ihaddpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1550 */ { UD_Ivhaddpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1551 */ { UD_Ihaddps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1552 */ { UD_Ivhaddps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1553 */ { UD_Ihsubpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1554 */ { UD_Ivhsubpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1555 */ { UD_Ihsubps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1556 */ { UD_Ivhsubps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1557 */ { UD_Iinsertps, O_V, O_Md, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1558 */ { UD_Ivinsertps, O_Vx, O_Hx, O_Md, O_Ib, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1559 */ { UD_Ilddqu, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1560 */ { UD_Ivlddqu, O_Vx, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1561 */ { UD_Imovddup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1562 */ { UD_Ivmovddup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1563 */ { UD_Imovddup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1564 */ { UD_Ivmovddup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1565 */ { UD_Imovshdup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1566 */ { UD_Ivmovshdup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1567 */ { UD_Imovshdup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1568 */ { UD_Ivmovshdup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1569 */ { UD_Imovsldup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1570 */ { UD_Ivmovsldup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1571 */ { UD_Imovsldup, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1572 */ { UD_Ivmovsldup, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1573 */ { UD_Ipabsb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1574 */ { UD_Ipabsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1575 */ { UD_Ivpabsb, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1576 */ { UD_Ipabsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1577 */ { UD_Ipabsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1578 */ { UD_Ivpabsw, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1579 */ { UD_Ipabsd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1580 */ { UD_Ipabsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1581 */ { UD_Ivpabsd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1582 */ { UD_Ipshufb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1583 */ { UD_Ipshufb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1584 */ { UD_Ivpshufb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1585 */ { UD_Iphaddw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1586 */ { UD_Iphaddw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1587 */ { UD_Ivphaddw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1588 */ { UD_Iphaddd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1589 */ { UD_Iphaddd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1590 */ { UD_Ivphaddd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1591 */ { UD_Iphaddsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1592 */ { UD_Iphaddsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1593 */ { UD_Ivphaddsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1594 */ { UD_Ipmaddubsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1595 */ { UD_Ipmaddubsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1596 */ { UD_Ivpmaddubsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1597 */ { UD_Iphsubw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1598 */ { UD_Iphsubw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1599 */ { UD_Ivphsubw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1600 */ { UD_Iphsubd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1601 */ { UD_Iphsubd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1602 */ { UD_Ivphsubd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1603 */ { UD_Iphsubsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1604 */ { UD_Iphsubsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1605 */ { UD_Ivphsubsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1606 */ { UD_Ipsignb, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1607 */ { UD_Ipsignb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1608 */ { UD_Ivpsignb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1609 */ { UD_Ipsignd, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1610 */ { UD_Ipsignd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1611 */ { UD_Ivpsignd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1612 */ { UD_Ipsignw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1613 */ { UD_Ipsignw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1614 */ { UD_Ivpsignw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1615 */ { UD_Ipmulhrsw, O_P, O_Q, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1616 */ { UD_Ipmulhrsw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1617 */ { UD_Ivpmulhrsw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1618 */ { UD_Ipalignr, O_P, O_Q, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1619 */ { UD_Ipalignr, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1620 */ { UD_Ivpalignr, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1621 */ { UD_Ipblendvb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1622 */ { UD_Ipmuldq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1623 */ { UD_Ivpmuldq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1624 */ { UD_Ipminsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1625 */ { UD_Ivpminsb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1626 */ { UD_Ipminsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1627 */ { UD_Ivpminsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1628 */ { UD_Ipminuw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1629 */ { UD_Ivpminuw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1630 */ { UD_Ipminud, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1631 */ { UD_Ivpminud, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1632 */ { UD_Ipmaxsb, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1633 */ { UD_Ivpmaxsb, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1634 */ { UD_Ipmaxsd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1635 */ { UD_Ivpmaxsd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1636 */ { UD_Ipmaxud, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1637 */ { UD_Ivpmaxud, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1638 */ { UD_Ipmaxuw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1639 */ { UD_Ivpmaxuw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1640 */ { UD_Ipmulld, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1641 */ { UD_Ivpmulld, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1642 */ { UD_Iphminposuw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1643 */ { UD_Ivphminposuw, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1644 */ { UD_Iroundps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1645 */ { UD_Ivroundps, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1646 */ { UD_Iroundpd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1647 */ { UD_Ivroundpd, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1648 */ { UD_Iroundss, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1649 */ { UD_Ivroundss, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1650 */ { UD_Iroundsd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1651 */ { UD_Ivroundsd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1652 */ { UD_Iblendpd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1653 */ { UD_Ivblendpd, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1654 */ { UD_Iblendps, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1655 */ { UD_Ivblendps, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1656 */ { UD_Iblendvpd, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1657 */ { UD_Iblendvps, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1658 */ { UD_Ibound, O_Gv, O_M, O_NONE, O_NONE, P_aso|P_oso },
- /* 1659 */ { UD_Ibsf, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1660 */ { UD_Ibsr, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1661 */ { UD_Ibswap, O_R0y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1662 */ { UD_Ibswap, O_R1y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1663 */ { UD_Ibswap, O_R2y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1664 */ { UD_Ibswap, O_R3y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1665 */ { UD_Ibswap, O_R4y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1666 */ { UD_Ibswap, O_R5y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1667 */ { UD_Ibswap, O_R6y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1668 */ { UD_Ibswap, O_R7y, O_NONE, O_NONE, O_NONE, P_oso|P_rexw|P_rexb },
- /* 1669 */ { UD_Ibt, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1670 */ { UD_Ibt, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1671 */ { UD_Ibtc, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1672 */ { UD_Ibtc, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1673 */ { UD_Ibtr, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1674 */ { UD_Ibtr, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1675 */ { UD_Ibts, O_Ev, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1676 */ { UD_Ibts, O_Ev, O_Ib, O_NONE, O_NONE, P_aso|P_oso|P_rexw|P_rexr|P_rexx|P_rexb },
- /* 1677 */ { UD_Ipblendw, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1678 */ { UD_Ivpblendw, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1679 */ { UD_Impsadbw, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1680 */ { UD_Ivmpsadbw, O_Vx, O_Hx, O_Wx, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1681 */ { UD_Imovntdqa, O_V, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1682 */ { UD_Ivmovntdqa, O_Vx, O_M, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb|P_vexl },
- /* 1683 */ { UD_Ipackusdw, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1684 */ { UD_Ivpackusdw, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb|P_vexl },
- /* 1685 */ { UD_Ipmovsxbw, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1686 */ { UD_Ivpmovsxbw, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1687 */ { UD_Ipmovsxbd, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1688 */ { UD_Ivpmovsxbd, O_Vx, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1689 */ { UD_Ipmovsxbq, O_V, O_MwU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1690 */ { UD_Ivpmovsxbq, O_Vx, O_MwU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1691 */ { UD_Ipmovsxwd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1692 */ { UD_Ivpmovsxwd, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1693 */ { UD_Ipmovsxwq, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1694 */ { UD_Ivpmovsxwq, O_Vx, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1695 */ { UD_Ipmovsxdq, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1696 */ { UD_Ipmovzxbw, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1697 */ { UD_Ivpmovzxbw, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1698 */ { UD_Ipmovzxbd, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1699 */ { UD_Ivpmovzxbd, O_Vx, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1700 */ { UD_Ipmovzxbq, O_V, O_MwU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1701 */ { UD_Ivpmovzxbq, O_Vx, O_MwU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1702 */ { UD_Ipmovzxwd, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1703 */ { UD_Ivpmovzxwd, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1704 */ { UD_Ipmovzxwq, O_V, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1705 */ { UD_Ivpmovzxwq, O_Vx, O_MdU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1706 */ { UD_Ipmovzxdq, O_V, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1707 */ { UD_Ivpmovzxdq, O_Vx, O_MqU, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1708 */ { UD_Ipcmpeqq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1709 */ { UD_Ivpcmpeqq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1710 */ { UD_Ipopcnt, O_Gv, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1711 */ { UD_Iptest, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1712 */ { UD_Ivptest, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb|P_vexl },
- /* 1713 */ { UD_Ipcmpestri, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1714 */ { UD_Ivpcmpestri, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1715 */ { UD_Ipcmpestrm, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1716 */ { UD_Ivpcmpestrm, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1717 */ { UD_Ipcmpgtq, O_V, O_W, O_NONE, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1718 */ { UD_Ivpcmpgtq, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1719 */ { UD_Ipcmpistri, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1720 */ { UD_Ivpcmpistri, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1721 */ { UD_Ipcmpistrm, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1722 */ { UD_Ivpcmpistrm, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1723 */ { UD_Imovbe, O_Gv, O_Mv, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1724 */ { UD_Imovbe, O_Mv, O_Gv, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1725 */ { UD_Icrc32, O_Gy, O_Eb, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1726 */ { UD_Icrc32, O_Gy, O_Ev, O_NONE, O_NONE, P_aso|P_oso|P_rexr|P_rexw|P_rexx|P_rexb },
- /* 1727 */ { UD_Ivbroadcastss, O_V, O_Md, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1728 */ { UD_Ivbroadcastsd, O_Vqq, O_Mq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1729 */ { UD_Ivextractf128, O_Wdq, O_Vqq, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1730 */ { UD_Ivinsertf128, O_Vqq, O_Hqq, O_Wdq, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1731 */ { UD_Ivmaskmovps, O_V, O_H, O_M, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1732 */ { UD_Ivmaskmovps, O_M, O_H, O_V, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1733 */ { UD_Ivmaskmovpd, O_V, O_H, O_M, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1734 */ { UD_Ivmaskmovpd, O_M, O_H, O_V, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1735 */ { UD_Ivpermilpd, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1736 */ { UD_Ivpermilpd, O_V, O_W, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1737 */ { UD_Ivpermilps, O_Vx, O_Hx, O_Wx, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1738 */ { UD_Ivpermilps, O_Vx, O_Wx, O_Ib, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1739 */ { UD_Ivperm2f128, O_Vqq, O_Hqq, O_Wqq, O_Ib, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1740 */ { UD_Ivtestps, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1741 */ { UD_Ivtestpd, O_Vx, O_Wx, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1742 */ { UD_Ivzeroupper, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1743 */ { UD_Ivzeroall, O_NONE, O_NONE, O_NONE, O_NONE, P_none },
- /* 1744 */ { UD_Ivblendvpd, O_Vx, O_Hx, O_Wx, O_Lx, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1745 */ { UD_Ivblendvps, O_Vx, O_Hx, O_Wx, O_Lx, P_aso|P_rexr|P_rexx|P_rexb|P_vexl },
- /* 1746 */ { UD_Ivmovsd, O_V, O_H, O_U, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1747 */ { UD_Ivmovsd, O_V, O_Mq, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1748 */ { UD_Ivmovsd, O_U, O_H, O_V, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1749 */ { UD_Ivmovsd, O_Mq, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1750 */ { UD_Ivmovss, O_V, O_H, O_U, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1751 */ { UD_Ivmovss, O_V, O_Md, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1752 */ { UD_Ivmovss, O_U, O_H, O_V, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1753 */ { UD_Ivmovss, O_Md, O_V, O_NONE, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1754 */ { UD_Ivpblendvb, O_V, O_H, O_W, O_L, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1755 */ { UD_Ivpsllw, O_V, O_H, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1756 */ { UD_Ivpsllw, O_H, O_V, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1757 */ { UD_Ivpslld, O_V, O_H, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1758 */ { UD_Ivpslld, O_H, O_V, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1759 */ { UD_Ivpsllq, O_V, O_H, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
- /* 1760 */ { UD_Ivpsllq, O_H, O_V, O_W, O_NONE, P_aso|P_rexr|P_rexx|P_rexb },
-};
-
-
-const char* ud_mnemonics_str[] = {
- "aaa",
- "aad",
- "aam",
- "aas",
- "adc",
- "add",
- "addpd",
- "addps",
- "addsd",
- "addss",
- "addsubpd",
- "addsubps",
- "aesdec",
- "aesdeclast",
- "aesenc",
- "aesenclast",
- "aesimc",
- "aeskeygenassist",
- "and",
- "andnpd",
- "andnps",
- "andpd",
- "andps",
- "arpl",
- "blendpd",
- "blendps",
- "blendvpd",
- "blendvps",
- "bound",
- "bsf",
- "bsr",
- "bswap",
- "bt",
- "btc",
- "btr",
- "bts",
- "call",
- "cbw",
- "cdq",
- "cdqe",
- "clc",
- "cld",
- "clflush",
- "clgi",
- "cli",
- "clts",
- "cmc",
- "cmova",
- "cmovae",
- "cmovb",
- "cmovbe",
- "cmovg",
- "cmovge",
- "cmovl",
- "cmovle",
- "cmovno",
- "cmovnp",
- "cmovns",
- "cmovnz",
- "cmovo",
- "cmovp",
- "cmovs",
- "cmovz",
- "cmp",
- "cmppd",
- "cmpps",
- "cmpsb",
- "cmpsd",
- "cmpsq",
- "cmpss",
- "cmpsw",
- "cmpxchg",
- "cmpxchg16b",
- "cmpxchg8b",
- "comisd",
- "comiss",
- "cpuid",
- "cqo",
- "crc32",
- "cvtdq2pd",
- "cvtdq2ps",
- "cvtpd2dq",
- "cvtpd2pi",
- "cvtpd2ps",
- "cvtpi2pd",
- "cvtpi2ps",
- "cvtps2dq",
- "cvtps2pd",
- "cvtps2pi",
- "cvtsd2si",
- "cvtsd2ss",
- "cvtsi2sd",
- "cvtsi2ss",
- "cvtss2sd",
- "cvtss2si",
- "cvttpd2dq",
- "cvttpd2pi",
- "cvttps2dq",
- "cvttps2pi",
- "cvttsd2si",
- "cvttss2si",
- "cwd",
- "cwde",
- "daa",
- "das",
- "dec",
- "div",
- "divpd",
- "divps",
- "divsd",
- "divss",
- "dppd",
- "dpps",
- "emms",
- "enter",
- "extractps",
- "f2xm1",
- "fabs",
- "fadd",
- "faddp",
- "fbld",
- "fbstp",
- "fchs",
- "fclex",
- "fcmovb",
- "fcmovbe",
- "fcmove",
- "fcmovnb",
- "fcmovnbe",
- "fcmovne",
- "fcmovnu",
- "fcmovu",
- "fcom",
- "fcom2",
- "fcomi",
- "fcomip",
- "fcomp",
- "fcomp3",
- "fcomp5",
- "fcompp",
- "fcos",
- "fdecstp",
- "fdiv",
- "fdivp",
- "fdivr",
- "fdivrp",
- "femms",
- "ffree",
- "ffreep",
- "fiadd",
- "ficom",
- "ficomp",
- "fidiv",
- "fidivr",
- "fild",
- "fimul",
- "fincstp",
- "fist",
- "fistp",
- "fisttp",
- "fisub",
- "fisubr",
- "fld",
- "fld1",
- "fldcw",
- "fldenv",
- "fldl2e",
- "fldl2t",
- "fldlg2",
- "fldln2",
- "fldpi",
- "fldz",
- "fmul",
- "fmulp",
- "fndisi",
- "fneni",
- "fninit",
- "fnop",
- "fnsave",
- "fnsetpm",
- "fnstcw",
- "fnstenv",
- "fnstsw",
- "fpatan",
- "fprem",
- "fprem1",
- "fptan",
- "frndint",
- "frstor",
- "frstpm",
- "fscale",
- "fsin",
- "fsincos",
- "fsqrt",
- "fst",
- "fstp",
- "fstp1",
- "fstp8",
- "fstp9",
- "fsub",
- "fsubp",
- "fsubr",
- "fsubrp",
- "ftst",
- "fucom",
- "fucomi",
- "fucomip",
- "fucomp",
- "fucompp",
- "fxam",
- "fxch",
- "fxch4",
- "fxch7",
- "fxrstor",
- "fxsave",
- "fxtract",
- "fyl2x",
- "fyl2xp1",
- "getsec",
- "haddpd",
- "haddps",
- "hlt",
- "hsubpd",
- "hsubps",
- "idiv",
- "imul",
- "in",
- "inc",
- "insb",
- "insd",
- "insertps",
- "insw",
- "int",
- "int1",
- "int3",
- "into",
- "invd",
- "invept",
- "invlpg",
- "invlpga",
- "invvpid",
- "iretd",
- "iretq",
- "iretw",
- "ja",
- "jae",
- "jb",
- "jbe",
- "jcxz",
- "jecxz",
- "jg",
- "jge",
- "jl",
- "jle",
- "jmp",
- "jno",
- "jnp",
- "jns",
- "jnz",
- "jo",
- "jp",
- "jrcxz",
- "js",
- "jz",
- "lahf",
- "lar",
- "lddqu",
- "ldmxcsr",
- "lds",
- "lea",
- "leave",
- "les",
- "lfence",
- "lfs",
- "lgdt",
- "lgs",
- "lidt",
- "lldt",
- "lmsw",
- "lock",
- "lodsb",
- "lodsd",
- "lodsq",
- "lodsw",
- "loop",
- "loope",
- "loopne",
- "lsl",
- "lss",
- "ltr",
- "maskmovdqu",
- "maskmovq",
- "maxpd",
- "maxps",
- "maxsd",
- "maxss",
- "mfence",
- "minpd",
- "minps",
- "minsd",
- "minss",
- "monitor",
- "montmul",
- "mov",
- "movapd",
- "movaps",
- "movbe",
- "movd",
- "movddup",
- "movdq2q",
- "movdqa",
- "movdqu",
- "movhlps",
- "movhpd",
- "movhps",
- "movlhps",
- "movlpd",
- "movlps",
- "movmskpd",
- "movmskps",
- "movntdq",
- "movntdqa",
- "movnti",
- "movntpd",
- "movntps",
- "movntq",
- "movq",
- "movq2dq",
- "movsb",
- "movsd",
- "movshdup",
- "movsldup",
- "movsq",
- "movss",
- "movsw",
- "movsx",
- "movsxd",
- "movupd",
- "movups",
- "movzx",
- "mpsadbw",
- "mul",
- "mulpd",
- "mulps",
- "mulsd",
- "mulss",
- "mwait",
- "neg",
- "nop",
- "not",
- "or",
- "orpd",
- "orps",
- "out",
- "outsb",
- "outsd",
- "outsw",
- "pabsb",
- "pabsd",
- "pabsw",
- "packssdw",
- "packsswb",
- "packusdw",
- "packuswb",
- "paddb",
- "paddd",
- "paddq",
- "paddsb",
- "paddsw",
- "paddusb",
- "paddusw",
- "paddw",
- "palignr",
- "pand",
- "pandn",
- "pavgb",
- "pavgusb",
- "pavgw",
- "pblendvb",
- "pblendw",
- "pclmulqdq",
- "pcmpeqb",
- "pcmpeqd",
- "pcmpeqq",
- "pcmpeqw",
- "pcmpestri",
- "pcmpestrm",
- "pcmpgtb",
- "pcmpgtd",
- "pcmpgtq",
- "pcmpgtw",
- "pcmpistri",
- "pcmpistrm",
- "pextrb",
- "pextrd",
- "pextrq",
- "pextrw",
- "pf2id",
- "pf2iw",
- "pfacc",
- "pfadd",
- "pfcmpeq",
- "pfcmpge",
- "pfcmpgt",
- "pfmax",
- "pfmin",
- "pfmul",
- "pfnacc",
- "pfpnacc",
- "pfrcp",
- "pfrcpit1",
- "pfrcpit2",
- "pfrsqit1",
- "pfrsqrt",
- "pfsub",
- "pfsubr",
- "phaddd",
- "phaddsw",
- "phaddw",
- "phminposuw",
- "phsubd",
- "phsubsw",
- "phsubw",
- "pi2fd",
- "pi2fw",
- "pinsrb",
- "pinsrd",
- "pinsrq",
- "pinsrw",
- "pmaddubsw",
- "pmaddwd",
- "pmaxsb",
- "pmaxsd",
- "pmaxsw",
- "pmaxub",
- "pmaxud",
- "pmaxuw",
- "pminsb",
- "pminsd",
- "pminsw",
- "pminub",
- "pminud",
- "pminuw",
- "pmovmskb",
- "pmovsxbd",
- "pmovsxbq",
- "pmovsxbw",
- "pmovsxdq",
- "pmovsxwd",
- "pmovsxwq",
- "pmovzxbd",
- "pmovzxbq",
- "pmovzxbw",
- "pmovzxdq",
- "pmovzxwd",
- "pmovzxwq",
- "pmuldq",
- "pmulhrsw",
- "pmulhrw",
- "pmulhuw",
- "pmulhw",
- "pmulld",
- "pmullw",
- "pmuludq",
- "pop",
- "popa",
- "popad",
- "popcnt",
- "popfd",
- "popfq",
- "popfw",
- "por",
- "prefetch",
- "prefetchnta",
- "prefetcht0",
- "prefetcht1",
- "prefetcht2",
- "psadbw",
- "pshufb",
- "pshufd",
- "pshufhw",
- "pshuflw",
- "pshufw",
- "psignb",
- "psignd",
- "psignw",
- "pslld",
- "pslldq",
- "psllq",
- "psllw",
- "psrad",
- "psraw",
- "psrld",
- "psrldq",
- "psrlq",
- "psrlw",
- "psubb",
- "psubd",
- "psubq",
- "psubsb",
- "psubsw",
- "psubusb",
- "psubusw",
- "psubw",
- "pswapd",
- "ptest",
- "punpckhbw",
- "punpckhdq",
- "punpckhqdq",
- "punpckhwd",
- "punpcklbw",
- "punpckldq",
- "punpcklqdq",
- "punpcklwd",
- "push",
- "pusha",
- "pushad",
- "pushfd",
- "pushfq",
- "pushfw",
- "pxor",
- "rcl",
- "rcpps",
- "rcpss",
- "rcr",
- "rdmsr",
- "rdpmc",
- "rdrand",
- "rdtsc",
- "rdtscp",
- "rep",
- "repne",
- "ret",
- "retf",
- "rol",
- "ror",
- "roundpd",
- "roundps",
- "roundsd",
- "roundss",
- "rsm",
- "rsqrtps",
- "rsqrtss",
- "sahf",
- "salc",
- "sar",
- "sbb",
- "scasb",
- "scasd",
- "scasq",
- "scasw",
- "seta",
- "setae",
- "setb",
- "setbe",
- "setg",
- "setge",
- "setl",
- "setle",
- "setno",
- "setnp",
- "setns",
- "setnz",
- "seto",
- "setp",
- "sets",
- "setz",
- "sfence",
- "sgdt",
- "shl",
- "shld",
- "shr",
- "shrd",
- "shufpd",
- "shufps",
- "sidt",
- "skinit",
- "sldt",
- "smsw",
- "sqrtpd",
- "sqrtps",
- "sqrtsd",
- "sqrtss",
- "stc",
- "std",
- "stgi",
- "sti",
- "stmxcsr",
- "stosb",
- "stosd",
- "stosq",
- "stosw",
- "str",
- "sub",
- "subpd",
- "subps",
- "subsd",
- "subss",
- "swapgs",
- "syscall",
- "sysenter",
- "sysexit",
- "sysret",
- "test",
- "ucomisd",
- "ucomiss",
- "ud2",
- "unpckhpd",
- "unpckhps",
- "unpcklpd",
- "unpcklps",
- "vaddpd",
- "vaddps",
- "vaddsd",
- "vaddss",
- "vaddsubpd",
- "vaddsubps",
- "vaesdec",
- "vaesdeclast",
- "vaesenc",
- "vaesenclast",
- "vaesimc",
- "vaeskeygenassist",
- "vandnpd",
- "vandnps",
- "vandpd",
- "vandps",
- "vblendpd",
- "vblendps",
- "vblendvpd",
- "vblendvps",
- "vbroadcastsd",
- "vbroadcastss",
- "vcmppd",
- "vcmpps",
- "vcmpsd",
- "vcmpss",
- "vcomisd",
- "vcomiss",
- "vcvtdq2pd",
- "vcvtdq2ps",
- "vcvtpd2dq",
- "vcvtpd2ps",
- "vcvtps2dq",
- "vcvtps2pd",
- "vcvtsd2si",
- "vcvtsd2ss",
- "vcvtsi2sd",
- "vcvtsi2ss",
- "vcvtss2sd",
- "vcvtss2si",
- "vcvttpd2dq",
- "vcvttps2dq",
- "vcvttsd2si",
- "vcvttss2si",
- "vdivpd",
- "vdivps",
- "vdivsd",
- "vdivss",
- "vdppd",
- "vdpps",
- "verr",
- "verw",
- "vextractf128",
- "vextractps",
- "vhaddpd",
- "vhaddps",
- "vhsubpd",
- "vhsubps",
- "vinsertf128",
- "vinsertps",
- "vlddqu",
- "vmaskmovdqu",
- "vmaskmovpd",
- "vmaskmovps",
- "vmaxpd",
- "vmaxps",
- "vmaxsd",
- "vmaxss",
- "vmcall",
- "vmclear",
- "vminpd",
- "vminps",
- "vminsd",
- "vminss",
- "vmlaunch",
- "vmload",
- "vmmcall",
- "vmovapd",
- "vmovaps",
- "vmovd",
- "vmovddup",
- "vmovdqa",
- "vmovdqu",
- "vmovhlps",
- "vmovhpd",
- "vmovhps",
- "vmovlhps",
- "vmovlpd",
- "vmovlps",
- "vmovmskpd",
- "vmovmskps",
- "vmovntdq",
- "vmovntdqa",
- "vmovntpd",
- "vmovntps",
- "vmovq",
- "vmovsd",
- "vmovshdup",
- "vmovsldup",
- "vmovss",
- "vmovupd",
- "vmovups",
- "vmpsadbw",
- "vmptrld",
- "vmptrst",
- "vmread",
- "vmresume",
- "vmrun",
- "vmsave",
- "vmulpd",
- "vmulps",
- "vmulsd",
- "vmulss",
- "vmwrite",
- "vmxoff",
- "vmxon",
- "vorpd",
- "vorps",
- "vpabsb",
- "vpabsd",
- "vpabsw",
- "vpackssdw",
- "vpacksswb",
- "vpackusdw",
- "vpackuswb",
- "vpaddb",
- "vpaddd",
- "vpaddq",
- "vpaddsb",
- "vpaddsw",
- "vpaddusb",
- "vpaddusw",
- "vpaddw",
- "vpalignr",
- "vpand",
- "vpandn",
- "vpavgb",
- "vpavgw",
- "vpblendvb",
- "vpblendw",
- "vpclmulqdq",
- "vpcmpeqb",
- "vpcmpeqd",
- "vpcmpeqq",
- "vpcmpeqw",
- "vpcmpestri",
- "vpcmpestrm",
- "vpcmpgtb",
- "vpcmpgtd",
- "vpcmpgtq",
- "vpcmpgtw",
- "vpcmpistri",
- "vpcmpistrm",
- "vperm2f128",
- "vpermilpd",
- "vpermilps",
- "vpextrb",
- "vpextrd",
- "vpextrq",
- "vpextrw",
- "vphaddd",
- "vphaddsw",
- "vphaddw",
- "vphminposuw",
- "vphsubd",
- "vphsubsw",
- "vphsubw",
- "vpinsrb",
- "vpinsrd",
- "vpinsrq",
- "vpinsrw",
- "vpmaddubsw",
- "vpmaddwd",
- "vpmaxsb",
- "vpmaxsd",
- "vpmaxsw",
- "vpmaxub",
- "vpmaxud",
- "vpmaxuw",
- "vpminsb",
- "vpminsd",
- "vpminsw",
- "vpminub",
- "vpminud",
- "vpminuw",
- "vpmovmskb",
- "vpmovsxbd",
- "vpmovsxbq",
- "vpmovsxbw",
- "vpmovsxwd",
- "vpmovsxwq",
- "vpmovzxbd",
- "vpmovzxbq",
- "vpmovzxbw",
- "vpmovzxdq",
- "vpmovzxwd",
- "vpmovzxwq",
- "vpmuldq",
- "vpmulhrsw",
- "vpmulhuw",
- "vpmulhw",
- "vpmulld",
- "vpmullw",
- "vpor",
- "vpsadbw",
- "vpshufb",
- "vpshufd",
- "vpshufhw",
- "vpshuflw",
- "vpsignb",
- "vpsignd",
- "vpsignw",
- "vpslld",
- "vpslldq",
- "vpsllq",
- "vpsllw",
- "vpsrad",
- "vpsraw",
- "vpsrld",
- "vpsrldq",
- "vpsrlq",
- "vpsrlw",
- "vpsubb",
- "vpsubd",
- "vpsubq",
- "vpsubsb",
- "vpsubsw",
- "vpsubusb",
- "vpsubusw",
- "vpsubw",
- "vptest",
- "vpunpckhbw",
- "vpunpckhdq",
- "vpunpckhqdq",
- "vpunpckhwd",
- "vpunpcklbw",
- "vpunpckldq",
- "vpunpcklqdq",
- "vpunpcklwd",
- "vpxor",
- "vrcpps",
- "vrcpss",
- "vroundpd",
- "vroundps",
- "vroundsd",
- "vroundss",
- "vrsqrtps",
- "vrsqrtss",
- "vshufpd",
- "vshufps",
- "vsqrtpd",
- "vsqrtps",
- "vsqrtsd",
- "vsqrtss",
- "vstmxcsr",
- "vsubpd",
- "vsubps",
- "vsubsd",
- "vsubss",
- "vtestpd",
- "vtestps",
- "vucomisd",
- "vucomiss",
- "vunpckhpd",
- "vunpckhps",
- "vunpcklpd",
- "vunpcklps",
- "vxorpd",
- "vxorps",
- "vzeroall",
- "vzeroupper",
- "wait",
- "wbinvd",
- "wrmsr",
- "xadd",
- "xchg",
- "xcryptcbc",
- "xcryptcfb",
- "xcryptctr",
- "xcryptecb",
- "xcryptofb",
- "xgetbv",
- "xlatb",
- "xor",
- "xorpd",
- "xorps",
- "xrstor",
- "xsave",
- "xsetbv",
- "xsha1",
- "xsha256",
- "xstore",
- "invalid",
- "3dnow",
- "none",
- "db",
- "pause"
-};
diff --git a/ext/myjit/disasm/udis86/itab.h b/ext/myjit/disasm/udis86/itab.h
deleted file mode 100755
index 3d54c43..0000000
--- a/ext/myjit/disasm/udis86/itab.h
+++ /dev/null
@@ -1,939 +0,0 @@
-#ifndef UD_ITAB_H
-#define UD_ITAB_H
-
-/* itab.h -- generated by udis86:scripts/ud_itab.py, do no edit */
-
-/* ud_table_type -- lookup table types (see decode.c) */
-enum ud_table_type {
- UD_TAB__OPC_VEX,
- UD_TAB__OPC_TABLE,
- UD_TAB__OPC_X87,
- UD_TAB__OPC_MOD,
- UD_TAB__OPC_RM,
- UD_TAB__OPC_OSIZE,
- UD_TAB__OPC_MODE,
- UD_TAB__OPC_VEX_L,
- UD_TAB__OPC_3DNOW,
- UD_TAB__OPC_REG,
- UD_TAB__OPC_ASIZE,
- UD_TAB__OPC_VEX_W,
- UD_TAB__OPC_SSE,
- UD_TAB__OPC_VENDOR
-};
-
-/* ud_mnemonic -- mnemonic constants */
-enum ud_mnemonic_code {
- UD_Iaaa,
- UD_Iaad,
- UD_Iaam,
- UD_Iaas,
- UD_Iadc,
- UD_Iadd,
- UD_Iaddpd,
- UD_Iaddps,
- UD_Iaddsd,
- UD_Iaddss,
- UD_Iaddsubpd,
- UD_Iaddsubps,
- UD_Iaesdec,
- UD_Iaesdeclast,
- UD_Iaesenc,
- UD_Iaesenclast,
- UD_Iaesimc,
- UD_Iaeskeygenassist,
- UD_Iand,
- UD_Iandnpd,
- UD_Iandnps,
- UD_Iandpd,
- UD_Iandps,
- UD_Iarpl,
- UD_Iblendpd,
- UD_Iblendps,
- UD_Iblendvpd,
- UD_Iblendvps,
- UD_Ibound,
- UD_Ibsf,
- UD_Ibsr,
- UD_Ibswap,
- UD_Ibt,
- UD_Ibtc,
- UD_Ibtr,
- UD_Ibts,
- UD_Icall,
- UD_Icbw,
- UD_Icdq,
- UD_Icdqe,
- UD_Iclc,
- UD_Icld,
- UD_Iclflush,
- UD_Iclgi,
- UD_Icli,
- UD_Iclts,
- UD_Icmc,
- UD_Icmova,
- UD_Icmovae,
- UD_Icmovb,
- UD_Icmovbe,
- UD_Icmovg,
- UD_Icmovge,
- UD_Icmovl,
- UD_Icmovle,
- UD_Icmovno,
- UD_Icmovnp,
- UD_Icmovns,
- UD_Icmovnz,
- UD_Icmovo,
- UD_Icmovp,
- UD_Icmovs,
- UD_Icmovz,
- UD_Icmp,
- UD_Icmppd,
- UD_Icmpps,
- UD_Icmpsb,
- UD_Icmpsd,
- UD_Icmpsq,
- UD_Icmpss,
- UD_Icmpsw,
- UD_Icmpxchg,
- UD_Icmpxchg16b,
- UD_Icmpxchg8b,
- UD_Icomisd,
- UD_Icomiss,
- UD_Icpuid,
- UD_Icqo,
- UD_Icrc32,
- UD_Icvtdq2pd,
- UD_Icvtdq2ps,
- UD_Icvtpd2dq,
- UD_Icvtpd2pi,
- UD_Icvtpd2ps,
- UD_Icvtpi2pd,
- UD_Icvtpi2ps,
- UD_Icvtps2dq,
- UD_Icvtps2pd,
- UD_Icvtps2pi,
- UD_Icvtsd2si,
- UD_Icvtsd2ss,
- UD_Icvtsi2sd,
- UD_Icvtsi2ss,
- UD_Icvtss2sd,
- UD_Icvtss2si,
- UD_Icvttpd2dq,
- UD_Icvttpd2pi,
- UD_Icvttps2dq,
- UD_Icvttps2pi,
- UD_Icvttsd2si,
- UD_Icvttss2si,
- UD_Icwd,
- UD_Icwde,
- UD_Idaa,
- UD_Idas,
- UD_Idec,
- UD_Idiv,
- UD_Idivpd,
- UD_Idivps,
- UD_Idivsd,
- UD_Idivss,
- UD_Idppd,
- UD_Idpps,
- UD_Iemms,
- UD_Ienter,
- UD_Iextractps,
- UD_If2xm1,
- UD_Ifabs,
- UD_Ifadd,
- UD_Ifaddp,
- UD_Ifbld,
- UD_Ifbstp,
- UD_Ifchs,
- UD_Ifclex,
- UD_Ifcmovb,
- UD_Ifcmovbe,
- UD_Ifcmove,
- UD_Ifcmovnb,
- UD_Ifcmovnbe,
- UD_Ifcmovne,
- UD_Ifcmovnu,
- UD_Ifcmovu,
- UD_Ifcom,
- UD_Ifcom2,
- UD_Ifcomi,
- UD_Ifcomip,
- UD_Ifcomp,
- UD_Ifcomp3,
- UD_Ifcomp5,
- UD_Ifcompp,
- UD_Ifcos,
- UD_Ifdecstp,
- UD_Ifdiv,
- UD_Ifdivp,
- UD_Ifdivr,
- UD_Ifdivrp,
- UD_Ifemms,
- UD_Iffree,
- UD_Iffreep,
- UD_Ifiadd,
- UD_Ificom,
- UD_Ificomp,
- UD_Ifidiv,
- UD_Ifidivr,
- UD_Ifild,
- UD_Ifimul,
- UD_Ifincstp,
- UD_Ifist,
- UD_Ifistp,
- UD_Ifisttp,
- UD_Ifisub,
- UD_Ifisubr,
- UD_Ifld,
- UD_Ifld1,
- UD_Ifldcw,
- UD_Ifldenv,
- UD_Ifldl2e,
- UD_Ifldl2t,
- UD_Ifldlg2,
- UD_Ifldln2,
- UD_Ifldpi,
- UD_Ifldz,
- UD_Ifmul,
- UD_Ifmulp,
- UD_Ifndisi,
- UD_Ifneni,
- UD_Ifninit,
- UD_Ifnop,
- UD_Ifnsave,
- UD_Ifnsetpm,
- UD_Ifnstcw,
- UD_Ifnstenv,
- UD_Ifnstsw,
- UD_Ifpatan,
- UD_Ifprem,
- UD_Ifprem1,
- UD_Ifptan,
- UD_Ifrndint,
- UD_Ifrstor,
- UD_Ifrstpm,
- UD_Ifscale,
- UD_Ifsin,
- UD_Ifsincos,
- UD_Ifsqrt,
- UD_Ifst,
- UD_Ifstp,
- UD_Ifstp1,
- UD_Ifstp8,
- UD_Ifstp9,
- UD_Ifsub,
- UD_Ifsubp,
- UD_Ifsubr,
- UD_Ifsubrp,
- UD_Iftst,
- UD_Ifucom,
- UD_Ifucomi,
- UD_Ifucomip,
- UD_Ifucomp,
- UD_Ifucompp,
- UD_Ifxam,
- UD_Ifxch,
- UD_Ifxch4,
- UD_Ifxch7,
- UD_Ifxrstor,
- UD_Ifxsave,
- UD_Ifxtract,
- UD_Ifyl2x,
- UD_Ifyl2xp1,
- UD_Igetsec,
- UD_Ihaddpd,
- UD_Ihaddps,
- UD_Ihlt,
- UD_Ihsubpd,
- UD_Ihsubps,
- UD_Iidiv,
- UD_Iimul,
- UD_Iin,
- UD_Iinc,
- UD_Iinsb,
- UD_Iinsd,
- UD_Iinsertps,
- UD_Iinsw,
- UD_Iint,
- UD_Iint1,
- UD_Iint3,
- UD_Iinto,
- UD_Iinvd,
- UD_Iinvept,
- UD_Iinvlpg,
- UD_Iinvlpga,
- UD_Iinvvpid,
- UD_Iiretd,
- UD_Iiretq,
- UD_Iiretw,
- UD_Ija,
- UD_Ijae,
- UD_Ijb,
- UD_Ijbe,
- UD_Ijcxz,
- UD_Ijecxz,
- UD_Ijg,
- UD_Ijge,
- UD_Ijl,
- UD_Ijle,
- UD_Ijmp,
- UD_Ijno,
- UD_Ijnp,
- UD_Ijns,
- UD_Ijnz,
- UD_Ijo,
- UD_Ijp,
- UD_Ijrcxz,
- UD_Ijs,
- UD_Ijz,
- UD_Ilahf,
- UD_Ilar,
- UD_Ilddqu,
- UD_Ildmxcsr,
- UD_Ilds,
- UD_Ilea,
- UD_Ileave,
- UD_Iles,
- UD_Ilfence,
- UD_Ilfs,
- UD_Ilgdt,
- UD_Ilgs,
- UD_Ilidt,
- UD_Illdt,
- UD_Ilmsw,
- UD_Ilock,
- UD_Ilodsb,
- UD_Ilodsd,
- UD_Ilodsq,
- UD_Ilodsw,
- UD_Iloop,
- UD_Iloope,
- UD_Iloopne,
- UD_Ilsl,
- UD_Ilss,
- UD_Iltr,
- UD_Imaskmovdqu,
- UD_Imaskmovq,
- UD_Imaxpd,
- UD_Imaxps,
- UD_Imaxsd,
- UD_Imaxss,
- UD_Imfence,
- UD_Iminpd,
- UD_Iminps,
- UD_Iminsd,
- UD_Iminss,
- UD_Imonitor,
- UD_Imontmul,
- UD_Imov,
- UD_Imovapd,
- UD_Imovaps,
- UD_Imovbe,
- UD_Imovd,
- UD_Imovddup,
- UD_Imovdq2q,
- UD_Imovdqa,
- UD_Imovdqu,
- UD_Imovhlps,
- UD_Imovhpd,
- UD_Imovhps,
- UD_Imovlhps,
- UD_Imovlpd,
- UD_Imovlps,
- UD_Imovmskpd,
- UD_Imovmskps,
- UD_Imovntdq,
- UD_Imovntdqa,
- UD_Imovnti,
- UD_Imovntpd,
- UD_Imovntps,
- UD_Imovntq,
- UD_Imovq,
- UD_Imovq2dq,
- UD_Imovsb,
- UD_Imovsd,
- UD_Imovshdup,
- UD_Imovsldup,
- UD_Imovsq,
- UD_Imovss,
- UD_Imovsw,
- UD_Imovsx,
- UD_Imovsxd,
- UD_Imovupd,
- UD_Imovups,
- UD_Imovzx,
- UD_Impsadbw,
- UD_Imul,
- UD_Imulpd,
- UD_Imulps,
- UD_Imulsd,
- UD_Imulss,
- UD_Imwait,
- UD_Ineg,
- UD_Inop,
- UD_Inot,
- UD_Ior,
- UD_Iorpd,
- UD_Iorps,
- UD_Iout,
- UD_Ioutsb,
- UD_Ioutsd,
- UD_Ioutsw,
- UD_Ipabsb,
- UD_Ipabsd,
- UD_Ipabsw,
- UD_Ipackssdw,
- UD_Ipacksswb,
- UD_Ipackusdw,
- UD_Ipackuswb,
- UD_Ipaddb,
- UD_Ipaddd,
- UD_Ipaddq,
- UD_Ipaddsb,
- UD_Ipaddsw,
- UD_Ipaddusb,
- UD_Ipaddusw,
- UD_Ipaddw,
- UD_Ipalignr,
- UD_Ipand,
- UD_Ipandn,
- UD_Ipavgb,
- UD_Ipavgusb,
- UD_Ipavgw,
- UD_Ipblendvb,
- UD_Ipblendw,
- UD_Ipclmulqdq,
- UD_Ipcmpeqb,
- UD_Ipcmpeqd,
- UD_Ipcmpeqq,
- UD_Ipcmpeqw,
- UD_Ipcmpestri,
- UD_Ipcmpestrm,
- UD_Ipcmpgtb,
- UD_Ipcmpgtd,
- UD_Ipcmpgtq,
- UD_Ipcmpgtw,
- UD_Ipcmpistri,
- UD_Ipcmpistrm,
- UD_Ipextrb,
- UD_Ipextrd,
- UD_Ipextrq,
- UD_Ipextrw,
- UD_Ipf2id,
- UD_Ipf2iw,
- UD_Ipfacc,
- UD_Ipfadd,
- UD_Ipfcmpeq,
- UD_Ipfcmpge,
- UD_Ipfcmpgt,
- UD_Ipfmax,
- UD_Ipfmin,
- UD_Ipfmul,
- UD_Ipfnacc,
- UD_Ipfpnacc,
- UD_Ipfrcp,
- UD_Ipfrcpit1,
- UD_Ipfrcpit2,
- UD_Ipfrsqit1,
- UD_Ipfrsqrt,
- UD_Ipfsub,
- UD_Ipfsubr,
- UD_Iphaddd,
- UD_Iphaddsw,
- UD_Iphaddw,
- UD_Iphminposuw,
- UD_Iphsubd,
- UD_Iphsubsw,
- UD_Iphsubw,
- UD_Ipi2fd,
- UD_Ipi2fw,
- UD_Ipinsrb,
- UD_Ipinsrd,
- UD_Ipinsrq,
- UD_Ipinsrw,
- UD_Ipmaddubsw,
- UD_Ipmaddwd,
- UD_Ipmaxsb,
- UD_Ipmaxsd,
- UD_Ipmaxsw,
- UD_Ipmaxub,
- UD_Ipmaxud,
- UD_Ipmaxuw,
- UD_Ipminsb,
- UD_Ipminsd,
- UD_Ipminsw,
- UD_Ipminub,
- UD_Ipminud,
- UD_Ipminuw,
- UD_Ipmovmskb,
- UD_Ipmovsxbd,
- UD_Ipmovsxbq,
- UD_Ipmovsxbw,
- UD_Ipmovsxdq,
- UD_Ipmovsxwd,
- UD_Ipmovsxwq,
- UD_Ipmovzxbd,
- UD_Ipmovzxbq,
- UD_Ipmovzxbw,
- UD_Ipmovzxdq,
- UD_Ipmovzxwd,
- UD_Ipmovzxwq,
- UD_Ipmuldq,
- UD_Ipmulhrsw,
- UD_Ipmulhrw,
- UD_Ipmulhuw,
- UD_Ipmulhw,
- UD_Ipmulld,
- UD_Ipmullw,
- UD_Ipmuludq,
- UD_Ipop,
- UD_Ipopa,
- UD_Ipopad,
- UD_Ipopcnt,
- UD_Ipopfd,
- UD_Ipopfq,
- UD_Ipopfw,
- UD_Ipor,
- UD_Iprefetch,
- UD_Iprefetchnta,
- UD_Iprefetcht0,
- UD_Iprefetcht1,
- UD_Iprefetcht2,
- UD_Ipsadbw,
- UD_Ipshufb,
- UD_Ipshufd,
- UD_Ipshufhw,
- UD_Ipshuflw,
- UD_Ipshufw,
- UD_Ipsignb,
- UD_Ipsignd,
- UD_Ipsignw,
- UD_Ipslld,
- UD_Ipslldq,
- UD_Ipsllq,
- UD_Ipsllw,
- UD_Ipsrad,
- UD_Ipsraw,
- UD_Ipsrld,
- UD_Ipsrldq,
- UD_Ipsrlq,
- UD_Ipsrlw,
- UD_Ipsubb,
- UD_Ipsubd,
- UD_Ipsubq,
- UD_Ipsubsb,
- UD_Ipsubsw,
- UD_Ipsubusb,
- UD_Ipsubusw,
- UD_Ipsubw,
- UD_Ipswapd,
- UD_Iptest,
- UD_Ipunpckhbw,
- UD_Ipunpckhdq,
- UD_Ipunpckhqdq,
- UD_Ipunpckhwd,
- UD_Ipunpcklbw,
- UD_Ipunpckldq,
- UD_Ipunpcklqdq,
- UD_Ipunpcklwd,
- UD_Ipush,
- UD_Ipusha,
- UD_Ipushad,
- UD_Ipushfd,
- UD_Ipushfq,
- UD_Ipushfw,
- UD_Ipxor,
- UD_Ircl,
- UD_Ircpps,
- UD_Ircpss,
- UD_Ircr,
- UD_Irdmsr,
- UD_Irdpmc,
- UD_Irdrand,
- UD_Irdtsc,
- UD_Irdtscp,
- UD_Irep,
- UD_Irepne,
- UD_Iret,
- UD_Iretf,
- UD_Irol,
- UD_Iror,
- UD_Iroundpd,
- UD_Iroundps,
- UD_Iroundsd,
- UD_Iroundss,
- UD_Irsm,
- UD_Irsqrtps,
- UD_Irsqrtss,
- UD_Isahf,
- UD_Isalc,
- UD_Isar,
- UD_Isbb,
- UD_Iscasb,
- UD_Iscasd,
- UD_Iscasq,
- UD_Iscasw,
- UD_Iseta,
- UD_Isetae,
- UD_Isetb,
- UD_Isetbe,
- UD_Isetg,
- UD_Isetge,
- UD_Isetl,
- UD_Isetle,
- UD_Isetno,
- UD_Isetnp,
- UD_Isetns,
- UD_Isetnz,
- UD_Iseto,
- UD_Isetp,
- UD_Isets,
- UD_Isetz,
- UD_Isfence,
- UD_Isgdt,
- UD_Ishl,
- UD_Ishld,
- UD_Ishr,
- UD_Ishrd,
- UD_Ishufpd,
- UD_Ishufps,
- UD_Isidt,
- UD_Iskinit,
- UD_Isldt,
- UD_Ismsw,
- UD_Isqrtpd,
- UD_Isqrtps,
- UD_Isqrtsd,
- UD_Isqrtss,
- UD_Istc,
- UD_Istd,
- UD_Istgi,
- UD_Isti,
- UD_Istmxcsr,
- UD_Istosb,
- UD_Istosd,
- UD_Istosq,
- UD_Istosw,
- UD_Istr,
- UD_Isub,
- UD_Isubpd,
- UD_Isubps,
- UD_Isubsd,
- UD_Isubss,
- UD_Iswapgs,
- UD_Isyscall,
- UD_Isysenter,
- UD_Isysexit,
- UD_Isysret,
- UD_Itest,
- UD_Iucomisd,
- UD_Iucomiss,
- UD_Iud2,
- UD_Iunpckhpd,
- UD_Iunpckhps,
- UD_Iunpcklpd,
- UD_Iunpcklps,
- UD_Ivaddpd,
- UD_Ivaddps,
- UD_Ivaddsd,
- UD_Ivaddss,
- UD_Ivaddsubpd,
- UD_Ivaddsubps,
- UD_Ivaesdec,
- UD_Ivaesdeclast,
- UD_Ivaesenc,
- UD_Ivaesenclast,
- UD_Ivaesimc,
- UD_Ivaeskeygenassist,
- UD_Ivandnpd,
- UD_Ivandnps,
- UD_Ivandpd,
- UD_Ivandps,
- UD_Ivblendpd,
- UD_Ivblendps,
- UD_Ivblendvpd,
- UD_Ivblendvps,
- UD_Ivbroadcastsd,
- UD_Ivbroadcastss,
- UD_Ivcmppd,
- UD_Ivcmpps,
- UD_Ivcmpsd,
- UD_Ivcmpss,
- UD_Ivcomisd,
- UD_Ivcomiss,
- UD_Ivcvtdq2pd,
- UD_Ivcvtdq2ps,
- UD_Ivcvtpd2dq,
- UD_Ivcvtpd2ps,
- UD_Ivcvtps2dq,
- UD_Ivcvtps2pd,
- UD_Ivcvtsd2si,
- UD_Ivcvtsd2ss,
- UD_Ivcvtsi2sd,
- UD_Ivcvtsi2ss,
- UD_Ivcvtss2sd,
- UD_Ivcvtss2si,
- UD_Ivcvttpd2dq,
- UD_Ivcvttps2dq,
- UD_Ivcvttsd2si,
- UD_Ivcvttss2si,
- UD_Ivdivpd,
- UD_Ivdivps,
- UD_Ivdivsd,
- UD_Ivdivss,
- UD_Ivdppd,
- UD_Ivdpps,
- UD_Iverr,
- UD_Iverw,
- UD_Ivextractf128,
- UD_Ivextractps,
- UD_Ivhaddpd,
- UD_Ivhaddps,
- UD_Ivhsubpd,
- UD_Ivhsubps,
- UD_Ivinsertf128,
- UD_Ivinsertps,
- UD_Ivlddqu,
- UD_Ivmaskmovdqu,
- UD_Ivmaskmovpd,
- UD_Ivmaskmovps,
- UD_Ivmaxpd,
- UD_Ivmaxps,
- UD_Ivmaxsd,
- UD_Ivmaxss,
- UD_Ivmcall,
- UD_Ivmclear,
- UD_Ivminpd,
- UD_Ivminps,
- UD_Ivminsd,
- UD_Ivminss,
- UD_Ivmlaunch,
- UD_Ivmload,
- UD_Ivmmcall,
- UD_Ivmovapd,
- UD_Ivmovaps,
- UD_Ivmovd,
- UD_Ivmovddup,
- UD_Ivmovdqa,
- UD_Ivmovdqu,
- UD_Ivmovhlps,
- UD_Ivmovhpd,
- UD_Ivmovhps,
- UD_Ivmovlhps,
- UD_Ivmovlpd,
- UD_Ivmovlps,
- UD_Ivmovmskpd,
- UD_Ivmovmskps,
- UD_Ivmovntdq,
- UD_Ivmovntdqa,
- UD_Ivmovntpd,
- UD_Ivmovntps,
- UD_Ivmovq,
- UD_Ivmovsd,
- UD_Ivmovshdup,
- UD_Ivmovsldup,
- UD_Ivmovss,
- UD_Ivmovupd,
- UD_Ivmovups,
- UD_Ivmpsadbw,
- UD_Ivmptrld,
- UD_Ivmptrst,
- UD_Ivmread,
- UD_Ivmresume,
- UD_Ivmrun,
- UD_Ivmsave,
- UD_Ivmulpd,
- UD_Ivmulps,
- UD_Ivmulsd,
- UD_Ivmulss,
- UD_Ivmwrite,
- UD_Ivmxoff,
- UD_Ivmxon,
- UD_Ivorpd,
- UD_Ivorps,
- UD_Ivpabsb,
- UD_Ivpabsd,
- UD_Ivpabsw,
- UD_Ivpackssdw,
- UD_Ivpacksswb,
- UD_Ivpackusdw,
- UD_Ivpackuswb,
- UD_Ivpaddb,
- UD_Ivpaddd,
- UD_Ivpaddq,
- UD_Ivpaddsb,
- UD_Ivpaddsw,
- UD_Ivpaddusb,
- UD_Ivpaddusw,
- UD_Ivpaddw,
- UD_Ivpalignr,
- UD_Ivpand,
- UD_Ivpandn,
- UD_Ivpavgb,
- UD_Ivpavgw,
- UD_Ivpblendvb,
- UD_Ivpblendw,
- UD_Ivpclmulqdq,
- UD_Ivpcmpeqb,
- UD_Ivpcmpeqd,
- UD_Ivpcmpeqq,
- UD_Ivpcmpeqw,
- UD_Ivpcmpestri,
- UD_Ivpcmpestrm,
- UD_Ivpcmpgtb,
- UD_Ivpcmpgtd,
- UD_Ivpcmpgtq,
- UD_Ivpcmpgtw,
- UD_Ivpcmpistri,
- UD_Ivpcmpistrm,
- UD_Ivperm2f128,
- UD_Ivpermilpd,
- UD_Ivpermilps,
- UD_Ivpextrb,
- UD_Ivpextrd,
- UD_Ivpextrq,
- UD_Ivpextrw,
- UD_Ivphaddd,
- UD_Ivphaddsw,
- UD_Ivphaddw,
- UD_Ivphminposuw,
- UD_Ivphsubd,
- UD_Ivphsubsw,
- UD_Ivphsubw,
- UD_Ivpinsrb,
- UD_Ivpinsrd,
- UD_Ivpinsrq,
- UD_Ivpinsrw,
- UD_Ivpmaddubsw,
- UD_Ivpmaddwd,
- UD_Ivpmaxsb,
- UD_Ivpmaxsd,
- UD_Ivpmaxsw,
- UD_Ivpmaxub,
- UD_Ivpmaxud,
- UD_Ivpmaxuw,
- UD_Ivpminsb,
- UD_Ivpminsd,
- UD_Ivpminsw,
- UD_Ivpminub,
- UD_Ivpminud,
- UD_Ivpminuw,
- UD_Ivpmovmskb,
- UD_Ivpmovsxbd,
- UD_Ivpmovsxbq,
- UD_Ivpmovsxbw,
- UD_Ivpmovsxwd,
- UD_Ivpmovsxwq,
- UD_Ivpmovzxbd,
- UD_Ivpmovzxbq,
- UD_Ivpmovzxbw,
- UD_Ivpmovzxdq,
- UD_Ivpmovzxwd,
- UD_Ivpmovzxwq,
- UD_Ivpmuldq,
- UD_Ivpmulhrsw,
- UD_Ivpmulhuw,
- UD_Ivpmulhw,
- UD_Ivpmulld,
- UD_Ivpmullw,
- UD_Ivpor,
- UD_Ivpsadbw,
- UD_Ivpshufb,
- UD_Ivpshufd,
- UD_Ivpshufhw,
- UD_Ivpshuflw,
- UD_Ivpsignb,
- UD_Ivpsignd,
- UD_Ivpsignw,
- UD_Ivpslld,
- UD_Ivpslldq,
- UD_Ivpsllq,
- UD_Ivpsllw,
- UD_Ivpsrad,
- UD_Ivpsraw,
- UD_Ivpsrld,
- UD_Ivpsrldq,
- UD_Ivpsrlq,
- UD_Ivpsrlw,
- UD_Ivpsubb,
- UD_Ivpsubd,
- UD_Ivpsubq,
- UD_Ivpsubsb,
- UD_Ivpsubsw,
- UD_Ivpsubusb,
- UD_Ivpsubusw,
- UD_Ivpsubw,
- UD_Ivptest,
- UD_Ivpunpckhbw,
- UD_Ivpunpckhdq,
- UD_Ivpunpckhqdq,
- UD_Ivpunpckhwd,
- UD_Ivpunpcklbw,
- UD_Ivpunpckldq,
- UD_Ivpunpcklqdq,
- UD_Ivpunpcklwd,
- UD_Ivpxor,
- UD_Ivrcpps,
- UD_Ivrcpss,
- UD_Ivroundpd,
- UD_Ivroundps,
- UD_Ivroundsd,
- UD_Ivroundss,
- UD_Ivrsqrtps,
- UD_Ivrsqrtss,
- UD_Ivshufpd,
- UD_Ivshufps,
- UD_Ivsqrtpd,
- UD_Ivsqrtps,
- UD_Ivsqrtsd,
- UD_Ivsqrtss,
- UD_Ivstmxcsr,
- UD_Ivsubpd,
- UD_Ivsubps,
- UD_Ivsubsd,
- UD_Ivsubss,
- UD_Ivtestpd,
- UD_Ivtestps,
- UD_Ivucomisd,
- UD_Ivucomiss,
- UD_Ivunpckhpd,
- UD_Ivunpckhps,
- UD_Ivunpcklpd,
- UD_Ivunpcklps,
- UD_Ivxorpd,
- UD_Ivxorps,
- UD_Ivzeroall,
- UD_Ivzeroupper,
- UD_Iwait,
- UD_Iwbinvd,
- UD_Iwrmsr,
- UD_Ixadd,
- UD_Ixchg,
- UD_Ixcryptcbc,
- UD_Ixcryptcfb,
- UD_Ixcryptctr,
- UD_Ixcryptecb,
- UD_Ixcryptofb,
- UD_Ixgetbv,
- UD_Ixlatb,
- UD_Ixor,
- UD_Ixorpd,
- UD_Ixorps,
- UD_Ixrstor,
- UD_Ixsave,
- UD_Ixsetbv,
- UD_Ixsha1,
- UD_Ixsha256,
- UD_Ixstore,
- UD_Iinvalid,
- UD_I3dnow,
- UD_Inone,
- UD_Idb,
- UD_Ipause,
- UD_MAX_MNEMONIC_CODE
-};
-
-extern const char * ud_mnemonics_str[];
-
-#endif /* UD_ITAB_H */
diff --git a/ext/myjit/disasm/udis86/syn-att.c b/ext/myjit/disasm/udis86/syn-att.c
deleted file mode 100755
index d1ba89b..0000000
--- a/ext/myjit/disasm/udis86/syn-att.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/* udis86 - libudis86/syn-att.c
- *
- * Copyright (c) 2002-2009 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "types.h"
-#include "extern.h"
-#include "decode.h"
-#include "itab.h"
-#include "syn.h"
-#include "udint.h"
-
-/* -----------------------------------------------------------------------------
- * opr_cast() - Prints an operand cast.
- * -----------------------------------------------------------------------------
- */
-static void
-opr_cast(struct ud* u, struct ud_operand* op)
-{
- switch(op->size) {
- case 16 : case 32 :
- ud_asmprintf(u, "*"); break;
- default: break;
- }
-}
-
-/* -----------------------------------------------------------------------------
- * gen_operand() - Generates assembly output for each operand.
- * -----------------------------------------------------------------------------
- */
-static void
-gen_operand(struct ud* u, struct ud_operand* op)
-{
- switch(op->type) {
- case UD_OP_CONST:
- ud_asmprintf(u, "$0x%x", op->lval.udword);
- break;
-
- case UD_OP_REG:
- ud_asmprintf(u, "%%%s", ud_reg_tab[op->base - UD_R_AL]);
- break;
-
- case UD_OP_MEM:
- if (u->br_far) {
- opr_cast(u, op);
- }
- if (u->pfx_seg) {
- ud_asmprintf(u, "%%%s:", ud_reg_tab[u->pfx_seg - UD_R_AL]);
- }
- if (op->offset != 0) {
- ud_syn_print_mem_disp(u, op, 0);
- }
- if (op->base) {
- ud_asmprintf(u, "(%%%s", ud_reg_tab[op->base - UD_R_AL]);
- }
- if (op->index) {
- if (op->base) {
- ud_asmprintf(u, ",");
- } else {
- ud_asmprintf(u, "(");
- }
- ud_asmprintf(u, "%%%s", ud_reg_tab[op->index - UD_R_AL]);
- }
- if (op->scale) {
- ud_asmprintf(u, ",%d", op->scale);
- }
- if (op->base || op->index) {
- ud_asmprintf(u, ")");
- }
- break;
-
- case UD_OP_IMM:
- ud_asmprintf(u, "$");
- ud_syn_print_imm(u, op);
- break;
-
- case UD_OP_JIMM:
- ud_syn_print_addr(u, ud_syn_rel_target(u, op));
- break;
-
- case UD_OP_PTR:
- switch (op->size) {
- case 32:
- ud_asmprintf(u, "$0x%x, $0x%x", op->lval.ptr.seg,
- op->lval.ptr.off & 0xFFFF);
- break;
- case 48:
- ud_asmprintf(u, "$0x%x, $0x%x", op->lval.ptr.seg,
- op->lval.ptr.off);
- break;
- }
- break;
-
- default: return;
- }
-}
-
-/* =============================================================================
- * translates to AT&T syntax
- * =============================================================================
- */
-extern void
-ud_translate_att(struct ud *u)
-{
- int size = 0;
- int star = 0;
-
- /* check if P_OSO prefix is used */
- if (! P_OSO(u->itab_entry->prefix) && u->pfx_opr) {
- switch (u->dis_mode) {
- case 16:
- ud_asmprintf(u, "o32 ");
- break;
- case 32:
- case 64:
- ud_asmprintf(u, "o16 ");
- break;
- }
- }
-
- /* check if P_ASO prefix was used */
- if (! P_ASO(u->itab_entry->prefix) && u->pfx_adr) {
- switch (u->dis_mode) {
- case 16:
- ud_asmprintf(u, "a32 ");
- break;
- case 32:
- ud_asmprintf(u, "a16 ");
- break;
- case 64:
- ud_asmprintf(u, "a32 ");
- break;
- }
- }
-
- if (u->pfx_lock)
- ud_asmprintf(u, "lock ");
- if (u->pfx_rep) {
- ud_asmprintf(u, "rep ");
- } else if (u->pfx_repe) {
- ud_asmprintf(u, "repe ");
- } else if (u->pfx_repne) {
- ud_asmprintf(u, "repne ");
- }
-
- /* special instructions */
- switch (u->mnemonic) {
- case UD_Iretf:
- ud_asmprintf(u, "lret ");
- break;
- case UD_Idb:
- ud_asmprintf(u, ".byte 0x%x", u->operand[0].lval.ubyte);
- return;
- case UD_Ijmp:
- case UD_Icall:
- if (u->br_far) ud_asmprintf(u, "l");
- if (u->operand[0].type == UD_OP_REG) {
- star = 1;
- }
- ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic));
- break;
- case UD_Ibound:
- case UD_Ienter:
- if (u->operand[0].type != UD_NONE)
- gen_operand(u, &u->operand[0]);
- if (u->operand[1].type != UD_NONE) {
- ud_asmprintf(u, ",");
- gen_operand(u, &u->operand[1]);
- }
- return;
- default:
- ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic));
- }
-
- if (size == 8) {
- ud_asmprintf(u, "b");
- } else if (size == 16) {
- ud_asmprintf(u, "w");
- } else if (size == 64) {
- ud_asmprintf(u, "q");
- }
-
- if (star) {
- ud_asmprintf(u, " *");
- } else {
- ud_asmprintf(u, " ");
- }
-
- if (u->operand[3].type != UD_NONE) {
- gen_operand(u, &u->operand[3]);
- ud_asmprintf(u, ", ");
- }
- if (u->operand[2].type != UD_NONE) {
- gen_operand(u, &u->operand[2]);
- ud_asmprintf(u, ", ");
- }
- if (u->operand[1].type != UD_NONE) {
- gen_operand(u, &u->operand[1]);
- ud_asmprintf(u, ", ");
- }
- if (u->operand[0].type != UD_NONE) {
- gen_operand(u, &u->operand[0]);
- }
-}
-
-/*
-vim: set ts=2 sw=2 expandtab
-*/
diff --git a/ext/myjit/disasm/udis86/syn-intel.c b/ext/myjit/disasm/udis86/syn-intel.c
deleted file mode 100755
index 0664fea..0000000
--- a/ext/myjit/disasm/udis86/syn-intel.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/* udis86 - libudis86/syn-intel.c
- *
- * Copyright (c) 2002-2013 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "types.h"
-#include "extern.h"
-#include "decode.h"
-#include "itab.h"
-#include "syn.h"
-#include "udint.h"
-
-/* -----------------------------------------------------------------------------
- * opr_cast() - Prints an operand cast.
- * -----------------------------------------------------------------------------
- */
-static void
-opr_cast(struct ud* u, struct ud_operand* op)
-{
- if (u->br_far) {
- ud_asmprintf(u, "far ");
- }
- switch(op->size) {
- case 8: ud_asmprintf(u, "byte " ); break;
- case 16: ud_asmprintf(u, "word " ); break;
- case 32: ud_asmprintf(u, "dword "); break;
- case 64: ud_asmprintf(u, "qword "); break;
- case 80: ud_asmprintf(u, "tword "); break;
- case 128: ud_asmprintf(u, "oword "); break;
- case 256: ud_asmprintf(u, "yword "); break;
- default: break;
- }
-}
-
-/* -----------------------------------------------------------------------------
- * gen_operand() - Generates assembly output for each operand.
- * -----------------------------------------------------------------------------
- */
-static void gen_operand(struct ud* u, struct ud_operand* op, int syn_cast)
-{
- switch(op->type) {
- case UD_OP_REG:
- ud_asmprintf(u, "%s", ud_reg_tab[op->base - UD_R_AL]);
- break;
-
- case UD_OP_MEM:
- if (syn_cast) {
- opr_cast(u, op);
- }
- ud_asmprintf(u, "[");
- if (u->pfx_seg) {
- ud_asmprintf(u, "%s:", ud_reg_tab[u->pfx_seg - UD_R_AL]);
- }
- if (op->base) {
- ud_asmprintf(u, "%s", ud_reg_tab[op->base - UD_R_AL]);
- }
- if (op->index) {
- ud_asmprintf(u, "%s%s", op->base != UD_NONE? "+" : "",
- ud_reg_tab[op->index - UD_R_AL]);
- if (op->scale) {
- ud_asmprintf(u, "*%d", op->scale);
- }
- }
- if (op->offset != 0) {
- ud_syn_print_mem_disp(u, op, (op->base != UD_NONE ||
- op->index != UD_NONE) ? 1 : 0);
- }
- ud_asmprintf(u, "]");
- break;
-
- case UD_OP_IMM:
- ud_syn_print_imm(u, op);
- break;
-
-
- case UD_OP_JIMM:
- ud_syn_print_addr(u, ud_syn_rel_target(u, op));
- break;
-
- case UD_OP_PTR:
- switch (op->size) {
- case 32:
- ud_asmprintf(u, "word 0x%x:0x%x", op->lval.ptr.seg,
- op->lval.ptr.off & 0xFFFF);
- break;
- case 48:
- ud_asmprintf(u, "dword 0x%x:0x%x", op->lval.ptr.seg,
- op->lval.ptr.off);
- break;
- }
- break;
-
- case UD_OP_CONST:
- if (syn_cast) opr_cast(u, op);
- ud_asmprintf(u, "%d", op->lval.udword);
- break;
-
- default: return;
- }
-}
-
-/* =============================================================================
- * translates to intel syntax
- * =============================================================================
- */
-extern void
-ud_translate_intel(struct ud* u)
-{
- /* check if P_OSO prefix is used */
- if (!P_OSO(u->itab_entry->prefix) && u->pfx_opr) {
- switch (u->dis_mode) {
- case 16: ud_asmprintf(u, "o32 "); break;
- case 32:
- case 64: ud_asmprintf(u, "o16 "); break;
- }
- }
-
- /* check if P_ASO prefix was used */
- if (!P_ASO(u->itab_entry->prefix) && u->pfx_adr) {
- switch (u->dis_mode) {
- case 16: ud_asmprintf(u, "a32 "); break;
- case 32: ud_asmprintf(u, "a16 "); break;
- case 64: ud_asmprintf(u, "a32 "); break;
- }
- }
-
- if (u->pfx_seg &&
- u->operand[0].type != UD_OP_MEM &&
- u->operand[1].type != UD_OP_MEM ) {
- ud_asmprintf(u, "%s ", ud_reg_tab[u->pfx_seg - UD_R_AL]);
- }
-
- if (u->pfx_lock) {
- ud_asmprintf(u, "lock ");
- }
- if (u->pfx_rep) {
- ud_asmprintf(u, "rep ");
- } else if (u->pfx_repe) {
- ud_asmprintf(u, "repe ");
- } else if (u->pfx_repne) {
- ud_asmprintf(u, "repne ");
- }
-
- /* print the instruction mnemonic */
- ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic));
-
- if (u->operand[0].type != UD_NONE) {
- int cast = 0;
- ud_asmprintf(u, " ");
- if (u->operand[0].type == UD_OP_MEM) {
- if (u->operand[1].type == UD_OP_IMM ||
- u->operand[1].type == UD_OP_CONST ||
- u->operand[1].type == UD_NONE ||
- (u->operand[0].size != u->operand[1].size)) {
- cast = 1;
- } else if (u->operand[1].type == UD_OP_REG &&
- u->operand[1].base == UD_R_CL) {
- switch (u->mnemonic) {
- case UD_Ircl:
- case UD_Irol:
- case UD_Iror:
- case UD_Ircr:
- case UD_Ishl:
- case UD_Ishr:
- case UD_Isar:
- cast = 1;
- break;
- default: break;
- }
- }
- }
- gen_operand(u, &u->operand[0], cast);
- }
-
- if (u->operand[1].type != UD_NONE) {
- int cast = 0;
- ud_asmprintf(u, ", ");
- if (u->operand[1].type == UD_OP_MEM &&
- u->operand[0].size != u->operand[1].size &&
- !ud_opr_is_sreg(&u->operand[0])) {
- cast = 1;
- }
- gen_operand(u, &u->operand[1], cast);
- }
-
- if (u->operand[2].type != UD_NONE) {
- int cast = 0;
- ud_asmprintf(u, ", ");
- if (u->operand[2].type == UD_OP_MEM &&
- u->operand[2].size != u->operand[1].size) {
- cast = 1;
- }
- gen_operand(u, &u->operand[2], cast);
- }
-
- if (u->operand[3].type != UD_NONE) {
- ud_asmprintf(u, ", ");
- gen_operand(u, &u->operand[3], 0);
- }
-}
-
-/*
-vim: set ts=2 sw=2 expandtab
-*/
diff --git a/ext/myjit/disasm/udis86/syn.c b/ext/myjit/disasm/udis86/syn.c
deleted file mode 100755
index 1b9e1d4..0000000
--- a/ext/myjit/disasm/udis86/syn.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* udis86 - libudis86/syn.c
- *
- * Copyright (c) 2002-2013 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "types.h"
-#include "decode.h"
-#include "syn.h"
-#include "udint.h"
-
-/*
- * Register Table - Order Matters (types.h)!
- *
- */
-const char* ud_reg_tab[] =
-{
- "al", "cl", "dl", "bl",
- "ah", "ch", "dh", "bh",
- "spl", "bpl", "sil", "dil",
- "r8b", "r9b", "r10b", "r11b",
- "r12b", "r13b", "r14b", "r15b",
-
- "ax", "cx", "dx", "bx",
- "sp", "bp", "si", "di",
- "r8w", "r9w", "r10w", "r11w",
- "r12w", "r13w", "r14w", "r15w",
-
- "eax", "ecx", "edx", "ebx",
- "esp", "ebp", "esi", "edi",
- "r8d", "r9d", "r10d", "r11d",
- "r12d", "r13d", "r14d", "r15d",
-
- "rax", "rcx", "rdx", "rbx",
- "rsp", "rbp", "rsi", "rdi",
- "r8", "r9", "r10", "r11",
- "r12", "r13", "r14", "r15",
-
- "es", "cs", "ss", "ds",
- "fs", "gs",
-
- "cr0", "cr1", "cr2", "cr3",
- "cr4", "cr5", "cr6", "cr7",
- "cr8", "cr9", "cr10", "cr11",
- "cr12", "cr13", "cr14", "cr15",
-
- "dr0", "dr1", "dr2", "dr3",
- "dr4", "dr5", "dr6", "dr7",
- "dr8", "dr9", "dr10", "dr11",
- "dr12", "dr13", "dr14", "dr15",
-
- "mm0", "mm1", "mm2", "mm3",
- "mm4", "mm5", "mm6", "mm7",
-
- "st0", "st1", "st2", "st3",
- "st4", "st5", "st6", "st7",
-
- "xmm0", "xmm1", "xmm2", "xmm3",
- "xmm4", "xmm5", "xmm6", "xmm7",
- "xmm8", "xmm9", "xmm10", "xmm11",
- "xmm12", "xmm13", "xmm14", "xmm15",
-
- "ymm0", "ymm1", "ymm2", "ymm3",
- "ymm4", "ymm5", "ymm6", "ymm7",
- "ymm8", "ymm9", "ymm10", "ymm11",
- "ymm12", "ymm13", "ymm14", "ymm15",
-
- "rip"
-};
-
-
-uint64_t
-ud_syn_rel_target(struct ud *u, struct ud_operand *opr)
-{
- const uint64_t trunc_mask = 0xffffffffffffffffull >> (64 - u->opr_mode);
- switch (opr->size) {
- case 8 : return (u->pc + opr->lval.sbyte) & trunc_mask;
- case 16: return (u->pc + opr->lval.sword) & trunc_mask;
- case 32: return (u->pc + opr->lval.sdword) & trunc_mask;
- default: UD_ASSERT(!"invalid relative offset size.");
- return 0ull;
- }
-}
-
-
-/*
- * asmprintf
- * Printf style function for printing translated assembly
- * output. Returns the number of characters written and
- * moves the buffer pointer forward. On an overflow,
- * returns a negative number and truncates the output.
- */
-int
-ud_asmprintf(struct ud *u, const char *fmt, ...)
-{
- int ret;
- int avail;
- va_list ap;
- va_start(ap, fmt);
- avail = u->asm_buf_size - u->asm_buf_fill - 1 /* nullchar */;
- ret = vsnprintf((char*) u->asm_buf + u->asm_buf_fill, avail, fmt, ap);
- if (ret < 0 || ret > avail) {
- u->asm_buf_fill = u->asm_buf_size - 1;
- } else {
- u->asm_buf_fill += ret;
- }
- va_end(ap);
- return ret;
-}
-
-
-void
-ud_syn_print_addr(struct ud *u, uint64_t addr)
-{
- const char *name = NULL;
- if (u->sym_resolver) {
- int64_t offset = 0;
- name = u->sym_resolver(u, addr, &offset);
- if (name) {
- if (offset) {
- ud_asmprintf(u, "%s%+" FMT64 "d", name, offset);
- } else {
- ud_asmprintf(u, "%s", name);
- }
- return;
- }
- }
- ud_asmprintf(u, "0x%" FMT64 "x", addr);
-}
-
-
-void
-ud_syn_print_imm(struct ud* u, const struct ud_operand *op)
-{
- uint64_t v;
- if (op->_oprcode == OP_sI && op->size != u->opr_mode) {
- if (op->size == 8) {
- v = (int64_t)op->lval.sbyte;
- } else {
- UD_ASSERT(op->size == 32);
- v = (int64_t)op->lval.sdword;
- }
- if (u->opr_mode < 64) {
- v = v & ((1ull << u->opr_mode) - 1ull);
- }
- } else {
- switch (op->size) {
- case 8 : v = op->lval.ubyte; break;
- case 16: v = op->lval.uword; break;
- case 32: v = op->lval.udword; break;
- case 64: v = op->lval.uqword; break;
- default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */
- }
- }
- ud_asmprintf(u, "0x%" FMT64 "x", v);
-}
-
-
-void
-ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *op, int sign)
-{
- UD_ASSERT(op->offset != 0);
- if (op->base == UD_NONE && op->index == UD_NONE) {
- uint64_t v;
- UD_ASSERT(op->scale == UD_NONE && op->offset != 8);
- /* unsigned mem-offset */
- switch (op->offset) {
- case 16: v = op->lval.uword; break;
- case 32: v = op->lval.udword; break;
- case 64: v = op->lval.uqword; break;
- default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */
- }
- ud_asmprintf(u, "0x%" FMT64 "x", v);
- } else {
- int64_t v;
- UD_ASSERT(op->offset != 64);
- switch (op->offset) {
- case 8 : v = op->lval.sbyte; break;
- case 16: v = op->lval.sword; break;
- case 32: v = op->lval.sdword; break;
- default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */
- }
- if (v < 0) {
- ud_asmprintf(u, "-0x%" FMT64 "x", -v);
- } else if (v > 0) {
- ud_asmprintf(u, "%s0x%" FMT64 "x", sign? "+" : "", v);
- }
- }
-}
-
-/*
-vim: set ts=2 sw=2 expandtab
-*/
diff --git a/ext/myjit/disasm/udis86/syn.h b/ext/myjit/disasm/udis86/syn.h
deleted file mode 100755
index d3b1e3f..0000000
--- a/ext/myjit/disasm/udis86/syn.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* udis86 - libudis86/syn.h
- *
- * Copyright (c) 2002-2009
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef UD_SYN_H
-#define UD_SYN_H
-
-#include "types.h"
-#ifndef __UD_STANDALONE__
-# include <stdarg.h>
-#endif /* __UD_STANDALONE__ */
-
-extern const char* ud_reg_tab[];
-
-uint64_t ud_syn_rel_target(struct ud*, struct ud_operand*);
-
-#ifdef __GNUC__
-int ud_asmprintf(struct ud *u, const char *fmt, ...)
- __attribute__ ((format (printf, 2, 3)));
-#else
-int ud_asmprintf(struct ud *u, const char *fmt, ...);
-#endif
-
-void ud_syn_print_addr(struct ud *u, uint64_t addr);
-void ud_syn_print_imm(struct ud* u, const struct ud_operand *op);
-void ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *, int sign);
-
-#endif /* UD_SYN_H */
-
-/*
-vim: set ts=2 sw=2 expandtab
-*/
diff --git a/ext/myjit/disasm/udis86/types.h b/ext/myjit/disasm/udis86/types.h
deleted file mode 100755
index 62fafcf..0000000
--- a/ext/myjit/disasm/udis86/types.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/* udis86 - libudis86/types.h
- *
- * Copyright (c) 2002-2013 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef UD_TYPES_H
-#define UD_TYPES_H
-
-#ifdef __KERNEL__
- /*
- * -D__KERNEL__ is automatically passed on the command line when
- * building something as part of the Linux kernel. Assume standalone
- * mode.
- */
-# include <linux/kernel.h>
-# include <linux/string.h>
-# ifndef __UD_STANDALONE__
-# define __UD_STANDALONE__ 1
-# endif
-#endif /* __KERNEL__ */
-
-//#if !defined(__UD_STANDALONE__)
-# include <stdint.h>
-# include <stdio.h>
-//#endif
-
-/* gcc specific extensions */
-#ifdef __GNUC__
-# define UD_ATTR_PACKED __attribute__((packed))
-#else
-# define UD_ATTR_PACKED
-#endif /* UD_ATTR_PACKED */
-
-
-/* -----------------------------------------------------------------------------
- * All possible "types" of objects in udis86. Order is Important!
- * -----------------------------------------------------------------------------
- */
-enum ud_type
-{
- UD_NONE,
-
- /* 8 bit GPRs */
- UD_R_AL, UD_R_CL, UD_R_DL, UD_R_BL,
- UD_R_AH, UD_R_CH, UD_R_DH, UD_R_BH,
- UD_R_SPL, UD_R_BPL, UD_R_SIL, UD_R_DIL,
- UD_R_R8B, UD_R_R9B, UD_R_R10B, UD_R_R11B,
- UD_R_R12B, UD_R_R13B, UD_R_R14B, UD_R_R15B,
-
- /* 16 bit GPRs */
- UD_R_AX, UD_R_CX, UD_R_DX, UD_R_BX,
- UD_R_SP, UD_R_BP, UD_R_SI, UD_R_DI,
- UD_R_R8W, UD_R_R9W, UD_R_R10W, UD_R_R11W,
- UD_R_R12W, UD_R_R13W, UD_R_R14W, UD_R_R15W,
-
- /* 32 bit GPRs */
- UD_R_EAX, UD_R_ECX, UD_R_EDX, UD_R_EBX,
- UD_R_ESP, UD_R_EBP, UD_R_ESI, UD_R_EDI,
- UD_R_R8D, UD_R_R9D, UD_R_R10D, UD_R_R11D,
- UD_R_R12D, UD_R_R13D, UD_R_R14D, UD_R_R15D,
-
- /* 64 bit GPRs */
- UD_R_RAX, UD_R_RCX, UD_R_RDX, UD_R_RBX,
- UD_R_RSP, UD_R_RBP, UD_R_RSI, UD_R_RDI,
- UD_R_R8, UD_R_R9, UD_R_R10, UD_R_R11,
- UD_R_R12, UD_R_R13, UD_R_R14, UD_R_R15,
-
- /* segment registers */
- UD_R_ES, UD_R_CS, UD_R_SS, UD_R_DS,
- UD_R_FS, UD_R_GS,
-
- /* control registers*/
- UD_R_CR0, UD_R_CR1, UD_R_CR2, UD_R_CR3,
- UD_R_CR4, UD_R_CR5, UD_R_CR6, UD_R_CR7,
- UD_R_CR8, UD_R_CR9, UD_R_CR10, UD_R_CR11,
- UD_R_CR12, UD_R_CR13, UD_R_CR14, UD_R_CR15,
-
- /* debug registers */
- UD_R_DR0, UD_R_DR1, UD_R_DR2, UD_R_DR3,
- UD_R_DR4, UD_R_DR5, UD_R_DR6, UD_R_DR7,
- UD_R_DR8, UD_R_DR9, UD_R_DR10, UD_R_DR11,
- UD_R_DR12, UD_R_DR13, UD_R_DR14, UD_R_DR15,
-
- /* mmx registers */
- UD_R_MM0, UD_R_MM1, UD_R_MM2, UD_R_MM3,
- UD_R_MM4, UD_R_MM5, UD_R_MM6, UD_R_MM7,
-
- /* x87 registers */
- UD_R_ST0, UD_R_ST1, UD_R_ST2, UD_R_ST3,
- UD_R_ST4, UD_R_ST5, UD_R_ST6, UD_R_ST7,
-
- /* extended multimedia registers */
- UD_R_XMM0, UD_R_XMM1, UD_R_XMM2, UD_R_XMM3,
- UD_R_XMM4, UD_R_XMM5, UD_R_XMM6, UD_R_XMM7,
- UD_R_XMM8, UD_R_XMM9, UD_R_XMM10, UD_R_XMM11,
- UD_R_XMM12, UD_R_XMM13, UD_R_XMM14, UD_R_XMM15,
-
- /* 256B multimedia registers */
- UD_R_YMM0, UD_R_YMM1, UD_R_YMM2, UD_R_YMM3,
- UD_R_YMM4, UD_R_YMM5, UD_R_YMM6, UD_R_YMM7,
- UD_R_YMM8, UD_R_YMM9, UD_R_YMM10, UD_R_YMM11,
- UD_R_YMM12, UD_R_YMM13, UD_R_YMM14, UD_R_YMM15,
-
- UD_R_RIP,
-
- /* Operand Types */
- UD_OP_REG, UD_OP_MEM, UD_OP_PTR, UD_OP_IMM,
- UD_OP_JIMM, UD_OP_CONST
-};
-
-#include "itab.h"
-
-union ud_lval {
- int8_t sbyte;
- uint8_t ubyte;
- int16_t sword;
- uint16_t uword;
- int32_t sdword;
- uint32_t udword;
- int64_t sqword;
- uint64_t uqword;
- struct {
- uint16_t seg;
- uint32_t off;
- } ptr;
-};
-
-/* -----------------------------------------------------------------------------
- * struct ud_operand - Disassembled instruction Operand.
- * -----------------------------------------------------------------------------
- */
-struct ud_operand {
- enum ud_type type;
- uint16_t size;
- enum ud_type base;
- enum ud_type index;
- uint8_t scale;
- uint8_t offset;
- union ud_lval lval;
- /*
- * internal use only
- */
- uint64_t _legacy; /* this will be removed in 1.8 */
- uint8_t _oprcode;
-};
-
-/* -----------------------------------------------------------------------------
- * struct ud - The udis86 object.
- * -----------------------------------------------------------------------------
- */
-struct ud
-{
- /*
- * input buffering
- */
- int (*inp_hook) (struct ud*);
-#ifndef __UD_STANDALONE__
- FILE* inp_file;
-#endif
- const uint8_t* inp_buf;
- size_t inp_buf_size;
- size_t inp_buf_index;
- uint8_t inp_curr;
- size_t inp_ctr;
- uint8_t inp_sess[64];
- int inp_end;
- int inp_peek;
-
- void (*translator)(struct ud*);
- uint64_t insn_offset;
- char insn_hexcode[64];
-
- /*
- * Assembly output buffer
- */
- char *asm_buf;
- size_t asm_buf_size;
- size_t asm_buf_fill;
- char asm_buf_int[128];
-
- /*
- * Symbol resolver for use in the translation phase.
- */
- const char* (*sym_resolver)(struct ud*, uint64_t addr, int64_t *offset);
-
- uint8_t dis_mode;
- uint64_t pc;
- uint8_t vendor;
- enum ud_mnemonic_code mnemonic;
- struct ud_operand operand[4];
- uint8_t error;
- uint8_t _rex;
- uint8_t pfx_rex;
- uint8_t pfx_seg;
- uint8_t pfx_opr;
- uint8_t pfx_adr;
- uint8_t pfx_lock;
- uint8_t pfx_str;
- uint8_t pfx_rep;
- uint8_t pfx_repe;
- uint8_t pfx_repne;
- uint8_t opr_mode;
- uint8_t adr_mode;
- uint8_t br_far;
- uint8_t br_near;
- uint8_t have_modrm;
- uint8_t modrm;
- uint8_t modrm_offset;
- uint8_t vex_op;
- uint8_t vex_b1;
- uint8_t vex_b2;
- uint8_t primary_opcode;
- void * user_opaque_data;
- struct ud_itab_entry * itab_entry;
- struct ud_lookup_table_list_entry *le;
-};
-
-/* -----------------------------------------------------------------------------
- * Type-definitions
- * -----------------------------------------------------------------------------
- */
-typedef enum ud_type ud_type_t;
-typedef enum ud_mnemonic_code ud_mnemonic_code_t;
-
-typedef struct ud ud_t;
-typedef struct ud_operand ud_operand_t;
-
-#define UD_SYN_INTEL ud_translate_intel
-#define UD_SYN_ATT ud_translate_att
-#define UD_EOI (-1)
-#define UD_INP_CACHE_SZ 32
-#define UD_VENDOR_AMD 0
-#define UD_VENDOR_INTEL 1
-#define UD_VENDOR_ANY 2
-
-#endif
-
-/*
-vim: set ts=2 sw=2 expandtab
-*/
diff --git a/ext/myjit/disasm/udis86/udint.h b/ext/myjit/disasm/udis86/udint.h
deleted file mode 100755
index 734f0ea..0000000
--- a/ext/myjit/disasm/udis86/udint.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* udis86 - libudis86/udint.h -- definitions for internal use only
- *
- * Copyright (c) 2002-2009 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef _UDINT_H_
-#define _UDINT_H_
-
-#include "types.h"
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#if defined(UD_DEBUG) && HAVE_ASSERT_H
-# include <assert.h>
-# define UD_ASSERT(_x) assert(_x)
-#else
-# define UD_ASSERT(_x)
-#endif /* !HAVE_ASSERT_H */
-
-#if defined(UD_DEBUG)
- #define UDERR(u, msg) \
- do { \
- (u)->error = 1; \
- fprintf(stderr, "decode-error: %s:%d: %s", \
- __FILE__, __LINE__, (msg)); \
- } while (0)
-#else
- #define UDERR(u, m) \
- do { \
- (u)->error = 1; \
- } while (0)
-#endif /* !LOGERR */
-
-#define UD_RETURN_ON_ERROR(u) \
- do { \
- if ((u)->error != 0) { \
- return (u)->error; \
- } \
- } while (0)
-
-#define UD_RETURN_WITH_ERROR(u, m) \
- do { \
- UDERR(u, m); \
- return (u)->error; \
- } while (0)
-
-#ifndef __UD_STANDALONE__
-# define UD_NON_STANDALONE(x) x
-#else
-# define UD_NON_STANDALONE(x)
-#endif
-
-/* printf formatting int64 specifier */
-#ifdef FMT64
-# undef FMT64
-#endif
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-# define FMT64 "I64"
-#else
-# if defined(__APPLE__)
-# define FMT64 "ll"
-# elif defined(__amd64__) || defined(__x86_64__)
-# define FMT64 "l"
-# else
-# define FMT64 "ll"
-# endif /* !x64 */
-#endif
-
-/* define an inline macro */
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-# define UD_INLINE __inline /* MS Visual Studio requires __inline
- instead of inline for C code */
-#else
-# define UD_INLINE inline
-#endif
-
-#endif /* _UDINT_H_ */
diff --git a/ext/myjit/disasm/udis86/udis86.c b/ext/myjit/disasm/udis86/udis86.c
deleted file mode 100755
index 1adaf59..0000000
--- a/ext/myjit/disasm/udis86/udis86.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/* udis86 - libudis86/udis86.c
- *
- * Copyright (c) 2002-2013 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "udint.h"
-#include "extern.h"
-#include "decode.h"
-
-#if !defined(__UD_STANDALONE__)
-//# if HAVE_STRING_H
-# include <string.h>
-//# endif
-#endif /* !__UD_STANDALONE__ */
-
-static void ud_inp_init(struct ud *u);
-
-/* =============================================================================
- * ud_init
- * Initializes ud_t object.
- * =============================================================================
- */
-extern void
-ud_init(struct ud* u)
-{
- memset((void*)u, 0, sizeof(struct ud));
- ud_set_mode(u, 16);
- u->mnemonic = UD_Iinvalid;
- ud_set_pc(u, 0);
-#ifndef __UD_STANDALONE__
- ud_set_input_file(u, stdin);
-#endif /* __UD_STANDALONE__ */
-
- ud_set_asm_buffer(u, u->asm_buf_int, sizeof(u->asm_buf_int));
-}
-
-
-/* =============================================================================
- * ud_disassemble
- * Disassembles one instruction and returns the number of
- * bytes disassembled. A zero means end of disassembly.
- * =============================================================================
- */
-extern unsigned int
-ud_disassemble(struct ud* u)
-{
- int len;
- if (u->inp_end) {
- return 0;
- }
- if ((len = ud_decode(u)) > 0) {
- if (u->translator != NULL) {
- u->asm_buf[0] = '\0';
- u->translator(u);
- }
- }
- return len;
-}
-
-
-/* =============================================================================
- * ud_set_mode() - Set Disassemly Mode.
- * =============================================================================
- */
-extern void
-ud_set_mode(struct ud* u, uint8_t m)
-{
- switch(m) {
- case 16:
- case 32:
- case 64: u->dis_mode = m ; return;
- default: u->dis_mode = 16; return;
- }
-}
-
-/* =============================================================================
- * ud_set_vendor() - Set vendor.
- * =============================================================================
- */
-extern void
-ud_set_vendor(struct ud* u, unsigned v)
-{
- switch(v) {
- case UD_VENDOR_INTEL:
- u->vendor = v;
- break;
- case UD_VENDOR_ANY:
- u->vendor = v;
- break;
- default:
- u->vendor = UD_VENDOR_AMD;
- }
-}
-
-/* =============================================================================
- * ud_set_pc() - Sets code origin.
- * =============================================================================
- */
-extern void
-ud_set_pc(struct ud* u, uint64_t o)
-{
- u->pc = o;
-}
-
-/* =============================================================================
- * ud_set_syntax() - Sets the output syntax.
- * =============================================================================
- */
-extern void
-ud_set_syntax(struct ud* u, void (*t)(struct ud*))
-{
- u->translator = t;
-}
-
-/* =============================================================================
- * ud_insn() - returns the disassembled instruction
- * =============================================================================
- */
-const char*
-ud_insn_asm(const struct ud* u)
-{
- return u->asm_buf;
-}
-
-/* =============================================================================
- * ud_insn_offset() - Returns the offset.
- * =============================================================================
- */
-uint64_t
-ud_insn_off(const struct ud* u)
-{
- return u->insn_offset;
-}
-
-
-/* =============================================================================
- * ud_insn_hex() - Returns hex form of disassembled instruction.
- * =============================================================================
- */
-const char*
-ud_insn_hex(struct ud* u)
-{
- u->insn_hexcode[0] = 0;
- if (!u->error) {
- unsigned int i;
- const unsigned char *src_ptr = ud_insn_ptr(u);
- char* src_hex;
- src_hex = (char*) u->insn_hexcode;
- /* for each byte used to decode instruction */
- for (i = 0; i < ud_insn_len(u) && i < sizeof(u->insn_hexcode) / 2;
- ++i, ++src_ptr) {
- sprintf(src_hex, "%02x", *src_ptr & 0xFF);
- src_hex += 2;
- }
- }
- return u->insn_hexcode;
-}
-
-
-/* =============================================================================
- * ud_insn_ptr
- * Returns a pointer to buffer containing the bytes that were
- * disassembled.
- * =============================================================================
- */
-extern const uint8_t*
-ud_insn_ptr(const struct ud* u)
-{
- return (u->inp_buf == NULL) ?
- u->inp_sess : u->inp_buf + (u->inp_buf_index - u->inp_ctr);
-}
-
-
-/* =============================================================================
- * ud_insn_len
- * Returns the count of bytes disassembled.
- * =============================================================================
- */
-extern unsigned int
-ud_insn_len(const struct ud* u)
-{
- return u->inp_ctr;
-}
-
-
-/* =============================================================================
- * ud_insn_get_opr
- * Return the operand struct representing the nth operand of
- * the currently disassembled instruction. Returns NULL if
- * there's no such operand.
- * =============================================================================
- */
-const struct ud_operand*
-ud_insn_opr(const struct ud *u, unsigned int n)
-{
- if (n > 3 || u->operand[n].type == UD_NONE) {
- return NULL;
- } else {
- return &u->operand[n];
- }
-}
-
-
-/* =============================================================================
- * ud_opr_is_sreg
- * Returns non-zero if the given operand is of a segment register type.
- * =============================================================================
- */
-int
-ud_opr_is_sreg(const struct ud_operand *opr)
-{
- return opr->type == UD_OP_REG &&
- opr->base >= UD_R_ES &&
- opr->base <= UD_R_GS;
-}
-
-
-/* =============================================================================
- * ud_opr_is_sreg
- * Returns non-zero if the given operand is of a general purpose
- * register type.
- * =============================================================================
- */
-int
-ud_opr_is_gpr(const struct ud_operand *opr)
-{
- return opr->type == UD_OP_REG &&
- opr->base >= UD_R_AL &&
- opr->base <= UD_R_R15;
-}
-
-
-/* =============================================================================
- * ud_set_user_opaque_data
- * ud_get_user_opaque_data
- * Get/set user opaqute data pointer
- * =============================================================================
- */
-void
-ud_set_user_opaque_data(struct ud * u, void* opaque)
-{
- u->user_opaque_data = opaque;
-}
-
-void*
-ud_get_user_opaque_data(const struct ud *u)
-{
- return u->user_opaque_data;
-}
-
-
-/* =============================================================================
- * ud_set_asm_buffer
- * Allow the user to set an assembler output buffer. If `buf` is NULL,
- * we switch back to the internal buffer.
- * =============================================================================
- */
-void
-ud_set_asm_buffer(struct ud *u, char *buf, size_t size)
-{
- if (buf == NULL) {
- ud_set_asm_buffer(u, u->asm_buf_int, sizeof(u->asm_buf_int));
- } else {
- u->asm_buf = buf;
- u->asm_buf_size = size;
- }
-}
-
-
-/* =============================================================================
- * ud_set_sym_resolver
- * Set symbol resolver for relative targets used in the translation
- * phase.
- *
- * The resolver is a function that takes a uint64_t address and returns a
- * symbolic name for the that address. The function also takes a second
- * argument pointing to an integer that the client can optionally set to a
- * non-zero value for offsetted targets. (symbol+offset) The function may
- * also return NULL, in which case the translator only prints the target
- * address.
- *
- * The function pointer maybe NULL which resets symbol resolution.
- * =============================================================================
- */
-void
-ud_set_sym_resolver(struct ud *u, const char* (*resolver)(struct ud*,
- uint64_t addr,
- int64_t *offset))
-{
- u->sym_resolver = resolver;
-}
-
-
-/* =============================================================================
- * ud_insn_mnemonic
- * Return the current instruction mnemonic.
- * =============================================================================
- */
-enum ud_mnemonic_code
-ud_insn_mnemonic(const struct ud *u)
-{
- return u->mnemonic;
-}
-
-
-/* =============================================================================
- * ud_lookup_mnemonic
- * Looks up mnemonic code in the mnemonic string table.
- * Returns NULL if the mnemonic code is invalid.
- * =============================================================================
- */
-const char*
-ud_lookup_mnemonic(enum ud_mnemonic_code c)
-{
- if (c < UD_MAX_MNEMONIC_CODE) {
- return ud_mnemonics_str[c];
- } else {
- return NULL;
- }
-}
-
-
-/*
- * ud_inp_init
- * Initializes the input system.
- */
-static void
-ud_inp_init(struct ud *u)
-{
- u->inp_hook = NULL;
- u->inp_buf = NULL;
- u->inp_buf_size = 0;
- u->inp_buf_index = 0;
- u->inp_curr = 0;
- u->inp_ctr = 0;
- u->inp_end = 0;
- u->inp_peek = UD_EOI;
- UD_NON_STANDALONE(u->inp_file = NULL);
-}
-
-
-/* =============================================================================
- * ud_inp_set_hook
- * Sets input hook.
- * =============================================================================
- */
-void
-ud_set_input_hook(register struct ud* u, int (*hook)(struct ud*))
-{
- ud_inp_init(u);
- u->inp_hook = hook;
-}
-
-/* =============================================================================
- * ud_inp_set_buffer
- * Set buffer as input.
- * =============================================================================
- */
-void
-ud_set_input_buffer(register struct ud* u, const uint8_t* buf, size_t len)
-{
- ud_inp_init(u);
- u->inp_buf = buf;
- u->inp_buf_size = len;
- u->inp_buf_index = 0;
-}
-
-
-#ifndef __UD_STANDALONE__
-/* =============================================================================
- * ud_input_set_file
- * Set FILE as input.
- * =============================================================================
- */
-static int
-inp_file_hook(struct ud* u)
-{
- return fgetc(u->inp_file);
-}
-
-void
-ud_set_input_file(register struct ud* u, FILE* f)
-{
- ud_inp_init(u);
- u->inp_hook = inp_file_hook;
- u->inp_file = f;
-}
-#endif /* __UD_STANDALONE__ */
-
-
-/* =============================================================================
- * ud_input_skip
- * Skip n input bytes.
- * ============================================================================
- */
-void
-ud_input_skip(struct ud* u, size_t n)
-{
- if (u->inp_end) {
- return;
- }
- if (u->inp_buf == NULL) {
- while (n--) {
- int c = u->inp_hook(u);
- if (c == UD_EOI) {
- goto eoi;
- }
- }
- return;
- } else {
- if (n > u->inp_buf_size ||
- u->inp_buf_index > u->inp_buf_size - n) {
- u->inp_buf_index = u->inp_buf_size;
- goto eoi;
- }
- u->inp_buf_index += n;
- return;
- }
-eoi:
- u->inp_end = 1;
- UDERR(u, "cannot skip, eoi received\b");
- return;
-}
-
-
-/* =============================================================================
- * ud_input_end
- * Returns non-zero on end-of-input.
- * =============================================================================
- */
-int
-ud_input_end(const struct ud *u)
-{
- return u->inp_end;
-}
-
-/* vim:set ts=2 sw=2 expandtab */
diff --git a/ext/myjit/disasm/udis86/udis86.h b/ext/myjit/disasm/udis86/udis86.h
deleted file mode 100755
index 18e71cc..0000000
--- a/ext/myjit/disasm/udis86/udis86.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* udis86 - udis86.h
- *
- * Copyright (c) 2002-2009 Vivek Thampi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef UDIS86_H
-#define UDIS86_H
-
-#include "types.h"
-#include "extern.h"
-#include "itab.h"
-
-#endif
diff --git a/ext/myjit/doc/ChangeLog b/ext/myjit/doc/ChangeLog
deleted file mode 100755
index 7ae9b26..0000000
--- a/ext/myjit/doc/ChangeLog
+++ /dev/null
@@ -1,128 +0,0 @@
-Version 0.9.0.0
-===============
-Funding for this release was provided by Christian Collberg, University
-of Arizona.
-
-+ new opcodes for mixing data and code
-+ proper support for JMPR
-+ support for warnings pointing out to the most commong issues in the compiled
-code
-+ new testing framework and new tests covering almost 100% LoC
-+ only public API is available through jitlib.h
-+ new standalone disassembler
-+ improved debugger
-+ improved code quality (fixed GCC's warnings; more consistent function names,
-etc.)
-+ various bugfixes
-
-Version 0.7.0.0
-===============
-+ support for optimizations
-+ adjacent addr+addi are converted into one LEA
-+ adjacent mul+add or shl+or are converted into one LEA
-+ if not necessary, prolog and epilogue of the function is skipped
-+ unused assignments can be skipped
-
-Version 0.6.0.0
-===============
-+ completely new linear scan register allocator
-
-Version 0.5.2.2
-===============
-+ proper parenthesis inside API macros (this has (slightly) changed the semantics of ld, st,
-fld, fst operations which have an expression as an immediate value)
-+ AMD64 and i386 have been merged to one common architecture `common86'
-+ AMD64: some MOV's and XOR's were replaced with MOVZX's
-
-Version 0.5.2.1
-===============
-+ AMD64: fixed number of integer overflows preventing to run MyJIT on MacOS X
-+ i386: correct stack alignment on MacOS X
-
-Version 0.5.2.0
-===============
-+ removed some unnecessary register moves related to register allocation --
-argument passing on AMD64 and SPARC should be faster as well as some
-conditional and unconditional jumps
-+ fixed bugs preventing to compile multiple functions with one instance of the
-compiler
-+ fixed CALLR issue on AMD64
-
-Version 0.5.1.1
-===============
-+ big documentation update
-+ SPARC: passing of immediate floats has been fixed
-
-Version 0.5.1.0
-===============
-+ SPARC: support for floating-point arithmetics
-+ optimized RETVAL operation makes R_RET register almost useless
-
-Version 0.5.0.1
-===============
-+ fixed reg. allocator bug (all platforms)
-+ i386: fixed fret/fretval bug
-+ AMD64: fixed fp-argument passing bug
-+ i386+AMD64: allowed longer jumps
-
-Version 0.5.0.0
-===============
-+ AMD64: support for floating-point arithmetics
-+ jit_prepare() no longer requires its argument
-+ i386: optimized handling of single precision floating-point values
-+ new register numbering scheme
-+ jit_print_ops() allows more verbose output
-+ fixed memory leaks
-
-Version 0.4.0.0
-===============
-+ macros JIT_FP, JIT_RETREG, JIT_IMMREG have been removed
-+ PUSHARG have been replaced with PUTARG along with the argument passing order
-+ new operation DECLARE_ARG and new semantics of GETARG
-+ register count detection
-+ infrastructure for floating-point arithmetics (registers, etc.)
-+ experimental support for FP arithmetics (requires i386-based processor with
-SSE2)
-
-Version 0.3.2.0
-===============
-+ AMD64, i386: MUL, DIV, MOD, LSH, and RSH use push & pop only if necessary
-+ SPARC: optimized MUL, DIV, and MOD for some immediate values
-+ SPARC: call operation does not use the temporary register, i.e., it's 10%
-faster
-+ SPARC: fixed stack corruption and the appropriate test-case is included
-+ changing of large immediate values into a MOV and register-based operations
-became part of the jitlib-core
-+ fixed jit_print_ops()
-+ new operation MSG
-+ jit_print_ops() and jit_dump have renamed to jit_dump_ops() and
-jit_dump_code()
-+ registers JIT_FP and JIT_RETREG have new aliases R_FP and R_OUT,
-respectively
-
-Version 0.3.1.0
-===============
-+ support for SPARC
-
-Version 0.3.0.0
-===============
-+ support for an unlimited number of registers
-+ automatic buffer size adjustment, i.e., it is not necessary set the size of
-the output buffer in advance
-+ particular parts of x86 and AMD64 code has been merged
-+ configurable register allocator which can shared by multiple processor types
-+ red-black trees are used to implement register mappings and sets
-+ API changes
- + jit_init has only one argument
- + jit_call has the same meaning as the jit_finish (jit_finish was
- removed)
-
-Version 0.2.5.0
-================
-+ support for AMD64 (x86_64) processors
-+ CPU detection
-
-Version 0.2.4.2
-===============
-+ initial release
-+ only x86 based processors are supported
diff --git a/ext/myjit/doc/README b/ext/myjit/doc/README
deleted file mode 100755
index 0f379c8..0000000
--- a/ext/myjit/doc/README
+++ /dev/null
@@ -1,644 +0,0 @@
-=====
-MyJIT
-=====
-
-MyJIT is a library that allows to generate machine code at run-time and afterwards execute it. The project has started as a part of the Just-in-Time compiler of the Schemik (http://schemik.sourceforge.net) programming language and as a replacement for the GNU lightning library (http://www.gnu.org/software/lightning/) fixing some of its design issues. However, it has evolved into a more powerful tool. Therefore, MyJIT has a very similar instruction set as GNU lightning but it differs in some key aspects. The most important features which make MyJIT different or which should be highlighted are:
-
-+ support for an unlimited number of registers
-+ thread-safety
-+ support for the i386, AMD64, and SPARC processors
-+ convenient debugging
-+ easy to use and easy to extend design
-+ support for optimizations
-+ the library is fully embeddable
-+ particular backward compatibility with GNU lightning
-
-===============
-Instruction Set
-===============
-
-The instruction set of the MyJIT intermediate language is inspired by GNU lightning and in some aspects resembles architecture of RISC processors. Each operation has up to four operands which can be immediate values (numbers, constants) or registers. The number of available registers is virtually unlimited.
-
-All general purpose registers and integer values are treated as signed integers and have the same size which corresponds to the register size of the CPU. Note that i386 and SPARC processors have 32 bit wide registers and AMD64 has 64 bit wide registers. In order to overcome this inconsistency, MyJIT provides the ``jit_value`` type which has the same size as the CPU's general purpose register. In specific cases, e.g., if smaller or ``unsigned`` value is needed and it is appropriate, you may specify the size or type of the value. This topic is discussed later.
-
-All floating-point numbers and registers are internally treated as double precision values. However, if necessary, the value can be converted into a single precision value.
-
-Typically, name of each instruction consists of three parts:
-
-+ name of the operation (e.g., ``add`` for addition, ``mul`` for multiplication, etc.)
-+ the name of the operation is often accompanied with the suffix ``r`` or ``i`` indicating whether the operation is taking merely registers or if it also takes an immediate value as its argument
-+ name of the operation can be equipped with additional flag delimited by the underscore (typically, this is used to identify operations handling unsigned numbers)
-
-Registers
----------
-
-MyJIT supports arbitrary number of register. If the number of used registers is higher than the number of available hardware registers, MyJIT emulates them. Nevertheless, to achieve the best performance, it is a good practice not to use too many registers. All registers are denoted by positive integers including zero. To refer to these registers you should use macros ``R(x)`` and ``FR(x)`` identifying general purpose and floating point registers, respectively. Note that registers ``R(x)`` and ``FR(x)`` are completely different register and do not occupy the same space.
-
-Besides, MyJIT has two special purpose registers---R_FP and R_OUT. R_FP serves as the frame pointer and is used to access dynamically allocated memory on the stack. The R_OUT can be used to handle the return values more efficiently. It can be used to read the return value right after the return from the function. Otherwise, the value of the register is undefined. Furthermore, it can be used right before the return from the function to set the return value more efficiently. If the value is set earlier, it can lead to undefined behavior. However, in most cases register allocator can optimize this which makes this register almost obsolete.
-
-Notation
---------
-
-In order to describe instruction set, we are using symbols ``reg`` and ``freg`` to denote general purpose and floating-point registers, respectively. Analogously, ``imm`` and ``fimm`` denote immediate integer values and floating-point values. Particular instructions (e.g., load and store operations) have an extra operand which specifies the size (number of bytes) of data they work with. This operand shall be denoted by ``size`` and ``fsize``. The value passed by the operand ``size`` can be 1, 2, 4, or 8. However, only the AMD64 port supports operation processing 8 bytes long values. The value passed by the operand ``fsize`` can be either 4 or 8. In other words, ``fsize`` denotes precision of the value.
-
-Instructions
-------------
-
-Transfer Operations
-...................
-These operations allow to assign a value into a register. The first operand is always a register and the second one can be either an immediate value or register.
-
-::
-
- movi reg, imm O1 := O2
- movr reg, reg O1 := O2
-
- fmovr freg, freg O1 := O2
- fmov freg, fimm O1 := O2
-
-
-Binary Arithmetic Operations
-............................
-Each binary arithmetic operation has exactly three operands. First two operands are always registers and the last one can be an immediate value or register. These operations are fully compatible with those in the GNU lightning instruction set.
-
-::
-
- addr reg, reg, reg O1 := O2 + O3
- addi reg, reg, imm O1 := O2 + O3
- addxr reg, reg, reg O1 := O2 + (O3 + carry)
- addxi reg, reg, imm O1 := O2 + (O3 + carry)
- addcr reg, reg, reg O1 := O2 + O3, set carry
- addci reg, reg, imm O1 := O2 + O3, set carry
-
- subr reg, reg, reg O1 := O2 - O3
- subi reg, reg, imm O1 := O2 - O3
- subxr reg, reg, reg O1 := O2 - (O3 + carry)
- subxi reg, reg, imm O1 := O2 - (O3 + carry)
- subcr reg, reg, reg O1 := O2 - O3, set carry
- subci reg, reg, imm O1 := O2 - O3, set carry
- rsbr reg, reg, reg O1 := O3 - O2
- rsbi reg, reg, imm O1 := O3 - O2
-
- mulr reg, reg, reg O1 := O2 * O3
- muli reg, reg, imm O1 := O2 * O3
- hmulr reg, reg, reg O1 := high bits of O2 * O3
- hmuli reg, reg, imm O1 := high bits of O2 * O3
-
- divr reg, reg, reg O1 := O2 / O3
- divi reg, reg, imm O1 := O2 / O3
- modr reg, reg, reg O1 := O2 % O3
- modi reg, reg, imm O1 := O2 % O3
-
- andr reg, reg, reg O1 := O2 & O3
- andi reg, reg, imm O1 := O2 & O3
- orr reg, reg, reg O1 := O2 | O3
- ori reg, reg, imm O1 := O2 | O3
- xorr reg, reg, reg O1 := O2 ^ O3
- xori reg, reg, imm O1 := O2 ^ O3
-
- lshr reg, reg, reg O1 := O2 << O3
- lshi reg, reg, imm O1 := O2 << O3
- rshr reg, reg, reg O1 := O2 >> O3
- rshi reg, reg, imm O1 := O2 >> O3
- rshr_u reg, reg, reg O1 := O2 >> O3 (unsigned variant)
- rshi_u reg, reg, imm O1 := O2 >> O3 (unsigned variant)
-
-Operations ``subx`` and ``addx`` have to directly follow ``subc`` and ``addc`` otherwise the result is undefined. Note that you can use the ``unsigned`` flag with the ``rshr`` operation to propagate the first bit accordingly.
-
-There are also equivalent operations for floating-point values.
-
-::
-
- faddr freg, freg, freg O1 := O2 + O3
- faddi freg, freg, fimm O1 := O2 + O3
- fsubr freg, freg, freg O1 := O2 - O3
- fsubi freg, freg, fimm O1 := O2 - O3
- frsbr freg, freg, freg O1 := O3 - O2
- frsbi freg, freg, fimm O1 := O3 - O2
- fmulr freg, freg, freg O1 := O2 * O3
- fmuli freg, freg, fimm O1 := O2 * O3
- fdivr freg, freg, freg O1 := O2 / O3
- fdivi freg, freg, fimm O1 := O2 / O3
-
-
-Unary Arithmetic Operations
-...........................
-These operations have two operands, both of which have to be registers.
-
-::
-
- negr reg O1 := -O2
- notr reg O1 := ~O2
- fnegr freg O1 := -O2
-
-Load Operations
-...............
-These operations transfer data from the memory into a register. Each operation has 3 or 4 operands. The last operand is an immediate value indicating the "size" of the data processed by this operation, i.e., a number of bytes copied from the memory to the register. It can be one of the following values: 1, 2, 4, or 8. Furthermore, the ``size`` cannot be larger than the size of the register. If the size of the data copied from the memory is smaller than the size of the register, the value is expanded to fit the entire register. Therefore, it may be necessary to specify additional sign flag.
-
-::
-
- ldr reg, reg, size O1 := *O2
- ldi reg, imm, size O1 := *O2
- ldr_u reg, reg, size O1 := *O2 (unsigned variant)
- ldi_u reg, imm, size O1 := *O2 (unsigned variant)
-
- ldxr reg, reg, reg, size O1 := *(O2 + O3)
- ldxi reg, reg, imm, size O1 := *(O2 + O3)
- ldxr_u reg, reg, reg, size O1 := *(O2 + O3) (unsigned variant)
- ldxi_u reg, reg, imm, size O1 := *(O2 + O3) (unsigned variant)
-
- fldr freg, reg, fsize O1 := *O2
- fldi freg, imm, fsize O1 := *O2
-
- fldxr freg, reg, reg, fsize O1 := *(O2 + O3)
- fldxi freg, reg, imm, fsize O1 := *(O2 + O3)
-
-
-Store Operations
-................
-These operations transfer data from the register into the memory. Each operation has 3 or 4 operands. The last operand is an immediate value and indicates the "size" of the data, see "Load Operations" for more details. The first operand can be either an immediate or register. Other operands must be registers.
-
-::
-
- str reg, reg, size *O1 := O2
- sti imm, reg, size *O1 := O2
-
- stxr reg, reg, reg, size *(O1 + O2) := O3
- stxi imm, reg, reg, size *(O1 + O2) := O3
-
- fstr reg, freg, fsize *O1 := O2
- fsti imm, freg, fsize *O1 := O2
-
- fstxr reg, reg, freg, fsize *(O1 + O2) := O3
- fstxi imm, reg, freg, fsize *(O1 + O2) := O3
-
-
-Compare Instructions
-....................
-These operations compare last two operands and store one or zero (if the condition was met or not, respectively) into the first operand. All these operations have three operands. The first two operands have to be registers and the last one can be either a register or an immediate value.
-
-::
-
- ltr reg, reg, reg O1 := (O2 < O3)
- lti reg, reg, imm O1 := (O2 < O3)
- ltr_u reg, reg, reg O1 := (O2 < O3) (unsigned variant)
- lti_u reg, reg, imm O1 := (O2 < O3) (unsigned variant)
-
- ler reg, reg, reg O1 := (O2 <= O3)
- lei reg, reg, imm O1 := (O2 <= O3)
- ler_u reg, reg, reg O1 := (O2 <= O3) (unsigned variant)
- lei_u reg, reg, imm O1 := (O2 <= O3) (unsigned variant)
-
- gtr reg, reg, reg O1 := (O2 > O3)
- gti reg, reg, imm O1 := (O2 > O3)
- gtr_u reg, reg, reg O1 := (O2 > O3) (unsigned variant)
- gti_u reg, reg, imm O1 := (O2 > O3) (unsigned variant)
-
- ger reg, reg, reg O1 := (O2 >= O3)
- gei reg, reg, imm O1 := (O2 >= O3)
- ger_u reg, reg, reg O1 := (O2 >= O3) (unsigned variant)
- gei_u reg, reg, imm O1 := (O2 >= O3) (unsigned variant)
-
- eqr reg, reg, reg O1 := (O2 == O3)
- eqi reg, reg, imm O1 := (O2 == O3)
-
- ner reg, reg, reg O1 := (O2 != O3)
- nei reg, reg, imm O1 := (O2 != O3)
-
-Conversions
-...........
-Register for integer and floating-pint values are independent and in order to convert value from one type to another you have to use one of the following operations.
-
-::
-
- extr freg, reg O1 := O2
- truncr reg, freg O1 := trunc(O2)
- ceilr reg, freg O1 := ceil(O2)
- floorr reg, freg O1 := floor(O2)
- roundr reg, freg O1 := round(O2)
-
-
-The operation ``truncr`` rounds the value towards zero and is the fastest one. Operations ``floorr`` and ``ceilr`` rounds the value towards negative or positive infinity, respectively. ``roundr`` rounds the given value to the nearest integer.
-
-
-Function declaration
-....................
-The following operations and auxiliary macros help to create a function, read its arguments, and return value.
-
-+ Operation ``prolog imm`` has one operand which is an immediate value, which is a reference to a pointer of the function defined by the intermediate code. In other words, MyJIT generates machine code for a function which resides somewhere in the memory. The address of the functions is handed by this reference. See the "Getting started" section, for more details and for an illustrative example.
-
-+ Operations ``retr reg``, ``reti imm``, ``fretr freg, fsize``, and ``freti freg, fsize`` set the return value and return control to the calling procedure (or function).
-
-+ Operation ``declare_arg imm, imm`` is not an actual operation but rather an auxiliary function which declares the type of the argument and its size (in this order); ``declare_arg`` can take the following types of arguments
-
- + ``JIT_SIGNED_NUM`` -- signed integer number
- + ``JIT_UNSIGNED_NUM`` -- unsigned integer number
- + ``JIT_FLOAT`` -- floating-point number
- + ``JIT_PTR`` -- pointer
-
-+ To read an argument there are ``getarg reg, imm`` and ``getarg freg, imm`` operations having two arguments. The destination register where the input argument will be stored and the immediate value which identifies position of the argument.
-
-+ Operation ``allocai imm`` reserves space on the stack which has at least the size specified by its operand. Note that the stack space may be aligned to some higher value. The macro returns an integer number which is an *offset from the frame pointer R_FP!*
-
-
-Function calls
-..............
-Each function call is done in three steps. The call is initiated by the operation ``prepare`` having no argument. In the second step, arguments are passed to a function using ``putarg`` or ``fputarg``. (The arguments are passed in the normal order not in reverse, cf. GNU Lightning.) Afterwards, the function is called with the ``call`` operation. To retrieve the returned value you can use operations ``retval`` or ``fretval``.
-
-Let us make few notes on function calls:
-
-+ If calling a function defined in the same instance of the compiler (e.g., recursive function), you cannot pass values through registers. Each function has its own set of registers.
-
-+ Only ``putargr``, ``putargi``, ``fputargr``, and ``fputargi`` operations are allowed inside the ``prepare-call`` block, otherwise, the behavior of the library is unspecified.
-
-List of operations related to function calls:
-
-+ ``prepare`` -- prepares function call (generic)
-+ ``putargr reg`` -- passes an argument to a function
-+ ``putargi imm`` -- passes an argument to a function
-+ ``fputargr freg, fsize`` -- passes the argument to a function
-+ ``fputargi fimm, fsize`` -- passes the argument to a function
-+ ``call imm`` -- calls a function
-+ ``callr reg``
-+ ``retval reg`` -- reads return value
-+ ``fretval freg, fsize`` -- reads return value
-
-Jumps
-.....
-Operations ``jmpi`` and ``jmpr`` can be used to implement unconditional jumps. Both operations have one operand, an address to jump to. To obtain this address you can use the ``get_label`` operation or use the forward declaration along with the ``patch`` operation.
-
-+ ``get_label`` is not an actual operation; it is a function that returns a ``jit_label`` value---value which corresponds to the current position in the code. This value can be passed to jmpi/call or to a branch operation.
-
-+ It may happen that one need to jump into a code which will be defined later. Therefore, one can use the forward declaration and set the address later. This means, one can declare that the operation ``jmpi`` or a branch operations jumps to the place defined by the JIT_FORWARD macro and store the pointer to the operation into some ``jit_op *`` value. To set the address later, there is the ``patch imm`` operation with an argument which is the patched operation. The following code illustrates the situation.
-
-::
-
- op = jmpi JIT_FORWARD
- ;
- ; some code
- ;
- patch op
-
-Branch Operations
-.................
-Branch operations represent conditional jumps and all have three operands. The first operand is an immediate value and represents the address to jump to. The latter two are values to be compared. The last operand can be either an immediate value or register.
-
-::
-
- bltr imm, reg, reg if (O2 < O3) goto O1
- blti imm, reg, imm if (O2 < O3) goto O1
- bltr_u imm, reg, reg if (O2 < O3) goto O1
- blti_u imm, reg, imm if (O2 < O3) goto O1
-
- bler imm, reg, reg if (O2 <= O3) goto O1
- blei imm, reg, imm if (O2 <= O3) goto O1
- bler_u imm, reg, reg if (O2 <= O3) goto O1
- blei_u imm, reg, imm if (O2 <= O3) goto O1
-
- bgtr imm, reg, reg if (O2 > O3) goto O1
- bgti imm, reg, imm if (O2 > O3) goto O1
- bgtr_u imm, reg, reg if (O2 > O3) goto O1
- bgti_u imm, reg, imm if (O2 > O3) goto O1
-
- bger imm, reg, reg if (O2 >= O3) goto O1
- bgei imm, reg, imm if (O2 >= O3) goto O1
- bger_u imm, reg, reg if (O2 >= O3) goto O1
- bgei_u imm, reg, imm if (O2 >= O3) goto O1
-
- beqr imm, reg, reg if (O2 == O3) goto O1
- beqi imm, reg, imm if (O2 == O3) goto O1
- bner imm, reg, reg if (O2 != O3) goto O1
- bnei imm, reg, imm if (O2 != O3) goto O1
-
- bmsr imm, reg, reg if (O2 & O3) goto O1
- bmsi imm, reg ,imm if (O2 & O3) goto O1
- bmcr imm, reg ,reg if !(O2 & O3) goto O1
- bmci imm, reg ,imm if !(O2 & O3) goto O1
-
- boaddr imm, reg, reg O2 += O3, goto O1 on overflow
- boaddi imm, reg, imm O2 += O3, goto O1 on overflow
- bnoaddr imm, reg, reg O2 += O3, goto O1 on not overflow
- bnoaddi imm, reg, imm O2 += O3, goto O1 on not overflow
-
- bosubr imm, reg, reg O2 -= O3, goto O1 on overflow
- bosubi imm, reg, imm O2 -= O3, goto O1 on overflow
- bnosubr imm, reg, reg O2 -= O3, goto O1 on not overflow
- bnosubi imm, reg, imm O2 -= O3, goto O1 on not overflow
-
- fbltr imm, freg, freg if (O2 < O3) goto O1
- fblti imm, freg, fimm if (O2 < O3) goto O1
- fbler imm, freg, freg if (O2 <= O3) goto O1
- fblei imm, freg, fimm if (O2 <= O3) goto O1
-
- fbgtr imm, freg, freg if (O2 > O3) goto O1
- fbgti imm, freg, fimm if (O2 > O3) goto O1
- fbger imm, freg, freg if (O2 >= O3) goto O1
- fbgei imm, freg, fimm if (O2 >= O3) goto O1
-
- fbeqr imm, freg, freg if (O2 == O3) goto O1
- fbeqi imm, freg, fimm if (O2 == O3) goto O1
- fbner imm, freg, freg if (O2 != O3) goto O1
- fbnei imm, freg, fimm if (O2 != O3) goto O1
-
-Misc
-....
-There is an operation that allows to emit raw bytes of data into a generated code:
-
-::
-
- data_byte imm
-
-This operation emits only one byte to a generated code. For convenience there are auxiliary macros emitting a sequence of bytes, string of chars (including the trailing \0), empty area, and values of common sizes, respectively.
-
-::
-
- jit_data_bytes(struct jit *jit, int count, unsigned char *data)
- jit_data_str(jit, str)
- jit_data_emptyarea(jit, size)
- jit_data_word(jit, a)
- jit_data_dword(jit, a)
- jit_data_qword(jit, a)
-
-If you are emitting raw data into a code, it is your responsibility to properly align code. For this purpose there is an operation:
-
-::
-
- jit_align imm
-
-
-This operation takes care of proper code alignment. Note that particular platforms have their specific requirements. On SPARC all instructions have to be aligned to 4 bytes, AMD64 favors alignment to 16 bytes, but it is not mandatory, etc. Safe bet is to use 16 as an operand of this operation.
-
-To obtain reference to a data or code you can use two operations:
-
-::
-
- ref_data reg, imm
- ref_code reg, imm
-
-That loads address of the label (second operand) into a register. The ref_data operation is intended for addresses of data (emitted with data_* operations) and ref_code is for address within an ordinary code. Note that address obtained with ref_code can be used only for local jumps inside a function. If necessary, for instance, if a some sort of branch table is needed, it is possible to emit address as a data with two operations.
-
-::
-
- data_code imm
- data_data imm
-
-
-Note that mixing code and data may not be a generally good idea and may lead to various issues, e.g. poor performance, weird behavior, etc. Albeit this feature is part of the library, users are encouraged to place data to some specific part of code (for instance, to the end of code) or use data that are not part of the code and are allocated elsewhere, for instance, with ordinary ``malloc``.
-
-===============
-Getting Started
-===============
-
-We start with a really simple example---function returning its argument incremented by one. The source code of this example can be found in ``demo1.c`` which is part of the MyJIT package.
-
-.. sourcecode:: c
-
- #include <stdlib.h>
- #include <stdio.h>
-
- // includes the header file
- #include "myjit/jitlib.h"
-
- // pointer to a function accepting one argument of type long and returning long value
- typedef long (* plfl)(long);
-
- int main()
- {
- // creates a new instance of the compiler
- struct jit * p = jit_init();
-
- plfl foo;
-
- // the code generated by the compiler will be assigned to the function `foo'
- jit_prolog(p, &foo);
-
- // the first argument of the function
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- // moves the first argument into the register R(0)
- jit_getarg(p, R(0), 0);
-
- // takes the value in R(0), increments it by one, and stores the result into the
- // register R(1)
- jit_addi(p, R(1), R(0), 1);
-
- // returns from the function and returns the value stored in the register R(1)
- jit_retr(p, R(1));
-
- // compiles the above defined code
- jit_generate_code(p);
-
- // checks, if it works
- printf("Check #1: %li\n", foo(1));
- printf("Check #2: %li\n", foo(100));
- printf("Check #3: %li\n", foo(255));
-
- // if you are interested, you can dump the machine code
- // this functionality is provided through the `gcc' and `objdump'
- // jit_dump_ops(p, JIT_DEBUG_CODE);
-
- // cleanup
- jit_free(p);
- return 0;
- }
-
-We assume that the code above is quite (self-)explanatory, and thus, we do not include more comments on this. However, let us make a note on compiling programs using MyJIT. To start with MyJIT, it is sufficient to copy the ``myjit`` subdirectory into your project. Programs using the MyJIT should include the ``#include "myjit/jitlib.h"`` header file. In order to link the application and build a proper executable file, it is necessary to also compile ``"myjit/libjit-core.c"``.
-
-For instance, to build a program with ``gcc`` you may use the following steps:
-
-.. sourcecode:: bash
-
- gcc -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 demo1.c
- gcc -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 myjit/jitlib-core.c
- gcc -o demo1 -g -Wall -std=c99 -pedantic demo1.o jitlib-core.o
-
-The first command compiles the example, the second one compiles functions used by MyJIT, and the last one links the object files together and creates an execute file---``demo1``.
-
-It should be emphasized that MyJIT conforms to the C99 standard and all MyJIT files should be compiled according to this standard.
-
-We also recommend to check out the ``demo2.c`` and ``demo3.c`` examples which are also included in the MyJIT package.
-
-=========
-Debugging
-=========
-
-Debugging messages
-------------------
-
-MyJIT contains several tools simplifying development. One of them is the ``msg`` operation which prints out the given message or a value of the given register. The ``msg`` operation has one or two operands. The first one is always an immediate value which is the string to display. The second operand is optional and it must be a register. In this case the first string serves as the format string for ``printf`` and the value of the register is printed out using this string. The example of the ``msg`` operation usage:
-
-.. sourcecode:: c
-
- jit_msg(jit, "Simple message\n");
- jit_msgr(jit, "Reg 1: %l\n", R(1));
-
-
-Warnings
---------
-One of the MyJIT's goals is to achieve maximal performance while emitting code. Thus, it does not do many checks while generating machine code from the intermediate language. Therefore, if the code in the intermediate language contains an error, it leads to a faulty machine code, and subsequently to a crash of the program. In order to avoid such errors, MyJIT contains a function:
-
-.. sourcecode:: c
-
- void jit_check_code(struct jit *jit, int warnings);
-
-Which can be called before code generation and which can point out to the most common errors. In the second argument you may specify if you want to be warned about all types of errors (``JIT_WARN_ALL``) or you can pick only some of them from the following list:
-
-+ ``JIT_WARN_DEAD_CODE`` -- detects unreachable code
-+ ``JIT_WARN_OP_WITHOUT_EFFECT`` -- displays warnings about operations without effect
-+ ``JIT_WARN_INVALID_DATA_SIZE`` -- displays warning if the size operand does not contain a valid value (i.e., 1, 2, 4, or 8)
-+ ``JIT_WARN_UNINITIALIZED_REG`` -- displays warning if an uninitialized register is used
-+ ``JIT_WARN_REGISTER_TYPE_MISMATCH`` -- displays warning if a general purpose register is used in place where the floating point register is expected, or vice versa
-+ ``JIT_WARN_MISSING_PATCH`` -- reports all jump operations with a ``JIT_FORWARD`` declaration but without corresponding ``patch``
-+ ``JIT_WARN_UNALIGNED_CODE`` -- displays warning if the code follows data section without alignment
-+ ``JIT_WARN_INVALID_CODE_REFERENCE`` -- displays warning if ``ref_code`` or ``data_code`` is referring to a data and not to a valid code
-+ ``JIT_WARN_INVALID_DATA_REFERENCE`` -- displays warning if ``ref_data`` or ``data_data`` is referring to a code and not to a data
-+ ``JIT_WARN_ALL`` -- displays all warnings
-
-
-
-Code listing
-------------
-
-In real programs is MyJIT typically called from various functions and code is constructed in several steps, thus it is sometimes difficult to figure out, how the code looks like. Therefore, MyJIT provides several means allowing to inspect final code in the intermediate language as well as in the machine code. This functionality is provided through the ``jit_dump_ops`` function. In the second argument you may specify if you want to list:
-
-+ list of all operations in the intermediate language (``JIT_DEBUG_OPS``)
-+ generated machine code (``JIT_DEBUG_CODE``)
-+ combination of both -- MyJIT operations and machine code (``JIT_DEBUG_COMBINED``)
-
-To make the navigation through the listing easier, we have included one auxiliary operation:
-
-::
-
- comment imm
-
-Which has only one argument -- string which will appear only in the dumps.
-
-
-*NOTICE!* Do not use debugging operations and functions in the production code. These operations are not efficient and may lead to a poor performance. You should rather call the ``printf`` function explicitly. The ``jit_dump_ops`` with the ``JIT_DEBUG_CODE`` is using ``gcc`` and ``objdump`` to disassemble the code, therefore, these two programs have to be present in the system, or, on OS X ``clang`` and ``otool`` are used. The ``JIT_DEBUG_COMBINED`` option requires ``myjit-disasm`` disassembler in the directory along with the debugged program, or the path to the disassembler has to be specified in the ``MYJIT_DISASM`` environment variable.
-
-Examples of the outputs for the above mentioned source code.
-
-Example of the IL listing (``JIT_DEBUG_OPS``)
-.............................................
-
-::
-
- prolog 0xbfe62858
- declarg integer, 0x4
- getarg r0, 0x0
- addi r1, r0, 0x1
- retr r1
-
-
-
-Example of the machine code listing (``JIT_DEBUG_CODE``)
-........................................................
-
-::
-
- 0000000000000000 <main>:
- 0: 55 push rbp
- 1: 48 8b ec mov rbp,rsp
- 4: 48 83 ec 20 sub rsp,0x20
- 8: 48 8b f7 mov rsi,rdi
- b: 48 8d 46 01 lea rax,[rsi+0x1]
- f: 48 8b e5 mov rsp,rbp
- 12: 5d pop rbp
- 13: c3 ret
-
-
-
-Example of the combined listing (``JIT_DEBUG_COMBINED``)
-........................................................
-
-::
-
- prolog 0x7fffa0371db0
- 0000: 55 push rbp
- 0001: 48 8b ec mov rbp, rsp
- 0004: 48 83 ec 20 sub rsp, 0x20
-
- declare_arg integer, 0x8
- getarg r0, 0x0
- 0008: 48 8b f7 mov rsi, rdi
-
- addi r1, r0, 0x1
- 000b: 48 8d 46 01 lea rax, [rsi+0x1]
-
- retr r1
- 000f: 48 8b e5 mov rsp, rbp
- 0012: 5d pop rbp
- 0013: c3 ret
-
-
-
-=============
-Optimizations
-=============
-Support for multiple optimizations is available since release 0.7. These optimizations may speed up your code but the code generation may take longer. Therefore, you can turn particular optimization off and on using ``jit_disable_optimization`` and ``jit_enable_optimization`` functions, respectively. Currently, there are available the following optimizations:
-
-+ ``JIT_OPT_OMIT_UNUSED_ASSIGNEMENTS`` -- compiler skips unused assignments. (Turned off by default.)
-+ ``JIT_OPT_JOIN_ADDMUL`` -- if possible, compiler joins adjacent ``mul`` and ``add`` (or two ``add``'s) into one ``LEA`` operation (Turned on by default.)
-+ ``JIT_OPT_OMIT_FRAME_PTR`` -- if possible, compiler skips prolog and epilogue of the function. This significantly speeds up small functions. (Turned on by default.)
-
-The optimized code for above mentioned example looks like this:
-
-::
-
- 00000000 <main>:
- 0: 8b 4c 24 04 mov ecx,DWORD PTR [esp+0x4]
- 4: 8d 41 01 lea eax,[ecx+0x1]
- 7: c3 ret
-
-Or, like this:
-
-::
-
- 0000000000000000 <main>:
- 0: 48 8d 47 01 lea rax,[rdi+1]
- 4: c3 ret
-
-========
-Download
-========
-
-Getting MyJIT
--------------
-
-The source code including this documentation and examples is available at SourceForge (http://sourceforge.net/projects/myjit/files) as of other information (http://sourceforge.net/projects/myjit)
-
-You can also checkout the latest release from the GIT repository:
-
-::
-
- git clone git://git.code.sf.net/p/myjit/maincode myjit-maincode
-
-Documentation
--------------
-
-Documentation is available in the ``doc/`` directory and on the project's website as a text file, `PDF file <http://myjit.sourceforge.net/readme.pdf>`_, or as a `single HTML page <http://myjit.sourceforge.net/readme.htm>`_.
-
-License
--------
-MyJIT is distributed under the terms of GNU Lesser General Public License v.3 or later (at your option).
-
-Despite the fact that MyJIT is very similar to GNU Lightning, it does not share any source code with this project. However, some files come from the Mono project by Novel. (http://www.mono-project.com)
-
-====================
-Notes on Development
-====================
-
-+ The primary use of this library is in our compiler of the Schemik programming language and the development of this library is driven by requirements of this compiler. Nevertheless, MyJIT is a general purpose library and its functionality is not limited.
-
-+ The library is almost complete and each release undergoes extensive testing (hundreds of tests), therefore, we hope there are no serious bugs. If you found any, please, let us know.
-
-+ Despite the fact that the library is almost complete, it is still under development and the API may slightly (but not much) change in the near future.
-
-+ Only the i386, AMD64, and SPARC platforms are supported right now, however, port to other architecture should be easy and straightforward.
-
-+ At this moment, MyJIT has support for floating point arithmetics. However, i386 port supports only processors having SSE2 unit, i.e., floating-point operations won't work on legacy CPUs without this unit.
-
-+ If you are using this library or if you want to contribute some code (e.g., port to some architecture), please, let us know.
-
-+ The documentation lacks information on internals of MyJIT. This is purely intentional because the library is still developed. We expect that the quality of the documentation will improve with the maturity of the project. If in doubts, ask in the mailing list (myjit-devel@lists.sourceforge.net). If you would like to participate on documentation improvements, please let us know, we will really appreciate it.
-
diff --git a/ext/myjit/doc/TODO b/ext/myjit/doc/TODO
deleted file mode 100755
index 43cd3da..0000000
--- a/ext/myjit/doc/TODO
+++ /dev/null
@@ -1,45 +0,0 @@
-ROADMAP
-=======
-
-+ release 0.7.0
- * optimizations
- * add + mul
- * shl + or
- * add + add
- * frame pointer
- * unused variables
-
-+ release 0.7.1
- * removed warnings
- * bug in JIT_OPT_JOIN_ADDMUL
- * opcodes as an enum
- * label to register operation
- * align operation
- * raw data in code
- * bogus demo.c file
- * all globals with the jit/JIT prefix
- * floating point comparisons
-
-+ release 0.8.0
- * warnings:
- * basic API
- * unused assignments
- * unused arguments
- * uninitialized registers
- * register type mismatches
-
-
-+ release 0.9.0
- * integrated disassambler
- * documentation update
- * op-codes reorganization
- * i386 testing
- * amd64 testing
- * sparc testing
-
-
-+ release 1.0.0
- + reg. allocator should be aware of operations having particular requirements on registers, e.g., MUL, DIV, SHL.
- + addmul+add
- + ld/st -> membase/memindex conversion
- + cpu detection
diff --git a/ext/myjit/doc/build/Makefile b/ext/myjit/doc/build/Makefile
deleted file mode 100755
index c85f31f..0000000
--- a/ext/myjit/doc/build/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-all: README html web pdf
-
-README: src/*
- cat src/01-About src/03-Instruction-set src/04-Getting-started src/05-Debugging src/06-Optimizations src/02-Download src/07-Notes > ../README
-
-html: README assets/*.css
- cat assets/main.css assets/code-style.css > assets/final-style.css
- rst2html -d -t --embed-stylesheet --stylesheet-path="assets/final-style.css" ../README > readme.htm
- cp readme.htm ../
-
-web: src/* assets/*.css assets/template.htm
- mkdir -p web
- cat assets/web-main.css assets/code-style.css > assets/final-style.css
- cd src; \
- for a in *; do \
- echo $$a; \
- rst2html --embed-stylesheet --stylesheet-path="../assets/final-style.css" --template="../assets/template.htm" $$a | grep -v "</body>\|</html>" > ../web/$$a.htm; \
- echo -e "</body>\n</html>\n" >> ../web/$$a.htm; \
- done
- cat web/01-About.htm | sed -e 's/<h1 class="title">/<h1 class="title">About /' > web/index.htm
-
-pdf: README assets/xetex-template.tex
- mkdir -p latex
- rst2xetex --template=assets/xetex-template.tex --use-verbatim-when-possible ../README | sed -e 's/section{MyJIT/section{About MyJIT/' > latex/readme.tex
- cd latex; xelatex readme.tex; xelatex readme.tex
- cp latex/readme.pdf ../
-
-clean:
- rm -f README
- rm -f readme.htm
- rm -f assets/final-style.css
- rm -fr web
- rm -fr latex
-
diff --git a/ext/myjit/doc/build/assets/code-style.css b/ext/myjit/doc/build/assets/code-style.css
deleted file mode 100755
index 60133de..0000000
--- a/ext/myjit/doc/build/assets/code-style.css
+++ /dev/null
@@ -1,62 +0,0 @@
-.hll { background-color: #ffffcc }
-.comment { color: #408080; /* font-style: italic*/ } /* Comment */
-.err { border: 1px solid #FF0000 } /* Error */
-.k { color: #008000; font-weight: bold } /* Keyword */
-.o { color: #666666 } /* Operator */
-.cm { color: #408080; font-style: italic } /* Comment.Multiline */
-.preproc { color: #BC7A00 } /* Comment.Preproc */
-.single { color: #408080; font-style: italic } /* Comment.Single */
-.cs { color: #408080; font-style: italic } /* Comment.Special */
-.gd { color: #A00000 } /* Generic.Deleted */
-.ge { font-style: italic } /* Generic.Emph */
-.gr { color: #FF0000 } /* Generic.Error */
-.gh { color: #000080; font-weight: bold } /* Generic.Heading */
-.gi { color: #00A000 } /* Generic.Inserted */
-.go { color: #888888 } /* Generic.Output */
-.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
-.gs { font-weight: bold } /* Generic.Strong */
-.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
-.gt { color: #0044DD } /* Generic.Traceback */
-.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
-.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
-.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
-.keyword { color: #008000; font-weight: bold; } /* Keyword.Pseudo */
-.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
-.type { color: #B00040 } /* Keyword.Type */
-.m { color: #666666 } /* Literal.Number */
-.s { color: #BA2121 } /* Literal.String */
-.na { color: #7D9029 } /* Name.Attribute */
-.nb { color: #008000 } /* Name.Builtin */
-.nc { color: #0000FF; font-weight: bold } /* Name.Class */
-.no { color: #880000 } /* Name.Constant */
-.nd { color: #AA22FF } /* Name.Decorator */
-.ni { color: #999999; font-weight: bold } /* Name.Entity */
-.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
-.function { color: #0000FF } /* Name.Function */
-.nl { color: #A0A000 } /* Name.Label */
-.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
-.nt { color: #008000; font-weight: bold } /* Name.Tag */
-.nv { color: #19177C } /* Name.Variable */
-.operator { /*color: #AA22FF;*/ /*font-weight: bold*/ } /* Operator.Word */
-.w { color: #bbbbbb } /* Text.Whitespace */
-.mf { color: #666666 } /* Literal.Number.Float */
-.mh { color: #666666 } /* Literal.Number.Hex */
-.integer { color: #666666 } /* Literal.Number.Integer */
-.mo { color: #666666 } /* Literal.Number.Oct */
-.sb { color: #BA2121 } /* Literal.String.Backtick */
-.string { color: #BA2121 } /* Literal.String.Char */
-.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
-.s2 { color: #BA2121 } /* Literal.String.Double */
-.escape { color: #BB6622;/* font-weight: bold */} /* Literal.String.Escape */
-.sh { color: #BA2121 } /* Literal.String.Heredoc */
-.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
-.sx { color: #008000 } /* Literal.String.Other */
-.sr { color: #BB6688 } /* Literal.String.Regex */
-.s1 { color: #BA2121 } /* Literal.String.Single */
-.ss { color: #19177C } /* Literal.String.Symbol */
-.bp { color: #008000 } /* Name.Builtin.Pseudo */
-.vc { color: #19177C } /* Name.Variable.Class */
-.vg { color: #19177C } /* Name.Variable.Global */
-.vi { color: #19177C } /* Name.Variable.Instance */
-.il { color: #666666 } /* Literal.Number.Integer.Long */
-
diff --git a/ext/myjit/doc/build/assets/ga.htm b/ext/myjit/doc/build/assets/ga.htm
deleted file mode 100755
index 1a8c579..0000000
--- a/ext/myjit/doc/build/assets/ga.htm
+++ /dev/null
@@ -1,9 +0,0 @@
-<script>
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
- ga('create', 'UA-16813798-1', 'auto');
- ga('send', 'pageview');
-</script>
diff --git a/ext/myjit/doc/build/assets/main.css b/ext/myjit/doc/build/assets/main.css
deleted file mode 100755
index 66a8023..0000000
--- a/ext/myjit/doc/build/assets/main.css
+++ /dev/null
@@ -1,71 +0,0 @@
-body {
- font-family: sans-serif;
- font-size: 10pt;
- margin-left: 10%;
- margin-right: 10%;
- background: white;
-}
-
-.title {
- font-size: 18pt;
-}
-
-h1 {
- color: #aa0000;
- font-size: 16pt;
- padding-bottom: 3pt;
- margin-top: 20pt;
- border-bottom: 1px solid #aa0000;
-}
-
-h2 {
- margin-top: 20pt;
- font-size: 13.5pt;
- color: #aa0000;
-}
-
-h3 {
- margin-top: 13pt;
- padding-top 0pt;
- font-size: 11.5pt;
- color: #aa0000;
- padding-bottom: 0px;
- margin-bottom: 0px;
-}
-
-
-
-pre, .pre, tt {
- color: #333333;
-}
-
-h3 tt {
- color: #aa0000;
-}
-
-
-a {
- color: #007700;
- text-decoration: none;
-}
-
-a:hover {
- color: #007700;
- text-decoration: underline;
-}
-
-hr {
- color: #aa0000;
- background-color: #aa0000;
- border: 0px;
- height: 1px;
-}
-
-.highlight {
- padding-top: 0px;
- padding-bottom: 0px;
- padding-left: 0px;
- padding-right: 0px;
- background: white;
- /*border: 1px solid #aa0000;*/
-}
diff --git a/ext/myjit/doc/build/assets/sflogo.htm b/ext/myjit/doc/build/assets/sflogo.htm
deleted file mode 100755
index ba55c47..0000000
--- a/ext/myjit/doc/build/assets/sflogo.htm
+++ /dev/null
@@ -1 +0,0 @@
-<a href="http://sourceforge.net/projects/myjit"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=325399&amp;type=16" width="150" height="40" alt="Get MyJIT at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a>
diff --git a/ext/myjit/doc/build/assets/template.htm b/ext/myjit/doc/build/assets/template.htm
deleted file mode 100755
index 3660b52..0000000
--- a/ext/myjit/doc/build/assets/template.htm
+++ /dev/null
@@ -1,40 +0,0 @@
-%(head_prefix)s
-%(head)s
-<link href='http://fonts.googleapis.com/css?family=Josefin+Sans|Gudea:400,400italic,700|Ubuntu+Mono:400,700' rel='stylesheet' type='text/css'>
-%(stylesheet)s
-%(body_prefix)s
-<div id="page">
-<ul class="mnu">
-<li class="mnu"><a href="index.htm">About</a></li>
-<li class="mnu"><a href="02-Download.htm">Download</a></li>
-<li class="mnu"><a href="03-Instruction-set.htm">Instruction set</a></li>
-<li class="mnu"><a href="04-Getting-started.htm">Getting started</a></li>
-<li class="mnu"><a href="05-Debugging.htm">Debugging</a></li>
-<li class="mnu"><a href="06-Optimizations.htm">Optimizations</a></li>
-<li class="mnu"><a href="07-Notes.htm">Notes</a></li>
-</ul>
-
-<div id="maincontent">
-<div id="banner">MyJIT library</div>
-%(body_pre_docinfo)s
-%(docinfo)s
-%(body)s
-<div id="footer">
-<div style="font: 8pt; widht: 200pt; margin-right: auto; display: inline-block; float: left;">
-&copy; Petr Krajča, 2015
-</div>
-<div style="margin-left: auto; width: 150px; margin-top: -7px;>"<a href="http://sourceforge.net/projects/myjit"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=325399&amp;type=16" width="150" height="40" alt="Get MyJIT at SourceForge.net. Fast, secure and Free Open Source software downloads"/></a></div>
-</div>
-</div>
-<script>
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
- ga('create', 'UA-16813798-1', 'auto');
- ga('send', 'pageview');
-</script>
-<br clear="both" />
-</div>
-%(body_suffix)s
diff --git a/ext/myjit/doc/build/assets/web-main.css b/ext/myjit/doc/build/assets/web-main.css
deleted file mode 100755
index be44fb2..0000000
--- a/ext/myjit/doc/build/assets/web-main.css
+++ /dev/null
@@ -1,124 +0,0 @@
-body {
-/* font-family: 'Pontano Sans', sans-serif;
- * */
-
- font-family: 'Gudea', sans-serif;
- font-size: 12pt;
- background: white;
- padding-top: 0px;
- margin-top: 0px;
-}
-
-#page {
- margin-left: auto;
- margin-right: auto;
- max-width: 900pt;
-}
-
-#maincontent {
- float: left;
- width: 80%;
-}
-
-#banner {
- font-family: 'Josefin Sans', sans-serif;
- background: #aa0000;
- display: block;
- color: white;
- font-size: 18pt;
- margin-left: auto;
- margin-right: auto;
- padding: 5pt;
- padding-bottom: 5pt;
-}
-
-.title {
- font-size: 18pt;
-}
-
-h1.title {
- font-family: 'Josefin Sans', sans-serif;
- color: #aa0000;
- font-size: 23pt;
- padding-bottom: 0pt;
- margin-top: 25pt;
- /*border-bottom: 1px solid #aa0000;*/
-}
-
-h1 {
- font-family: 'Josefin Sans', sans-serif;
- margin-top: 20pt;
- margin-bottom: 2pt;
- font-size: 17pt;
- color: #aa0000;
-}
-
-h2 {
- font-family: 'Josefin Sans', sans-serif;
- margin-top: 20pt;
- font-size: 14pt;
- color: #aa0000;
- padding-bottom: 0px;
- margin-bottom: -5pt;
-}
-
-li {
- margin-bottom: 5pt;
-}
-
-
-
-pre, .pre, tt {
- color: #333333;
- font-family: 'Ubuntu Mono' ;
-}
-
-h2 tt {
- color: #aa0000;
-}
-
-a {
- color: #007700;
- text-decoration: none;
-}
-
-a:hover {
- color: #007700;
- text-decoration: underline;
-}
-
-hr {
- color: #aa0000;
- background-color: #aa0000;
- border: 0px;
- height: 1px;
-}
-
-.highlight {
- padding-top: 0px;
- padding-bottom: 0px;
- padding-left: 0px;
- padding-right: 0px;
- background: white;
- /*border: 1px solid #aa0000;*/
-}
-
-ul.mnu li.mnu a {
- color: #aa0000;
-}
-
-ul.mnu li.mnu {
- margin-bottom: 10pt;
- list-style-type: none;
-}
-ul.mnu {
- width: 120pt;
- margin-top: 70pt;
- float: left;
-}
-
-#footer {
- padding: 20pt;
- border-top: 1px solid #aa0000;
- padding: 5pt;
-}
diff --git a/ext/myjit/doc/build/assets/xetex-template.tex b/ext/myjit/doc/build/assets/xetex-template.tex
deleted file mode 100755
index 064fbe9..0000000
--- a/ext/myjit/doc/build/assets/xetex-template.tex
+++ /dev/null
@@ -1,92 +0,0 @@
-$head_prefix% generated by Docutils <http://docutils.sourceforge.net/>
-% rubber: set program xelatex
-\usepackage[no-sscript]{xltxtra} % loads fixltx2e, metalogo, xunicode, fontspec
-% \defaultfontfeatures{Scale=MatchLowercase}
-$requirements
-%%% Custom LaTeX preamble
-%%% User specified packages and stylesheets
-\setmainfont{Droid Serif}
-\setsansfont{Josefin Sans}
-\setmonofont[HyphenChar=None,Scale=MatchLowercase]{Ubuntu Mono}
-
-\setcounter{secnumdepth}{3}
-
-\setcounter{secnumdepth}{3}
-\usepackage[a4paper,margin=2.5cm]{geometry}
-\linespread{1.5}
-
-\usepackage{xcolor}
-\definecolor{mygray}{RGB}{165,165,165}
-\usepackage{titlesec}
-\usepackage{ifthen}
-%\titleformat{\section}[display]
-%{\fontsize{27pt}{10pt}\sf} % format
-%{\newpage} % label
-%{0.5ex} % sep
-%{%
-%% \rule{\textwidth}{1pt}
-%\begin{flushright}
-%{\fontsize{56pt}{0pt}\sf
-%\color{mygray}
-%\ifthenelse{\equal{\thesection}{0}}{}{\arabic{section}}
-%}
-%} % before-code
-%[
-%\end{flushright}
-%\vspace{5ex}%
-%]
-\titleformat{\section}[display]
-{\fontsize{27pt}{10pt}\sf} % format
-{} % label
-{0.5ex} % sep
-{%
-% \rule{\textwidth}{1pt}
-\begin{flushright}
-{\fontsize{56pt}{0pt}\sf
-\color{mygray}
-\ifthenelse{\equal{\thesection}{0}}{}{\arabic{section}}
-}
-} % before-code
-[
-\end{flushright}
-\vspace{5ex}%
-]
-
-\let\stdsection\section
-\renewcommand\section{\newpage\stdsection}
-
-%\usepackage{fancyhdr}
-%\fancyhf{}
-%\lhead{ \fancyplain{}{\leftmark} }
-%\rhead{ \fancyplain{}{\thepage} }
-
-
-$stylesheet
-%%% Fallback definitions for Docutils-specific commands
-$fallbacks$pdfsetup
-$titledata
-%%% Body
-\begin{document}
-\thispagestyle{empty}
-~\vskip 4cm
-\begin{flushright}
-\noindent{\fontsize{27pt}{10pt} \sf MyJIT: Documentation} \\ [2.5mm]
-\Large{\sf version 0.9.0.x}\\
-\vspace{15cm}
-\Large{\sf Petr Krajča, 2015} \\ [4mm]
-{\sf
-Dept. Computer Science\\ [-3mm]
-Palacký University Olomouc\\
-}
-
-\end{flushright}
-\pagebreak
-\pagenumbering{roman}
-\setcounter{page}{1}
-\tableofcontents
-\pagebreak
-\pagestyle{plain}
-\pagenumbering{arabic}
-\setcounter{page}{1}
-$body_pre_docinfo$docinfo$dedication$abstract$body
-\end{document}
diff --git a/ext/myjit/doc/build/src/01-About b/ext/myjit/doc/build/src/01-About
deleted file mode 100755
index ea524b0..0000000
--- a/ext/myjit/doc/build/src/01-About
+++ /dev/null
@@ -1,15 +0,0 @@
-=====
-MyJIT
-=====
-
-MyJIT is a library that allows to generate machine code at run-time and afterwards execute it. The project has started as a part of the Just-in-Time compiler of the Schemik (http://schemik.sourceforge.net) programming language and as a replacement for the GNU lightning library (http://www.gnu.org/software/lightning/) fixing some of its design issues. However, it has evolved into a more powerful tool. Therefore, MyJIT has a very similar instruction set as GNU lightning but it differs in some key aspects. The most important features which make MyJIT different or which should be highlighted are:
-
-+ support for an unlimited number of registers
-+ thread-safety
-+ support for the i386, AMD64, and SPARC processors
-+ convenient debugging
-+ easy to use and easy to extend design
-+ support for optimizations
-+ the library is fully embeddable
-+ particular backward compatibility with GNU lightning
-
diff --git a/ext/myjit/doc/build/src/02-Download b/ext/myjit/doc/build/src/02-Download
deleted file mode 100755
index 46f93e3..0000000
--- a/ext/myjit/doc/build/src/02-Download
+++ /dev/null
@@ -1,26 +0,0 @@
-========
-Download
-========
-
-Getting MyJIT
--------------
-
-The source code including this documentation and examples is available at SourceForge (http://sourceforge.net/projects/myjit/files) as of other information (http://sourceforge.net/projects/myjit)
-
-You can also checkout the latest release from the GIT repository:
-
-::
-
- git clone git://git.code.sf.net/p/myjit/maincode myjit-maincode
-
-Documentation
--------------
-
-Documentation is available in the ``doc/`` directory and on the project's website as a text file, `PDF file <http://myjit.sourceforge.net/readme.pdf>`_, or as a `single HTML page <http://myjit.sourceforge.net/readme.htm>`_.
-
-License
--------
-MyJIT is distributed under the terms of GNU Lesser General Public License v.3 or later (at your option).
-
-Despite the fact that MyJIT is very similar to GNU Lightning, it does not share any source code with this project. However, some files come from the Mono project by Novel. (http://www.mono-project.com)
-
diff --git a/ext/myjit/doc/build/src/03-Instruction-set b/ext/myjit/doc/build/src/03-Instruction-set
deleted file mode 100755
index 08c837c..0000000
--- a/ext/myjit/doc/build/src/03-Instruction-set
+++ /dev/null
@@ -1,372 +0,0 @@
-===============
-Instruction Set
-===============
-
-The instruction set of the MyJIT intermediate language is inspired by GNU lightning and in some aspects resembles architecture of RISC processors. Each operation has up to four operands which can be immediate values (numbers, constants) or registers. The number of available registers is virtually unlimited.
-
-All general purpose registers and integer values are treated as signed integers and have the same size which corresponds to the register size of the CPU. Note that i386 and SPARC processors have 32 bit wide registers and AMD64 has 64 bit wide registers. In order to overcome this inconsistency, MyJIT provides the ``jit_value`` type which has the same size as the CPU's general purpose register. In specific cases, e.g., if smaller or ``unsigned`` value is needed and it is appropriate, you may specify the size or type of the value. This topic is discussed later.
-
-All floating-point numbers and registers are internally treated as double precision values. However, if necessary, the value can be converted into a single precision value.
-
-Typically, name of each instruction consists of three parts:
-
-+ name of the operation (e.g., ``add`` for addition, ``mul`` for multiplication, etc.)
-+ the name of the operation is often accompanied with the suffix ``r`` or ``i`` indicating whether the operation is taking merely registers or if it also takes an immediate value as its argument
-+ name of the operation can be equipped with additional flag delimited by the underscore (typically, this is used to identify operations handling unsigned numbers)
-
-Registers
----------
-
-MyJIT supports arbitrary number of register. If the number of used registers is higher than the number of available hardware registers, MyJIT emulates them. Nevertheless, to achieve the best performance, it is a good practice not to use too many registers. All registers are denoted by positive integers including zero. To refer to these registers you should use macros ``R(x)`` and ``FR(x)`` identifying general purpose and floating point registers, respectively. Note that registers ``R(x)`` and ``FR(x)`` are completely different register and do not occupy the same space.
-
-Besides, MyJIT has two special purpose registers---R_FP and R_OUT. R_FP serves as the frame pointer and is used to access dynamically allocated memory on the stack. The R_OUT can be used to handle the return values more efficiently. It can be used to read the return value right after the return from the function. Otherwise, the value of the register is undefined. Furthermore, it can be used right before the return from the function to set the return value more efficiently. If the value is set earlier, it can lead to undefined behavior. However, in most cases register allocator can optimize this which makes this register almost obsolete.
-
-Notation
---------
-
-In order to describe instruction set, we are using symbols ``reg`` and ``freg`` to denote general purpose and floating-point registers, respectively. Analogously, ``imm`` and ``fimm`` denote immediate integer values and floating-point values. Particular instructions (e.g., load and store operations) have an extra operand which specifies the size (number of bytes) of data they work with. This operand shall be denoted by ``size`` and ``fsize``. The value passed by the operand ``size`` can be 1, 2, 4, or 8. However, only the AMD64 port supports operation processing 8 bytes long values. The value passed by the operand ``fsize`` can be either 4 or 8. In other words, ``fsize`` denotes precision of the value.
-
-Instructions
-------------
-
-Transfer Operations
-...................
-These operations allow to assign a value into a register. The first operand is always a register and the second one can be either an immediate value or register.
-
-::
-
- movi reg, imm O1 := O2
- movr reg, reg O1 := O2
-
- fmovr freg, freg O1 := O2
- fmov freg, fimm O1 := O2
-
-
-Binary Arithmetic Operations
-............................
-Each binary arithmetic operation has exactly three operands. First two operands are always registers and the last one can be an immediate value or register. These operations are fully compatible with those in the GNU lightning instruction set.
-
-::
-
- addr reg, reg, reg O1 := O2 + O3
- addi reg, reg, imm O1 := O2 + O3
- addxr reg, reg, reg O1 := O2 + (O3 + carry)
- addxi reg, reg, imm O1 := O2 + (O3 + carry)
- addcr reg, reg, reg O1 := O2 + O3, set carry
- addci reg, reg, imm O1 := O2 + O3, set carry
-
- subr reg, reg, reg O1 := O2 - O3
- subi reg, reg, imm O1 := O2 - O3
- subxr reg, reg, reg O1 := O2 - (O3 + carry)
- subxi reg, reg, imm O1 := O2 - (O3 + carry)
- subcr reg, reg, reg O1 := O2 - O3, set carry
- subci reg, reg, imm O1 := O2 - O3, set carry
- rsbr reg, reg, reg O1 := O3 - O2
- rsbi reg, reg, imm O1 := O3 - O2
-
- mulr reg, reg, reg O1 := O2 * O3
- muli reg, reg, imm O1 := O2 * O3
- hmulr reg, reg, reg O1 := high bits of O2 * O3
- hmuli reg, reg, imm O1 := high bits of O2 * O3
-
- divr reg, reg, reg O1 := O2 / O3
- divi reg, reg, imm O1 := O2 / O3
- modr reg, reg, reg O1 := O2 % O3
- modi reg, reg, imm O1 := O2 % O3
-
- andr reg, reg, reg O1 := O2 & O3
- andi reg, reg, imm O1 := O2 & O3
- orr reg, reg, reg O1 := O2 | O3
- ori reg, reg, imm O1 := O2 | O3
- xorr reg, reg, reg O1 := O2 ^ O3
- xori reg, reg, imm O1 := O2 ^ O3
-
- lshr reg, reg, reg O1 := O2 << O3
- lshi reg, reg, imm O1 := O2 << O3
- rshr reg, reg, reg O1 := O2 >> O3
- rshi reg, reg, imm O1 := O2 >> O3
- rshr_u reg, reg, reg O1 := O2 >> O3 (unsigned variant)
- rshi_u reg, reg, imm O1 := O2 >> O3 (unsigned variant)
-
-Operations ``subx`` and ``addx`` have to directly follow ``subc`` and ``addc`` otherwise the result is undefined. Note that you can use the ``unsigned`` flag with the ``rshr`` operation to propagate the first bit accordingly.
-
-There are also equivalent operations for floating-point values.
-
-::
-
- faddr freg, freg, freg O1 := O2 + O3
- faddi freg, freg, fimm O1 := O2 + O3
- fsubr freg, freg, freg O1 := O2 - O3
- fsubi freg, freg, fimm O1 := O2 - O3
- frsbr freg, freg, freg O1 := O3 - O2
- frsbi freg, freg, fimm O1 := O3 - O2
- fmulr freg, freg, freg O1 := O2 * O3
- fmuli freg, freg, fimm O1 := O2 * O3
- fdivr freg, freg, freg O1 := O2 / O3
- fdivi freg, freg, fimm O1 := O2 / O3
-
-
-Unary Arithmetic Operations
-...........................
-These operations have two operands, both of which have to be registers.
-
-::
-
- negr reg O1 := -O2
- notr reg O1 := ~O2
- fnegr freg O1 := -O2
-
-Load Operations
-...............
-These operations transfer data from the memory into a register. Each operation has 3 or 4 operands. The last operand is an immediate value indicating the "size" of the data processed by this operation, i.e., a number of bytes copied from the memory to the register. It can be one of the following values: 1, 2, 4, or 8. Furthermore, the ``size`` cannot be larger than the size of the register. If the size of the data copied from the memory is smaller than the size of the register, the value is expanded to fit the entire register. Therefore, it may be necessary to specify additional sign flag.
-
-::
-
- ldr reg, reg, size O1 := *O2
- ldi reg, imm, size O1 := *O2
- ldr_u reg, reg, size O1 := *O2 (unsigned variant)
- ldi_u reg, imm, size O1 := *O2 (unsigned variant)
-
- ldxr reg, reg, reg, size O1 := *(O2 + O3)
- ldxi reg, reg, imm, size O1 := *(O2 + O3)
- ldxr_u reg, reg, reg, size O1 := *(O2 + O3) (unsigned variant)
- ldxi_u reg, reg, imm, size O1 := *(O2 + O3) (unsigned variant)
-
- fldr freg, reg, fsize O1 := *O2
- fldi freg, imm, fsize O1 := *O2
-
- fldxr freg, reg, reg, fsize O1 := *(O2 + O3)
- fldxi freg, reg, imm, fsize O1 := *(O2 + O3)
-
-
-Store Operations
-................
-These operations transfer data from the register into the memory. Each operation has 3 or 4 operands. The last operand is an immediate value and indicates the "size" of the data, see "Load Operations" for more details. The first operand can be either an immediate or register. Other operands must be registers.
-
-::
-
- str reg, reg, size *O1 := O2
- sti imm, reg, size *O1 := O2
-
- stxr reg, reg, reg, size *(O1 + O2) := O3
- stxi imm, reg, reg, size *(O1 + O2) := O3
-
- fstr reg, freg, fsize *O1 := O2
- fsti imm, freg, fsize *O1 := O2
-
- fstxr reg, reg, freg, fsize *(O1 + O2) := O3
- fstxi imm, reg, freg, fsize *(O1 + O2) := O3
-
-
-Compare Instructions
-....................
-These operations compare last two operands and store one or zero (if the condition was met or not, respectively) into the first operand. All these operations have three operands. The first two operands have to be registers and the last one can be either a register or an immediate value.
-
-::
-
- ltr reg, reg, reg O1 := (O2 < O3)
- lti reg, reg, imm O1 := (O2 < O3)
- ltr_u reg, reg, reg O1 := (O2 < O3) (unsigned variant)
- lti_u reg, reg, imm O1 := (O2 < O3) (unsigned variant)
-
- ler reg, reg, reg O1 := (O2 <= O3)
- lei reg, reg, imm O1 := (O2 <= O3)
- ler_u reg, reg, reg O1 := (O2 <= O3) (unsigned variant)
- lei_u reg, reg, imm O1 := (O2 <= O3) (unsigned variant)
-
- gtr reg, reg, reg O1 := (O2 > O3)
- gti reg, reg, imm O1 := (O2 > O3)
- gtr_u reg, reg, reg O1 := (O2 > O3) (unsigned variant)
- gti_u reg, reg, imm O1 := (O2 > O3) (unsigned variant)
-
- ger reg, reg, reg O1 := (O2 >= O3)
- gei reg, reg, imm O1 := (O2 >= O3)
- ger_u reg, reg, reg O1 := (O2 >= O3) (unsigned variant)
- gei_u reg, reg, imm O1 := (O2 >= O3) (unsigned variant)
-
- eqr reg, reg, reg O1 := (O2 == O3)
- eqi reg, reg, imm O1 := (O2 == O3)
-
- ner reg, reg, reg O1 := (O2 != O3)
- nei reg, reg, imm O1 := (O2 != O3)
-
-Conversions
-...........
-Register for integer and floating-pint values are independent and in order to convert value from one type to another you have to use one of the following operations.
-
-::
-
- extr freg, reg O1 := O2
- truncr reg, freg O1 := trunc(O2)
- ceilr reg, freg O1 := ceil(O2)
- floorr reg, freg O1 := floor(O2)
- roundr reg, freg O1 := round(O2)
-
-
-The operation ``truncr`` rounds the value towards zero and is the fastest one. Operations ``floorr`` and ``ceilr`` rounds the value towards negative or positive infinity, respectively. ``roundr`` rounds the given value to the nearest integer.
-
-
-Function declaration
-....................
-The following operations and auxiliary macros help to create a function, read its arguments, and return value.
-
-+ Operation ``prolog imm`` has one operand which is an immediate value, which is a reference to a pointer of the function defined by the intermediate code. In other words, MyJIT generates machine code for a function which resides somewhere in the memory. The address of the functions is handed by this reference. See the "Getting started" section, for more details and for an illustrative example.
-
-+ Operations ``retr reg``, ``reti imm``, ``fretr freg, fsize``, and ``freti freg, fsize`` set the return value and return control to the calling procedure (or function).
-
-+ Operation ``declare_arg imm, imm`` is not an actual operation but rather an auxiliary function which declares the type of the argument and its size (in this order); ``declare_arg`` can take the following types of arguments
-
- + ``JIT_SIGNED_NUM`` -- signed integer number
- + ``JIT_UNSIGNED_NUM`` -- unsigned integer number
- + ``JIT_FLOAT`` -- floating-point number
- + ``JIT_PTR`` -- pointer
-
-+ To read an argument there are ``getarg reg, imm`` and ``getarg freg, imm`` operations having two arguments. The destination register where the input argument will be stored and the immediate value which identifies position of the argument.
-
-+ Operation ``allocai imm`` reserves space on the stack which has at least the size specified by its operand. Note that the stack space may be aligned to some higher value. The macro returns an integer number which is an *offset from the frame pointer R_FP!*
-
-
-Function calls
-..............
-Each function call is done in three steps. The call is initiated by the operation ``prepare`` having no argument. In the second step, arguments are passed to a function using ``putarg`` or ``fputarg``. (The arguments are passed in the normal order not in reverse, cf. GNU Lightning.) Afterwards, the function is called with the ``call`` operation. To retrieve the returned value you can use operations ``retval`` or ``fretval``.
-
-Let us make few notes on function calls:
-
-+ If calling a function defined in the same instance of the compiler (e.g., recursive function), you cannot pass values through registers. Each function has its own set of registers.
-
-+ Only ``putargr``, ``putargi``, ``fputargr``, and ``fputargi`` operations are allowed inside the ``prepare-call`` block, otherwise, the behavior of the library is unspecified.
-
-List of operations related to function calls:
-
-+ ``prepare`` -- prepares function call (generic)
-+ ``putargr reg`` -- passes an argument to a function
-+ ``putargi imm`` -- passes an argument to a function
-+ ``fputargr freg, fsize`` -- passes the argument to a function
-+ ``fputargi fimm, fsize`` -- passes the argument to a function
-+ ``call imm`` -- calls a function
-+ ``callr reg``
-+ ``retval reg`` -- reads return value
-+ ``fretval freg, fsize`` -- reads return value
-
-Jumps
-.....
-Operations ``jmpi`` and ``jmpr`` can be used to implement unconditional jumps. Both operations have one operand, an address to jump to. To obtain this address you can use the ``get_label`` operation or use the forward declaration along with the ``patch`` operation.
-
-+ ``get_label`` is not an actual operation; it is a function that returns a ``jit_label`` value---value which corresponds to the current position in the code. This value can be passed to jmpi/call or to a branch operation.
-
-+ It may happen that one need to jump into a code which will be defined later. Therefore, one can use the forward declaration and set the address later. This means, one can declare that the operation ``jmpi`` or a branch operations jumps to the place defined by the JIT_FORWARD macro and store the pointer to the operation into some ``jit_op *`` value. To set the address later, there is the ``patch imm`` operation with an argument which is the patched operation. The following code illustrates the situation.
-
-::
-
- op = jmpi JIT_FORWARD
- ;
- ; some code
- ;
- patch op
-
-Branch Operations
-.................
-Branch operations represent conditional jumps and all have three operands. The first operand is an immediate value and represents the address to jump to. The latter two are values to be compared. The last operand can be either an immediate value or register.
-
-::
-
- bltr imm, reg, reg if (O2 < O3) goto O1
- blti imm, reg, imm if (O2 < O3) goto O1
- bltr_u imm, reg, reg if (O2 < O3) goto O1
- blti_u imm, reg, imm if (O2 < O3) goto O1
-
- bler imm, reg, reg if (O2 <= O3) goto O1
- blei imm, reg, imm if (O2 <= O3) goto O1
- bler_u imm, reg, reg if (O2 <= O3) goto O1
- blei_u imm, reg, imm if (O2 <= O3) goto O1
-
- bgtr imm, reg, reg if (O2 > O3) goto O1
- bgti imm, reg, imm if (O2 > O3) goto O1
- bgtr_u imm, reg, reg if (O2 > O3) goto O1
- bgti_u imm, reg, imm if (O2 > O3) goto O1
-
- bger imm, reg, reg if (O2 >= O3) goto O1
- bgei imm, reg, imm if (O2 >= O3) goto O1
- bger_u imm, reg, reg if (O2 >= O3) goto O1
- bgei_u imm, reg, imm if (O2 >= O3) goto O1
-
- beqr imm, reg, reg if (O2 == O3) goto O1
- beqi imm, reg, imm if (O2 == O3) goto O1
- bner imm, reg, reg if (O2 != O3) goto O1
- bnei imm, reg, imm if (O2 != O3) goto O1
-
- bmsr imm, reg, reg if (O2 & O3) goto O1
- bmsi imm, reg ,imm if (O2 & O3) goto O1
- bmcr imm, reg ,reg if !(O2 & O3) goto O1
- bmci imm, reg ,imm if !(O2 & O3) goto O1
-
- boaddr imm, reg, reg O2 += O3, goto O1 on overflow
- boaddi imm, reg, imm O2 += O3, goto O1 on overflow
- bnoaddr imm, reg, reg O2 += O3, goto O1 on not overflow
- bnoaddi imm, reg, imm O2 += O3, goto O1 on not overflow
-
- bosubr imm, reg, reg O2 -= O3, goto O1 on overflow
- bosubi imm, reg, imm O2 -= O3, goto O1 on overflow
- bnosubr imm, reg, reg O2 -= O3, goto O1 on not overflow
- bnosubi imm, reg, imm O2 -= O3, goto O1 on not overflow
-
- fbltr imm, freg, freg if (O2 < O3) goto O1
- fblti imm, freg, fimm if (O2 < O3) goto O1
- fbler imm, freg, freg if (O2 <= O3) goto O1
- fblei imm, freg, fimm if (O2 <= O3) goto O1
-
- fbgtr imm, freg, freg if (O2 > O3) goto O1
- fbgti imm, freg, fimm if (O2 > O3) goto O1
- fbger imm, freg, freg if (O2 >= O3) goto O1
- fbgei imm, freg, fimm if (O2 >= O3) goto O1
-
- fbeqr imm, freg, freg if (O2 == O3) goto O1
- fbeqi imm, freg, fimm if (O2 == O3) goto O1
- fbner imm, freg, freg if (O2 != O3) goto O1
- fbnei imm, freg, fimm if (O2 != O3) goto O1
-
-Misc
-....
-There is an operation that allows to emit raw bytes of data into a generated code:
-
-::
-
- data_byte imm
-
-This operation emits only one byte to a generated code. For convenience there are auxiliary macros emitting a sequence of bytes, string of chars (including the trailing \0), empty area, and values of common sizes, respectively.
-
-::
-
- jit_data_bytes(struct jit *jit, int count, unsigned char *data)
- jit_data_str(jit, str)
- jit_data_emptyarea(jit, size)
- jit_data_word(jit, a)
- jit_data_dword(jit, a)
- jit_data_qword(jit, a)
-
-If you are emitting raw data into a code, it is your responsibility to properly align code. For this purpose there is an operation:
-
-::
-
- jit_align imm
-
-
-This operation takes care of proper code alignment. Note that particular platforms have their specific requirements. On SPARC all instructions have to be aligned to 4 bytes, AMD64 favors alignment to 16 bytes, but it is not mandatory, etc. Safe bet is to use 16 as an operand of this operation.
-
-To obtain reference to a data or code you can use two operations:
-
-::
-
- ref_data reg, imm
- ref_code reg, imm
-
-That loads address of the label (second operand) into a register. The ref_data operation is intended for addresses of data (emitted with data_* operations) and ref_code is for address within an ordinary code. Note that address obtained with ref_code can be used only for local jumps inside a function. If necessary, for instance, if a some sort of branch table is needed, it is possible to emit address as a data with two operations.
-
-::
-
- data_code imm
- data_data imm
-
-
-Note that mixing code and data may not be a generally good idea and may lead to various issues, e.g. poor performance, weird behavior, etc. Albeit this feature is part of the library, users are encouraged to place data to some specific part of code (for instance, to the end of code) or use data that are not part of the code and are allocated elsewhere, for instance, with ordinary ``malloc``.
-
diff --git a/ext/myjit/doc/build/src/04-Getting-started b/ext/myjit/doc/build/src/04-Getting-started
deleted file mode 100755
index 29d4121..0000000
--- a/ext/myjit/doc/build/src/04-Getting-started
+++ /dev/null
@@ -1,73 +0,0 @@
-===============
-Getting Started
-===============
-
-We start with a really simple example---function returning its argument incremented by one. The source code of this example can be found in ``demo1.c`` which is part of the MyJIT package.
-
-.. sourcecode:: c
-
- #include <stdlib.h>
- #include <stdio.h>
-
- // includes the header file
- #include "myjit/jitlib.h"
-
- // pointer to a function accepting one argument of type long and returning long value
- typedef long (* plfl)(long);
-
- int main()
- {
- // creates a new instance of the compiler
- struct jit * p = jit_init();
-
- plfl foo;
-
- // the code generated by the compiler will be assigned to the function `foo'
- jit_prolog(p, &foo);
-
- // the first argument of the function
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- // moves the first argument into the register R(0)
- jit_getarg(p, R(0), 0);
-
- // takes the value in R(0), increments it by one, and stores the result into the
- // register R(1)
- jit_addi(p, R(1), R(0), 1);
-
- // returns from the function and returns the value stored in the register R(1)
- jit_retr(p, R(1));
-
- // compiles the above defined code
- jit_generate_code(p);
-
- // checks, if it works
- printf("Check #1: %li\n", foo(1));
- printf("Check #2: %li\n", foo(100));
- printf("Check #3: %li\n", foo(255));
-
- // if you are interested, you can dump the machine code
- // this functionality is provided through the `gcc' and `objdump'
- // jit_dump_ops(p, JIT_DEBUG_CODE);
-
- // cleanup
- jit_free(p);
- return 0;
- }
-
-We assume that the code above is quite (self-)explanatory, and thus, we do not include more comments on this. However, let us make a note on compiling programs using MyJIT. To start with MyJIT, it is sufficient to copy the ``myjit`` subdirectory into your project. Programs using the MyJIT should include the ``#include "myjit/jitlib.h"`` header file. In order to link the application and build a proper executable file, it is necessary to also compile ``"myjit/libjit-core.c"``.
-
-For instance, to build a program with ``gcc`` you may use the following steps:
-
-.. sourcecode:: bash
-
- gcc -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 demo1.c
- gcc -c -g -Winline -Wall -std=c99 -pedantic -D_XOPEN_SOURCE=600 myjit/jitlib-core.c
- gcc -o demo1 -g -Wall -std=c99 -pedantic demo1.o jitlib-core.o
-
-The first command compiles the example, the second one compiles functions used by MyJIT, and the last one links the object files together and creates an execute file---``demo1``.
-
-It should be emphasized that MyJIT conforms to the C99 standard and all MyJIT files should be compiled according to this standard.
-
-We also recommend to check out the ``demo2.c`` and ``demo3.c`` examples which are also included in the MyJIT package.
-
diff --git a/ext/myjit/doc/build/src/05-Debugging b/ext/myjit/doc/build/src/05-Debugging
deleted file mode 100755
index 4e26a83..0000000
--- a/ext/myjit/doc/build/src/05-Debugging
+++ /dev/null
@@ -1,114 +0,0 @@
-=========
-Debugging
-=========
-
-Debugging messages
-------------------
-
-MyJIT contains several tools simplifying development. One of them is the ``msg`` operation which prints out the given message or a value of the given register. The ``msg`` operation has one or two operands. The first one is always an immediate value which is the string to display. The second operand is optional and it must be a register. In this case the first string serves as the format string for ``printf`` and the value of the register is printed out using this string. The example of the ``msg`` operation usage:
-
-.. sourcecode:: c
-
- jit_msg(jit, "Simple message\n");
- jit_msgr(jit, "Reg 1: %l\n", R(1));
-
-
-Warnings
---------
-One of the MyJIT's goals is to achieve maximal performance while emitting code. Thus, it does not do many checks while generating machine code from the intermediate language. Therefore, if the code in the intermediate language contains an error, it leads to a faulty machine code, and subsequently to a crash of the program. In order to avoid such errors, MyJIT contains a function:
-
-.. sourcecode:: c
-
- void jit_check_code(struct jit *jit, int warnings);
-
-Which can be called before code generation and which can point out to the most common errors. In the second argument you may specify if you want to be warned about all types of errors (``JIT_WARN_ALL``) or you can pick only some of them from the following list:
-
-+ ``JIT_WARN_DEAD_CODE`` -- detects unreachable code
-+ ``JIT_WARN_OP_WITHOUT_EFFECT`` -- displays warnings about operations without effect
-+ ``JIT_WARN_INVALID_DATA_SIZE`` -- displays warning if the size operand does not contain a valid value (i.e., 1, 2, 4, or 8)
-+ ``JIT_WARN_UNINITIALIZED_REG`` -- displays warning if an uninitialized register is used
-+ ``JIT_WARN_REGISTER_TYPE_MISMATCH`` -- displays warning if a general purpose register is used in place where the floating point register is expected, or vice versa
-+ ``JIT_WARN_MISSING_PATCH`` -- reports all jump operations with a ``JIT_FORWARD`` declaration but without corresponding ``patch``
-+ ``JIT_WARN_UNALIGNED_CODE`` -- displays warning if the code follows data section without alignment
-+ ``JIT_WARN_INVALID_CODE_REFERENCE`` -- displays warning if ``ref_code`` or ``data_code`` is referring to a data and not to a valid code
-+ ``JIT_WARN_INVALID_DATA_REFERENCE`` -- displays warning if ``ref_data`` or ``data_data`` is referring to a code and not to a data
-+ ``JIT_WARN_ALL`` -- displays all warnings
-
-
-
-Code listing
-------------
-
-In real programs is MyJIT typically called from various functions and code is constructed in several steps, thus it is sometimes difficult to figure out, how the code looks like. Therefore, MyJIT provides several means allowing to inspect final code in the intermediate language as well as in the machine code. This functionality is provided through the ``jit_dump_ops`` function. In the second argument you may specify if you want to list:
-
-+ list of all operations in the intermediate language (``JIT_DEBUG_OPS``)
-+ generated machine code (``JIT_DEBUG_CODE``)
-+ combination of both -- MyJIT operations and machine code (``JIT_DEBUG_COMBINED``)
-
-To make the navigation through the listing easier, we have included one auxiliary operation:
-
-::
-
- comment imm
-
-Which has only one argument -- string which will appear only in the dumps.
-
-
-*NOTICE!* Do not use debugging operations and functions in the production code. These operations are not efficient and may lead to a poor performance. You should rather call the ``printf`` function explicitly. The ``jit_dump_ops`` with the ``JIT_DEBUG_CODE`` is using ``gcc`` and ``objdump`` to disassemble the code, therefore, these two programs have to be present in the system, or, on OS X ``clang`` and ``otool`` are used. The ``JIT_DEBUG_COMBINED`` option requires ``myjit-disasm`` disassembler in the directory along with the debugged program, or the path to the disassembler has to be specified in the ``MYJIT_DISASM`` environment variable.
-
-Examples of the outputs for the above mentioned source code.
-
-Example of the IL listing (``JIT_DEBUG_OPS``)
-.............................................
-
-::
-
- prolog 0xbfe62858
- declarg integer, 0x4
- getarg r0, 0x0
- addi r1, r0, 0x1
- retr r1
-
-
-
-Example of the machine code listing (``JIT_DEBUG_CODE``)
-........................................................
-
-::
-
- 0000000000000000 <main>:
- 0: 55 push rbp
- 1: 48 8b ec mov rbp,rsp
- 4: 48 83 ec 20 sub rsp,0x20
- 8: 48 8b f7 mov rsi,rdi
- b: 48 8d 46 01 lea rax,[rsi+0x1]
- f: 48 8b e5 mov rsp,rbp
- 12: 5d pop rbp
- 13: c3 ret
-
-
-
-Example of the combined listing (``JIT_DEBUG_COMBINED``)
-........................................................
-
-::
-
- prolog 0x7fffa0371db0
- 0000: 55 push rbp
- 0001: 48 8b ec mov rbp, rsp
- 0004: 48 83 ec 20 sub rsp, 0x20
-
- declare_arg integer, 0x8
- getarg r0, 0x0
- 0008: 48 8b f7 mov rsi, rdi
-
- addi r1, r0, 0x1
- 000b: 48 8d 46 01 lea rax, [rsi+0x1]
-
- retr r1
- 000f: 48 8b e5 mov rsp, rbp
- 0012: 5d pop rbp
- 0013: c3 ret
-
-
-
diff --git a/ext/myjit/doc/build/src/06-Optimizations b/ext/myjit/doc/build/src/06-Optimizations
deleted file mode 100755
index e18c641..0000000
--- a/ext/myjit/doc/build/src/06-Optimizations
+++ /dev/null
@@ -1,26 +0,0 @@
-=============
-Optimizations
-=============
-Support for multiple optimizations is available since release 0.7. These optimizations may speed up your code but the code generation may take longer. Therefore, you can turn particular optimization off and on using ``jit_disable_optimization`` and ``jit_enable_optimization`` functions, respectively. Currently, there are available the following optimizations:
-
-+ ``JIT_OPT_OMIT_UNUSED_ASSIGNEMENTS`` -- compiler skips unused assignments. (Turned off by default.)
-+ ``JIT_OPT_JOIN_ADDMUL`` -- if possible, compiler joins adjacent ``mul`` and ``add`` (or two ``add``'s) into one ``LEA`` operation (Turned on by default.)
-+ ``JIT_OPT_OMIT_FRAME_PTR`` -- if possible, compiler skips prolog and epilogue of the function. This significantly speeds up small functions. (Turned on by default.)
-
-The optimized code for above mentioned example looks like this:
-
-::
-
- 00000000 <main>:
- 0: 8b 4c 24 04 mov ecx,DWORD PTR [esp+0x4]
- 4: 8d 41 01 lea eax,[ecx+0x1]
- 7: c3 ret
-
-Or, like this:
-
-::
-
- 0000000000000000 <main>:
- 0: 48 8d 47 01 lea rax,[rdi+1]
- 4: c3 ret
-
diff --git a/ext/myjit/doc/build/src/07-Notes b/ext/myjit/doc/build/src/07-Notes
deleted file mode 100755
index 8152091..0000000
--- a/ext/myjit/doc/build/src/07-Notes
+++ /dev/null
@@ -1,18 +0,0 @@
-====================
-Notes on Development
-====================
-
-+ The primary use of this library is in our compiler of the Schemik programming language and the development of this library is driven by requirements of this compiler. Nevertheless, MyJIT is a general purpose library and its functionality is not limited.
-
-+ The library is almost complete and each release undergoes extensive testing (hundreds of tests), therefore, we hope there are no serious bugs. If you found any, please, let us know.
-
-+ Despite the fact that the library is almost complete, it is still under development and the API may slightly (but not much) change in the near future.
-
-+ Only the i386, AMD64, and SPARC platforms are supported right now, however, port to other architecture should be easy and straightforward.
-
-+ At this moment, MyJIT has support for floating point arithmetics. However, i386 port supports only processors having SSE2 unit, i.e., floating-point operations won't work on legacy CPUs without this unit.
-
-+ If you are using this library or if you want to contribute some code (e.g., port to some architecture), please, let us know.
-
-+ The documentation lacks information on internals of MyJIT. This is purely intentional because the library is still developed. We expect that the quality of the documentation will improve with the maturity of the project. If in doubts, ask in the mailing list (myjit-devel@lists.sourceforge.net). If you would like to participate on documentation improvements, please let us know, we will really appreciate it.
-
diff --git a/ext/myjit/doc/readme.htm b/ext/myjit/doc/readme.htm
deleted file mode 100755
index 982f946..0000000
--- a/ext/myjit/doc/readme.htm
+++ /dev/null
@@ -1,717 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
-<title></title>
-<style type="text/css">
-
-body {
- font-family: sans-serif;
- font-size: 10pt;
- margin-left: 10%;
- margin-right: 10%;
- background: white;
-}
-
-.title {
- font-size: 18pt;
-}
-
-h1 {
- color: #aa0000;
- font-size: 16pt;
- padding-bottom: 3pt;
- margin-top: 20pt;
- border-bottom: 1px solid #aa0000;
-}
-
-h2 {
- margin-top: 20pt;
- font-size: 13.5pt;
- color: #aa0000;
-}
-
-h3 {
- margin-top: 13pt;
- padding-top 0pt;
- font-size: 11.5pt;
- color: #aa0000;
- padding-bottom: 0px;
- margin-bottom: 0px;
-}
-
-
-
-pre, .pre, tt {
- color: #333333;
-}
-
-h3 tt {
- color: #aa0000;
-}
-
-
-a {
- color: #007700;
- text-decoration: none;
-}
-
-a:hover {
- color: #007700;
- text-decoration: underline;
-}
-
-hr {
- color: #aa0000;
- background-color: #aa0000;
- border: 0px;
- height: 1px;
-}
-
-.highlight {
- padding-top: 0px;
- padding-bottom: 0px;
- padding-left: 0px;
- padding-right: 0px;
- background: white;
- /*border: 1px solid #aa0000;*/
-}
-.hll { background-color: #ffffcc }
-.comment { color: #408080; /* font-style: italic*/ } /* Comment */
-.err { border: 1px solid #FF0000 } /* Error */
-.k { color: #008000; font-weight: bold } /* Keyword */
-.o { color: #666666 } /* Operator */
-.cm { color: #408080; font-style: italic } /* Comment.Multiline */
-.preproc { color: #BC7A00 } /* Comment.Preproc */
-.single { color: #408080; font-style: italic } /* Comment.Single */
-.cs { color: #408080; font-style: italic } /* Comment.Special */
-.gd { color: #A00000 } /* Generic.Deleted */
-.ge { font-style: italic } /* Generic.Emph */
-.gr { color: #FF0000 } /* Generic.Error */
-.gh { color: #000080; font-weight: bold } /* Generic.Heading */
-.gi { color: #00A000 } /* Generic.Inserted */
-.go { color: #888888 } /* Generic.Output */
-.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
-.gs { font-weight: bold } /* Generic.Strong */
-.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
-.gt { color: #0044DD } /* Generic.Traceback */
-.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
-.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
-.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
-.keyword { color: #008000; font-weight: bold; } /* Keyword.Pseudo */
-.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
-.type { color: #B00040 } /* Keyword.Type */
-.m { color: #666666 } /* Literal.Number */
-.s { color: #BA2121 } /* Literal.String */
-.na { color: #7D9029 } /* Name.Attribute */
-.nb { color: #008000 } /* Name.Builtin */
-.nc { color: #0000FF; font-weight: bold } /* Name.Class */
-.no { color: #880000 } /* Name.Constant */
-.nd { color: #AA22FF } /* Name.Decorator */
-.ni { color: #999999; font-weight: bold } /* Name.Entity */
-.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
-.function { color: #0000FF } /* Name.Function */
-.nl { color: #A0A000 } /* Name.Label */
-.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
-.nt { color: #008000; font-weight: bold } /* Name.Tag */
-.nv { color: #19177C } /* Name.Variable */
-.operator { /*color: #AA22FF;*/ /*font-weight: bold*/ } /* Operator.Word */
-.w { color: #bbbbbb } /* Text.Whitespace */
-.mf { color: #666666 } /* Literal.Number.Float */
-.mh { color: #666666 } /* Literal.Number.Hex */
-.integer { color: #666666 } /* Literal.Number.Integer */
-.mo { color: #666666 } /* Literal.Number.Oct */
-.sb { color: #BA2121 } /* Literal.String.Backtick */
-.string { color: #BA2121 } /* Literal.String.Char */
-.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
-.s2 { color: #BA2121 } /* Literal.String.Double */
-.escape { color: #BB6622;/* font-weight: bold */} /* Literal.String.Escape */
-.sh { color: #BA2121 } /* Literal.String.Heredoc */
-.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
-.sx { color: #008000 } /* Literal.String.Other */
-.sr { color: #BB6688 } /* Literal.String.Regex */
-.s1 { color: #BA2121 } /* Literal.String.Single */
-.ss { color: #19177C } /* Literal.String.Symbol */
-.bp { color: #008000 } /* Name.Builtin.Pseudo */
-.vc { color: #19177C } /* Name.Variable.Class */
-.vg { color: #19177C } /* Name.Variable.Global */
-.vi { color: #19177C } /* Name.Variable.Instance */
-.il { color: #666666 } /* Literal.Number.Integer.Long */
-
-
-</style>
-</head>
-<body>
-<div class="document">
-
-
-<div class="section" id="myjit">
-<h1>MyJIT</h1>
-<p>MyJIT is a library that allows to generate machine code at run-time and afterwards execute it. The project has started as a part of the Just-in-Time compiler of the Schemik (<a class="reference external" href="http://schemik.sourceforge.net">http://schemik.sourceforge.net</a>) programming language and as a replacement for the GNU lightning library (<a class="reference external" href="http://www.gnu.org/software/lightning/">http://www.gnu.org/software/lightning/</a>) fixing some of its design issues. However, it has evolved into a more powerful tool. Therefore, MyJIT has a very similar instruction set as GNU lightning but it differs in some key aspects. The most important features which make MyJIT different or which should be highlighted are:</p>
-<ul class="simple">
-<li>support for an unlimited number of registers</li>
-<li>thread-safety</li>
-<li>support for the i386, AMD64, and SPARC processors</li>
-<li>convenient debugging</li>
-<li>easy to use and easy to extend design</li>
-<li>support for optimizations</li>
-<li>the library is fully embeddable</li>
-<li>particular backward compatibility with GNU lightning</li>
-</ul>
-</div>
-<div class="section" id="instruction-set">
-<h1>Instruction Set</h1>
-<p>The instruction set of the MyJIT intermediate language is inspired by GNU lightning and in some aspects resembles architecture of RISC processors. Each operation has up to four operands which can be immediate values (numbers, constants) or registers. The number of available registers is virtually unlimited.</p>
-<p>All general purpose registers and integer values are treated as signed integers and have the same size which corresponds to the register size of the CPU. Note that i386 and SPARC processors have 32 bit wide registers and AMD64 has 64 bit wide registers. In order to overcome this inconsistency, MyJIT provides the <tt class="docutils literal">jit_value</tt> type which has the same size as the CPU's general purpose register. In specific cases, e.g., if smaller or <tt class="docutils literal">unsigned</tt> value is needed and it is appropriate, you may specify the size or type of the value. This topic is discussed later.</p>
-<p>All floating-point numbers and registers are internally treated as double precision values. However, if necessary, the value can be converted into a single precision value.</p>
-<p>Typically, name of each instruction consists of three parts:</p>
-<ul class="simple">
-<li>name of the operation (e.g., <tt class="docutils literal">add</tt> for addition, <tt class="docutils literal">mul</tt> for multiplication, etc.)</li>
-<li>the name of the operation is often accompanied with the suffix <tt class="docutils literal">r</tt> or <tt class="docutils literal">i</tt> indicating whether the operation is taking merely registers or if it also takes an immediate value as its argument</li>
-<li>name of the operation can be equipped with additional flag delimited by the underscore (typically, this is used to identify operations handling unsigned numbers)</li>
-</ul>
-<div class="section" id="registers">
-<h2>Registers</h2>
-<p>MyJIT supports arbitrary number of register. If the number of used registers is higher than the number of available hardware registers, MyJIT emulates them. Nevertheless, to achieve the best performance, it is a good practice not to use too many registers. All registers are denoted by positive integers including zero. To refer to these registers you should use macros <tt class="docutils literal">R(x)</tt> and <tt class="docutils literal">FR(x)</tt> identifying general purpose and floating point registers, respectively. Note that registers <tt class="docutils literal">R(x)</tt> and <tt class="docutils literal">FR(x)</tt> are completely different register and do not occupy the same space.</p>
-<p>Besides, MyJIT has two special purpose registers---R_FP and R_OUT. R_FP serves as the frame pointer and is used to access dynamically allocated memory on the stack. The R_OUT can be used to handle the return values more efficiently. It can be used to read the return value right after the return from the function. Otherwise, the value of the register is undefined. Furthermore, it can be used right before the return from the function to set the return value more efficiently. If the value is set earlier, it can lead to undefined behavior. However, in most cases register allocator can optimize this which makes this register almost obsolete.</p>
-</div>
-<div class="section" id="notation">
-<h2>Notation</h2>
-<p>In order to describe instruction set, we are using symbols <tt class="docutils literal">reg</tt> and <tt class="docutils literal">freg</tt> to denote general purpose and floating-point registers, respectively. Analogously, <tt class="docutils literal">imm</tt> and <tt class="docutils literal">fimm</tt> denote immediate integer values and floating-point values. Particular instructions (e.g., load and store operations) have an extra operand which specifies the size (number of bytes) of data they work with. This operand shall be denoted by <tt class="docutils literal">size</tt> and <tt class="docutils literal">fsize</tt>. The value passed by the operand <tt class="docutils literal">size</tt> can be 1, 2, 4, or 8. However, only the AMD64 port supports operation processing 8 bytes long values. The value passed by the operand <tt class="docutils literal">fsize</tt> can be either 4 or 8. In other words, <tt class="docutils literal">fsize</tt> denotes precision of the value.</p>
-</div>
-<div class="section" id="instructions">
-<h2>Instructions</h2>
-<div class="section" id="transfer-operations">
-<h3>Transfer Operations</h3>
-<p>These operations allow to assign a value into a register. The first operand is always a register and the second one can be either an immediate value or register.</p>
-<pre class="literal-block">
-movi reg, imm O1 := O2
-movr reg, reg O1 := O2
-
-fmovr freg, freg O1 := O2
-fmov freg, fimm O1 := O2
-</pre>
-</div>
-<div class="section" id="binary-arithmetic-operations">
-<h3>Binary Arithmetic Operations</h3>
-<p>Each binary arithmetic operation has exactly three operands. First two operands are always registers and the last one can be an immediate value or register. These operations are fully compatible with those in the GNU lightning instruction set.</p>
-<pre class="literal-block">
-addr reg, reg, reg O1 := O2 + O3
-addi reg, reg, imm O1 := O2 + O3
-addxr reg, reg, reg O1 := O2 + (O3 + carry)
-addxi reg, reg, imm O1 := O2 + (O3 + carry)
-addcr reg, reg, reg O1 := O2 + O3, set carry
-addci reg, reg, imm O1 := O2 + O3, set carry
-
-subr reg, reg, reg O1 := O2 - O3
-subi reg, reg, imm O1 := O2 - O3
-subxr reg, reg, reg O1 := O2 - (O3 + carry)
-subxi reg, reg, imm O1 := O2 - (O3 + carry)
-subcr reg, reg, reg O1 := O2 - O3, set carry
-subci reg, reg, imm O1 := O2 - O3, set carry
-rsbr reg, reg, reg O1 := O3 - O2
-rsbi reg, reg, imm O1 := O3 - O2
-
-mulr reg, reg, reg O1 := O2 * O3
-muli reg, reg, imm O1 := O2 * O3
-hmulr reg, reg, reg O1 := high bits of O2 * O3
-hmuli reg, reg, imm O1 := high bits of O2 * O3
-
-divr reg, reg, reg O1 := O2 / O3
-divi reg, reg, imm O1 := O2 / O3
-modr reg, reg, reg O1 := O2 % O3
-modi reg, reg, imm O1 := O2 % O3
-
-andr reg, reg, reg O1 := O2 &amp; O3
-andi reg, reg, imm O1 := O2 &amp; O3
-orr reg, reg, reg O1 := O2 | O3
-ori reg, reg, imm O1 := O2 | O3
-xorr reg, reg, reg O1 := O2 ^ O3
-xori reg, reg, imm O1 := O2 ^ O3
-
-lshr reg, reg, reg O1 := O2 &lt;&lt; O3
-lshi reg, reg, imm O1 := O2 &lt;&lt; O3
-rshr reg, reg, reg O1 := O2 &gt;&gt; O3
-rshi reg, reg, imm O1 := O2 &gt;&gt; O3
-rshr_u reg, reg, reg O1 := O2 &gt;&gt; O3 (unsigned variant)
-rshi_u reg, reg, imm O1 := O2 &gt;&gt; O3 (unsigned variant)
-</pre>
-<p>Operations <tt class="docutils literal">subx</tt> and <tt class="docutils literal">addx</tt> have to directly follow <tt class="docutils literal">subc</tt> and <tt class="docutils literal">addc</tt> otherwise the result is undefined. Note that you can use the <tt class="docutils literal">unsigned</tt> flag with the <tt class="docutils literal">rshr</tt> operation to propagate the first bit accordingly.</p>
-<p>There are also equivalent operations for floating-point values.</p>
-<pre class="literal-block">
-faddr freg, freg, freg O1 := O2 + O3
-faddi freg, freg, fimm O1 := O2 + O3
-fsubr freg, freg, freg O1 := O2 - O3
-fsubi freg, freg, fimm O1 := O2 - O3
-frsbr freg, freg, freg O1 := O3 - O2
-frsbi freg, freg, fimm O1 := O3 - O2
-fmulr freg, freg, freg O1 := O2 * O3
-fmuli freg, freg, fimm O1 := O2 * O3
-fdivr freg, freg, freg O1 := O2 / O3
-fdivi freg, freg, fimm O1 := O2 / O3
-</pre>
-</div>
-<div class="section" id="unary-arithmetic-operations">
-<h3>Unary Arithmetic Operations</h3>
-<p>These operations have two operands, both of which have to be registers.</p>
-<pre class="literal-block">
-negr reg O1 := -O2
-notr reg O1 := ~O2
-fnegr freg O1 := -O2
-</pre>
-</div>
-<div class="section" id="load-operations">
-<h3>Load Operations</h3>
-<p>These operations transfer data from the memory into a register. Each operation has 3 or 4 operands. The last operand is an immediate value indicating the &quot;size&quot; of the data processed by this operation, i.e., a number of bytes copied from the memory to the register. It can be one of the following values: 1, 2, 4, or 8. Furthermore, the <tt class="docutils literal">size</tt> cannot be larger than the size of the register. If the size of the data copied from the memory is smaller than the size of the register, the value is expanded to fit the entire register. Therefore, it may be necessary to specify additional sign flag.</p>
-<pre class="literal-block">
-ldr reg, reg, size O1 := *O2
-ldi reg, imm, size O1 := *O2
-ldr_u reg, reg, size O1 := *O2 (unsigned variant)
-ldi_u reg, imm, size O1 := *O2 (unsigned variant)
-
-ldxr reg, reg, reg, size O1 := *(O2 + O3)
-ldxi reg, reg, imm, size O1 := *(O2 + O3)
-ldxr_u reg, reg, reg, size O1 := *(O2 + O3) (unsigned variant)
-ldxi_u reg, reg, imm, size O1 := *(O2 + O3) (unsigned variant)
-
-fldr freg, reg, fsize O1 := *O2
-fldi freg, imm, fsize O1 := *O2
-
-fldxr freg, reg, reg, fsize O1 := *(O2 + O3)
-fldxi freg, reg, imm, fsize O1 := *(O2 + O3)
-</pre>
-</div>
-<div class="section" id="store-operations">
-<h3>Store Operations</h3>
-<p>These operations transfer data from the register into the memory. Each operation has 3 or 4 operands. The last operand is an immediate value and indicates the &quot;size&quot; of the data, see &quot;Load Operations&quot; for more details. The first operand can be either an immediate or register. Other operands must be registers.</p>
-<pre class="literal-block">
-str reg, reg, size *O1 := O2
-sti imm, reg, size *O1 := O2
-
-stxr reg, reg, reg, size *(O1 + O2) := O3
-stxi imm, reg, reg, size *(O1 + O2) := O3
-
-fstr reg, freg, fsize *O1 := O2
-fsti imm, freg, fsize *O1 := O2
-
-fstxr reg, reg, freg, fsize *(O1 + O2) := O3
-fstxi imm, reg, freg, fsize *(O1 + O2) := O3
-</pre>
-</div>
-<div class="section" id="compare-instructions">
-<h3>Compare Instructions</h3>
-<p>These operations compare last two operands and store one or zero (if the condition was met or not, respectively) into the first operand. All these operations have three operands. The first two operands have to be registers and the last one can be either a register or an immediate value.</p>
-<pre class="literal-block">
-ltr reg, reg, reg O1 := (O2 &lt; O3)
-lti reg, reg, imm O1 := (O2 &lt; O3)
-ltr_u reg, reg, reg O1 := (O2 &lt; O3) (unsigned variant)
-lti_u reg, reg, imm O1 := (O2 &lt; O3) (unsigned variant)
-
-ler reg, reg, reg O1 := (O2 &lt;= O3)
-lei reg, reg, imm O1 := (O2 &lt;= O3)
-ler_u reg, reg, reg O1 := (O2 &lt;= O3) (unsigned variant)
-lei_u reg, reg, imm O1 := (O2 &lt;= O3) (unsigned variant)
-
-gtr reg, reg, reg O1 := (O2 &gt; O3)
-gti reg, reg, imm O1 := (O2 &gt; O3)
-gtr_u reg, reg, reg O1 := (O2 &gt; O3) (unsigned variant)
-gti_u reg, reg, imm O1 := (O2 &gt; O3) (unsigned variant)
-
-ger reg, reg, reg O1 := (O2 &gt;= O3)
-gei reg, reg, imm O1 := (O2 &gt;= O3)
-ger_u reg, reg, reg O1 := (O2 &gt;= O3) (unsigned variant)
-gei_u reg, reg, imm O1 := (O2 &gt;= O3) (unsigned variant)
-
-eqr reg, reg, reg O1 := (O2 == O3)
-eqi reg, reg, imm O1 := (O2 == O3)
-
-ner reg, reg, reg O1 := (O2 != O3)
-nei reg, reg, imm O1 := (O2 != O3)
-</pre>
-</div>
-<div class="section" id="conversions">
-<h3>Conversions</h3>
-<p>Register for integer and floating-pint values are independent and in order to convert value from one type to another you have to use one of the following operations.</p>
-<pre class="literal-block">
-extr freg, reg O1 := O2
-truncr reg, freg O1 := trunc(O2)
-ceilr reg, freg O1 := ceil(O2)
-floorr reg, freg O1 := floor(O2)
-roundr reg, freg O1 := round(O2)
-</pre>
-<p>The operation <tt class="docutils literal">truncr</tt> rounds the value towards zero and is the fastest one. Operations <tt class="docutils literal">floorr</tt> and <tt class="docutils literal">ceilr</tt> rounds the value towards negative or positive infinity, respectively. <tt class="docutils literal">roundr</tt> rounds the given value to the nearest integer.</p>
-</div>
-<div class="section" id="function-declaration">
-<h3>Function declaration</h3>
-<p>The following operations and auxiliary macros help to create a function, read its arguments, and return value.</p>
-<ul>
-<li><p class="first">Operation <tt class="docutils literal">prolog imm</tt> has one operand which is an immediate value, which is a reference to a pointer of the function defined by the intermediate code. In other words, MyJIT generates machine code for a function which resides somewhere in the memory. The address of the functions is handed by this reference. See the &quot;Getting started&quot; section, for more details and for an illustrative example.</p>
-</li>
-<li><p class="first">Operations <tt class="docutils literal">retr reg</tt>, <tt class="docutils literal">reti imm</tt>, <tt class="docutils literal">fretr freg, fsize</tt>, and <tt class="docutils literal">freti freg, fsize</tt> set the return value and return control to the calling procedure (or function).</p>
-</li>
-<li><p class="first">Operation <tt class="docutils literal">declare_arg imm, imm</tt> is not an actual operation but rather an auxiliary function which declares the type of the argument and its size (in this order); <tt class="docutils literal">declare_arg</tt> can take the following types of arguments</p>
-<blockquote>
-<ul class="simple">
-<li><tt class="docutils literal">JIT_SIGNED_NUM</tt> -- signed integer number</li>
-<li><tt class="docutils literal">JIT_UNSIGNED_NUM</tt> -- unsigned integer number</li>
-<li><tt class="docutils literal">JIT_FLOAT</tt> -- floating-point number</li>
-<li><tt class="docutils literal">JIT_PTR</tt> -- pointer</li>
-</ul>
-</blockquote>
-</li>
-<li><p class="first">To read an argument there are <tt class="docutils literal">getarg reg, imm</tt> and <tt class="docutils literal">getarg freg, imm</tt> operations having two arguments. The destination register where the input argument will be stored and the immediate value which identifies position of the argument.</p>
-</li>
-<li><p class="first">Operation <tt class="docutils literal">allocai imm</tt> reserves space on the stack which has at least the size specified by its operand. Note that the stack space may be aligned to some higher value. The macro returns an integer number which is an <em>offset from the frame pointer R_FP!</em></p>
-</li>
-</ul>
-</div>
-<div class="section" id="function-calls">
-<h3>Function calls</h3>
-<p>Each function call is done in three steps. The call is initiated by the operation <tt class="docutils literal">prepare</tt> having no argument. In the second step, arguments are passed to a function using <tt class="docutils literal">putarg</tt> or <tt class="docutils literal">fputarg</tt>. (The arguments are passed in the normal order not in reverse, cf. GNU Lightning.) Afterwards, the function is called with the <tt class="docutils literal">call</tt> operation. To retrieve the returned value you can use operations <tt class="docutils literal">retval</tt> or <tt class="docutils literal">fretval</tt>.</p>
-<p>Let us make few notes on function calls:</p>
-<ul class="simple">
-<li>If calling a function defined in the same instance of the compiler (e.g., recursive function), you cannot pass values through registers. Each function has its own set of registers.</li>
-<li>Only <tt class="docutils literal">putargr</tt>, <tt class="docutils literal">putargi</tt>, <tt class="docutils literal">fputargr</tt>, and <tt class="docutils literal">fputargi</tt> operations are allowed inside the <tt class="docutils literal"><span class="pre">prepare-call</span></tt> block, otherwise, the behavior of the library is unspecified.</li>
-</ul>
-<p>List of operations related to function calls:</p>
-<ul class="simple">
-<li><tt class="docutils literal">prepare</tt> -- prepares function call (generic)</li>
-<li><tt class="docutils literal">putargr reg</tt> -- passes an argument to a function</li>
-<li><tt class="docutils literal">putargi imm</tt> -- passes an argument to a function</li>
-<li><tt class="docutils literal">fputargr freg, fsize</tt> -- passes the argument to a function</li>
-<li><tt class="docutils literal">fputargi fimm, fsize</tt> -- passes the argument to a function</li>
-<li><tt class="docutils literal">call imm</tt> -- calls a function</li>
-<li><tt class="docutils literal">callr reg</tt></li>
-<li><tt class="docutils literal">retval reg</tt> -- reads return value</li>
-<li><tt class="docutils literal">fretval freg, fsize</tt> -- reads return value</li>
-</ul>
-</div>
-<div class="section" id="jumps">
-<h3>Jumps</h3>
-<p>Operations <tt class="docutils literal">jmpi</tt> and <tt class="docutils literal">jmpr</tt> can be used to implement unconditional jumps. Both operations have one operand, an address to jump to. To obtain this address you can use the <tt class="docutils literal">get_label</tt> operation or use the forward declaration along with the <tt class="docutils literal">patch</tt> operation.</p>
-<ul class="simple">
-<li><tt class="docutils literal">get_label</tt> is not an actual operation; it is a function that returns a <tt class="docutils literal">jit_label</tt> value---value which corresponds to the current position in the code. This value can be passed to jmpi/call or to a branch operation.</li>
-<li>It may happen that one need to jump into a code which will be defined later. Therefore, one can use the forward declaration and set the address later. This means, one can declare that the operation <tt class="docutils literal">jmpi</tt> or a branch operations jumps to the place defined by the JIT_FORWARD macro and store the pointer to the operation into some <tt class="docutils literal">jit_op *</tt> value. To set the address later, there is the <tt class="docutils literal">patch imm</tt> operation with an argument which is the patched operation. The following code illustrates the situation.</li>
-</ul>
-<pre class="literal-block">
-op = jmpi JIT_FORWARD
- ;
- ; some code
- ;
- patch op
-</pre>
-</div>
-<div class="section" id="branch-operations">
-<h3>Branch Operations</h3>
-<p>Branch operations represent conditional jumps and all have three operands. The first operand is an immediate value and represents the address to jump to. The latter two are values to be compared. The last operand can be either an immediate value or register.</p>
-<pre class="literal-block">
-bltr imm, reg, reg if (O2 &lt; O3) goto O1
-blti imm, reg, imm if (O2 &lt; O3) goto O1
-bltr_u imm, reg, reg if (O2 &lt; O3) goto O1
-blti_u imm, reg, imm if (O2 &lt; O3) goto O1
-
-bler imm, reg, reg if (O2 &lt;= O3) goto O1
-blei imm, reg, imm if (O2 &lt;= O3) goto O1
-bler_u imm, reg, reg if (O2 &lt;= O3) goto O1
-blei_u imm, reg, imm if (O2 &lt;= O3) goto O1
-
-bgtr imm, reg, reg if (O2 &gt; O3) goto O1
-bgti imm, reg, imm if (O2 &gt; O3) goto O1
-bgtr_u imm, reg, reg if (O2 &gt; O3) goto O1
-bgti_u imm, reg, imm if (O2 &gt; O3) goto O1
-
-bger imm, reg, reg if (O2 &gt;= O3) goto O1
-bgei imm, reg, imm if (O2 &gt;= O3) goto O1
-bger_u imm, reg, reg if (O2 &gt;= O3) goto O1
-bgei_u imm, reg, imm if (O2 &gt;= O3) goto O1
-
-beqr imm, reg, reg if (O2 == O3) goto O1
-beqi imm, reg, imm if (O2 == O3) goto O1
-bner imm, reg, reg if (O2 != O3) goto O1
-bnei imm, reg, imm if (O2 != O3) goto O1
-
-bmsr imm, reg, reg if (O2 &amp; O3) goto O1
-bmsi imm, reg ,imm if (O2 &amp; O3) goto O1
-bmcr imm, reg ,reg if !(O2 &amp; O3) goto O1
-bmci imm, reg ,imm if !(O2 &amp; O3) goto O1
-
-boaddr imm, reg, reg O2 += O3, goto O1 on overflow
-boaddi imm, reg, imm O2 += O3, goto O1 on overflow
-bnoaddr imm, reg, reg O2 += O3, goto O1 on not overflow
-bnoaddi imm, reg, imm O2 += O3, goto O1 on not overflow
-
-bosubr imm, reg, reg O2 -= O3, goto O1 on overflow
-bosubi imm, reg, imm O2 -= O3, goto O1 on overflow
-bnosubr imm, reg, reg O2 -= O3, goto O1 on not overflow
-bnosubi imm, reg, imm O2 -= O3, goto O1 on not overflow
-
-fbltr imm, freg, freg if (O2 &lt; O3) goto O1
-fblti imm, freg, fimm if (O2 &lt; O3) goto O1
-fbler imm, freg, freg if (O2 &lt;= O3) goto O1
-fblei imm, freg, fimm if (O2 &lt;= O3) goto O1
-
-fbgtr imm, freg, freg if (O2 &gt; O3) goto O1
-fbgti imm, freg, fimm if (O2 &gt; O3) goto O1
-fbger imm, freg, freg if (O2 &gt;= O3) goto O1
-fbgei imm, freg, fimm if (O2 &gt;= O3) goto O1
-
-fbeqr imm, freg, freg if (O2 == O3) goto O1
-fbeqi imm, freg, fimm if (O2 == O3) goto O1
-fbner imm, freg, freg if (O2 != O3) goto O1
-fbnei imm, freg, fimm if (O2 != O3) goto O1
-</pre>
-</div>
-<div class="section" id="misc">
-<h3>Misc</h3>
-<p>There is an operation that allows to emit raw bytes of data into a generated code:</p>
-<pre class="literal-block">
-data_byte imm
-</pre>
-<p>This operation emits only one byte to a generated code. For convenience there are auxiliary macros emitting a sequence of bytes, string of chars (including the trailing 0), empty area, and values of common sizes, respectively.</p>
-<pre class="literal-block">
-jit_data_bytes(struct jit *jit, int count, unsigned char *data)
-jit_data_str(jit, str)
-jit_data_emptyarea(jit, size)
-jit_data_word(jit, a)
-jit_data_dword(jit, a)
-jit_data_qword(jit, a)
-</pre>
-<p>If you are emitting raw data into a code, it is your responsibility to properly align code. For this purpose there is an operation:</p>
-<pre class="literal-block">
-jit_align imm
-</pre>
-<p>This operation takes care of proper code alignment. Note that particular platforms have their specific requirements. On SPARC all instructions have to be aligned to 4 bytes, AMD64 favors alignment to 16 bytes, but it is not mandatory, etc. Safe bet is to use 16 as an operand of this operation.</p>
-<p>To obtain reference to a data or code you can use two operations:</p>
-<pre class="literal-block">
-ref_data reg, imm
-ref_code reg, imm
-</pre>
-<p>That loads address of the label (second operand) into a register. The ref_data operation is intended for addresses of data (emitted with data_* operations) and ref_code is for address within an ordinary code. Note that address obtained with ref_code can be used only for local jumps inside a function. If necessary, for instance, if a some sort of branch table is needed, it is possible to emit address as a data with two operations.</p>
-<pre class="literal-block">
-data_code imm
-data_data imm
-</pre>
-<p>Note that mixing code and data may not be a generally good idea and may lead to various issues, e.g. poor performance, weird behavior, etc. Albeit this feature is part of the library, users are encouraged to place data to some specific part of code (for instance, to the end of code) or use data that are not part of the code and are allocated elsewhere, for instance, with ordinary <tt class="docutils literal">malloc</tt>.</p>
-</div>
-</div>
-</div>
-<div class="section" id="getting-started">
-<h1>Getting Started</h1>
-<p>We start with a really simple example---function returning its argument incremented by one. The source code of this example can be found in <tt class="docutils literal">demo1.c</tt> which is part of the MyJIT package.</p>
-<pre class="code c literal-block">
-<span class="comment preproc">#include &lt;stdlib.h&gt;
-#include &lt;stdio.h&gt;
-</span>
-<span class="comment single">// includes the header file
-</span><span class="comment preproc">#include &quot;myjit/jitlib.h&quot;
-</span>
-<span class="comment single">// pointer to a function accepting one argument of type long and returning long value
-</span><span class="keyword">typedef</span> <span class="name function">long</span> <span class="punctuation">(</span><span class="operator">*</span> <span class="name">plfl</span><span class="punctuation">)(</span><span class="keyword type">long</span><span class="punctuation">);</span>
-
-<span class="keyword type">int</span> <span class="name function">main</span><span class="punctuation">()</span>
-<span class="punctuation">{</span>
- <span class="comment single">// creates a new instance of the compiler
-</span> <span class="keyword">struct</span> <span class="name">jit</span> <span class="operator">*</span> <span class="name">p</span> <span class="operator">=</span> <span class="name">jit_init</span><span class="punctuation">();</span>
-
- <span class="name">plfl</span> <span class="name">foo</span><span class="punctuation">;</span>
-
- <span class="comment single">// the code generated by the compiler will be assigned to the function `foo'
-</span> <span class="name">jit_prolog</span><span class="punctuation">(</span><span class="name">p</span><span class="punctuation">,</span> <span class="operator">&amp;</span><span class="name">foo</span><span class="punctuation">);</span>
-
- <span class="comment single">// the first argument of the function
-</span> <span class="name">jit_declare_arg</span><span class="punctuation">(</span><span class="name">p</span><span class="punctuation">,</span> <span class="name">JIT_SIGNED_NUM</span><span class="punctuation">,</span> <span class="keyword">sizeof</span><span class="punctuation">(</span><span class="keyword type">long</span><span class="punctuation">));</span>
-
- <span class="comment single">// moves the first argument into the register R(0)
-</span> <span class="name">jit_getarg</span><span class="punctuation">(</span><span class="name">p</span><span class="punctuation">,</span> <span class="name">R</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">),</span> <span class="literal number integer">0</span><span class="punctuation">);</span>
-
- <span class="comment single">// takes the value in R(0), increments it by one, and stores the result into the
-</span> <span class="comment single">// register R(1)
-</span> <span class="name">jit_addi</span><span class="punctuation">(</span><span class="name">p</span><span class="punctuation">,</span> <span class="name">R</span><span class="punctuation">(</span><span class="literal number integer">1</span><span class="punctuation">),</span> <span class="name">R</span><span class="punctuation">(</span><span class="literal number integer">0</span><span class="punctuation">),</span> <span class="literal number integer">1</span><span class="punctuation">);</span>
-
- <span class="comment single">// returns from the function and returns the value stored in the register R(1)
-</span> <span class="name">jit_retr</span><span class="punctuation">(</span><span class="name">p</span><span class="punctuation">,</span> <span class="name">R</span><span class="punctuation">(</span><span class="literal number integer">1</span><span class="punctuation">));</span>
-
- <span class="comment single">// compiles the above defined code
-</span> <span class="name">jit_generate_code</span><span class="punctuation">(</span><span class="name">p</span><span class="punctuation">);</span>
-
- <span class="comment single">// checks, if it works
-</span> <span class="name">printf</span><span class="punctuation">(</span><span class="literal string">&quot;Check #1: %li</span><span class="literal string escape">\n</span><span class="literal string">&quot;</span><span class="punctuation">,</span> <span class="name">foo</span><span class="punctuation">(</span><span class="literal number integer">1</span><span class="punctuation">));</span>
- <span class="name">printf</span><span class="punctuation">(</span><span class="literal string">&quot;Check #2: %li</span><span class="literal string escape">\n</span><span class="literal string">&quot;</span><span class="punctuation">,</span> <span class="name">foo</span><span class="punctuation">(</span><span class="literal number integer">100</span><span class="punctuation">));</span>
- <span class="name">printf</span><span class="punctuation">(</span><span class="literal string">&quot;Check #3: %li</span><span class="literal string escape">\n</span><span class="literal string">&quot;</span><span class="punctuation">,</span> <span class="name">foo</span><span class="punctuation">(</span><span class="literal number integer">255</span><span class="punctuation">));</span>
-
- <span class="comment single">// if you are interested, you can dump the machine code
-</span> <span class="comment single">// this functionality is provided through the `gcc' and `objdump'
-</span> <span class="comment single">// jit_dump_ops(p, JIT_DEBUG_CODE);
-</span>
- <span class="comment single">// cleanup
-</span> <span class="name">jit_free</span><span class="punctuation">(</span><span class="name">p</span><span class="punctuation">);</span>
- <span class="keyword">return</span> <span class="literal number integer">0</span><span class="punctuation">;</span>
-<span class="punctuation">}</span>
-</pre>
-<p>We assume that the code above is quite (self-)explanatory, and thus, we do not include more comments on this. However, let us make a note on compiling programs using MyJIT. To start with MyJIT, it is sufficient to copy the <tt class="docutils literal">myjit</tt> subdirectory into your project. Programs using the MyJIT should include the <tt class="docutils literal">#include &quot;myjit/jitlib.h&quot;</tt> header file. In order to link the application and build a proper executable file, it is necessary to also compile <tt class="docutils literal"><span class="pre">&quot;myjit/libjit-core.c&quot;</span></tt>.</p>
-<p>For instance, to build a program with <tt class="docutils literal">gcc</tt> you may use the following steps:</p>
-<pre class="code bash literal-block">
-gcc -c -g -Winline -Wall -std<span class="operator">=</span>c99 -pedantic -D_XOPEN_SOURCE<span class="operator">=</span>600 demo1.c
-gcc -c -g -Winline -Wall -std<span class="operator">=</span>c99 -pedantic -D_XOPEN_SOURCE<span class="operator">=</span>600 myjit/jitlib-core.c
-gcc -o demo1 -g -Wall -std<span class="operator">=</span>c99 -pedantic demo1.o jitlib-core.o
-</pre>
-<p>The first command compiles the example, the second one compiles functions used by MyJIT, and the last one links the object files together and creates an execute file---<tt class="docutils literal">demo1</tt>.</p>
-<p>It should be emphasized that MyJIT conforms to the C99 standard and all MyJIT files should be compiled according to this standard.</p>
-<p>We also recommend to check out the <tt class="docutils literal">demo2.c</tt> and <tt class="docutils literal">demo3.c</tt> examples which are also included in the MyJIT package.</p>
-</div>
-<div class="section" id="debugging">
-<h1>Debugging</h1>
-<div class="section" id="debugging-messages">
-<h2>Debugging messages</h2>
-<p>MyJIT contains several tools simplifying development. One of them is the <tt class="docutils literal">msg</tt> operation which prints out the given message or a value of the given register. The <tt class="docutils literal">msg</tt> operation has one or two operands. The first one is always an immediate value which is the string to display. The second operand is optional and it must be a register. In this case the first string serves as the format string for <tt class="docutils literal">printf</tt> and the value of the register is printed out using this string. The example of the <tt class="docutils literal">msg</tt> operation usage:</p>
-<pre class="code c literal-block">
-<span class="name">jit_msg</span><span class="punctuation">(</span><span class="name">jit</span><span class="punctuation">,</span> <span class="literal string">&quot;Simple message</span><span class="literal string escape">\n</span><span class="literal string">&quot;</span><span class="punctuation">);</span>
-<span class="name">jit_msgr</span><span class="punctuation">(</span><span class="name">jit</span><span class="punctuation">,</span> <span class="literal string">&quot;Reg 1: %l</span><span class="literal string escape">\n</span><span class="literal string">&quot;</span><span class="punctuation">,</span> <span class="name">R</span><span class="punctuation">(</span><span class="literal number integer">1</span><span class="punctuation">));</span>
-</pre>
-</div>
-<div class="section" id="warnings">
-<h2>Warnings</h2>
-<p>One of the MyJIT's goals is to achieve maximal performance while emitting code. Thus, it does not do many checks while generating machine code from the intermediate language. Therefore, if the code in the intermediate language contains an error, it leads to a faulty machine code, and subsequently to a crash of the program. In order to avoid such errors, MyJIT contains a function:</p>
-<pre class="code c literal-block">
-<span class="keyword type">void</span> <span class="name function">jit_check_code</span><span class="punctuation">(</span><span class="keyword">struct</span> <span class="name">jit</span> <span class="operator">*</span><span class="name">jit</span><span class="punctuation">,</span> <span class="keyword type">int</span> <span class="name">warnings</span><span class="punctuation">);</span>
-</pre>
-<p>Which can be called before code generation and which can point out to the most common errors. In the second argument you may specify if you want to be warned about all types of errors (<tt class="docutils literal">JIT_WARN_ALL</tt>) or you can pick only some of them from the following list:</p>
-<ul class="simple">
-<li><tt class="docutils literal">JIT_WARN_DEAD_CODE</tt> -- detects unreachable code</li>
-<li><tt class="docutils literal">JIT_WARN_OP_WITHOUT_EFFECT</tt> -- displays warnings about operations without effect</li>
-<li><tt class="docutils literal">JIT_WARN_INVALID_DATA_SIZE</tt> -- displays warning if the size operand does not contain a valid value (i.e., 1, 2, 4, or 8)</li>
-<li><tt class="docutils literal">JIT_WARN_UNINITIALIZED_REG</tt> -- displays warning if an uninitialized register is used</li>
-<li><tt class="docutils literal">JIT_WARN_REGISTER_TYPE_MISMATCH</tt> -- displays warning if a general purpose register is used in place where the floating point register is expected, or vice versa</li>
-<li><tt class="docutils literal">JIT_WARN_MISSING_PATCH</tt> -- reports all jump operations with a <tt class="docutils literal">JIT_FORWARD</tt> declaration but without corresponding <tt class="docutils literal">patch</tt></li>
-<li><tt class="docutils literal">JIT_WARN_UNALIGNED_CODE</tt> -- displays warning if the code follows data section without alignment</li>
-<li><tt class="docutils literal">JIT_WARN_INVALID_CODE_REFERENCE</tt> -- displays warning if <tt class="docutils literal">ref_code</tt> or <tt class="docutils literal">data_code</tt> is referring to a data and not to a valid code</li>
-<li><tt class="docutils literal">JIT_WARN_INVALID_DATA_REFERENCE</tt> -- displays warning if <tt class="docutils literal">ref_data</tt> or <tt class="docutils literal">data_data</tt> is referring to a code and not to a data</li>
-<li><tt class="docutils literal">JIT_WARN_ALL</tt> -- displays all warnings</li>
-</ul>
-</div>
-<div class="section" id="code-listing">
-<h2>Code listing</h2>
-<p>In real programs is MyJIT typically called from various functions and code is constructed in several steps, thus it is sometimes difficult to figure out, how the code looks like. Therefore, MyJIT provides several means allowing to inspect final code in the intermediate language as well as in the machine code. This functionality is provided through the <tt class="docutils literal">jit_dump_ops</tt> function. In the second argument you may specify if you want to list:</p>
-<ul class="simple">
-<li>list of all operations in the intermediate language (<tt class="docutils literal">JIT_DEBUG_OPS</tt>)</li>
-<li>generated machine code (<tt class="docutils literal">JIT_DEBUG_CODE</tt>)</li>
-<li>combination of both -- MyJIT operations and machine code (<tt class="docutils literal">JIT_DEBUG_COMBINED</tt>)</li>
-</ul>
-<p>To make the navigation through the listing easier, we have included one auxiliary operation:</p>
-<pre class="literal-block">
-comment imm
-</pre>
-<p>Which has only one argument -- string which will appear only in the dumps.</p>
-<p><em>NOTICE!</em> Do not use debugging operations and functions in the production code. These operations are not efficient and may lead to a poor performance. You should rather call the <tt class="docutils literal">printf</tt> function explicitly. The <tt class="docutils literal">jit_dump_ops</tt> with the <tt class="docutils literal">JIT_DEBUG_CODE</tt> is using <tt class="docutils literal">gcc</tt> and <tt class="docutils literal">objdump</tt> to disassemble the code, therefore, these two programs have to be present in the system, or, on OS X <tt class="docutils literal">clang</tt> and <tt class="docutils literal">otool</tt> are used. The <tt class="docutils literal">JIT_DEBUG_COMBINED</tt> option requires <tt class="docutils literal"><span class="pre">myjit-disasm</span></tt> disassembler in the directory along with the debugged program, or the path to the disassembler has to be specified in the <tt class="docutils literal">MYJIT_DISASM</tt> environment variable.</p>
-<p>Examples of the outputs for the above mentioned source code.</p>
-<div class="section" id="example-of-the-il-listing-jit-debug-ops">
-<h3>Example of the IL listing (<tt class="docutils literal">JIT_DEBUG_OPS</tt>)</h3>
-<pre class="literal-block">
-prolog 0xbfe62858
-declarg integer, 0x4
-getarg r0, 0x0
-addi r1, r0, 0x1
-retr r1
-</pre>
-</div>
-<div class="section" id="example-of-the-machine-code-listing-jit-debug-code">
-<h3>Example of the machine code listing (<tt class="docutils literal">JIT_DEBUG_CODE</tt>)</h3>
-<pre class="literal-block">
-0000000000000000 &lt;main&gt;:
- 0: 55 push rbp
- 1: 48 8b ec mov rbp,rsp
- 4: 48 83 ec 20 sub rsp,0x20
- 8: 48 8b f7 mov rsi,rdi
- b: 48 8d 46 01 lea rax,[rsi+0x1]
- f: 48 8b e5 mov rsp,rbp
- 12: 5d pop rbp
- 13: c3 ret
-</pre>
-</div>
-<div class="section" id="example-of-the-combined-listing-jit-debug-combined">
-<h3>Example of the combined listing (<tt class="docutils literal">JIT_DEBUG_COMBINED</tt>)</h3>
-<pre class="literal-block">
- prolog 0x7fffa0371db0
-0000: 55 push rbp
-0001: 48 8b ec mov rbp, rsp
-0004: 48 83 ec 20 sub rsp, 0x20
-
- declare_arg integer, 0x8
- getarg r0, 0x0
-0008: 48 8b f7 mov rsi, rdi
-
- addi r1, r0, 0x1
-000b: 48 8d 46 01 lea rax, [rsi+0x1]
-
- retr r1
-000f: 48 8b e5 mov rsp, rbp
-0012: 5d pop rbp
-0013: c3 ret
-</pre>
-</div>
-</div>
-</div>
-<div class="section" id="optimizations">
-<h1>Optimizations</h1>
-<p>Support for multiple optimizations is available since release 0.7. These optimizations may speed up your code but the code generation may take longer. Therefore, you can turn particular optimization off and on using <tt class="docutils literal">jit_disable_optimization</tt> and <tt class="docutils literal">jit_enable_optimization</tt> functions, respectively. Currently, there are available the following optimizations:</p>
-<ul class="simple">
-<li><tt class="docutils literal">JIT_OPT_OMIT_UNUSED_ASSIGNEMENTS</tt> -- compiler skips unused assignments. (Turned off by default.)</li>
-<li><tt class="docutils literal">JIT_OPT_JOIN_ADDMUL</tt> -- if possible, compiler joins adjacent <tt class="docutils literal">mul</tt> and <tt class="docutils literal">add</tt> (or two <tt class="docutils literal">add</tt>'s) into one <tt class="docutils literal">LEA</tt> operation (Turned on by default.)</li>
-<li><tt class="docutils literal">JIT_OPT_OMIT_FRAME_PTR</tt> -- if possible, compiler skips prolog and epilogue of the function. This significantly speeds up small functions. (Turned on by default.)</li>
-</ul>
-<p>The optimized code for above mentioned example looks like this:</p>
-<pre class="literal-block">
-00000000 &lt;main&gt;:
- 0: 8b 4c 24 04 mov ecx,DWORD PTR [esp+0x4]
- 4: 8d 41 01 lea eax,[ecx+0x1]
- 7: c3 ret
-</pre>
-<p>Or, like this:</p>
-<pre class="literal-block">
-0000000000000000 &lt;main&gt;:
- 0: 48 8d 47 01 lea rax,[rdi+1]
- 4: c3 ret
-</pre>
-</div>
-<div class="section" id="download">
-<h1>Download</h1>
-<div class="section" id="getting-myjit">
-<h2>Getting MyJIT</h2>
-<p>The source code including this documentation and examples is available at SourceForge (<a class="reference external" href="http://sourceforge.net/projects/myjit/files">http://sourceforge.net/projects/myjit/files</a>) as of other information (<a class="reference external" href="http://sourceforge.net/projects/myjit">http://sourceforge.net/projects/myjit</a>)</p>
-<p>You can also checkout the latest release from the GIT repository:</p>
-<pre class="literal-block">
-git clone git://git.code.sf.net/p/myjit/maincode myjit-maincode
-</pre>
-</div>
-<div class="section" id="documentation">
-<h2>Documentation</h2>
-<p>Documentation is available in the <tt class="docutils literal">doc/</tt> directory and on the project's website as a text file, <a class="reference external" href="http://myjit.sourceforge.net/readme.pdf">PDF file</a>, or as a <a class="reference external" href="http://myjit.sourceforge.net/readme.htm">single HTML page</a>.</p>
-</div>
-<div class="section" id="license">
-<h2>License</h2>
-<p>MyJIT is distributed under the terms of GNU Lesser General Public License v.3 or later (at your option).</p>
-<p>Despite the fact that MyJIT is very similar to GNU Lightning, it does not share any source code with this project. However, some files come from the Mono project by Novel. (<a class="reference external" href="http://www.mono-project.com">http://www.mono-project.com</a>)</p>
-</div>
-</div>
-<div class="section" id="notes-on-development">
-<h1>Notes on Development</h1>
-<ul class="simple">
-<li>The primary use of this library is in our compiler of the Schemik programming language and the development of this library is driven by requirements of this compiler. Nevertheless, MyJIT is a general purpose library and its functionality is not limited.</li>
-<li>The library is almost complete and each release undergoes extensive testing (hundreds of tests), therefore, we hope there are no serious bugs. If you found any, please, let us know.</li>
-<li>Despite the fact that the library is almost complete, it is still under development and the API may slightly (but not much) change in the near future.</li>
-<li>Only the i386, AMD64, and SPARC platforms are supported right now, however, port to other architecture should be easy and straightforward.</li>
-<li>At this moment, MyJIT has support for floating point arithmetics. However, i386 port supports only processors having SSE2 unit, i.e., floating-point operations won't work on legacy CPUs without this unit.</li>
-<li>If you are using this library or if you want to contribute some code (e.g., port to some architecture), please, let us know.</li>
-<li>The documentation lacks information on internals of MyJIT. This is purely intentional because the library is still developed. We expect that the quality of the documentation will improve with the maturity of the project. If in doubts, ask in the mailing list (<a class="reference external" href="mailto:myjit-devel&#64;lists.sourceforge.net">myjit-devel&#64;lists.sourceforge.net</a>). If you would like to participate on documentation improvements, please let us know, we will really appreciate it.</li>
-</ul>
-</div>
-</div>
-<div class="footer">
-<hr class="footer" />
-Generated on: 2015-03-15 17:43 UTC.
-
-</div>
-</body>
-</html>
diff --git a/ext/myjit/doc/readme.pdf b/ext/myjit/doc/readme.pdf
deleted file mode 100755
index 4614b80..0000000
--- a/ext/myjit/doc/readme.pdf
+++ /dev/null
Binary files differ
diff --git a/ext/myjit/extras/myjit-unique.sh b/ext/myjit/extras/myjit-unique.sh
deleted file mode 100755
index 4300c37..0000000
--- a/ext/myjit/extras/myjit-unique.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/bash
-
-PREFIX="jit_internal_"
-TARGET_DIR="../myjit-unique"
-SCRIPT=`mktemp`
-
-
-#
-# lists all functions in the source codes passed to the stdin
-#
-function list_functions {
- sed -n -e '/^[[:alpha:]].*(/p' | \
- sed -e 's/\([^ ]*\)(.*/#\1/' -e 's/.*#//' | \
- grep -v "^jit" | sort | uniq
-}
-
-
-#
-# lists all types in the source codes passed to the stdin
-#
-function list_types {
- tr '\r\n' ' ' | sed -e 's/{[^}]*}//g' | tr ';' '\n' | sed -n -e '/typedef/ {s/.* //p}' | \
- grep -v "^jit" | sort | uniq | grep -v "value"
-}
-
-
-function list_constants {
- echo "OUT_REGS"
- echo "x86_cc_unsigned_map"
- echo "x86_cc_signed_map"
-}
-
-#
-# reads a list of symbols from stdin and prints sed script
-#
-function create_sed_script {
- while read SYMBOL; do
- echo "s/$SYMBOL/$PREFIX$SYMBOL/g"
- done
-
-}
-
-cat ../myjit/*.c ../myjit/*.h | list_functions | create_sed_script > "$SCRIPT"
-cat ../myjit/*.c ../myjit/*.h | list_types | create_sed_script >> "$SCRIPT"
-cat ../myjit/*.c ../myjit/*.h | list_constants | create_sed_script >> "$SCRIPT"
-
-
-
-mkdir -p "$TARGET_DIR"
-
-cd ../myjit
-for FILE in *.c *.h
-do
- echo $FILE
- sed -f "$SCRIPT" $FILE > "$TARGET_DIR/$FILE"
-done
-
-rm -f "$SCRIPT"
diff --git a/ext/myjit/junk/Makefile b/ext/myjit/junk/Makefile
deleted file mode 100755
index 444e320..0000000
--- a/ext/myjit/junk/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-sse-test: sse-test.c
- gcc -g -Wall -o sse-test sse-test.c
diff --git a/ext/myjit/junk/opcodes-debugger.c b/ext/myjit/junk/opcodes-debugger.c
deleted file mode 100755
index c7306fd..0000000
--- a/ext/myjit/junk/opcodes-debugger.c
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "../dis-asm/dis-asm.h"
-#include "../dis-asm/bfd.h"
-
-#define OUTPUT_BUF_SIZE (8192)
-
-
-static void override_printf(char * buf, const char * format, ...)
-{
- va_list args;
-
- buf += strlen(buf);
-
- va_start(args, format);
- vsprintf(buf, format, args);
- va_end(args);
-}
-
-static void override_print_address(bfd_vma addr, struct disassemble_info *info)
-{
- char * buf = info->stream;
- buf += strlen(buf);
-
- sprintf(buf, "0x%lx", (long)addr);
-}
-
-static void * get_libocodes_handle()
-{
- char buf[1024];
-
- void * handle;
- handle = dlopen("libopcodes.so", RTLD_LAZY);
- if (handle) return handle;
-
- FILE * f = popen("/sbin/ldconfig -p", "r");
- while (f && !feof(f)) {
- char * b;
- fgets(buf, 1024, f);
- b = strstr(buf, "libopcodes");
- if (b) {
- fclose(f);
- for (int i = 0; i < strlen(b); i++) {
- if (isspace(b[i])) {
- b[i] = '\0';
- break;
- }
- }
- return dlopen(b, RTLD_LAZY);
- }
- }
- fclose(f);
- return NULL;
-}
-
-int opcodes_based_debugger(struct jit * jit)
-{
- struct disassemble_info info;
- unsigned long count, pc, buf_size;
- char output_buf[OUTPUT_BUF_SIZE];
- char * error;
-
- void (* __init_disassemble_info) (struct disassemble_info *info, void *stream, fprintf_ftype fprintf_func);
- int (* __print_insn) (bfd_vma, disassemble_info *);
-
- void * handle = get_libocodes_handle();
-
- if (!handle) {
- fprintf(stderr, "Unable to find libopcodes library.\n");
- return -1;
- }
-
- dlerror(); // Clear any existing error
-
- *(void **) (&__init_disassemble_info) = dlsym(handle, "init_disassemble_info");
-
- if ((error = dlerror()) != NULL) {
- fprintf(stderr, "%s\n", error);
- return -1;
- }
-
- fprintf_ftype print_fn = (fprintf_ftype) override_printf;
- __init_disassemble_info(&info, output_buf, print_fn);
- info.print_address_func = override_print_address;
-
-#ifdef JIT_ARCH_I386
- info.mach = bfd_mach_i386_i386_intel_syntax;
- info.endian = BFD_ENDIAN_LITTLE;
-
- *(void **) (&__print_insn) = dlsym(handle, "print_insn_i386_intel");
-#endif
-
-#ifdef JIT_ARCH_AMD64
- info.mach = bfd_mach_x86_64_intel_syntax;;
- info.endian = BFD_ENDIAN_LITTLE;
-
- *(void **) (&__print_insn) = dlsym(handle, "print_insn_x86_64_intel_syntax");
-#endif
-
-#ifdef JIT_ARCH_SPARC
- info.mach = bfd_mach_sparc_sparclite;
- info.endian = BFD_ENDIAN_BIG;
-
- *(void **) (&__print_insn) = dlsym(handle, "print_insn_sparclite");
-#endif
-
- if ((error = dlerror()) != NULL) {
- fprintf(stderr, "%s\n", error);
- return -1;
- }
-
- buf_size = (unsigned long)(jit->ip - jit->buf);
- info.buffer = (void *)jit->buf;
- info.buffer_length = buf_size;
-
- for (pc = 0; pc < buf_size; ) {
- sprintf(output_buf, "%4lx: ", pc);
- count = __print_insn(pc, &info);
- printf("%s\n", output_buf);
- pc += count;
- }
- return 0;
-}
diff --git a/ext/myjit/junk/sse-test.c b/ext/myjit/junk/sse-test.c
deleted file mode 100755
index 7c3632d..0000000
--- a/ext/myjit/junk/sse-test.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-
-#include "../myjit/x86-codegen.h"
-
-void jit_dump_code(unsigned char * buf, int buf_size)
-{
- int i;
- FILE * f = stdout;
-
- char * source_file_name = tempnam(NULL, "myjit");
- char * obj_file_name = tempnam(NULL, "myjit");
-
- char * cmd1_fmt = "gcc -x assembler -c -o %s %s";
- char cmd1[strlen(cmd1_fmt) + strlen(source_file_name) + strlen(obj_file_name)];
-
- char * cmd2_fmt = "objdump -d -M intel %s";
- char cmd2[strlen(cmd2_fmt) + strlen(obj_file_name)];
-
- f = fopen(source_file_name, "w");
-
- fprintf (f, ".text\n.align 4\n.globl main\n.type main,@function\nmain:\n");
- for (i = 0; i < buf_size; i++)
- fprintf(f, ".byte %d\n", (unsigned int)buf[i]);
- fclose(f);
-
- sprintf(cmd1, cmd1_fmt, obj_file_name, source_file_name);
- system(cmd1);
-
- sprintf(cmd2, cmd2_fmt, obj_file_name);
- system(cmd2);
-
- unlink(source_file_name);
- unlink(obj_file_name);
-
- free(source_file_name);
- free(obj_file_name);
-}
-
-typedef double (*pdfdd)(double, double);
-
-int main()
-{
- pdfdd foo;
- unsigned char * buffer;
-
- posix_memalign((void **)&buffer, sysconf(_SC_PAGE_SIZE), 4096);
- mprotect(buffer, 4096, PROT_READ | PROT_EXEC | PROT_WRITE);
-
- unsigned char * buf = buffer;
- static const double b = 2.2;
- static const double c = 2.3;
-
- foo = (pdfdd)buf;
- x86_push_reg(buf, X86_EBP);
- x86_mov_reg_reg(buf, X86_EBP, X86_ESP, 4);
-
-// x86_movsd_reg_membase(buf, X86_XMM0, X86_ESP, 0);
- x86_movsd_reg_mem(buf, X86_XMM0, &b);
- x86_movsd_reg_mem(buf, X86_XMM1, &c);
-
- //x86_movsd_reg_reg(buf, X86_XMM0, X86_XMM1);
- //
- //
- x86_movlpd_xreg_membase(buf, X86_XMM1, X86_EBP, 16);
- x86_sse_alu_pd_reg_reg(buf, X86_SSE_DIV, X86_XMM0, X86_XMM1);
-
-
- // pushes FP number on the top of the stack
- // x86_push_imm(buf, *((unsigned long long *)&b) >> 32);
- // x86_push_imm(buf, *((unsigned long long *)&b) && 0xffffffff);
-
- x86_alu_reg_imm(buf, X86_SUB, X86_ESP, 8); // creates extra space on the stack
- x86_movlpd_membase_xreg(buf, X86_XMM0, X86_ESP, 0); // pushes the value on the top of the stack
- x86_fld_membase(buf, X86_ESP, 0, 1); // transfers the value from the stack to the ST(0)
-
- x86_mov_reg_reg(buf, X86_ESP, X86_EBP, 4);
- x86_pop_reg(buf, X86_EBP);
- x86_ret(buf);
-
- int buf_size = (int)buf - (int)buffer;
- jit_dump_code(buffer, buf_size);
-
- double x = foo(1.2, 2.5);
- printf(":XX:%f\n", x);
-
- return 0;
-}
diff --git a/ext/myjit/myjit-disasm b/ext/myjit/myjit-disasm
deleted file mode 100755
index 26974c1..0000000
--- a/ext/myjit/myjit-disasm
+++ /dev/null
Binary files differ
diff --git a/ext/myjit/myjit/amd64-codegen.h b/ext/myjit/myjit/amd64-codegen.h
deleted file mode 100755
index 73dc979..0000000
--- a/ext/myjit/myjit/amd64-codegen.h
+++ /dev/null
@@ -1,1686 +0,0 @@
-/*
- * amd64-codegen.h: Macros for generating amd64 code
- *
- * Authors:
- * Petr Krajca (petr.krajca@upol.cz)
- * Paolo Molaro (lupus@ximian.com)
- * Intel Corporation (ORP Project)
- * Sergey Chaban (serge@wildwestsoftware.com)
- * Dietmar Maurer (dietmar@ximian.com)
- * Patrik Torstensson
- * Zalman Stern
- *
- * Copyright (C) 2000 Intel Corporation. All rights reserved.
- * Copyright (C) 2001, 2002 Ximian, Inc.
- * Copyright (C) 2010, Petr Krajca
- */
-
-#ifndef AMD64_H
-#define AMD64_H
-
-#include <assert.h>
-
-typedef enum jit_amd64_gp_regs {
- AMD64_RAX = 0,
- AMD64_RCX = 1,
- AMD64_RDX = 2,
- AMD64_RBX = 3,
- AMD64_RSP = 4,
- AMD64_RBP = 5,
- AMD64_RSI = 6,
- AMD64_RDI = 7,
- AMD64_R8 = 8,
- AMD64_R9 = 9,
- AMD64_R10 = 10,
- AMD64_R11 = 11,
- AMD64_R12 = 12,
- AMD64_R13 = 13,
- AMD64_R14 = 14,
- AMD64_R15 = 15,
- AMD64_RIP = 16,
- AMD64_NREG
-} AMD64_Reg_No;
-
-typedef enum jit_amd64_fp_regs {
- AMD64_XMM0 = 0,
- AMD64_XMM1 = 1,
- AMD64_XMM2 = 2,
- AMD64_XMM3 = 3,
- AMD64_XMM4 = 4,
- AMD64_XMM5 = 5,
- AMD64_XMM6 = 6,
- AMD64_XMM7 = 7,
- AMD64_XMM8 = 8,
- AMD64_XMM9 = 9,
- AMD64_XMM10 = 10,
- AMD64_XMM11 = 11,
- AMD64_XMM12 = 12,
- AMD64_XMM13 = 13,
- AMD64_XMM14 = 14,
- AMD64_XMM15 = 15,
- AMD64_XMM_NREG = 16,
-} AMD64_XMM_Reg_No;
-
-typedef enum
-{
- AMD64_REX_B = 1, /* The register in r/m field, base register in SIB byte, or reg in opcode is 8-15 rather than 0-7 */
- AMD64_REX_X = 2, /* The index register in SIB byte is 8-15 rather than 0-7 */
- AMD64_REX_R = 4, /* The reg field of ModRM byte is 8-15 rather than 0-7 */
- AMD64_REX_W = 8 /* Opeartion is 64-bits instead of 32 (default) or 16 (with 0x66 prefix) */
-} AMD64_REX_Bits;
-
-#ifdef TARGET_WIN32
-#define AMD64_ARG_REG1 AMD64_RCX
-#define AMD64_ARG_REG2 AMD64_RDX
-#define AMD64_ARG_REG3 AMD64_R8
-#define AMD64_ARG_REG4 AMD64_R9
-#else
-#define AMD64_ARG_REG1 AMD64_RDI
-#define AMD64_ARG_REG2 AMD64_RSI
-#define AMD64_ARG_REG3 AMD64_RDX
-#define AMD64_ARG_REG4 AMD64_RCX
-#endif
-
-#ifdef TARGET_WIN32
-#define AMD64_CALLEE_REGS ((1<<AMD64_RAX) | (1<<AMD64_RCX) | (1<<AMD64_RDX) | (1<<AMD64_R8) | (1<<AMD64_R9) | (1<<AMD64_R10))
-#define AMD64_IS_CALLEE_REG(reg) (AMD64_CALLEE_REGS & (1 << (reg)))
-
-#define AMD64_ARGUMENT_REGS ((1<<AMD64_RDX) | (1<<AMD64_RCX) | (1<<AMD64_R8) | (1<<AMD64_R9))
-#define AMD64_IS_ARGUMENT_REG(reg) (AMD64_ARGUMENT_REGS & (1 << (reg)))
-
-#define AMD64_CALLEE_SAVED_REGS ((1<<AMD64_RDI) | (1<<AMD64_RSI) | (1<<AMD64_RBX) | (1<<AMD64_R12) | (1<<AMD64_R13) | (1<<AMD64_R14) | (1<<AMD64_R15) | (1<<AMD64_RBP))
-#define AMD64_IS_CALLEE_SAVED_REG(reg) (0!=(AMD64_CALLEE_SAVED_REGS & (1 << (reg))))
-#else
-#define AMD64_CALLEE_REGS ((1<<AMD64_RAX) | (1<<AMD64_RCX) | (1<<AMD64_RDX) | (1<<AMD64_RSI) | (1<<AMD64_RDI) | (1<<AMD64_R8) | (1<<AMD64_R9) | (1<<AMD64_R10))
-#define AMD64_IS_CALLEE_REG(reg) (AMD64_CALLEE_REGS & (1 << (reg)))
-
-#define AMD64_ARGUMENT_REGS ((1<<AMD64_RDI) | (1<<AMD64_RSI) | (1<<AMD64_RDX) | (1<<AMD64_RCX) | (1<<AMD64_R8) | (1<<AMD64_R9))
-#define AMD64_IS_ARGUMENT_REG(reg) (AMD64_ARGUMENT_REGS & (1 << (reg)))
-
-#define AMD64_CALLEE_SAVED_REGS ((1<<AMD64_RBX) | (1<<AMD64_R12) | (1<<AMD64_R13) | (1<<AMD64_R14) | (1<<AMD64_R15) | (1<<AMD64_RBP))
-#define AMD64_IS_CALLEE_SAVED_REG(reg) (0!=(AMD64_CALLEE_SAVED_REGS & (1 << (reg))))
-#endif
-
-#define AMD64_REX(bits) ((unsigned char)(0x40 | (bits)))
-#define amd64_emit_rex(inst, width, reg_modrm, reg_index, reg_rm_base_opcode) do \
- { \
- int reg_rm_base_opcode2=reg_rm_base_opcode; \
- if(reg_rm_base_opcode==AMD64_RIP) reg_rm_base_opcode2=0b100; \
- unsigned char _amd64_rex_bits = \
- (((width) > 4) ? AMD64_REX_W : 0) | \
- (((reg_modrm) > 7) ? AMD64_REX_R : 0) | \
- (((reg_index) > 7) ? AMD64_REX_X : 0) | \
- (((reg_rm_base_opcode2) > 7) ? AMD64_REX_B : 0); \
- if ((_amd64_rex_bits != 0) || (((width) == 1))) *(inst)++ = AMD64_REX(_amd64_rex_bits); \
- } while (0)
-
-typedef union {
- size_t val;
- unsigned char b [8];
-} amd64_imm_buf;
-
-#include "x86-codegen.h"
-#define amd64_patch(ins,target) \
- do { \
- unsigned char rex_correction = 0; \
- if ((*((unsigned char*)(ins)) & 0xf0) == 0x40) rex_correction++; \
- unsigned char* pos = (ins) + 1 + rex_correction; \
- int disp, size = 0; \
- switch (*((unsigned char*)(ins) + rex_correction)) { \
- case 0xe8: case 0xe9: ++size; break; /* call, jump32 */ \
- case 0x0f: if (!(*pos >= 0x70 && *pos <= 0x8f)) assert (0); \
- ++size; ++pos; break; /* prefix for 32-bit disp */ \
- case 0xe0: case 0xe1: case 0xe2: /* loop */ \
- case 0xeb: /* jump8 */ \
- /* conditional jump opcodes */ \
- case 0x70: case 0x71: case 0x72: case 0x73: \
- case 0x74: case 0x75: case 0x76: case 0x77: \
- case 0x78: case 0x79: case 0x7a: case 0x7b: \
- case 0x7c: case 0x7d: case 0x7e: case 0x7f: \
- break; \
- default: assert (0); \
- } \
- disp = (target) - pos; \
- if (size) x86_imm_emit32 (pos, disp - 4); \
- else if (x86_is_imm8 (disp - 1)) x86_imm_emit8 (pos, disp - 1); \
- else assert (0); \
- } while (0)
-
-
-/* In 64 bit mode, all registers have a low byte subregister */
-#undef X86_IS_BYTE_REG
-#define X86_IS_BYTE_REG(reg) 1
-
-#define amd64_modrm_mod(modrm) ((modrm) >> 6)
-#define amd64_modrm_reg(modrm) (((modrm) >> 3) & 0x7)
-#define amd64_modrm_rm(modrm) ((modrm) & 0x7)
-
-#define amd64_rex_r(rex) ((((rex) >> 2) & 0x1) << 3)
-#define amd64_rex_x(rex) ((((rex) >> 1) & 0x1) << 3)
-#define amd64_rex_b(rex) ((((rex) >> 0) & 0x1) << 3)
-
-#define amd64_sib_scale(sib) ((sib) >> 6)
-#define amd64_sib_index(sib) (((sib) >> 3) & 0x7)
-#define amd64_sib_base(sib) ((sib) & 0x7)
-
-#define amd64_is_imm32(val) ((int64_t)val >= -((int64_t)1<<31) && (int64_t)val <= (((int64_t)1<<31)-1))
-
-#define x86_imm_emit64(inst,imm) \
- do { \
- amd64_imm_buf imb; \
- imb.val = (size_t) (imm); \
- *(inst)++ = imb.b [0]; \
- *(inst)++ = imb.b [1]; \
- *(inst)++ = imb.b [2]; \
- *(inst)++ = imb.b [3]; \
- *(inst)++ = imb.b [4]; \
- *(inst)++ = imb.b [5]; \
- *(inst)++ = imb.b [6]; \
- *(inst)++ = imb.b [7]; \
- } while (0)
-
-#define amd64_membase_emit(inst,reg,basereg,disp) do { \
- if ((basereg) == AMD64_RIP) { \
- x86_address_byte ((inst), 0, (reg)&0x7, 5); \
- x86_imm_emit32 ((inst), (disp)); \
- } \
- else \
- x86_membase_emit ((inst),(reg)&0x7, (basereg)&0x7, (disp)); \
-} while (0)
-
-
-#define amd64_mem_emit(inst, disp) do { *(inst)++ = 0x04; *(inst)++ = 0x25; x86_imm_emit32((inst), (disp)); } while (0)
-
-
-#define amd64_alu_reg_imm_size(inst,opc,reg,imm,size) \
- do { \
- if (x86_is_imm8((imm))) { \
- amd64_emit_rex(inst, size, 0, 0, (reg)); \
- *(inst)++ = (unsigned char)0x83; \
- x86_reg_emit ((inst), (opc), (reg)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else if ((reg) == AMD64_RAX) { \
- amd64_emit_rex(inst, size, 0, 0, 0); \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 5; \
- x86_imm_emit32 ((inst), (imm)); \
- } else { \
- amd64_emit_rex(inst, size, 0, 0, (reg)); \
- *(inst)++ = (unsigned char)0x81; \
- x86_reg_emit ((inst), (opc), (reg)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define amd64_alu_reg_imm(inst,opc,reg,imm) amd64_alu_reg_imm_size((inst),(opc),(reg),(imm),8)
-
-#define amd64_alu_reg_reg_size(inst,opc,dreg,reg,size) \
- do { \
- amd64_emit_rex(inst, size, (dreg), 0, (reg)); \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define amd64_alu_reg_reg(inst,opc,dreg,reg) amd64_alu_reg_reg_size ((inst),(opc),(dreg),(reg),8)
-
-#define amd64_mov_regp_reg(inst,regp,reg,size) \
- do { \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, (size), (reg), 0, (regp)); \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x88; break; \
- case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \
- default: assert (0); \
- } \
- x86_regp_emit ((inst), (reg), (regp)); \
- } while (0)
-
-#define amd64_mov_membase_reg(inst,basereg,disp,reg,size) \
- do { \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, (size), (reg), 0, (basereg)); \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x88; break; \
- case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \
- default: assert (0); \
- } \
- x86_membase_emit ((inst), ((reg)&0x7), ((basereg)&0x7), (disp)); \
- } while (0)
-
-#define amd64_mov_mem_reg(inst,mem,reg,size) \
- do { \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, (size), (reg), 0, 0); \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x88; break; \
- case 2: case 4: case 8: *(inst)++ = (unsigned char)0x89; break; \
- default: assert (0); \
- } \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-#define amd64_mov_reg_reg(inst,dreg,reg,size) \
- do { \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, (size), (dreg), 0, (reg)); \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x8a; break; \
- case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \
- default: assert (0); \
- } \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define amd64_mov_reg_mem(inst,reg,mem,size) \
- do { \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, (size), (reg), 0, 0); \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x8a; break; \
- case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \
- default: assert (0); \
- } \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-#define amd64_mov_reg_membase(inst,reg,basereg,disp,size) \
- do { \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, (size), (reg), 0, (basereg)); \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x8a; break; \
- case 2: case 4: case 8: *(inst)++ = (unsigned char)0x8b; break; \
- default: assert (0); \
- } \
- amd64_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define amd64_movzx_reg_reg(inst,dreg,reg,size) \
- do { \
- if ((size) == 4) { \
- amd64_mov_reg_reg(inst, dreg, reg, 4); \
- break; \
- } \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, 8, (dreg), 0, (reg)); \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x0f; *(inst)++ = (unsigned char)0xb6; break; \
- case 2: *(inst)++ = (unsigned char)0x0f; *(inst)++ = (unsigned char)0xb7; break; \
- default: assert (0); \
- } \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define amd64_movzx_reg_mem(inst,reg,mem,size) \
- do { \
- if ((size) == 4) { \
- amd64_mov_reg_mem(inst,reg,mem,size); \
- break; \
- } \
- amd64_emit_rex(inst,8,(reg),0,0); \
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xb6; break; \
- case 2: *(inst)++ = (unsigned char)0xb7; break; \
- default: assert (0); \
- } \
- /*x86_mem_emit ((inst), (reg), (mem)); */ \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-#define amd64_movzx_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) \
- do { \
- if ((size) == 4) { \
- amd64_mov_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size); \
- break; \
- } \
- amd64_emit_rex ((inst),8,(reg),(indexreg),(basereg));\
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xb6; break; \
- case 2: *(inst)++ = (unsigned char)0xb7; break; \
- default: assert (0); \
- } \
- x86_memindex_emit ((inst), (reg)&0x7, (basereg)&0x7, (disp), (indexreg)&0x7, (shift)); \
- } while (0)
-
-
-#define amd64_movzx_reg_membase(inst,reg,basereg,disp,size) \
- do { \
- if ((size) == 4) { \
- amd64_mov_reg_membase(inst, reg, basereg, disp,size); \
- break; \
- } \
- amd64_emit_rex(inst,8,(reg),0,(basereg)); \
- *(inst)++ = (unsigned char)0x0f; \
- switch (size) {\
- case 1: *(inst)++ = (unsigned char)0xb6; break; \
- case 2: *(inst)++ = (unsigned char)0xb7; break; \
- default: assert(0);\
- }\
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-/////////////////////////////////////////////////////////////////////////////////////////////////
-#define amd64_movsx_reg_reg(inst,dreg,reg,size) \
- do { \
- if ((size) == 4) { \
- amd64_movsxd_reg_reg(inst, dreg, reg); \
- break; \
- } \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, 8, (dreg), 0, (reg)); \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x0f; *(inst)++ = (unsigned char)0xbe; break; \
- case 2: *(inst)++ = (unsigned char)0x0f; *(inst)++ = (unsigned char)0xbf; break; \
- default: assert (0); \
- } \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-
-#define amd64_movsx_reg_mem(inst,reg,mem,size) \
- do { \
- if ((size) == 4) { \
- amd64_movsxd_reg_mem(inst,reg,mem); \
- break; \
- } \
- amd64_emit_rex(inst,8,(reg),0,0); \
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xbe; break; \
- case 2: *(inst)++ = (unsigned char)0xbf; break; \
- default: assert (0); \
- } \
- /*x86_mem_emit ((inst), (reg), (mem)); */ \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-#define amd64_movsx_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) \
- do { \
- if ((size) == 4) { \
- amd64_movsxd_reg_memindex(inst,reg,basereg,disp,indexreg,shift); \
- break; \
- } \
- amd64_emit_rex ((inst),8,(reg),(indexreg),(basereg));\
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xbe; break; \
- case 2: *(inst)++ = (unsigned char)0xbf; break; \
- default: assert (0); \
- } \
- x86_memindex_emit ((inst), (reg)&0x7, (basereg)&0x7, (disp), (indexreg)&0x7, (shift)); \
- } while (0)
-
-
-#define amd64_movsx_reg_membase(inst,reg,basereg,disp,size) \
- do { \
- if ((size) == 4) { \
- amd64_movsxd_reg_membase(inst, reg, basereg, disp); \
- break; \
- } \
- amd64_emit_rex(inst,8,(reg),0,(basereg)); \
- *(inst)++ = (unsigned char)0x0f; \
- switch (size) {\
- case 1: *(inst)++ = (unsigned char)0xbe; break; \
- case 2: *(inst)++ = (unsigned char)0xbf; break; \
- default: assert(0);\
- }\
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define amd64_movsxd_reg_mem(inst,reg,mem) \
- do { \
- amd64_emit_rex(inst,8,(reg),0,0); \
- *(inst)++ = (unsigned char)0x63; \
- /*x86_mem_emit ((inst), ((reg)&0x7), (mem));*/ \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-#define amd64_sse_alu_pd_reg_mem(inst,op,reg,mem) \
-do { \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst,8,(reg),0,0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)op; \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
-} while (0)
-
-/*
-#define amd64_sse_alu_sd_reg_mem(inst,op,reg,mem) \
-do { \
- *(inst)++ = (unsigned char)0xf2; \
- amd64_emit_rex(inst,8,(reg),0,0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)op; \
- //x86_mem_emit ((inst), ((reg)&0x7), (mem)); \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
-} while (0)
-*/
-#define amd64_sse_alu_sd_reg_mem(inst,op,reg,mem) \
-do { \
- *(inst)++ = (unsigned char)0xf2; \
- amd64_emit_rex(inst,8,(reg),0,0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)op; \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
-} while (0)
-
-
-#define amd64_sse_alu_sd_reg_reg(inst,opc,dreg,reg) \
- emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, opc)
-
-#define amd64_sse_alu_pd_reg_reg(inst,opc,dreg,reg) \
- emit_sse_reg_reg ((inst), (dreg), (reg), 0x66, 0x0f, opc)
-
-#define amd64_sse_alu_pd_reg_reg_imm(ip, op, dreg, reg, imm) \
- emit_sse_reg_reg_imm(ip, dreg, reg, 0x66, 0x0f, op, imm)
-
-#define amd64_sse_alu_pd_reg_membase(inst,opc,dreg,basereg,disp) \
- emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0x66, 0x0f, opc)
-
-#define amd64_sse_alu_sd_reg_membase(inst,opc,dreg,basereg,disp) \
- emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0xf2, 0x0f, opc)
-
-
-#define amd64_movsxd_reg_memindex(inst,reg,basereg,disp,indexreg,shift) \
- do { \
- amd64_emit_rex ((inst),8,(reg),(indexreg),(basereg));\
- *(inst)++ = (unsigned char)0x63; \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define amd64_movsxd_reg_membase(inst,reg,basereg,disp) \
- do { \
- amd64_emit_rex(inst,8,(reg),0,(basereg)); \
- *(inst)++ = (unsigned char)0x63; \
- x86_membase_emit ((inst), ((reg)&0x7), ((basereg)&0x7), (disp)); \
- } while (0)
-
-#define amd64_movsxd_reg_reg(inst,dreg,reg) \
- do { \
- amd64_emit_rex(inst,8,(dreg),0,(reg)); \
- *(inst)++ = (unsigned char)0x63; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-/* Pretty much the only instruction that supports a 64-bit immediate. Optimize for common case of
- * 32-bit immediate. Pepper with casts to avoid warnings.
- */
-#define amd64_mov_reg_imm_size(inst,reg,imm,size) \
- do { \
- amd64_emit_rex(inst, (size), 0, 0, (reg)); \
- *(inst)++ = (unsigned char)0xb8 + ((reg) & 0x7); \
- if ((size) == 8) \
- x86_imm_emit64 ((inst), (size_t)(imm)); \
- else \
- x86_imm_emit32 ((inst), (int)(size_t)(imm)); \
- } while (0)
-
-#define amd64_mov_reg_imm(inst,reg,imm) \
- do { \
- int _amd64_width_temp = ((size_t)(imm) == (size_t)(int)(size_t)(imm)); \
- amd64_mov_reg_imm_size ((inst), (reg), (imm), (_amd64_width_temp ? 4 : 8)); \
- } while (0)
-
-#define amd64_set_reg_template(inst,reg) amd64_mov_reg_imm_size ((inst),(reg), 0, 8)
-
-#define amd64_set_template(inst,reg) amd64_set_reg_template((inst),(reg))
-
-#define amd64_mov_membase_imm(inst,basereg,disp,imm,size) \
- do { \
- if ((size) == 2) \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, (size) == 1 ? 0 : (size), 0, 0, (basereg)); \
- if ((size) == 1) { \
- *(inst)++ = (unsigned char)0xc6; \
- x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else if ((size) == 2) { \
- *(inst)++ = (unsigned char)0xc7; \
- x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \
- x86_imm_emit16 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0xc7; \
- x86_membase_emit ((inst), 0, (basereg) & 0x7, (disp)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define amd64_lea_membase(inst,reg,basereg,disp) \
- do { \
- amd64_emit_rex(inst, 8, (reg), 0, (basereg)); \
- *(inst)++ = (unsigned char)0x8d; \
- amd64_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-/* Instruction are implicitly 64-bits so don't generate REX for just the size. */
-#define amd64_push_reg(inst,reg) \
- do { \
- amd64_emit_rex(inst, 0, 0, 0, (reg)); \
- *(inst)++ = (unsigned char)0x50 + ((reg) & 0x7); \
- } while (0)
-
-/* Instruction is implicitly 64-bits so don't generate REX for just the size. */
-#define amd64_push_membase(inst,basereg,disp) \
- do { \
- amd64_emit_rex(inst, 0, 0, 0, (basereg)); \
- *(inst)++ = (unsigned char)0xff; \
- x86_membase_emit ((inst), 6, (basereg) & 0x7, (disp)); \
- } while (0)
-
-#define amd64_pop_reg(inst,reg) \
- do { \
- amd64_emit_rex(inst, 0, 0, 0, (reg)); \
- *(inst)++ = (unsigned char)0x58 + ((reg) & 0x7); \
- } while (0)
-
-#define amd64_call_reg(inst,reg) \
- do { \
- amd64_emit_rex(inst, 0, 0, 0, (reg)); \
- *(inst)++ = (unsigned char)0xff; \
- x86_reg_emit ((inst), 2, ((reg) & 0x7)); \
- } while (0)
-
-#define amd64_ret(inst) do { *(inst)++ = (unsigned char)0xc3; } while (0)
-#define amd64_leave(inst) do { *(inst)++ = (unsigned char)0xc9; } while (0)
-#define amd64_movsd_reg_regp(inst,reg,regp) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- amd64_emit_rex(inst, 0, (reg), 0, (regp)); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \
- } while (0)
-
-#define amd64_movsd_regp_reg(inst,regp,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- amd64_emit_rex(inst, 0, (reg), 0, (regp)); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \
- } while (0)
-
-#define amd64_movss_reg_regp(inst,reg,regp) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex(inst, 0, (reg), 0, (regp)); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \
- } while (0)
-
-#define amd64_movss_regp_reg(inst,regp,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex(inst, 0, (reg), 0, (regp)); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_regp_emit ((inst), (reg) & 0x7, (regp) & 0x7); \
- } while (0)
-
-#define amd64_movsd_reg_membase(inst,reg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \
- } while (0)
-#define amd64_movsd_reg_mem(inst,reg,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- amd64_emit_rex(inst, 0, (reg), 0, 0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-#define amd64_movss_reg_mem(inst,reg,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex(inst, 0, (reg), 0, 0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-#define amd64_movss_mem_reg(inst,mem,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex(inst, 0, (reg), 0, 0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-#define amd64_movlpd_mem_reg(inst,mem,reg) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, 0, (reg), 0, 0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x13; \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-
-
-#define amd64_sse_cvtss2sd_reg_mem(inst,reg,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex(inst, 0, (reg), 0, 0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x5a; \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-
-#define amd64_sse_cvtss2sd_reg_memindex(inst,reg,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex ((inst),8,(reg),(indexreg),(basereg));\
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x5a; \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define amd64_sse_movlpd_xreg_memindex(inst,reg,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex ((inst),8,(reg),(indexreg),(basereg));\
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x12; \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define amd64_sse_movlpd_memindex_xreg(inst,basereg,disp,indexreg,shift,reg) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex ((inst),8,(reg),(indexreg),(basereg));\
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x13; \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define amd64_sse_movss_memindex_xreg(inst,basereg,disp,indexreg,shift,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex ((inst),8,(reg),(indexreg),(basereg));\
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define amd64_sse_xorpd_reg_mem(inst,reg,mem) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- amd64_emit_rex(inst, 0, (reg), 0, 0); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x57; \
- x86_address_byte ((inst), 0, (reg), 4); \
- x86_address_byte ((inst), 0, 4, 5); \
- x86_imm_emit32 ((inst), (mem)); \
- } while (0)
-
-
-#define amd64_movss_reg_membase(inst,reg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \
- } while (0)
-
-#define amd64_movsd_membase_reg(inst,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \
- } while (0)
-
-#define amd64_movss_membase_reg(inst,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- amd64_emit_rex(inst, 0, (reg), 0, (basereg)); \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_membase_emit ((inst), (reg) & 0x7, (basereg) & 0x7, (disp)); \
- } while (0)
-
-/* The original inc_reg opcode is used as the REX prefix */
-#define amd64_inc_reg_size(inst,reg,size) \
- do { \
- amd64_emit_rex ((inst),(size),0,0,(reg)); \
- *(inst)++ = (unsigned char)0xff; \
- x86_reg_emit ((inst),0,(reg) & 0x7); \
- } while (0)
-
-#define amd64_dec_reg_size(inst,reg,size) \
- do { \
- amd64_emit_rex ((inst),(size),0,0,(reg)); \
- *(inst)++ = (unsigned char)0xff; \
- x86_reg_emit ((inst),1,(reg) & 0x7); \
- } while (0)
-
-/* From the AMD64 Software Optimization Manual */
-#define amd64_padding_size(inst,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = 0x90; break; \
- case 2: *(inst)++ = 0x66; *(inst)++ = 0x90; break; \
- case 3: *(inst)++ = 0x66; *(inst)++ = 0x66; *(inst)++ = 0x90; break; \
- default: amd64_emit_rex ((inst),8,0,0,0); x86_padding ((inst), (size) - 1); \
- }; \
- } while (0)
-
-#define amd64_fld_membase_size(inst,basereg,disp,is_double,size) do { \
- amd64_emit_rex ((inst),0,0,0,(basereg)); \
- *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \
- amd64_membase_emit ((inst), 0, (basereg), (disp)); \
-} while (0)
-
-#define amd64_call_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); *(inst)++ = (unsigned char)0xff; amd64_membase_emit ((inst),2, (basereg),(disp)); } while (0)
-#define amd64_jump_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); *(inst)++ = (unsigned char)0xff; amd64_membase_emit ((inst), 4, (basereg), (disp)); } while (0)
-
-#define amd64_jump_code_size(inst,target,size) do { \
- if (amd64_is_imm32 ((int64_t)(target) - (int64_t)(inst))) { \
- x86_jump_code((inst),(target)); \
- } else { \
- amd64_jump_membase ((inst), AMD64_RIP, 0); \
- *(uint64_t*)(inst) = (uint64_t)(target); \
- (inst) += 8; \
- } \
-} while (0)
-
-/*
- * SSE
- */
-
-//TODO Reorganize SSE opcode defines.
-
-/* Two opcode SSE defines */
-
-#define emit_sse_reg_reg_op2_size(inst,dreg,reg,op1,op2,size) do { \
- amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \
- *(inst)++ = (unsigned char)(op1); \
- *(inst)++ = (unsigned char)(op2); \
- x86_reg_emit ((inst), (dreg), (reg)); \
-} while (0)
-
-#define emit_sse_reg_reg_op2(inst,dreg,reg,op1,op2) emit_sse_reg_reg_op2_size ((inst), (dreg), (reg), (op1), (op2), 0)
-
-#define emit_sse_reg_reg_op2_imm(inst,dreg,reg,op1,op2,imm) do { \
- emit_sse_reg_reg_op2 ((inst), (dreg), (reg), (op1), (op2)); \
- x86_imm_emit8 ((inst), (imm)); \
-} while (0)
-
-#define emit_sse_membase_reg_op2(inst,basereg,disp,reg,op1,op2) do { \
- amd64_emit_rex ((inst), 0, (reg), 0, (basereg)); \
- *(inst)++ = (unsigned char)(op1); \
- *(inst)++ = (unsigned char)(op2); \
- amd64_membase_emit ((inst), (reg), (basereg), (disp)); \
-} while (0)
-
-#define emit_sse_reg_membase_op2(inst,dreg,basereg,disp,op1,op2) do { \
- amd64_emit_rex ((inst), 0, (dreg), 0, (basereg) == AMD64_RIP ? 0 : (basereg)); \
- *(inst)++ = (unsigned char)(op1); \
- *(inst)++ = (unsigned char)(op2); \
- amd64_membase_emit ((inst), (dreg), (basereg), (disp)); \
-} while (0)
-
-/* Three opcode SSE defines */
-
-#define emit_opcode3(inst,op1,op2,op3) do { \
- *(inst)++ = (unsigned char)(op1); \
- *(inst)++ = (unsigned char)(op2); \
- *(inst)++ = (unsigned char)(op3); \
-} while (0)
-
-#define emit_sse_reg_reg_size(inst,dreg,reg,op1,op2,op3,size) do { \
- *(inst)++ = (unsigned char)(op1); \
- amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \
- *(inst)++ = (unsigned char)(op2); \
- *(inst)++ = (unsigned char)(op3); \
- x86_reg_emit ((inst), (dreg), (reg)); \
-} while (0)
-
-#define emit_sse_reg_reg(inst,dreg,reg,op1,op2,op3) emit_sse_reg_reg_size ((inst), (dreg), (reg), (op1), (op2), (op3), 0)
-
-#define emit_sse_reg_reg_imm(inst,dreg,reg,op1,op2,op3,imm) do { \
- emit_sse_reg_reg ((inst), (dreg), (reg), (op1), (op2), (op3)); \
- x86_imm_emit8 ((inst), (imm)); \
-} while (0)
-
-#define emit_sse_membase_reg(inst,basereg,disp,reg,op1,op2,op3) do { \
- *(inst)++ = (unsigned char)(op1); \
- amd64_emit_rex ((inst), 0, (reg), 0, (basereg)); \
- *(inst)++ = (unsigned char)(op2); \
- *(inst)++ = (unsigned char)(op3); \
- amd64_membase_emit ((inst), (reg), (basereg), (disp)); \
-} while (0)
-
-#define emit_sse_reg_membase(inst,dreg,basereg,disp,op1,op2,op3) do { \
- *(inst)++ = (unsigned char)(op1); \
- amd64_emit_rex ((inst), 0, (dreg), 0, (basereg) == AMD64_RIP ? 0 : (basereg)); \
- *(inst)++ = (unsigned char)(op2); \
- *(inst)++ = (unsigned char)(op3); \
- amd64_membase_emit ((inst), (dreg), (basereg), (disp)); \
-} while (0)
-
-/* Four opcode SSE defines */
-
-#define emit_sse_reg_reg_op4_size(inst,dreg,reg,op1,op2,op3,op4,size) do { \
- *(inst)++ = (unsigned char)(op1); \
- amd64_emit_rex ((inst), size, (dreg), 0, (reg)); \
- *(inst)++ = (unsigned char)(op2); \
- *(inst)++ = (unsigned char)(op3); \
- *(inst)++ = (unsigned char)(op4); \
- x86_reg_emit ((inst), (dreg), (reg)); \
-} while (0)
-
-#define emit_sse_reg_reg_op4(inst,dreg,reg,op1,op2,op3,op4) emit_sse_reg_reg_op4_size ((inst), (dreg), (reg), (op1), (op2), (op3), (op4), 0)
-
-/* specific SSE opcode defines */
-
-#define amd64_sse_xorpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg), 0x66, 0x0f, 0x57)
-
-#define amd64_sse_xorpd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst),(dreg),(basereg), (disp), 0x66, 0x0f, 0x57)
-
-#define amd64_sse_andpd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst),(dreg),(basereg), (disp), 0x66, 0x0f, 0x54)
-
-#define amd64_sse_movsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x10)
-
-#define amd64_sse_movsd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0xf2, 0x0f, 0x10)
-
-#define amd64_sse_movlpd_membase_xreg(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0x66, 0x0f, 0x13)
-#define amd64_sse_movlpd_xreg_membase(inst,dreg,basereg,disp) emit_sse_membase_reg ((inst), (basereg), (disp), (dreg), 0x66, 0x0f, 0x12)
-
-
-
-#define amd64_sse_movsd_membase_reg(inst,basereg,disp,reg) emit_sse_membase_reg ((inst), (basereg), (disp), (reg), 0xf2, 0x0f, 0x11)
-
-#define amd64_sse_movss_membase_reg(inst,basereg,disp,reg) emit_sse_membase_reg ((inst), (basereg), (disp), (reg), 0xf3, 0x0f, 0x11)
-
-#define amd64_sse_movss_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0xf3, 0x0f, 0x10)
-
-#define amd64_sse_comisd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg),0x66,0x0f,0x2f)
-
-#define amd64_sse_comisd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase ((inst), (dreg), (basereg), (disp), 0x66, 0x0f, 0x2f)
-
-#define amd64_sse_ucomisd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst),(dreg),(reg),0x66,0x0f,0x2e)
-
-#define amd64_sse_cvtsd2si_reg_reg(inst,dreg,reg) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2d, 8)
-
-#define amd64_sse_cvttsd2si_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2c, (size))
-
-#define amd64_sse_cvttsd2si_reg_reg(inst,dreg,reg) amd64_sse_cvttsd2si_reg_reg_size ((inst), (dreg), (reg), 8)
-
-#define amd64_sse_cvtsi2sd_reg_reg_size(inst,dreg,reg,size) emit_sse_reg_reg_size ((inst), (dreg), (reg), 0xf2, 0x0f, 0x2a, (size))
-
-#define amd64_sse_cvtsi2sd_reg_reg(inst,dreg,reg) amd64_sse_cvtsi2sd_reg_reg_size ((inst), (dreg), (reg), 8)
-
-#define amd64_sse_cvtsd2ss_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5a)
-
-#define amd64_sse_cvtss2sd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf3, 0x0f, 0x5a)
-
-#define amd64_sse_addsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x58)
-
-#define amd64_sse_subsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5c)
-
-#define amd64_sse_mulsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x59)
-
-#define amd64_sse_divsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg ((inst), (dreg), (reg), 0xf2, 0x0f, 0x5e)
-
-#define amd64_sse_sqrtsd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x51)
-
-
-#define amd64_sse_pinsrw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm ((inst), (dreg), (reg), 0x66, 0x0f, 0xc4, (imm))
-
-#define amd64_sse_pextrw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm ((inst), (dreg), (reg), 0x66, 0x0f, 0xc5, (imm))
-
-
-#define amd64_sse_cvttsd2si_reg_xreg_size(inst,reg,xreg,size) emit_sse_reg_reg_size ((inst), (reg), (xreg), 0xf2, 0x0f, 0x2c, (size))
-
-
-#define amd64_sse_addps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x58)
-
-#define amd64_sse_divps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5e)
-
-#define amd64_sse_mulps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x59)
-
-#define amd64_sse_subps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5c)
-
-#define amd64_sse_maxps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5f)
-
-#define amd64_sse_minps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x5d)
-
-#define amd64_sse_cmpps_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_op2_imm((inst), (dreg), (reg), 0x0f, 0xc2, (imm))
-
-#define amd64_sse_andps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x54)
-
-#define amd64_sse_andnps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x55)
-
-#define amd64_sse_orps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x56)
-
-#define amd64_sse_xorps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x57)
-
-#define amd64_sse_sqrtps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x51)
-
-#define amd64_sse_rsqrtps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x52)
-
-#define amd64_sse_rcpps_reg_reg(inst,dreg,reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x53)
-
-#define amd64_sse_addsubps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0xd0)
-
-#define amd64_sse_haddps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x7c)
-
-#define amd64_sse_hsubps_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x7d)
-
-#define amd64_sse_movshdup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf3, 0x0f, 0x16)
-
-#define amd64_sse_movsldup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf3, 0x0f, 0x12)
-
-
-#define amd64_sse_pshufhw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0xf3, 0x0f, 0x70, (imm))
-
-#define amd64_sse_pshuflw_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0xf2, 0x0f, 0x70, (imm))
-
-#define amd64_sse_pshufd_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0x66, 0x0f, 0x70, (imm))
-
-
-#define amd64_sse_addpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x58)
-
-#define amd64_sse_divpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5e)
-
-#define amd64_sse_mulpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x59)
-
-#define amd64_sse_subpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5c)
-
-#define amd64_sse_maxpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5f)
-
-#define amd64_sse_minpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x5d)
-
-#define amd64_sse_cmppd_reg_reg_imm(inst,dreg,reg,imm) emit_sse_reg_reg_imm((inst), (dreg), (reg), 0x66, 0x0f, 0xc2, (imm))
-
-#define amd64_sse_andpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x54)
-
-#define amd64_sse_andnpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x55)
-
-#define amd64_sse_orpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x56)
-
-#define amd64_sse_sqrtpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x51)
-
-#define amd64_sse_rsqrtpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x52)
-
-#define amd64_sse_rcppd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x53)
-
-#define amd64_sse_addsubpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd0)
-
-#define amd64_sse_haddpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x7c)
-
-#define amd64_sse_hsubpd_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x7d)
-
-#define amd64_sse_movddup_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0xf2, 0x0f, 0x12)
-
-
-#define amd64_sse_pmovmskb_reg_reg(inst,dreg,reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd7)
-
-
-#define amd64_sse_pand_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdb)
-
-#define amd64_sse_por_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xeb)
-
-#define amd64_sse_pxor_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xef)
-
-
-#define amd64_sse_paddb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfc)
-
-#define amd64_sse_paddw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfd)
-
-#define amd64_sse_paddd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfe)
-
-#define amd64_sse_paddq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd4)
-
-
-#define amd64_sse_psubb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf8)
-
-#define amd64_sse_psubw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf9)
-
-#define amd64_sse_psubd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfa)
-
-#define amd64_sse_psubq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xfb)
-
-
-#define amd64_sse_pmaxub_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xde)
-
-#define amd64_sse_pmaxuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3e)
-
-#define amd64_sse_pmaxud_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3f)
-
-
-#define amd64_sse_pmaxsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3c)
-
-#define amd64_sse_pmaxsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xee)
-
-#define amd64_sse_pmaxsd_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3d)
-
-
-#define amd64_sse_pavgb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe0)
-
-#define amd64_sse_pavgw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe3)
-
-
-#define amd64_sse_pminub_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xda)
-
-#define amd64_sse_pminuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3a)
-
-#define amd64_sse_pminud_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x3b)
-
-
-#define amd64_sse_pminsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x38)
-
-#define amd64_sse_pminsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xea)
-
-#define amd64_sse_pminsd_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x39)
-
-
-#define amd64_sse_pcmpeqb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x74)
-
-#define amd64_sse_pcmpeqw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x75)
-
-#define amd64_sse_pcmpeqd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x76)
-
-#define amd64_sse_pcmpeqq_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x29)
-
-
-#define amd64_sse_pcmpgtb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x64)
-
-#define amd64_sse_pcmpgtw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x65)
-
-#define amd64_sse_pcmpgtd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x66)
-
-#define amd64_sse_pcmpgtq_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x37)
-
-
-#define amd64_sse_psadbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf6)
-
-
-#define amd64_sse_punpcklbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x60)
-
-#define amd64_sse_punpcklwd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x61)
-
-#define amd64_sse_punpckldq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x62)
-
-#define amd64_sse_punpcklqdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6c)
-
-#define amd64_sse_unpcklpd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x14)
-
-#define amd64_sse_unpcklps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x14)
-
-
-#define amd64_sse_punpckhbw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x68)
-
-#define amd64_sse_punpckhwd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x69)
-
-#define amd64_sse_punpckhdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6a)
-
-#define amd64_sse_punpckhqdq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6d)
-
-#define amd64_sse_unpckhpd_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x15)
-
-#define amd64_sse_unpckhps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x15)
-
-
-#define amd64_sse_packsswb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x63)
-
-#define amd64_sse_packssdw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x6b)
-
-#define amd64_sse_packuswb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0x67)
-
-#define amd64_sse_packusdw_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x2b)
-
-
-#define amd64_sse_paddusb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdc)
-
-#define amd64_sse_psubusb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd8)
-
-#define amd64_sse_paddusw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xdd)
-
-#define amd64_sse_psubusw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd8)
-
-
-#define amd64_sse_paddsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xec)
-
-#define amd64_sse_psubsb_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe8)
-
-#define amd64_sse_paddsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xed)
-
-#define amd64_sse_psubsw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe9)
-
-
-#define amd64_sse_pmullw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd5)
-
-#define amd64_sse_pmulld_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op4((inst), (dreg), (reg), 0x66, 0x0f, 0x38, 0x40)
-
-#define amd64_sse_pmuludq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf4)
-
-#define amd64_sse_pmulhuw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe4)
-
-#define amd64_sse_pmulhw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe5)
-
-
-#define amd64_sse_psrlw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x71, (imm))
-
-#define amd64_sse_psrlw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd1)
-
-
-#define amd64_sse_psraw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x71, (imm))
-
-#define amd64_sse_psraw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe1)
-
-
-#define amd64_sse_psllw_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x71, (imm))
-
-#define amd64_sse_psllw_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf1)
-
-
-#define amd64_sse_psrld_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x72, (imm))
-
-#define amd64_sse_psrld_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd2)
-
-
-#define amd64_sse_psrad_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x72, (imm))
-
-#define amd64_sse_psrad_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe2)
-
-
-#define amd64_sse_pslld_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x72, (imm))
-
-#define amd64_sse_pslld_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf2)
-
-
-#define amd64_sse_psrlq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHR, (reg), 0x66, 0x0f, 0x73, (imm))
-
-#define amd64_sse_psrlq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xd3)
-
-
-#define amd64_sse_psraq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SAR, (reg), 0x66, 0x0f, 0x73, (imm))
-
-#define amd64_sse_psraq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xe3)
-
-
-#define amd64_sse_psllq_reg_imm(inst, reg, imm) emit_sse_reg_reg_imm((inst), X86_SSE_SHL, (reg), 0x66, 0x0f, 0x73, (imm))
-
-#define amd64_sse_psllq_reg_reg(inst, dreg, reg) emit_sse_reg_reg((inst), (dreg), (reg), 0x66, 0x0f, 0xf3)
-
-
-#define amd64_movd_xreg_reg_size(inst,dreg,sreg,size) emit_sse_reg_reg_size((inst), (dreg), (sreg), 0x66, 0x0f, 0x6e, (size))
-
-#define amd64_movd_reg_xreg_size(inst,dreg,sreg,size) emit_sse_reg_reg_size((inst), (sreg), (dreg), 0x66, 0x0f, 0x7e, (size))
-
-#define amd64_movd_xreg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase((inst), (dreg), (basereg), (disp), 0x66, 0x0f, 0x6e)
-#define amd64_sse_cvtss2sd_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase((inst), (dreg), (basereg), (disp), 0xf3, 0x0f, 0x5a)
-#define amd64_sse_cvtsd2ss_reg_membase(inst,dreg,basereg,disp) emit_sse_reg_membase((inst), (dreg), (basereg), (disp), 0xf2, 0x0f, 0x5a)
-
-
-#define amd64_movlhps_reg_reg(inst,dreg,sreg) emit_sse_reg_reg_op2((inst), (dreg), (sreg), 0x0f, 0x16)
-
-#define amd64_movhlps_reg_reg(inst,dreg,sreg) emit_sse_reg_reg_op2((inst), (dreg), (sreg), 0x0f, 0x12)
-
-
-#define amd64_sse_movups_membase_reg(inst, basereg, disp, reg) emit_sse_membase_reg_op2((inst), (basereg), (disp), (reg), 0x0f, 0x11)
-
-#define amd64_sse_movups_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x10)
-
-#define amd64_sse_movaps_membase_reg(inst, basereg, disp, reg) emit_sse_membase_reg_op2((inst), (basereg), (disp), (reg), 0x0f, 0x29)
-
-#define amd64_sse_movaps_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x28)
-
-#define amd64_sse_movaps_reg_reg(inst, dreg, reg) emit_sse_reg_reg_op2((inst), (dreg), (reg), 0x0f, 0x28)
-
-#define amd64_sse_movntps_reg_membase(inst, dreg, basereg, disp) emit_sse_reg_membase_op2((inst), (dreg), (basereg), (disp), 0x0f, 0x2b)
-
-#define amd64_sse_prefetch_reg_membase(inst, arg, basereg, disp) emit_sse_reg_membase_op2((inst), (arg), (basereg), (disp), 0x0f, 0x18)
-
-/* Generated from x86-codegen.h */
-
-#define amd64_breakpoint_size(inst,size) do { x86_breakpoint(inst); } while (0)
-#define amd64_cld_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_cld(inst); } while (0)
-#define amd64_stosb_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_stosb(inst); } while (0)
-#define amd64_stosl_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_stosl(inst); } while (0)
-#define amd64_stosd_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_stosd(inst); } while (0)
-#define amd64_movsb_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_movsb(inst); } while (0)
-#define amd64_movsl_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_movsl(inst); } while (0)
-#define amd64_movsd_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_movsd(inst); } while (0)
-#define amd64_prefix_size(inst,p,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_prefix((inst), p); } while (0)
-#define amd64_rdtsc_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_rdtsc(inst); } while (0)
-#define amd64_cmpxchg_reg_reg_size(inst,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_cmpxchg_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); } while (0)
-#define amd64_cmpxchg_mem_reg_size(inst,mem,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_cmpxchg_mem_reg((inst),(mem),((reg)&0x7)); } while (0)
-#define amd64_cmpxchg_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_cmpxchg_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7)); } while (0)
-#define amd64_xchg_reg_reg_size(inst,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_xchg_reg_reg((inst),((dreg)&0x7),((reg)&0x7),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_xchg_mem_reg_size(inst,mem,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_xchg_mem_reg((inst),(mem),((reg)&0x7),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_xchg_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_xchg_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_inc_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_inc_mem((inst),(mem)); } while (0)
-#define amd64_inc_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_inc_membase((inst),((basereg)&0x7),(disp)); } while (0)
-//#define amd64_inc_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_inc_reg((inst),((reg)&0x7)); } while (0)
-#define amd64_dec_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_dec_mem((inst),(mem)); } while (0)
-#define amd64_dec_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_dec_membase((inst),((basereg)&0x7),(disp)); } while (0)
-//#define amd64_dec_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_dec_reg((inst),((reg)&0x7)); } while (0)
-#define amd64_not_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_not_mem((inst),(mem)); } while (0)
-#define amd64_not_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_not_membase((inst),((basereg)&0x7),(disp)); } while (0)
-#define amd64_not_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_not_reg((inst),((reg)&0x7)); } while (0)
-#define amd64_neg_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_neg_mem((inst),(mem)); } while (0)
-#define amd64_neg_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_neg_membase((inst),((basereg)&0x7),(disp)); } while (0)
-#define amd64_neg_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_neg_reg((inst),((reg)&0x7)); } while (0)
-#define amd64_nop_size(inst,size) do { x86_nop(inst); } while (0)
-//#define amd64_alu_reg_imm_size(inst,opc,reg,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_reg_imm((inst),(opc),((reg)&0x7),(imm)); } while (0)
-#define amd64_alu_mem_imm_size(inst,opc,mem,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_alu_mem_imm((inst),(opc),(mem),(imm)); } while (0)
-#define amd64_alu_membase_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_alu_membase_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); } while (0)
-#define amd64_alu_membase8_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_alu_membase8_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); } while (0)
-#define amd64_alu_mem_reg_size(inst,opc,mem,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_mem_reg((inst),(opc),(mem),((reg)&0x7)); } while (0)
-#define amd64_alu_membase_reg_size(inst,opc,basereg,disp,reg,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_alu_membase_reg((inst),(opc),((basereg)&0x7),(disp),((reg)&0x7)); } while (0)
-//#define amd64_alu_reg_reg_size(inst,opc,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_alu_reg_reg((inst),(opc),((dreg)&0x7),((reg)&0x7)); } while (0)
-#define amd64_alu_reg8_reg8_size(inst,opc,dreg,reg,is_dreg_h,is_reg_h,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_alu_reg8_reg8((inst),(opc),((dreg)&0x7),((reg)&0x7),(is_dreg_h),(is_reg_h)); } while (0)
-#define amd64_alu_reg_mem_size(inst,opc,reg,mem,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_alu_reg_mem((inst),(opc),((reg)&0x7),(mem)); } while (0)
-#define amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_alu_reg_membase((inst),(opc),((reg)&0x7),((basereg)&0x7),(disp)); } while (0)
-#define amd64_test_reg_imm_size(inst,reg,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_test_reg_imm((inst),((reg)&0x7),(imm)); } while (0)
-#define amd64_test_mem_imm_size(inst,mem,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_test_mem_imm((inst),(mem),(imm)); } while (0)
-#define amd64_test_membase_imm_size(inst,basereg,disp,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_test_membase_imm((inst),((basereg)&0x7),(disp),(imm)); } while (0)
-#define amd64_test_reg_reg_size(inst,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_test_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); } while (0)
-#define amd64_test_mem_reg_size(inst,mem,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_test_mem_reg((inst),(mem),((reg)&0x7)); } while (0)
-#define amd64_test_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_test_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7)); } while (0)
-#define amd64_shift_reg_imm_size(inst,opc,reg,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_reg_imm((inst),(opc),((reg)&0x7),(imm)); } while (0)
-#define amd64_shift_mem_imm_size(inst,opc,mem,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_mem_imm((inst),(opc),(mem),(imm)); } while (0)
-#define amd64_shift_membase_imm_size(inst,opc,basereg,disp,imm,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_shift_membase_imm((inst),(opc),((basereg)&0x7),(disp),(imm)); } while (0)
-#define amd64_shift_reg_size(inst,opc,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_reg((inst),(opc),((reg)&0x7)); } while (0)
-#define amd64_shift_mem_size(inst,opc,mem,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_shift_mem((inst),(opc),(mem)); } while (0)
-#define amd64_shift_membase_size(inst,opc,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_shift_membase((inst),(opc),((basereg)&0x7),(disp)); } while (0)
-#define amd64_shrd_reg_size(inst,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shrd_reg((inst),((dreg)&0x7),((reg)&0x7)); } while (0)
-#define amd64_shrd_reg_imm_size(inst,dreg,reg,shamt,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shrd_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(shamt)); } while (0)
-#define amd64_shld_reg_size(inst,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shld_reg((inst),((dreg)&0x7),((reg)&0x7)); } while (0)
-#define amd64_shld_reg_imm_size(inst,dreg,reg,shamt,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_shld_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(shamt)); } while (0)
-#define amd64_mul_reg_size(inst,reg,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mul_reg((inst),((reg)&0x7),(is_signed)); } while (0)
-#define amd64_mul_mem_size(inst,mem,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_mul_mem((inst),(mem),(is_signed)); } while (0)
-#define amd64_mul_membase_size(inst,basereg,disp,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_mul_membase((inst),((basereg)&0x7),(disp),(is_signed)); } while (0)
-#define amd64_imul_reg_reg_size(inst,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_imul_reg_reg((inst),((dreg)&0x7),((reg)&0x7)); } while (0)
-#define amd64_imul_reg_mem_size(inst,reg,mem,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_imul_reg_mem((inst),((reg)&0x7),(mem)); } while (0)
-#define amd64_imul_reg_membase_size(inst,reg,basereg,disp,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_imul_reg_membase((inst),((reg)&0x7),((basereg)&0x7),(disp)); } while (0)
-#define amd64_imul_reg_reg_imm_size(inst,dreg,reg,imm,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_imul_reg_reg_imm((inst),((dreg)&0x7),((reg)&0x7),(imm)); } while (0)
-#define amd64_imul_reg_mem_imm_size(inst,reg,mem,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_imul_reg_mem_imm((inst),((reg)&0x7),(mem),(imm)); } while (0)
-#define amd64_imul_reg_membase_imm_size(inst,reg,basereg,disp,imm,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_imul_reg_membase_imm((inst),((reg)&0x7),((basereg)&0x7),(disp),(imm)); } while (0)
-#define amd64_div_reg_size(inst,reg,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_div_reg((inst),((reg)&0x7),(is_signed)); } while (0)
-#define amd64_div_mem_size(inst,mem,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_div_mem((inst),(mem),(is_signed)); } while (0)
-#define amd64_div_membase_size(inst,basereg,disp,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_div_membase((inst),((basereg)&0x7),(disp),(is_signed)); } while (0)
-#define amd64_mov_mem_reg_size(inst,mem,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_mem_reg((inst),(mem),((reg)&0x7),(size) == 8 ? 4 : (size)); } while (0)
-//#define amd64_mov_regp_reg_size(inst,regp,reg,size) do { amd64_emit_rex ((inst),(size),(regp),0,(reg)); x86_mov_regp_reg((inst),(regp),((reg)&0x7),(size) == 8 ? 4 : (size)); } while (0)
-//#define amd64_mov_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_mov_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_mov_memindex_reg_size(inst,basereg,disp,indexreg,shift,reg,size) do { amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_mov_memindex_reg((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),((reg)&0x7),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_mov_reg_reg_size(inst,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_mov_reg_reg((inst),((dreg)&0x7),((reg)&0x7),(size) == 8 ? 4 : (size)); } while (0)
-//#define amd64_mov_reg_mem_size(inst,reg,mem,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_reg_mem((inst),((reg)&0x7),(mem),(size) == 8 ? 4 : (size)); } while (0)
-//#define amd64_mov_reg_membase_size(inst,reg,basereg,disp,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_mov_reg_membase((inst),((reg)&0x7),((basereg)&0x7),(disp),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_mov_reg_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) do { amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_mov_reg_memindex((inst),((reg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_clear_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_clear_reg((inst),((reg)&0x7)); } while (0)
-//#define amd64_mov_reg_imm_size(inst,reg,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_mov_reg_imm((inst),((reg)&0x7),(imm)); } while (0)
-//#define amd64_mov_mem_imm_size(inst,mem,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_mov_mem_imm((inst),(mem),(imm),(size) == 8 ? 4 : (size)); } while (0)
- #define amd64_mov_mem_imm_size(inst,mem,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); \
- if ((size) == 1) { \
- *(inst)++ = (unsigned char)0xc6; \
- amd64_mem_emit ((inst), (mem)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else if ((size) == 2) { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0xc7; \
- amd64_mem_emit ((inst), (mem)); \
- x86_imm_emit16 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0xc7; \
- amd64_mem_emit ((inst), (mem)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-
-//#define amd64_mov_membase_imm_size(inst,basereg,disp,imm,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_mov_membase_imm((inst),((basereg)&0x7),(disp),(imm),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_mov_memindex_imm_size(inst,basereg,disp,indexreg,shift,imm,size) do { amd64_emit_rex ((inst),(size),0,(indexreg),(basereg)); x86_mov_memindex_imm((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(imm),(size) == 8 ? 4 : (size)); } while (0)
-#define amd64_lea_mem_size(inst,reg,mem,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_lea_mem((inst),((reg)&0x7),(mem)); } while (0)
-//#define amd64_lea_membase_size(inst,reg,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_lea_membase((inst),((reg)&0x7),((basereg)&0x7),(disp)); } while (0)
-//#define amd64_lea_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) do { amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_lea_memindex((inst),((reg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift)); } while (0)
-
-#define amd64_lea_memindex_size(inst,reg,basereg,disp,indexreg,shift,size) do { amd64_emit_rex ((inst),(size),(reg),(indexreg),(basereg)); x86_lea_memindex((inst),((reg)&0x7),(basereg),(disp),((indexreg)&0x7),(shift)); } while (0)
-
-
-#define amd64_widen_reg_size(inst,dreg,reg,is_signed,is_half,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_widen_reg((inst),((dreg)&0x7),((reg)&0x7),(is_signed),(is_half)); } while (0)
-#define amd64_widen_mem_size(inst,dreg,mem,is_signed,is_half,size) do { amd64_emit_rex ((inst),(size),(dreg),0,0); x86_widen_mem((inst),((dreg)&0x7),(mem),(is_signed),(is_half)); } while (0)
-#define amd64_widen_membase_size(inst,dreg,basereg,disp,is_signed,is_half,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(basereg)); x86_widen_membase((inst),((dreg)&0x7),((basereg)&0x7),(disp),(is_signed),(is_half)); } while (0)
-#define amd64_widen_memindex_size(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half,size) do { amd64_emit_rex ((inst),(size),(dreg),(indexreg),(basereg)); x86_widen_memindex((inst),((dreg)&0x7),((basereg)&0x7),(disp),((indexreg)&0x7),(shift),(is_signed),(is_half)); } while (0)
-#define amd64_cdq_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_cdq(inst); } while (0)
-#define amd64_wait_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_wait(inst); } while (0)
-#define amd64_fp_op_mem_size(inst,opc,mem,is_double,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fp_op_mem((inst),(opc),(mem),(is_double)); } while (0)
-#define amd64_fp_op_membase_size(inst,opc,basereg,disp,is_double,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fp_op_membase((inst),(opc),((basereg)&0x7),(disp),(is_double)); } while (0)
-#define amd64_fp_op_size(inst,opc,index,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fp_op((inst),(opc),(index)); } while (0)
-#define amd64_fp_op_reg_size(inst,opc,index,pop_stack,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fp_op_reg((inst),(opc),(index),(pop_stack)); } while (0)
-#define amd64_fp_int_op_membase_size(inst,opc,basereg,disp,is_int,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fp_int_op_membase((inst),(opc),((basereg)&0x7),(disp),(is_int)); } while (0)
-#define amd64_fstp_size(inst,index,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fstp((inst),(index)); } while (0)
-#define amd64_fcompp_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fcompp(inst); } while (0)
-#define amd64_fucompp_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fucompp(inst); } while (0)
-#define amd64_fnstsw_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fnstsw(inst); } while (0)
-#define amd64_fnstcw_size(inst,mem,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fnstcw((inst),(mem)); } while (0)
-#define amd64_fnstcw_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_fnstcw_membase((inst),((basereg)&0x7),(disp)); } while (0)
-#define amd64_fldcw_size(inst,mem,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fldcw((inst),(mem)); } while (0)
-#define amd64_fldcw_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fldcw_membase((inst),((basereg)&0x7),(disp)); } while (0)
-#define amd64_fchs_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fchs(inst); } while (0)
-#define amd64_frem_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_frem(inst); } while (0)
-#define amd64_fxch_size(inst,index,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fxch((inst),(index)); } while (0)
-#define amd64_fcomi_size(inst,index,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fcomi((inst),(index)); } while (0)
-#define amd64_fcomip_size(inst,index,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fcomip((inst),(index)); } while (0)
-#define amd64_fucomi_size(inst,index,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fucomi((inst),(index)); } while (0)
-#define amd64_fucomip_size(inst,index,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fucomip((inst),(index)); } while (0)
-#define amd64_fld_size(inst,mem,is_double,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fld((inst),(mem),(is_double)); } while (0)
-//#define amd64_fld_membase_size(inst,basereg,disp,is_double,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fld_membase((inst),((basereg)&0x7),(disp),(is_double)); } while (0)
-#define amd64_fld80_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fld80_mem((inst),(mem)); } while (0)
-#define amd64_fld80_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_fld80_membase((inst),((basereg)&0x7),(disp)); } while (0)
-#define amd64_fild_size(inst,mem,is_int64_t,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fild((inst),(mem),(is_int64_t)); } while (0)
-#define amd64_fild_membase_size(inst,basereg,disp,is_int64_t,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fild_membase((inst),((basereg)&0x7),(disp),(is_int64_t)); } while (0)
-#define amd64_fld_reg_size(inst,index,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fld_reg((inst),(index)); } while (0)
-#define amd64_fldz_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fldz(inst); } while (0)
-#define amd64_fld1_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fld1(inst); } while (0)
-#define amd64_fldpi_size(inst,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fldpi(inst); } while (0)
-#define amd64_fst_size(inst,mem,is_double,pop_stack,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fst((inst),(mem),(is_double),(pop_stack)); } while (0)
-#define amd64_fst_membase_size(inst,basereg,disp,is_double,pop_stack,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fst_membase((inst),((basereg)&0x7),(disp),(is_double),(pop_stack)); } while (0)
-#define amd64_fst80_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fst80_mem((inst),(mem)); } while (0)
-#define amd64_fst80_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fst80_membase((inst),((basereg)&0x7),(disp)); } while (0)
-#define amd64_fist_pop_size(inst,mem,is_int64_t,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_fist_pop((inst),(mem),(is_int64_t)); } while (0)
-#define amd64_fist_pop_membase_size(inst,basereg,disp,is_int64_t,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fist_pop_membase((inst),((basereg)&0x7),(disp),(is_int64_t)); } while (0)
-#define amd64_fstsw_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_fstsw(inst); } while (0)
-#define amd64_fist_membase_size(inst,basereg,disp,is_int,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_fist_membase((inst),((basereg)&0x7),(disp),(is_int)); } while (0)
-//#define amd64_push_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_push_reg((inst),((reg)&0x7)); } while (0)
-#define amd64_push_regp_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_push_regp((inst),((reg)&0x7)); } while (0)
-#define amd64_push_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_push_mem((inst),(mem)); } while (0)
-//#define amd64_push_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_push_membase((inst),((basereg)&0x7),(disp)); } while (0)
-#define amd64_push_memindex_size(inst,basereg,disp,indexreg,shift,size) do { amd64_emit_rex ((inst),(size),0,(indexreg),(basereg)); x86_push_memindex((inst),((basereg)&0x7),(disp),((indexreg)&0x7),(shift)); } while (0)
-#define amd64_push_imm_size(inst,imm,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_push_imm((inst),(imm)); } while (0)
-//#define amd64_pop_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_pop_reg((inst),((reg)&0x7)); } while (0)
-#define amd64_pop_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_pop_mem((inst),(mem)); } while (0)
-#define amd64_pop_membase_size(inst,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_pop_membase((inst),((basereg)&0x7),(disp)); } while (0)
-#define amd64_pushad_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_pushad(inst); } while (0)
-#define amd64_pushfd_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_pushfd(inst); } while (0)
-#define amd64_popad_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_popad(inst); } while (0)
-#define amd64_popfd_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_popfd(inst); } while (0)
-#define amd64_loop_size(inst,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_loop((inst),(imm)); } while (0)
-#define amd64_loope_size(inst,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_loope((inst),(imm)); } while (0)
-#define amd64_loopne_size(inst,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_loopne((inst),(imm)); } while (0)
-#define amd64_jump32_size(inst,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_jump32((inst),(imm)); } while (0)
-#define amd64_jump8_size(inst,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_jump8((inst),(imm)); } while (0)
-#define amd64_jump_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),0,0,0,(reg)); x86_jump_reg((inst),((reg)&0x7)); } while (0)
-#define amd64_jump_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_jump_mem((inst),(mem)); } while (0)
-#define amd64_jump_disp_size(inst,disp,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_jump_disp((inst),(disp)); } while (0)
-#define amd64_jump_disp32_size(inst,disp,size) do { amd64_emit_rex ((inst),0,0,0,0); x86_jump_disp32((inst),(disp)); } while (0)
-#define amd64_branch8_size(inst,cond,imm,is_signed,size) do { x86_branch8((inst),(cond),(imm),(is_signed)); } while (0)
-#define amd64_branch32_size(inst,cond,imm,is_signed,size) do { x86_branch32((inst),(cond),(imm),(is_signed)); } while (0)
-#define amd64_branch_size(inst,cond,target,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_branch((inst),(cond),(target),(is_signed)); } while (0)
-#define amd64_branch_disp_size(inst,cond,disp,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_branch_disp((inst),(cond),(disp),(is_signed)); } while (0)
-#define amd64_branch_disp32_size(inst,cond,disp,is_signed,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_branch_disp32((inst),(cond),(disp),(is_signed)); } while (0)
-
-#define amd64_set_reg_size(inst,cond,reg,is_signed,size) do { amd64_emit_rex((inst),1,0,0,(reg)); x86_set_reg((inst),(cond),((reg)&0x7),(is_signed)); } while (0)
-#define amd64_set_mem_size(inst,cond,mem,is_signed,size) do { x86_set_mem((inst),(cond),(mem),(is_signed)); } while (0)
-#define amd64_set_membase_size(inst,cond,basereg,disp,is_signed,size) do { amd64_emit_rex ((inst),0,0,0,(basereg)); x86_set_membase((inst),(cond),((basereg)&0x7),(disp),(is_signed)); } while (0)
-#define amd64_call_imm_size(inst,disp,size) do { x86_call_imm((inst),(disp)); } while (0)
-//#define amd64_call_reg_size(inst,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_call_reg((inst),((reg)&0x7)); } while (0)
-#define amd64_call_mem_size(inst,mem,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_call_mem((inst),(mem)); } while (0)
-#define amd64_call_code_size(inst,target,size) do { x86_call_code((inst),(target)); } while (0)
-//#define amd64_ret_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_ret(inst); } while (0)
-#define amd64_ret_imm_size(inst,imm,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_ret_imm((inst),(imm)); } while (0)
-#define amd64_cmov_reg_size(inst,cond,is_signed,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_cmov_reg((inst),(cond),(is_signed),((dreg)&0x7),((reg)&0x7)); } while (0)
-#define amd64_cmov_mem_size(inst,cond,is_signed,reg,mem,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_cmov_mem((inst),(cond),(is_signed),((reg)&0x7),(mem)); } while (0)
-#define amd64_cmov_membase_size(inst,cond,is_signed,reg,basereg,disp,size) do { amd64_emit_rex ((inst),(size),0,0,(basereg)); x86_cmov_membase((inst),(cond),(is_signed),((reg)&0x7),((basereg)&0x7),(disp)); } while (0)
-#define amd64_enter_size(inst,framesize) do { amd64_emit_rex ((inst),(size),0,0,0); x86_enter((inst),(framesize)); } while (0)
-//#define amd64_leave_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_leave(inst); } while (0)
-#define amd64_sahf_size(inst,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_sahf(inst); } while (0)
-#define amd64_fsin_size(inst,size) do { x86_fsin(inst); } while (0)
-#define amd64_fcos_size(inst,size) do { x86_fcos(inst); } while (0)
-#define amd64_fabs_size(inst,size) do { x86_fabs(inst); } while (0)
-#define amd64_ftst_size(inst,size) do { x86_ftst(inst); } while (0)
-#define amd64_fxam_size(inst,size) do { x86_fxam(inst); } while (0)
-#define amd64_fpatan_size(inst,size) do { x86_fpatan(inst); } while (0)
-#define amd64_fprem_size(inst,size) do { x86_fprem(inst); } while (0)
-#define amd64_fprem1_size(inst,size) do { x86_fprem1(inst); } while (0)
-#define amd64_frndint_size(inst,size) do { x86_frndint(inst); } while (0)
-#define amd64_fsqrt_size(inst,size) do { x86_fsqrt(inst); } while (0)
-#define amd64_fptan_size(inst,size) do { x86_fptan(inst); } while (0)
-//#define amd64_padding_size(inst,size) do { x86_padding((inst),(size)); } while (0)
-#define amd64_prolog_size(inst,frame_size,reg_mask,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_prolog((inst),(frame_size),(reg_mask)); } while (0)
-#define amd64_epilog_size(inst,reg_mask,size) do { amd64_emit_rex ((inst),(size),0,0,0); x86_epilog((inst),(reg_mask)); } while (0)
-#define amd64_xadd_reg_reg_size(inst,dreg,reg,size) do { amd64_emit_rex ((inst),(size),(dreg),0,(reg)); x86_xadd_reg_reg ((inst), (dreg), (reg), (size)); } while (0)
-#define amd64_xadd_mem_reg_size(inst,mem,reg,size) do { amd64_emit_rex ((inst),(size),0,0,(reg)); x86_xadd_mem_reg((inst),(mem),((reg)&0x7), (size)); } while (0)
-#define amd64_xadd_membase_reg_size(inst,basereg,disp,reg,size) do { amd64_emit_rex ((inst),(size),(reg),0,(basereg)); x86_xadd_membase_reg((inst),((basereg)&0x7),(disp),((reg)&0x7),(size)); } while (0)
-
-
-
-
-#define amd64_breakpoint(inst) amd64_breakpoint_size(inst,8)
-#define amd64_cld(inst) amd64_cld_size(inst,8)
-#define amd64_stosb(inst) amd64_stosb_size(inst,8)
-#define amd64_stosl(inst) amd64_stosl_size(inst,8)
-#define amd64_stosd(inst) amd64_stosd_size(inst,8)
-#define amd64_movsb(inst) amd64_movsb_size(inst,8)
-#define amd64_movsl(inst) amd64_movsl_size(inst,8)
-#define amd64_movsd(inst) amd64_movsd_size(inst,8)
-#define amd64_prefix(inst,p) amd64_prefix_size(inst,p,8)
-#define amd64_rdtsc(inst) amd64_rdtsc_size(inst,8)
-#define amd64_cmpxchg_reg_reg(inst,dreg,reg) amd64_cmpxchg_reg_reg_size(inst,dreg,reg,8)
-#define amd64_cmpxchg_mem_reg(inst,mem,reg) amd64_cmpxchg_mem_reg_size(inst,mem,reg,8)
-#define amd64_cmpxchg_membase_reg(inst,basereg,disp,reg) amd64_cmpxchg_membase_reg_size(inst,basereg,disp,reg,8)
-#define amd64_xchg_reg_reg(inst,dreg,reg,size) amd64_xchg_reg_reg_size(inst,dreg,reg,size)
-#define amd64_xchg_mem_reg(inst,mem,reg,size) amd64_xchg_mem_reg_size(inst,mem,reg,size)
-#define amd64_xchg_membase_reg(inst,basereg,disp,reg,size) amd64_xchg_membase_reg_size(inst,basereg,disp,reg,size)
-#define amd64_xadd_reg_reg(inst,dreg,reg,size) amd64_xadd_reg_reg_size(inst,dreg,reg,size)
-#define amd64_xadd_mem_reg(inst,mem,reg,size) amd64_xadd_mem_reg_size(inst,mem,reg,size)
-#define amd64_xadd_membase_reg(inst,basereg,disp,reg,size) amd64_xadd_membase_reg_size(inst,basereg,disp,reg,size)
-#define amd64_inc_mem(inst,mem) amd64_inc_mem_size(inst,mem,8)
-#define amd64_inc_membase(inst,basereg,disp) amd64_inc_membase_size(inst,basereg,disp,8)
-#define amd64_inc_reg(inst,reg) amd64_inc_reg_size(inst,reg,8)
-#define amd64_dec_mem(inst,mem) amd64_dec_mem_size(inst,mem,8)
-#define amd64_dec_membase(inst,basereg,disp) amd64_dec_membase_size(inst,basereg,disp,8)
-#define amd64_dec_reg(inst,reg) amd64_dec_reg_size(inst,reg,8)
-#define amd64_not_mem(inst,mem) amd64_not_mem_size(inst,mem,8)
-#define amd64_not_membase(inst,basereg,disp) amd64_not_membase_size(inst,basereg,disp,8)
-#define amd64_not_reg(inst,reg) amd64_not_reg_size(inst,reg,8)
-#define amd64_neg_mem(inst,mem) amd64_neg_mem_size(inst,mem,8)
-#define amd64_neg_membase(inst,basereg,disp) amd64_neg_membase_size(inst,basereg,disp,8)
-#define amd64_neg_reg(inst,reg) amd64_neg_reg_size(inst,reg,8)
-#define amd64_nop(inst) amd64_nop_size(inst,8)
-//#define amd64_alu_reg_imm(inst,opc,reg,imm) amd64_alu_reg_imm_size(inst,opc,reg,imm,8)
-#define amd64_alu_mem_imm(inst,opc,mem,imm) amd64_alu_mem_imm_size(inst,opc,mem,imm,8)
-#define amd64_alu_membase_imm(inst,opc,basereg,disp,imm) amd64_alu_membase_imm_size(inst,opc,basereg,disp,imm,8)
-#define amd64_alu_mem_reg(inst,opc,mem,reg) amd64_alu_mem_reg_size(inst,opc,mem,reg,8)
-#define amd64_alu_membase_reg(inst,opc,basereg,disp,reg) amd64_alu_membase_reg_size(inst,opc,basereg,disp,reg,8)
-//#define amd64_alu_reg_reg(inst,opc,dreg,reg) amd64_alu_reg_reg_size(inst,opc,dreg,reg,8)
-#define amd64_alu_reg8_reg8(inst,opc,dreg,reg,is_dreg_h,is_reg_h) amd64_alu_reg8_reg8_size(inst,opc,dreg,reg,is_dreg_h,is_reg_h,8)
-#define amd64_alu_reg_mem(inst,opc,reg,mem) amd64_alu_reg_mem_size(inst,opc,reg,mem,8)
-#define amd64_alu_reg_membase(inst,opc,reg,basereg,disp) amd64_alu_reg_membase_size(inst,opc,reg,basereg,disp,8)
-#define amd64_test_reg_imm(inst,reg,imm) amd64_test_reg_imm_size(inst,reg,imm,8)
-#define amd64_test_mem_imm(inst,mem,imm) amd64_test_mem_imm_size(inst,mem,imm,8)
-#define amd64_test_membase_imm(inst,basereg,disp,imm) amd64_test_membase_imm_size(inst,basereg,disp,imm,8)
-#define amd64_test_reg_reg(inst,dreg,reg) amd64_test_reg_reg_size(inst,dreg,reg,8)
-#define amd64_test_mem_reg(inst,mem,reg) amd64_test_mem_reg_size(inst,mem,reg,8)
-#define amd64_test_membase_reg(inst,basereg,disp,reg) amd64_test_membase_reg_size(inst,basereg,disp,reg,8)
-#define amd64_shift_reg_imm(inst,opc,reg,imm) amd64_shift_reg_imm_size(inst,opc,reg,imm,8)
-#define amd64_shift_mem_imm(inst,opc,mem,imm) amd64_shift_mem_imm_size(inst,opc,mem,imm,8)
-#define amd64_shift_membase_imm(inst,opc,basereg,disp,imm) amd64_shift_membase_imm_size(inst,opc,basereg,disp,imm,8)
-#define amd64_shift_reg(inst,opc,reg) amd64_shift_reg_size(inst,opc,reg,8)
-#define amd64_shift_mem(inst,opc,mem) amd64_shift_mem_size(inst,opc,mem,8)
-#define amd64_shift_membase(inst,opc,basereg,disp) amd64_shift_membase_size(inst,opc,basereg,disp,8)
-#define amd64_shrd_reg(inst,dreg,reg) amd64_shrd_reg_size(inst,dreg,reg,8)
-#define amd64_shrd_reg_imm(inst,dreg,reg,shamt) amd64_shrd_reg_imm_size(inst,dreg,reg,shamt,8)
-#define amd64_shld_reg(inst,dreg,reg) amd64_shld_reg_size(inst,dreg,reg,8)
-#define amd64_shld_reg_imm(inst,dreg,reg,shamt) amd64_shld_reg_imm_size(inst,dreg,reg,shamt,8)
-#define amd64_mul_reg(inst,reg,is_signed) amd64_mul_reg_size(inst,reg,is_signed,8)
-#define amd64_mul_mem(inst,mem,is_signed) amd64_mul_mem_size(inst,mem,is_signed,8)
-#define amd64_mul_membase(inst,basereg,disp,is_signed) amd64_mul_membase_size(inst,basereg,disp,is_signed,8)
-#define amd64_imul_reg_reg(inst,dreg,reg) amd64_imul_reg_reg_size(inst,dreg,reg,8)
-#define amd64_imul_reg_mem(inst,reg,mem) amd64_imul_reg_mem_size(inst,reg,mem,8)
-#define amd64_imul_reg_membase(inst,reg,basereg,disp) amd64_imul_reg_membase_size(inst,reg,basereg,disp,8)
-#define amd64_imul_reg_reg_imm(inst,dreg,reg,imm) amd64_imul_reg_reg_imm_size(inst,dreg,reg,imm,8)
-#define amd64_imul_reg_mem_imm(inst,reg,mem,imm) amd64_imul_reg_mem_imm_size(inst,reg,mem,imm,8)
-#define amd64_imul_reg_membase_imm(inst,reg,basereg,disp,imm) amd64_imul_reg_membase_imm_size(inst,reg,basereg,disp,imm,8)
-#define amd64_div_reg(inst,reg,is_signed) amd64_div_reg_size(inst,reg,is_signed,8)
-#define amd64_div_mem(inst,mem,is_signed) amd64_div_mem_size(inst,mem,is_signed,8)
-#define amd64_div_membase(inst,basereg,disp,is_signed) amd64_div_membase_size(inst,basereg,disp,is_signed,8)
-//#define amd64_mov_mem_reg(inst,mem,reg,size) amd64_mov_mem_reg_size(inst,mem,reg,size)
-//#define amd64_mov_regp_reg(inst,regp,reg,size) amd64_mov_regp_reg_size(inst,regp,reg,size)
-//#define amd64_mov_membase_reg(inst,basereg,disp,reg,size) amd64_mov_membase_reg_size(inst,basereg,disp,reg,size)
-#define amd64_mov_memindex_reg(inst,basereg,disp,indexreg,shift,reg,size) amd64_mov_memindex_reg_size(inst,basereg,disp,indexreg,shift,reg,size)
-//#define amd64_mov_reg_reg(inst,dreg,reg,size) amd64_mov_reg_reg_size(inst,dreg,reg,size)
-//#define amd64_mov_reg_mem(inst,reg,mem,size) amd64_mov_reg_mem_size(inst,reg,mem,size)
-//#define amd64_mov_reg_membase(inst,reg,basereg,disp,size) amd64_mov_reg_membase_size(inst,reg,basereg,disp,size)
-#define amd64_mov_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) amd64_mov_reg_memindex_size(inst,reg,basereg,disp,indexreg,shift,size)
-#define amd64_clear_reg(inst,reg) amd64_clear_reg_size(inst,reg,8)
-//#define amd64_mov_reg_imm(inst,reg,imm) amd64_mov_reg_imm_size(inst,reg,imm,8)
-#define amd64_mov_mem_imm(inst,mem,imm,size) amd64_mov_mem_imm_size(inst,mem,imm,size)
-//#define amd64_mov_membase_imm(inst,basereg,disp,imm,size) amd64_mov_membase_imm_size(inst,basereg,disp,imm,size)
-#define amd64_mov_memindex_imm(inst,basereg,disp,indexreg,shift,imm,size) amd64_mov_memindex_imm_size(inst,basereg,disp,indexreg,shift,imm,size)
-#define amd64_lea_mem(inst,reg,mem) amd64_lea_mem_size(inst,reg,mem,8)
-//#define amd64_lea_membase(inst,reg,basereg,disp) amd64_lea_membase_size(inst,reg,basereg,disp,8)
-#define amd64_lea_memindex(inst,reg,basereg,disp,indexreg,shift) amd64_lea_memindex_size(inst,reg,basereg,disp,indexreg,shift,8)
-#define amd64_widen_reg(inst,dreg,reg,is_signed,is_half) amd64_widen_reg_size(inst,dreg,reg,is_signed,is_half,8)
-#define amd64_widen_mem(inst,dreg,mem,is_signed,is_half) amd64_widen_mem_size(inst,dreg,mem,is_signed,is_half,8)
-#define amd64_widen_membase(inst,dreg,basereg,disp,is_signed,is_half) amd64_widen_membase_size(inst,dreg,basereg,disp,is_signed,is_half,8)
-#define amd64_widen_memindex(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half) amd64_widen_memindex_size(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half,8)
-#define amd64_cdq(inst) amd64_cdq_size(inst,8)
-#define amd64_wait(inst) amd64_wait_size(inst,8)
-#define amd64_fp_op_mem(inst,opc,mem,is_double) amd64_fp_op_mem_size(inst,opc,mem,is_double,8)
-#define amd64_fp_op_membase(inst,opc,basereg,disp,is_double) amd64_fp_op_membase_size(inst,opc,basereg,disp,is_double,8)
-#define amd64_fp_op(inst,opc,index) amd64_fp_op_size(inst,opc,index,8)
-#define amd64_fp_op_reg(inst,opc,index,pop_stack) amd64_fp_op_reg_size(inst,opc,index,pop_stack,8)
-#define amd64_fp_int_op_membase(inst,opc,basereg,disp,is_int) amd64_fp_int_op_membase_size(inst,opc,basereg,disp,is_int,8)
-#define amd64_fstp(inst,index) amd64_fstp_size(inst,index,8)
-#define amd64_fcompp(inst) amd64_fcompp_size(inst,8)
-#define amd64_fucompp(inst) amd64_fucompp_size(inst,8)
-#define amd64_fnstsw(inst) amd64_fnstsw_size(inst,8)
-#define amd64_fnstcw(inst,mem) amd64_fnstcw_size(inst,mem,8)
-#define amd64_fnstcw_membase(inst,basereg,disp) amd64_fnstcw_membase_size(inst,basereg,disp,8)
-#define amd64_fldcw(inst,mem) amd64_fldcw_size(inst,mem,8)
-#define amd64_fldcw_membase(inst,basereg,disp) amd64_fldcw_membase_size(inst,basereg,disp,8)
-#define amd64_fchs(inst) amd64_fchs_size(inst,8)
-#define amd64_frem(inst) amd64_frem_size(inst,8)
-#define amd64_fxch(inst,index) amd64_fxch_size(inst,index,8)
-#define amd64_fcomi(inst,index) amd64_fcomi_size(inst,index,8)
-#define amd64_fcomip(inst,index) amd64_fcomip_size(inst,index,8)
-#define amd64_fucomi(inst,index) amd64_fucomi_size(inst,index,8)
-#define amd64_fucomip(inst,index) amd64_fucomip_size(inst,index,8)
-#define amd64_fld(inst,mem,is_double) amd64_fld_size(inst,mem,is_double,8)
-#define amd64_fld_membase(inst,basereg,disp,is_double) amd64_fld_membase_size(inst,basereg,disp,is_double,8)
-#define amd64_fld80_mem(inst,mem) amd64_fld80_mem_size(inst,mem,8)
-#define amd64_fld80_membase(inst,basereg,disp) amd64_fld80_membase_size(inst,basereg,disp,8)
-#define amd64_fild(inst,mem,is_int64_t) amd64_fild_size(inst,mem,is_int64_t,8)
-#define amd64_fild_membase(inst,basereg,disp,is_int64_t) amd64_fild_membase_size(inst,basereg,disp,is_int64_t,8)
-#define amd64_fld_reg(inst,index) amd64_fld_reg_size(inst,index,8)
-#define amd64_fldz(inst) amd64_fldz_size(inst,8)
-#define amd64_fld1(inst) amd64_fld1_size(inst,8)
-#define amd64_fldpi(inst) amd64_fldpi_size(inst,8)
-#define amd64_fst(inst,mem,is_double,pop_stack) amd64_fst_size(inst,mem,is_double,pop_stack,8)
-#define amd64_fst_membase(inst,basereg,disp,is_double,pop_stack) amd64_fst_membase_size(inst,basereg,disp,is_double,pop_stack,8)
-#define amd64_fst80_mem(inst,mem) amd64_fst80_mem_size(inst,mem,8)
-#define amd64_fst80_membase(inst,basereg,disp) amd64_fst80_membase_size(inst,basereg,disp,8)
-#define amd64_fist_pop(inst,mem,is_int64_t) amd64_fist_pop_size(inst,mem,is_int64_t,8)
-#define amd64_fist_pop_membase(inst,basereg,disp,is_int64_t) amd64_fist_pop_membase_size(inst,basereg,disp,is_int64_t,8)
-#define amd64_fstsw(inst) amd64_fstsw_size(inst,8)
-#define amd64_fist_membase(inst,basereg,disp,is_int) amd64_fist_membase_size(inst,basereg,disp,is_int,8)
-//#define amd64_push_reg(inst,reg) amd64_push_reg_size(inst,reg,8)
-#define amd64_push_regp(inst,reg) amd64_push_regp_size(inst,reg,8)
-#define amd64_push_mem(inst,mem) amd64_push_mem_size(inst,mem,8)
-//#define amd64_push_membase(inst,basereg,disp) amd64_push_membase_size(inst,basereg,disp,8)
-#define amd64_push_memindex(inst,basereg,disp,indexreg,shift) amd64_push_memindex_size(inst,basereg,disp,indexreg,shift,8)
-#define amd64_push_imm(inst,imm) amd64_push_imm_size(inst,imm,8)
-//#define amd64_pop_reg(inst,reg) amd64_pop_reg_size(inst,reg,8)
-#define amd64_pop_mem(inst,mem) amd64_pop_mem_size(inst,mem,8)
-#define amd64_pop_membase(inst,basereg,disp) amd64_pop_membase_size(inst,basereg,disp,8)
-#define amd64_pushad(inst) amd64_pushad_size(inst,8)
-#define amd64_pushfd(inst) amd64_pushfd_size(inst,8)
-#define amd64_popad(inst) amd64_popad_size(inst,8)
-#define amd64_popfd(inst) amd64_popfd_size(inst,8)
-#define amd64_loop(inst,imm) amd64_loop_size(inst,imm,8)
-#define amd64_loope(inst,imm) amd64_loope_size(inst,imm,8)
-#define amd64_loopne(inst,imm) amd64_loopne_size(inst,imm,8)
-#define amd64_jump32(inst,imm) amd64_jump32_size(inst,imm,8)
-#define amd64_jump8(inst,imm) amd64_jump8_size(inst,imm,8)
-#define amd64_jump_reg(inst,reg) amd64_jump_reg_size(inst,reg,8)
-#define amd64_jump_mem(inst,mem) amd64_jump_mem_size(inst,mem,8)
-#define amd64_jump_membase(inst,basereg,disp) amd64_jump_membase_size(inst,basereg,disp,8)
-#define amd64_jump_code(inst,target) amd64_jump_code_size(inst,target,8)
-#define amd64_jump_disp(inst,disp) amd64_jump_disp_size(inst,disp,8)
-#define amd64_jump_disp32(inst,disp) amd64_jump_disp32_size(inst,disp,8)
-#define amd64_branch8(inst,cond,imm,is_signed) amd64_branch8_size(inst,cond,imm,is_signed,8)
-#define amd64_branch32(inst,cond,imm,is_signed) amd64_branch32_size(inst,cond,imm,is_signed,8)
-#define amd64_branch(inst,cond,target,is_signed) amd64_branch_size(inst,cond,target,is_signed,8)
-#define amd64_branch_disp(inst,cond,disp,is_signed) amd64_branch_disp_size(inst,cond,disp,is_signed,8)
-#define amd64_branch_disp32(inst,cond,disp,is_signed) amd64_branch_disp32_size(inst,cond,disp,is_signed,8)
-#define amd64_set_reg(inst,cond,reg,is_signed) amd64_set_reg_size(inst,cond,reg,is_signed,8)
-#define amd64_set_mem(inst,cond,mem,is_signed) amd64_set_mem_size(inst,cond,mem,is_signed,8)
-#define amd64_set_membase(inst,cond,basereg,disp,is_signed) amd64_set_membase_size(inst,cond,basereg,disp,is_signed,8)
-#define amd64_call_imm(inst,disp) amd64_call_imm_size(inst,disp,8)
-//#define amd64_call_reg(inst,reg) amd64_call_reg_size(inst,reg,8)
-#define amd64_call_mem(inst,mem) amd64_call_mem_size(inst,mem,8)
-#define amd64_call_membase(inst,basereg,disp) amd64_call_membase_size(inst,basereg,disp,8)
-#define amd64_call_code(inst,target) amd64_call_code_size(inst,target,8)
-//#define amd64_ret(inst) amd64_ret_size(inst,8)
-#define amd64_ret_imm(inst,imm) amd64_ret_imm_size(inst,imm,8)
-#define amd64_cmov_reg(inst,cond,is_signed,dreg,reg) amd64_cmov_reg_size(inst,cond,is_signed,dreg,reg,8)
-#define amd64_cmov_mem(inst,cond,is_signed,reg,mem) amd64_cmov_mem_size(inst,cond,is_signed,reg,mem,8)
-#define amd64_cmov_membase(inst,cond,is_signed,reg,basereg,disp) amd64_cmov_membase_size(inst,cond,is_signed,reg,basereg,disp,8)
-#define amd64_enter(inst,framesize) amd64_enter_size(inst,framesize)
-//#define amd64_leave(inst) amd64_leave_size(inst,8)
-#define amd64_sahf(inst) amd64_sahf_size(inst,8)
-#define amd64_fsin(inst) amd64_fsin_size(inst,8)
-#define amd64_fcos(inst) amd64_fcos_size(inst,8)
-#define amd64_fabs(inst) amd64_fabs_size(inst,8)
-#define amd64_ftst(inst) amd64_ftst_size(inst,8)
-#define amd64_fxam(inst) amd64_fxam_size(inst,8)
-#define amd64_fpatan(inst) amd64_fpatan_size(inst,8)
-#define amd64_fprem(inst) amd64_fprem_size(inst,8)
-#define amd64_fprem1(inst) amd64_fprem1_size(inst,8)
-#define amd64_frndint(inst) amd64_frndint_size(inst,8)
-#define amd64_fsqrt(inst) amd64_fsqrt_size(inst,8)
-#define amd64_fptan(inst) amd64_fptan_size(inst,8)
-#define amd64_padding(inst,size) amd64_padding_size(inst,size)
-#define amd64_prolog(inst,frame,reg_mask) amd64_prolog_size(inst,frame,reg_mask,8)
-#define amd64_epilog(inst,reg_mask) amd64_epilog_size(inst,reg_mask,8)
-
-#endif // AMD64_H
diff --git a/ext/myjit/myjit/amd64-specific.h b/ext/myjit/myjit/amd64-specific.h
deleted file mode 100755
index 7438cb5..0000000
--- a/ext/myjit/myjit/amd64-specific.h
+++ /dev/null
@@ -1,644 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "amd64-codegen.h"
-#ifndef TARGET_WIN32
-#include <sys/ptrace.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/user.h>
-#endif
-/* Stack frame organization:
- *
- * RBP +--------------+
- * | allocai mem |
- * RBP - n +--------------+
- * | GP registers |
- * RPB - m +--------------+
- * | FP registers |
- * RPB - k +--------------+
- * | shadow space |
- * | for arg.regs |
- * RPB - l +--------------+
- */
-
-#define GET_GPREG_POS(jit, r) (- ((JIT_REG(r).id + 1) * REG_SIZE) - jit_current_func_info(jit)->allocai_mem)
-#define GET_FPREG_POS(jit, r) (- jit_current_func_info(jit)->gp_reg_count * REG_SIZE - (JIT_REG(r).id + 1) * sizeof(jit_float) - jit_current_func_info(jit)->allocai_mem)
-#define GET_ARG_SPILL_POS(jit, info, arg) ((- (arg + info->gp_reg_count + info->fp_reg_count) * REG_SIZE) - jit_current_func_info(jit)->allocai_mem)
-static inline int GET_REG_POS(struct jit * jit, int r)
-{
- if (JIT_REG(r).spec == JIT_RTYPE_REG) {
- if (JIT_REG(r). type == JIT_RTYPE_INT) return GET_GPREG_POS(jit, r);
- else return GET_FPREG_POS(jit, r);
- } else return GET_ARG_SPILL_POS(jit, jit_current_func_info(jit), JIT_REG(r).id);
-}
-
-#include "x86-common-stuff.c"
-extern void jit_DebugggerHit();
-static void jit_insert_breakpoint(struct jit *jit,jit_breakpoint_t *bp,void(*routine)(jit_debugger_regs* regs),jit_debugger_ctrl *ctrl) {
- amd64_mov_reg_imm(jit->ip,AMD64_RAX,ctrl);
- amd64_push_reg(jit->ip,AMD64_RAX);
- amd64_mov_reg_imm(jit->ip,AMD64_RAX,bp);
- amd64_push_reg(jit->ip,AMD64_RAX);
- amd64_mov_reg_imm(jit->ip,AMD64_RAX,routine);
- amd64_push_reg(jit->ip,AMD64_RAX);
- amd64_mov_reg_imm(jit->ip,AMD64_RAX,jit_DebugggerHit);
- amd64_call_reg(jit->ip,AMD64_RAX);
- amd64_alu_reg_imm(jit->ip, X86_ADD, AMD64_RSP, 3*8);
-}
-void *jit_debugger_get_vreg_ptr_from_parent(struct jit *jit,void *fptr,struct jit_op *op,jit_value r) {
- jit_hw_reg *reg;
- if(JIT_REG(r).type) {
- if((reg=rmap_get(op->regmap,r))&&jit_set_get(op->live_in,r))
- return NULL;
- } else
- if((reg=rmap_get(op->regmap,r))&&jit_set_get(op->live_in,r))
- return NULL;
- return (fptr+GET_REG_POS(jit,r));
-}
-void *jit_debugger_get_reg_ptr(struct jit *jit,jit_debugger_regs *regs,struct jit_op *op,jit_value r) {
- jit_hw_reg *reg;
- if(JIT_REG(r).type) {
- if((reg=rmap_get(op->regmap,r))&&jit_set_get(op->live_in,r)) {
- switch(reg->id) {
- case AMD64_XMM0: return &regs->XMM0;
- case AMD64_XMM1: return &regs->XMM1;
- case AMD64_XMM2: return &regs->XMM2;
- case AMD64_XMM3: return &regs->XMM3;
- case AMD64_XMM4: return &regs->XMM4;
- case AMD64_XMM5: return &regs->XMM5;
- case AMD64_XMM6: return &regs->XMM6;
- case AMD64_XMM7: return &regs->XMM7;
- }
- } else if(jit_set_get(op->live_in,r)) {
- return (regs->RBP+GET_REG_POS(jit,r));
- }
- } else {
- if((reg=rmap_get(op->regmap,r))&&jit_set_get(op->live_in,r)) {
- switch(reg->id) {
- case AMD64_RAX:
- return &regs->RAX;
- case AMD64_RBX:
- return &regs->RBX;
- case AMD64_RCX:
- return &regs->RCX;
- case AMD64_RDX:
- return &regs->RDX;
- case AMD64_RSI:
- return &regs->RSI;
- case AMD64_RDI:
- return &regs->RDI;
- case AMD64_RSP:
- return &regs->RSP;
- case AMD64_RBP:
- return &regs->RBP;
- case AMD64_R8:
- return &regs->R8;
- case AMD64_R9:
- return &regs->R9;
- case AMD64_R10:
- return &regs->R10;
- case AMD64_R11:
- return &regs->R11;
- case AMD64_R12:
- return &regs->R12;
- case AMD64_R13:
- return &regs->R13;
- case AMD64_R14:
- return &regs->R14;
- case AMD64_R15:
- return &regs->R15;
- }
- } else if(jit_set_get(op->live_in,r)) {
- return (regs->RBP+GET_REG_POS(jit,r));
- }
- }
- return NULL;
-}
-void jit_init_arg_params(struct jit * jit, struct jit_func_info * info, int p, int * phys_reg)
-{
- #ifndef TARGET_WIN32
- struct jit_inp_arg * a = &(info->args[p]);
- if (a->type != JIT_FLOAT_NUM) { // normal argument
- int pos = a->gp_pos;
- if (pos < jit->reg_al->gp_arg_reg_cnt) {
- a->passed_by_reg = 1;
- a->location.reg = jit->reg_al->gp_arg_regs[pos]->id;
- a->spill_pos = GET_ARG_SPILL_POS(jit, info, p);
- } else {
- int stack_pos = (pos - jit->reg_al->gp_arg_reg_cnt) + MAX(0, (a->fp_pos - jit->reg_al->fp_arg_reg_cnt));
-
- a->location.stack_pos = 16 + stack_pos * 8;
- a->spill_pos = 16 + stack_pos * 8;
- a->passed_by_reg = 0;
- }
- a->overflow = 0;
- return;
- }
-
- // FP argument
- int pos = a->fp_pos;
- if (pos < jit->reg_al->fp_arg_reg_cnt) {
- a->passed_by_reg = 1;
- a->location.reg = jit->reg_al->fp_arg_regs[pos]->id;
- a->spill_pos = GET_ARG_SPILL_POS(jit, info, p);
- } else {
-
- int stack_pos = (pos - jit->reg_al->fp_arg_reg_cnt) + MAX(0, (a->gp_pos - jit->reg_al->gp_arg_reg_cnt));
-
- a->location.stack_pos = 16 + stack_pos * 8;
- a->spill_pos = 16 + stack_pos * 8;
- a->passed_by_reg = 0;
- }
- a->overflow = 0;
- #else
- struct jit_inp_arg * a = &(info->args[p]);
- if (a->type != JIT_FLOAT_NUM) { // normal argument
- if (p < 4) {
- a->passed_by_reg = 1;
- a->location.reg = jit->reg_al->gp_arg_regs[p]->id;
- a->spill_pos = GET_ARG_SPILL_POS(jit, info, p);
- } else {
- int stack_pos = MAX(0, p-4);
- //windows pushes 4 home registers after we push the arguments
- stack_pos+=4;
- a->location.stack_pos = 16 + stack_pos * 8;
- a->spill_pos = 16 + stack_pos * 8;
- a->passed_by_reg = 0;
- }
- a->overflow = 0;
- return;
- }
- // FP argument
- if (p< 4) {
- a->passed_by_reg = 1;
- a->location.reg = jit->reg_al->fp_arg_regs[p]->id;
- a->spill_pos = GET_ARG_SPILL_POS(jit, info, p);
- } else {
- int stack_pos = MAX(0, (p - 4));
- //windows pushes 4 home registers after we push the arguments
- stack_pos+=4;
- a->location.stack_pos = 16 + stack_pos * 8;
- a->spill_pos = 16 + stack_pos * 8;
- a->passed_by_reg = 0;
- }
- a->overflow = 0;
- #endif
-}
-
-/**
- * Assigns integer value to register which is used to pass the argument
- */
-static inline void emit_set_arg(struct jit * jit, struct jit_out_arg * arg)
-{
- int sreg;
- int reg = jit->reg_al->gp_arg_regs[arg->argpos]->id;
- jit_value value = arg->value.generic;
- if (arg->isreg) {
- if (is_spilled(value, jit->prepared_args.op, &sreg)) {
- amd64_mov_reg_membase(jit->ip, reg, AMD64_RBP, GET_REG_POS(jit, value), REG_SIZE);
- } else {
- if (reg != sreg) amd64_mov_reg_reg(jit->ip, reg, sreg, REG_SIZE);
- }
- } else amd64_mov_reg_imm_size(jit->ip, reg, value, 8);
-}
-
-/**
- * Assigns FP value to register which is used to pass the argument
- */
-static inline void emit_set_fparg(struct jit * jit, struct jit_out_arg * arg)
-{
- int sreg;
- int reg = jit->reg_al->fp_arg_regs[arg->argpos]->id;
- jit_value value = arg->value.generic;
- if (arg->isreg) {
- if (is_spilled(value, jit->prepared_args.op, &sreg)) {
- int pos = GET_REG_POS(jit, value);
- if (arg->size == sizeof(float))
- amd64_sse_cvtsd2ss_reg_membase(jit->ip, reg, AMD64_RBP, pos);
- else amd64_sse_movlpd_xreg_membase(jit->ip, reg, AMD64_RBP, pos);
- } else {
- if (arg->size == sizeof(float))
- amd64_sse_cvtsd2ss_reg_reg(jit->ip, reg, sreg);
- else if (reg != sreg) amd64_sse_movsd_reg_reg(jit->ip, reg, sreg);
- }
- } else { // immediate value
- if (arg->size == sizeof(float)) {
- float val = (float)arg->value.fp;
- unsigned int tmp;
-
- memcpy(&tmp, &val, sizeof(float));
- //amd64_mov_reg_imm_size(jit->ip, AMD64_RAX, *(unsigned int *)&val, 4);
- amd64_mov_reg_imm_size(jit->ip, AMD64_RAX, tmp, 4);
- amd64_movd_xreg_reg_size(jit->ip, reg, AMD64_RAX, 4);
- } else {
- amd64_mov_reg_imm_size(jit->ip, AMD64_RAX, value, 8);
- amd64_movd_xreg_reg_size(jit->ip, reg, AMD64_RAX, 8);
- }
- }
-}
-
-/**
- * Pushes integer value on the stack
- */
-static inline void emit_push_arg(struct jit * jit, struct jit_out_arg * arg)
-{
- int sreg;
- if (arg->isreg) {
- if (is_spilled(arg->value.generic, jit->prepared_args.op, &sreg))
- amd64_push_membase(jit->ip, AMD64_RBP, GET_REG_POS(jit, arg->value.generic));
- else amd64_push_reg(jit->ip, sreg);
- } else {
- amd64_mov_reg_imm_size(jit->ip, AMD64_RAX, arg->value.generic, REG_SIZE);
- amd64_push_reg(jit->ip, AMD64_RAX);
- }
-}
-
-/**
- * Pushes float value on the stack
- */
-static inline void emit_fppush_arg(struct jit * jit, struct jit_out_arg * arg)
-{
- int sreg;
- if (arg->size == sizeof(double)) {
- if (arg->isreg) {
- if (is_spilled(arg->value.generic, jit->prepared_args.op, &sreg)) {
- int pos = GET_FPREG_POS(jit, arg->value.generic);
- amd64_push_membase(jit->ip, AMD64_RBP, pos);
- } else {
- // ``PUSH sreg'' for XMM regs
- amd64_alu_reg_imm(jit->ip, X86_SUB, AMD64_RSP, 8);
- amd64_sse_movlpd_membase_xreg(jit->ip, sreg, AMD64_RSP, 0);
- }
- } else {
- double b = arg->value.fp;
- uint64_t tmp;
- memcpy(&tmp, &b, sizeof(double));
- amd64_mov_reg_imm_size(jit->ip, AMD64_RAX, tmp, 8);
- amd64_push_reg(jit->ip, AMD64_RAX);
- }
-
- } else {
- if (arg->isreg) {
- if (is_spilled(arg->value.generic, jit->prepared_args.op, &sreg)) {
- amd64_sse_cvtsd2ss_reg_membase(jit->ip, AMD64_XMM0, AMD64_RBP, GET_REG_POS(jit, arg->value.generic));
- } else {
- amd64_sse_cvtsd2ss_reg_reg(jit->ip, AMD64_XMM0, sreg);
- }
- amd64_alu_reg_imm(jit->ip, X86_SUB, AMD64_RSP, 8);
- amd64_sse_movlpd_membase_xreg(jit->ip, AMD64_XMM0, AMD64_RSP, 0);
- } else {
- float b = arg->value.fp;
- uint64_t tmp = 0;
- memcpy(&tmp, &b, sizeof(float));
-
- amd64_mov_reg_imm_size(jit->ip, AMD64_RAX, tmp, 8);
- amd64_push_reg(jit->ip, AMD64_RAX);
- }
- }
-}
-
-static inline int emit_arguments(struct jit * jit)
-{
- int stack_correction = 0;
- struct jit_out_arg * args = jit->prepared_args.args;
-
-
- #ifndef TARGET_WIN32
- int gp_pushed = MAX(jit->prepared_args.gp_args - jit->reg_al->gp_arg_reg_cnt, 0);
- int fp_pushed = MAX(jit->prepared_args.fp_args - jit->reg_al->fp_arg_reg_cnt, 0);
- if (jit_current_func_info(jit)->has_prolog) {
- if ((jit->push_count + gp_pushed + fp_pushed) % 2) {
- amd64_alu_reg_imm(jit->ip, X86_SUB, AMD64_RSP, 8);
- stack_correction = 8;
- }
- } else {
- if ((jit->push_count + gp_pushed + fp_pushed) % 2 == 0) {
- amd64_alu_reg_imm(jit->ip, X86_SUB, AMD64_RSP, 8);
- stack_correction = 8;
- }
- }
- #else
- int pushed = MAX(jit->prepared_args.gp_args +jit->prepared_args.fp_args -4, 0);
- if (jit_current_func_info(jit)->has_prolog) {
- //Windwos reqeuires at least 4 stack fields
- int64_t pt=0;
- if(pushed<4) {
- stack_correction = 8*(4-pushed);
- pt=4-pushed;
- } else pt=pushed;
- pushed=jit->push_count*8+stack_correction+8*pushed;
- if (pushed % 16 != 0)
- stack_correction +=8;
- if(stack_correction)
- amd64_alu_reg_imm(jit->ip, X86_SUB, AMD64_RSP, stack_correction);
- } else {
- if ((jit->push_count + pushed) % 2 == 0) {
- amd64_alu_reg_imm(jit->ip, X86_SUB, AMD64_RSP, 8);
- stack_correction = 8;
- }
- }
-
- #endif
- #ifndef TARGET_WIN32
- for (int x = jit->prepared_args.count - 1; x >= 0; x --) {
- struct jit_out_arg * arg = &(args[x]);
- if (!arg->isfp) {
- if (arg->argpos < jit->reg_al->gp_arg_reg_cnt) emit_set_arg(jit, arg);
- else {
- emit_push_arg(jit, arg);
- }
- } else {
- if (arg->argpos < jit->reg_al->fp_arg_reg_cnt) emit_set_fparg(jit, arg);
- else {
- emit_fppush_arg(jit, arg);
- }
- }
- }
- /* AL is used to pass the number of floating point arguments passed through the XMM0-XMM7 registers */
- int fp_reg_arg_cnt = MIN(jit->prepared_args.fp_args, jit->reg_al->fp_arg_reg_cnt);
- if (fp_reg_arg_cnt != 0) amd64_mov_reg_imm(jit->ip, AMD64_RAX, fp_reg_arg_cnt);
- else amd64_alu_reg_reg_size(jit->ip, X86_XOR, AMD64_RAX, AMD64_RAX, 4);
-
- #else
- for (int x = jit->prepared_args.count - 1; x >= 0; x --) {
- struct jit_out_arg * arg = &(args[x]);
- if (!arg->isfp) {
- if (arg->argpos < 4) emit_set_arg(jit, arg);
- else {
- emit_push_arg(jit, arg);
- }
- } else {
- if (arg->argpos < 4) emit_set_fparg(jit, arg);
- else {
- emit_fppush_arg(jit, arg);
- }
- }
- }
- #endif
- return stack_correction;
-}
-
-static void emit_funcall(struct jit * jit, struct jit_op * op, int imm)
-{
-
- // correctly aligns stack to 16 bytes
- int stack_correction = emit_arguments(jit);
-
- #ifdef TARGET_WIN32
- amd64_push_reg(jit->ip,AMD64_R8);
- amd64_push_reg(jit->ip,AMD64_R9);
- amd64_push_reg(jit->ip,AMD64_RDX);
- amd64_push_reg(jit->ip,AMD64_RCX);
- #endif
- if (!imm) {
- jit_hw_reg * hreg = rmap_get(op->regmap, op->arg[0]);
- if (hreg) amd64_call_reg(jit->ip, hreg->id);
- else amd64_call_membase(jit->ip, AMD64_RBP, GET_REG_POS(jit, op->arg[0]));
- } else {
- if (jit_is_label(jit, (void *)op->arg[0])) {
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- amd64_call_imm(jit->ip, JIT_GET_ADDR(jit, op->arg[0]) - 4); // 4: magic constant
- } else {
- // external functions may reside anywhere in the memory
- // even in the place which is not addressable with 32bit wide value
- // therefore external functions are called using %r11 register
- // which is caller-saved register and its value should be already on stack
- amd64_mov_reg_imm_size(jit->ip, AMD64_R11, op->arg[0], 8);
- amd64_call_reg(jit->ip, AMD64_R11);
- }
- }
- stack_correction += jit->prepared_args.stack_size;
- #ifdef TARGET_WIN32
- stack_correction+=4*8;
- #endif
- if (stack_correction)
- amd64_alu_reg_imm(jit->ip, X86_ADD, AMD64_RSP, stack_correction);
- JIT_FREE(jit->prepared_args.args);
-
- jit->push_count -= emit_pop_caller_saved_regs(jit, op);
-}
-
-static void emit_prolog_op(struct jit * jit, jit_op * op)
-{
- jit->current_func = op;
- struct jit_func_info * info = jit_current_func_info(jit);
-
- int prolog = jit_current_func_info(jit)->has_prolog;
-
- while ((jit_value)jit->ip % 16)
- amd64_nop(jit->ip);
-
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- if (prolog) {
- amd64_push_reg(jit->ip, AMD64_RBP);
- amd64_mov_reg_reg(jit->ip, AMD64_RBP, AMD64_RSP, 8);
- }
-
- int stack_mem = info->allocai_mem + info->gp_reg_count * REG_SIZE + info->fp_reg_count * sizeof(jit_float) + info->general_arg_cnt * REG_SIZE + info->float_arg_cnt * sizeof(jit_float);
-
- stack_mem = jit_value_align(stack_mem, JIT_STACK_ALIGNMENT); // 16-bytes aligned
-
- if (prolog)
- amd64_alu_reg_imm(jit->ip, X86_SUB, AMD64_RSP, stack_mem);
- jit->push_count = emit_push_callee_saved_regs(jit, op);
-}
-static void emit_msg_op(struct jit * jit, jit_op * op)
-{
- /*
- int64_t stackOff=0;
- struct jit_reg_allocator * al = jit->reg_al;
- for (int i = 0; i < al->gp_reg_cnt; i++)
- if (!al->gp_regs[i].callee_saved) {
- stackOff+=8;
- amd64_push_reg(jit->ip, al->gp_regs[i].id);
- }
- int value, iter;
- vec_foreach(&op->live_in->vec,value,iter) {
- jit_hw_reg *hw=rmap_get(op->regmap,value);
- (stackOff+=8);
- if(hw)
- amd64_push_reg(jit->ip,hw->id);
- else
- amd64_push_imm(jit->ip, 0);
- }
-
- if(stackOff%16!=0)
- amd64_push_reg(jit->ip,AMD64_RAX);
-
- amd64_mov_reg_reg_size(jit->ip, AMD64_ARG_REG1, AMD64_RSP,8);
- amd64_mov_reg_imm(jit->ip, AMD64_ARG_REG2, op->arg[2]);
- amd64_mov_reg_imm(jit->ip, AMD64_ARG_REG3, CallDebugger);
- amd64_call_reg(jit->ip, AMD64_ARG_REG3);
-
- if(stackOff%16!=0)
- amd64_pop_reg(jit->ip,AMD64_RAX);
-
- vec_foreach_rev(&op->live_in->vec,value,iter) {
- jit_hw_reg *hw=rmap_get(op->regmap,value);
- stackOff-=8;
- if(hw)
- amd64_pop_reg(jit->ip,hw->id);
- else
- amd64_pop_reg(jit->ip, AMD64_RAX);
- }
- for (int i = al->gp_reg_cnt - 1; i >= 0; i--)
- if (!al->gp_regs[i].callee_saved) {
- stackOff-=8;
- amd64_pop_reg(jit->ip, al->gp_regs[i].id);
- }
- assert(stackOff==0);
- */
-}
-
-static void emit_fret_op(struct jit * jit, jit_op * op)
-{
- jit_value arg = op->r_arg[0];
-
- if (op->arg_size == sizeof(float))
- sse_cvtsd2ss_reg_reg(jit->ip, arg, arg);
-
- // pushes the value beyond the top of the stack
- sse_movlpd_membase_xreg(jit->ip, arg, COMMON86_SP, -8);
- common86_mov_reg_membase(jit->ip, COMMON86_AX, COMMON86_SP, -8, 8);
- // transfers the value from the stack to RAX
- sse_movsd_reg_membase(jit->ip, COMMON86_XMM0, COMMON86_SP, -8);
-
- // common epilogue
- jit->push_count -= emit_pop_callee_saved_regs(jit);
- if (jit_current_func_info(jit)->has_prolog) {
- common86_mov_reg_reg(jit->ip, COMMON86_SP, COMMON86_BP, 8);
- common86_pop_reg(jit->ip, COMMON86_BP);
- }
- common86_ret(jit->ip);
-}
-
-static void emit_fretval_op(struct jit * jit, jit_op * op)
-{
- jit_value arg = op->r_arg[0];
- if (op->arg_size == sizeof(float)) sse_cvtss2sd_reg_reg(jit->ip, arg, COMMON86_XMM0);
- else if (arg != COMMON86_XMM0) sse_movsd_reg_reg(jit->ip, arg, COMMON86_XMM0);
-}
-
-void jit_patch_external_calls(struct jit * jit)
-{
- // On AMD64 called function can be anywhere in the memory, even so far that its address won't fit into
- // 32bit address, therefore all external function calls are handed through the R_IMM register
-}
-
-struct jit_reg_allocator * jit_reg_allocator_create()
-{
- struct jit_reg_allocator * a = JIT_MALLOC(sizeof(struct jit_reg_allocator));
- a->gp_reg_cnt = 12;
-
- a->gp_regs = JIT_MALLOC(sizeof(jit_hw_reg) * (2+a->gp_reg_cnt));
- a->gp_regs[0] = (jit_hw_reg) { AMD64_RBX, "rbx", AMD64_IS_CALLEE_SAVED_REG(AMD64_RBX), 0, 8 };
- a->gp_regs[1] = (jit_hw_reg) { AMD64_RCX, "rcx", AMD64_IS_CALLEE_SAVED_REG(AMD64_RCX), 0, 4 };
- a->gp_regs[2] = (jit_hw_reg) { AMD64_RDX, "rdx", AMD64_IS_CALLEE_SAVED_REG(AMD64_RDX), 0, 3 };
- a->gp_regs[3] = (jit_hw_reg) { AMD64_RSI, "rsi", AMD64_IS_CALLEE_SAVED_REG(AMD64_RSI), 0, 2 };
- a->gp_regs[4] = (jit_hw_reg) { AMD64_RDI, "rdi", AMD64_IS_CALLEE_SAVED_REG(AMD64_RDI), 0, 1 };
- a->gp_regs[5] = (jit_hw_reg) { AMD64_R8, "r8", AMD64_IS_CALLEE_SAVED_REG(AMD64_R8), 0, 5 };
- a->gp_regs[6] = (jit_hw_reg) { AMD64_R9, "r9", AMD64_IS_CALLEE_SAVED_REG(AMD64_R9), 0, 6 };
- a->gp_regs[7] = (jit_hw_reg) { AMD64_R10, "r10", AMD64_IS_CALLEE_SAVED_REG(AMD64_R10), 0, 9 };
- a->gp_regs[8] = (jit_hw_reg) { AMD64_R11, "r11", AMD64_IS_CALLEE_SAVED_REG(AMD64_R11), 0, 10 };
- a->gp_regs[9] = (jit_hw_reg) { AMD64_R12, "r12", AMD64_IS_CALLEE_SAVED_REG(AMD64_R12), 0, 11 };
- a->gp_regs[10] = (jit_hw_reg) { AMD64_R14, "r14", AMD64_IS_CALLEE_SAVED_REG(AMD64_R14), 0, 13 };
- a->gp_regs[11] = (jit_hw_reg) { AMD64_R15, "r15", AMD64_IS_CALLEE_SAVED_REG(AMD64_R15), 0, 14 };
- //RAX is a accumulator
- a->gp_regs[12] = (jit_hw_reg) { AMD64_RAX, "rax", AMD64_IS_CALLEE_SAVED_REG(AMD64_RAX), 0, 7 };
-
- // R13 has some addressing limitations, therefore it is not used as GPR
- // since it may lead to unexpected behavior
-// a->gp_regs[13] = (jit_hw_reg) { AMD64_R13, 0, "r13", 1, 0, 12 };
-
-
- a->gp_arg_reg_cnt = 6;
-
- a->fp_reg = AMD64_RBP;
- a->ret_reg = &(a->gp_regs[12]);
-
- a->fp_reg_cnt = 9;
-
- int reg = 0;
- a->fp_regs = JIT_MALLOC(sizeof(jit_hw_reg) * (1+a->fp_reg_cnt));
-
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM1, "xmm1", 0, 1, 98 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM2, "xmm2", 0, 1, 97 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM3, "xmm3", 0, 1, 96 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM4, "xmm4", 0, 1, 95 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM5, "xmm5", 0, 1, 94 };
- #ifdef TARGET_WIN32
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM6, "xmm6", 1, 1, 93 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM7, "xmm7", 1, 1, 92 };
- //a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM11, "xmm11", 0, 1, 3 };
- //a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM10, "xmm10", 0, 1, 4 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM13, "xmm13", 1, 1, 1 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM12, "xmm12", 1, 1, 2 };
- #else
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM6, "xmm6", 0, 1, 93 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM7, "xmm7", 0, 1, 92 };
- //a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM11, "xmm11", 0, 1, 3 };
- //a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM10, "xmm10", 0, 1, 4 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM13, "xmm13", 0, 1, 1 };
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM12, "xmm12", 0, 1, 2 };
- #endif
- //XMM0 is used as an accumulator
- a->fp_regs[reg++] = (jit_hw_reg) { AMD64_XMM0, "xmm0", 0, 1, 99 };
- /*
-#ifndef JIT_REGISTER_TEST
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM4, "xmm4", 0, 1, 5 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM5, "xmm5", 0, 1, 6 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM6, "xmm6", 0, 1, 7 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM7, "xmm7", 0, 1, 8 };
-#endif
-*/
-
- a->fpret_reg = &(a->fp_regs[reg-1]);
-
- #ifndef TARGET_WIN32
- a->gp_arg_reg_cnt = 6;
- a->gp_arg_regs = JIT_MALLOC(sizeof(jit_hw_reg *) * 6);
- a->gp_arg_regs[0] = &(a->gp_regs[5-1]);
- a->gp_arg_regs[1] = &(a->gp_regs[4-1]);
- a->gp_arg_regs[2] = &(a->gp_regs[3-1]);
- a->gp_arg_regs[3] = &(a->gp_regs[2-1]);
- a->gp_arg_regs[4] = &(a->gp_regs[6-1]);
- a->gp_arg_regs[5] = &(a->gp_regs[7-1]);
-
- a->fp_arg_reg_cnt = 8;
- a->fp_arg_regs = JIT_MALLOC(sizeof(jit_hw_reg *) * 8);
- for (int i = 1; i < 8; i++)
- a->fp_arg_regs[i] = &(a->fp_regs[i-1]);
- a->fp_arg_regs[0]=&a->fp_regs[reg-1]; //Last is accumalator
- #else
- a->gp_arg_reg_cnt = 4;
- a->gp_arg_regs = JIT_MALLOC(sizeof(jit_hw_reg *) * 4);
- a->gp_arg_regs[0]=&(a->gp_regs[2-1]); //RCX
- a->gp_arg_regs[1]=&(a->gp_regs[3-1]); //RDX
- a->gp_arg_regs[2]=&(a->gp_regs[6-1]); //R8
- a->gp_arg_regs[3]=&(a->gp_regs[7-1]); //R9
- a->fp_arg_reg_cnt = 4;
- a->fp_arg_regs = JIT_MALLOC(sizeof(jit_hw_reg *) * 4);
- for (int i = 1; i < 4; i++)
- a->fp_arg_regs[i] = &(a->fp_regs[i-1]);
- a->fp_arg_regs[0]=&a->fp_regs[reg-1]; //Last is accumalator
- #endif
-
- return a;
-}
diff --git a/ext/myjit/myjit/code-check.c b/ext/myjit/myjit/code-check.c
deleted file mode 100755
index e22c38b..0000000
--- a/ext/myjit/myjit/code-check.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-static void jit_dead_code_analysis(struct jit *jit, int remove_dead_code);
-static inline void jit_expand_patches_and_labels(struct jit *jit);
-static inline void jit_flw_analysis(struct jit *jit);
-static inline void jit_prepare_reg_counts(struct jit *jit);
-static inline void jit_prepare_arguments(struct jit *jit);
-void jit_get_reg_name(struct jit_disasm *disasm, char * r, int reg);
-
-static struct jit_disasm jit_debugging_disasm = {
- .indent_template = " ",
- .reg_template = "r%i",
- .freg_template = "fr%i",
- .arg_template = "arg%i",
- .farg_template = "farg%i",
- .reg_out_template = "out",
- .reg_fp_template = "fp",
- .reg_imm_template = "imm",
- .reg_fimm_template = "fimm",
- .reg_unknown_template = "(unknown reg.)",
- .label_template = "<label>",
- .label_forward_template = "<label>",
- .generic_addr_template = "<addr: 0x%lx>",
- .generic_value_template = "0x%lx",
-};
-
-
-
-static void report_warning(struct jit *jit, jit_op *op, char *desc)
-{
- fprintf(stdout, "%s at function `%s' (%s:%i)\n", desc, op->debug_info->function, op->debug_info->filename, op->debug_info->lineno);
- print_op(stdout, &jit_debugging_disasm, op, NULL, 0);
- fprintf(stdout, "\n");
-}
-
-static void append_msg(char *buf, char *format, ...)
-{
- va_list ap;
- if (strlen(buf)) strcat(buf, ", ");
- va_start(ap, format);
- vsprintf(buf + strlen(buf), format, ap);
- va_end(ap);
-}
-
-static void cleanup(struct jit *jit)
-{
- for (jit_op *op = jit_op_first(jit->ops); op; op = op->next) {
- if (op->live_in) {
- jit_set_free(op->live_in);
- op->live_in = NULL;
- }
- if (op->live_out) {
- jit_set_free(op->live_out);
- op->live_out = NULL;
- }
- if (GET_OP(op) == JIT_PROLOG) {
- if (op->arg[1]) {
- struct jit_func_info *info = (struct jit_func_info *)op->arg[1];
- JIT_FREE(info->args);
- info->args = NULL;
- }
- }
- if (GET_OP(op) == JIT_PREPARE) {
- op->arg[0] = 0;
- op->arg[1] = 0;
- }
- }
-}
-
-static int check_dead_code(jit_op *op, char *msg_buf)
-{
- if (!op->in_use) {
- append_msg(msg_buf, "unreachable operation");
- return JIT_WARN_DEAD_CODE;
- }
- return 0;
-}
-
-static int check_missing_patches(jit_op *op, char *msg_buf)
-{
- if ((((GET_OP(op) == JIT_CALL) || (GET_OP(op) == JIT_JMP)) && IS_IMM(op)) || is_cond_branch_op(op)) {
- if ((op->arg[0] == (jit_value) JIT_FORWARD) && (op->jmp_addr == NULL)) {
- append_msg(msg_buf, "missing patch");
- return JIT_WARN_MISSING_PATCH;
- }
- }
- // FIXME: DATA_CADDR, DATA_DADDR, CODE_ADDR, DATA_ADDR
- return 0;
-}
-
-static int check_op_without_effect(jit_op *op, char *msg_buf)
-{
- // we have to skip these operations since, these are working with the flag register
- jit_opcode code = GET_OP(op);
- if ((code == JIT_ADDC) || (code == JIT_ADDX) || (code == JIT_SUBC) || (code == JIT_SUBX)
- || (code == JIT_BOADD) || (code == JIT_BOSUB) || (code == JIT_BNOADD) || (code == JIT_BNOSUB)) return 0;
-
- for (int i = 0; i < 3; i++) {
- if ((ARG_TYPE(op, i + 1) == TREG) && (!jit_set_get(op->live_out, op->arg[i]))) {
- append_msg(msg_buf, "operation without effect");
- return JIT_WARN_OP_WITHOUT_EFFECT;
- }
- }
- return 0;
-}
-
-static void print_regs(jit_tree_key reg, jit_tree_value v, void *thunk)
-{
- char buf[32];
- if (reg == R_FP) return;
- jit_get_reg_name(&jit_debugging_disasm, buf, reg);
- strcat(thunk, " ");
- strcat(thunk, buf);
-}
-
-static int check_uninitialized_registers(jit_op *op, char *msg_buf)
-{
- if (GET_OP(op) != JIT_PROLOG) return 0;
-
- if (op->live_in->vec.length != 0) {
- char buf[4096];
- buf[0] = '\0';
- //jit_tree_walk(op->live_in->root, print_regs, buf);
- //if (strlen(buf)) {
- // append_msg(msg_buf, "uninitialized register(s): %s", buf);
- // return JIT_WARN_UNINITIALIZED_REG;
- //}
- }
- return 0;
-}
-
-static int valid_size(int size) {
- switch (size) {
- case 1: case 2: case 4:
-#ifdef JIT_ARCH_AMD64
- case 8:
-#endif
- return 1;
- default:
- return 0;
- }
-}
-
-static int valid_fsize(int size)
-{
- return (size == 4) || (size == 8);
-}
-
-static int check_argument_sizes(jit_op *op, char *msg_buf)
-{
- switch (GET_OP(op)) {
- case JIT_LD: case JIT_LDX: case JIT_ST: case JIT_STX:
- if (valid_size(op->arg_size)) return 0;
- break;
-
- case JIT_FLD: case JIT_FLDX: case JIT_FST: case JIT_FSTX:
- case JIT_FPUTARG: case JIT_FRET: case JIT_FRETVAL:
- if (valid_fsize(op->arg_size)) return 0;
- break;
-
- case JIT_DECL_ARG:
- if (((op->arg[0] == JIT_SIGNED_NUM) || (op->arg[0] == JIT_UNSIGNED_NUM)) && valid_size(op->arg[1])) return 0;
- if ((op->arg[0] == JIT_FLOAT_NUM) && valid_fsize(op->arg[1])) return 0;
- if ((op->arg[0] == JIT_PTR) && (op->arg[1] == sizeof(void *))) return 0;
- break;
- default:
- return 0;
- }
-
- append_msg(msg_buf, "invalid data size");
- return JIT_WARN_INVALID_DATA_SIZE;
-}
-
-#define CHECK_ARG_TYPE(op, index, _type) (((ARG_TYPE(op, index) != REG) && (ARG_TYPE(op, index) != TREG)) || (JIT_REG(op->arg[index - 1]).type == _type))
-
-static int check_register_types(struct jit *jit, jit_op *op, char *msg_buf)
-{
- switch (GET_OP(op)) {
- case JIT_GETARG: {
- struct jit_func_info * info = jit_current_func_info(jit);
- if (info->args[op->arg[1]].type == JIT_FLOAT_NUM) {
- if (CHECK_ARG_TYPE(op, 1, JIT_RTYPE_FLOAT)) return 0;
- } else {
- if (CHECK_ARG_TYPE(op, 1, JIT_RTYPE_INT)) return 0;
- }
- break;
- }
- case JIT_FST:
- case JIT_TRUNC:
- case JIT_CEIL:
- case JIT_ROUND:
- case JIT_FLOOR:
- if (CHECK_ARG_TYPE(op, 1, JIT_RTYPE_INT) && CHECK_ARG_TYPE(op, 2, JIT_RTYPE_FLOAT)) return 0;
- break;
- case JIT_EXT:
- case JIT_FLD:
- if (CHECK_ARG_TYPE(op, 1, JIT_RTYPE_FLOAT) && CHECK_ARG_TYPE(op, 2, JIT_RTYPE_INT)) return 0;
- break;
- case JIT_FLDX:
- if (CHECK_ARG_TYPE(op, 1, JIT_RTYPE_FLOAT) && CHECK_ARG_TYPE(op, 2, JIT_RTYPE_INT) && CHECK_ARG_TYPE(op, 3, JIT_RTYPE_INT)) return 0;
- break;
- case JIT_FSTX:
- if (CHECK_ARG_TYPE(op, 1, JIT_RTYPE_INT) && CHECK_ARG_TYPE(op, 2, JIT_RTYPE_INT) && CHECK_ARG_TYPE(op, 3, JIT_RTYPE_FLOAT)) return 0;
- break;
- case JIT_FORCE_SPILL:
- case JIT_FORCE_ASSOC:
- return 0;
- default:
- if (!op->fp && CHECK_ARG_TYPE(op, 1, JIT_RTYPE_INT) && CHECK_ARG_TYPE(op, 2, JIT_RTYPE_INT) && CHECK_ARG_TYPE(op, 3, JIT_RTYPE_INT)) return 0;
- if (op->fp && CHECK_ARG_TYPE(op, 1, JIT_RTYPE_FLOAT) && CHECK_ARG_TYPE(op, 2, JIT_RTYPE_FLOAT) && CHECK_ARG_TYPE(op, 3, JIT_RTYPE_FLOAT)) return 0;
- }
- append_msg(msg_buf, "register type mismatch");
- return JIT_WARN_REGISTER_TYPE_MISMATCH;
-}
-
-static int jit_op_is_data_op(jit_op *op)
-{
- while (op && ((GET_OP(op) == JIT_LABEL) || (GET_OP(op) == JIT_PATCH))) op = op->next;
- if (!op) return 0;
-
- jit_opcode code = GET_OP(op);
- return ((code == JIT_DATA_BYTE) || (code == JIT_DATA_REF_CODE) || (code == JIT_DATA_REF_DATA)||(code==JIT_DATA_CODE_OFFSET));
-}
-
-static int check_data_alignment(jit_op *op, char *msg_buf)
-{
- if (jit_op_is_data_op(op) || (GET_OP(op) == JIT_CODE_ALIGN)) return 0;
- if ((GET_OP(op) == JIT_LABEL) || (GET_OP(op) == JIT_PATCH)) return 0;
- jit_op * prev = op->prev;
- while (prev) {
- if ((GET_OP(prev) == JIT_LABEL) || (GET_OP(prev) == JIT_PATCH))
- prev = prev->prev;
- else break;
- }
- if (jit_op_is_data_op(prev)) {
- append_msg(msg_buf, "instruction follows unaligned data block");
- return JIT_WARN_UNALIGNED_CODE;
- }
- return 0;
-}
-
-static int check_data_references(jit_op *op, char *msg_buf)
-{
- if (((GET_OP(op) == JIT_REF_DATA) || (GET_OP(op) == JIT_DATA_REF_DATA)) && !jit_op_is_data_op(op->jmp_addr)) {
- append_msg(msg_buf, "invalid data reference");
- return JIT_WARN_INVALID_DATA_REFERENCE;
- }
- return 0;
-}
-
-static int check_code_references(jit_op *op, char *msg_buf)
-{
- if (((GET_OP(op) == JIT_REF_CODE) || (GET_OP(op) == JIT_DATA_REF_CODE)||(GET_OP(op)==JIT_DATA_CODE_OFFSET)) && jit_op_is_data_op(op->jmp_addr)) {
- append_msg(msg_buf, "invalid code reference");
- return JIT_WARN_INVALID_CODE_REFERENCE;
- }
- return 0;
-}
-
-
-void jit_check_code(struct jit *jit, int warnings)
-{
- char buf[8192];
-
- jit_expand_patches_and_labels(jit);
- jit_dead_code_analysis(jit, 0);
- jit_prepare_reg_counts(jit);
- jit_prepare_arguments(jit);
- jit_flw_analysis(jit);
-
- for (jit_op *op = jit_op_first(jit->ops); op; op = op->next) {
- if (GET_OP(op) == JIT_PROLOG) jit->current_func = op;
- if (!op->debug_info) continue;
- buf[0] = '\0';
-
- if (warnings & JIT_WARN_DEAD_CODE) op->debug_info->warnings |= check_dead_code(op, buf);
- if (warnings & JIT_WARN_MISSING_PATCH) op->debug_info->warnings |= check_missing_patches(op, buf);
- if (warnings & JIT_WARN_OP_WITHOUT_EFFECT) op->debug_info->warnings |= check_op_without_effect(op, buf);
- if (warnings & JIT_WARN_UNINITIALIZED_REG) op->debug_info->warnings |= check_uninitialized_registers(op, buf);
- if (warnings & JIT_WARN_INVALID_DATA_SIZE) op->debug_info->warnings |= check_argument_sizes(op, buf);
- if (warnings & JIT_WARN_REGISTER_TYPE_MISMATCH) op->debug_info->warnings |= check_register_types(jit, op, buf);
- if (warnings & JIT_WARN_UNALIGNED_CODE) op->debug_info->warnings |= check_data_alignment(op, buf);
- if (warnings & JIT_WARN_INVALID_DATA_REFERENCE) op->debug_info->warnings |= check_data_references(op, buf);
- if (warnings & JIT_WARN_INVALID_CODE_REFERENCE) op->debug_info->warnings |= check_code_references(op, buf);
-
- if (op->debug_info->warnings) report_warning(jit, op, buf);
- }
-
- cleanup(jit);
-}
diff --git a/ext/myjit/myjit/common86-codegen.h b/ext/myjit/myjit/common86-codegen.h
deleted file mode 100755
index 891f667..0000000
--- a/ext/myjit/myjit/common86-codegen.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* This header file provides mappings of macros common to x86 and amd64 platform
- * according to currently used CPU.
- */
-#ifdef JIT_ARCH_I386
-#include "x86-codegen.h"
-
-#define COMMON86_AX X86_EAX
-#define COMMON86_BX X86_EBX
-#define COMMON86_CX X86_ECX
-#define COMMON86_DX X86_EDX
-#define COMMON86_SI X86_ESI
-#define COMMON86_DI X86_EDI
-#define COMMON86_SP X86_ESP
-#define COMMON86_BP X86_EBP
-#define COMMON86_XMM0 X86_XMM0
-
-#define common86_mov_reg_reg(ptr, reg1, reg2, size) x86_mov_reg_reg(ptr, reg1, reg2, size)
-#define common86_movsx_reg_reg(ptr, reg1, reg2, size) x86_movsx_reg_reg(ptr, reg1, reg2, size)
-#define common86_movzx_reg_reg(ptr, reg1, reg2, size) x86_movzx_reg_reg(ptr, reg1, reg2, size)
-#define common86_mov_reg_imm(ptr, reg, imm) x86_mov_reg_imm(ptr, reg, imm)
-#define common86_mov_reg_imm_size(ptr, reg, imm, size) x86_mov_reg_imm(ptr, reg, imm)
-#define common86_xchg_reg_reg(ptr, reg1, reg2, size) x86_xchg_reg_reg(ptr, reg1, reg2, size)
-#define common86_mov_reg_mem(ptr, reg, mem, size) x86_mov_reg_mem(ptr, reg, mem, size)
-#define common86_movsx_reg_mem(ptr, reg, mem, size) x86_movsx_reg_mem(ptr, reg, mem, size)
-#define common86_movzx_reg_mem(ptr, reg, mem, size) x86_movzx_reg_mem(ptr, reg, mem, size)
-#define common86_mov_reg_membase(ptr, reg, basereg, disp, size) x86_mov_reg_membase(ptr, reg, basereg, disp, size)
-#define common86_movsx_reg_membase(ptr, reg, basereg, disp, size) x86_movsx_reg_membase(ptr, reg, basereg, disp, size)
-#define common86_movzx_reg_membase(ptr, reg, basereg, disp, size) x86_movzx_reg_membase(ptr, reg, basereg, disp, size)
-#define common86_mov_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size) x86_mov_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size)
-#define common86_movsx_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size) x86_movsx_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size)
-#define common86_movzx_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size) x86_movzx_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size)
-
-#define common86_mov_mem_reg(ptr, mem, reg, size) x86_mov_mem_reg(ptr, mem, reg, size)
-#define common86_mov_mem_imm(ptr, mem, imm, size) x86_mov_mem_imm(ptr, mem, imm, size)
-#define common86_mov_membase_imm(ptr, basereg, disp, imm, size) x86_mov_membase_imm(ptr, basereg, disp, imm, size)
-#define common86_mov_membase_reg(ptr, basereg, disp, reg, size) x86_mov_membase_reg(ptr, basereg, disp, reg, size)
-#define common86_mov_memindex_reg(ptr, basereg, disp, indexreg, shift, reg, size) x86_mov_memindex_reg(ptr, basereg, disp, indexreg, shift, reg, size)
-#define common86_mov_memindex_imm(ptr, basereg, disp, indexreg, shift, imm, size) x86_mov_memindex_imm(ptr, basereg, disp, indexreg, shift, imm, size)
-
-
-
-#define common86_alu_reg_reg(ptr, op, reg1, reg2) x86_alu_reg_reg(ptr, op, reg1, reg2)
-#define common86_alu_reg_imm(ptr, op, reg, imm) x86_alu_reg_imm(ptr, op, reg, imm)
-#define common86_alu_reg_membase(ptr, op, reg, basereg, disp) x86_alu_reg_membase(ptr, op, reg, basereg, disp)
-
-#define common86_shift_reg_imm(ptr, op, reg, imm) x86_shift_reg_imm(ptr, op, reg, imm)
-#define common86_shift_reg(ptr, op, reg) x86_shift_reg(ptr, op, reg)
-#define common86_mul_reg(ptr, reg, sign) x86_mul_reg(ptr, reg, sign)
-#define common86_div_reg(ptr, reg, sign) x86_div_reg(ptr, reg, sign)
-#define common86_div_membase(ptr, basereg, disp, sign) x86_div_membase(ptr, basereg, disp, sign)
-#define common86_cdq(ptr) x86_cdq(ptr)
-#define common86_neg_reg(ptr, reg) x86_neg_reg(ptr, reg)
-#define common86_not_reg(ptr, reg) x86_not_reg(ptr, reg)
-
-
-#define common86_set_reg(ptr, cond, reg, size) x86_set_reg(ptr, cond, reg, size)
-#define common86_test_reg_reg(ptr, reg1, reg2) x86_test_reg_reg(ptr, reg1, reg2)
-#define common86_test_reg_imm(ptr, reg, imm) x86_test_reg_imm(ptr, reg, imm)
-#define common86_branch_disp32(ptr, cond, addr, sign) x86_branch_disp32(ptr, cond, addr, sign)
-#define common86_branch_disp(ptr, cond, addr, sign) x86_branch_disp(ptr, cond, addr, sign)
-
-#define common86_patch(op, ptr) x86_patch(op, ptr)
-#define common86_jump_disp(op, disp) x86_jump_disp(op, disp)
-#define common86_jump_disp32(op, disp) x86_jump_disp32(op, disp)
-#define common86_jump_reg(op, reg) x86_jump_reg(op, reg)
-#define common86_ret(ptr) x86_ret(ptr)
-
-#define common86_lea_membase(ptr, reg, basereg, disp) x86_lea_membase(ptr, reg, basereg, disp)
-#define common86_lea_memindex(ptr, reg, basereg, disp, indexreg, shift) x86_lea_memindex(ptr, reg, basereg, disp, indexreg, shift)
-
-#define common86_push_reg(ptr, reg) x86_push_reg(ptr, reg)
-#define common86_pop_reg(ptr, reg) x86_pop_reg(ptr, reg)
-
-
-#define common86_nop(ptr) x86_nop(ptr)
-
-#endif
-
-
-
-#ifdef JIT_ARCH_AMD64
-#include "amd64-codegen.h"
-
-#define COMMON86_AX AMD64_RAX
-#define COMMON86_BX AMD64_RBX
-#define COMMON86_CX AMD64_RCX
-#define COMMON86_DX AMD64_RDX
-#define COMMON86_SI AMD64_RSI
-#define COMMON86_DI AMD64_RDI
-#define COMMON86_SP AMD64_RSP
-#define COMMON86_BP AMD64_RBP
-#define COMMON86_XMM0 AMD64_XMM0
-
-#define common86_mov_reg_reg(ptr, reg1, reg2, size) amd64_mov_reg_reg(ptr, reg1, reg2, size)
-#define common86_movsx_reg_reg(ptr, reg1, reg2, size) amd64_movsx_reg_reg(ptr, reg1, reg2, size)
-#define common86_movzx_reg_reg(ptr, reg1, reg2, size) amd64_movzx_reg_reg(ptr, reg1, reg2, size)
-#define common86_mov_reg_imm_size(ptr, reg, imm, size) amd64_mov_reg_imm_size(ptr, reg, imm, size)
-#define common86_mov_reg_imm(ptr, reg, imm) amd64_mov_reg_imm_size(ptr, reg, imm, sizeof(void *))
-#define common86_mov_reg_mem(ptr, reg, mem, size) amd64_mov_reg_mem(ptr, reg, mem, size)
-#define common86_movsx_reg_mem(ptr, reg, mem, size) amd64_movsx_reg_mem(ptr, reg, mem, size)
-#define common86_movzx_reg_mem(ptr, reg, mem, size) amd64_movzx_reg_mem(ptr, reg, mem, size)
-#define common86_mov_reg_membase(ptr, reg, basereg, disp, size) amd64_mov_reg_membase(ptr, reg, basereg, disp, size)
-#define common86_movsx_reg_membase(ptr, reg, basereg, disp, size) amd64_movsx_reg_membase(ptr, reg, basereg, disp, size)
-#define common86_movzx_reg_membase(ptr, reg, basereg, disp, size) amd64_movzx_reg_membase(ptr, reg, basereg, disp, size)
-
-#define common86_mov_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size) amd64_mov_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size)
-#define common86_movsx_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size) amd64_movsx_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size)
-#define common86_movzx_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size) amd64_movzx_reg_memindex(ptr, reg, basereg, disp, indexreg, shift, size)
-
-#define common86_mov_mem_reg(ptr, mem, reg, size) amd64_mov_mem_reg(ptr, mem, reg, size)
-#define common86_mov_mem_imm(ptr, mem, imm, size) amd64_mov_mem_imm(ptr, mem, imm, size)
-#define common86_mov_membase_imm(ptr, basereg, disp, imm, size) amd64_mov_membase_imm(ptr, basereg, disp, imm, size)
-#define common86_mov_membase_reg(ptr, basereg, disp, reg, size) amd64_mov_membase_reg(ptr, basereg, disp, reg, size)
-#define common86_mov_memindex_reg(ptr, basereg, disp, indexreg, shift, reg, size) amd64_mov_memindex_reg(ptr, basereg, disp, indexreg, shift, reg, size)
-#define common86_mov_memindex_imm(ptr, basereg, disp, indexreg, shift, imm, size) amd64_mov_memindex_imm(ptr, basereg, disp, indexreg, shift, imm, size)
-
-
-
-#define common86_xchg_reg_reg(ptr, reg1, reg2, size) amd64_xchg_reg_reg(ptr, reg1, reg2, size)
-
-#define common86_alu_reg_reg(ptr, op, reg1, reg2) amd64_alu_reg_reg(ptr, op, reg1, reg2)
-#define common86_alu_reg_imm(ptr, op, reg, imm) amd64_alu_reg_imm(ptr, op, reg, imm)
-#define common86_alu_reg_membase(ptr, op, reg, basereg, disp) amd64_alu_reg_membase(ptr, op, reg, basereg, disp)
-
-#define common86_shift_reg_imm(ptr, op, reg, imm) amd64_shift_reg_imm(ptr, op, reg, imm)
-#define common86_shift_reg(ptr, op, reg) amd64_shift_reg(ptr, op, reg)
-#define common86_mul_reg(ptr, reg, sign) amd64_mul_reg(ptr, reg, sign)
-#define common86_div_reg(ptr, reg, sign) amd64_div_reg(ptr, reg, sign)
-#define common86_div_membase(ptr, basereg, disp, sign) amd64_div_membase(ptr, basereg, disp, sign)
-#define common86_cdq(ptr) amd64_cdq(ptr)
-#define common86_neg_reg(ptr, reg) amd64_neg_reg(ptr, reg)
-#define common86_not_reg(ptr, reg) amd64_not_reg(ptr, reg)
-
-
-#define common86_set_reg(ptr, cond, reg, size) amd64_set_reg(ptr, cond, reg, size)
-#define common86_test_reg_reg(ptr, reg1, reg2) amd64_test_reg_reg(ptr, reg1, reg2)
-#define common86_test_reg_imm(ptr, reg, imm) amd64_test_reg_imm(ptr, reg, imm)
-#define common86_branch_disp32(ptr, cond, addr, sign) amd64_branch_disp32(ptr, cond, addr, sign)
-#define common86_branch_disp(ptr, cond, addr, sign) amd64_branch_disp(ptr, cond, addr, sign)
-
-#define common86_patch(op, ptr) amd64_patch(op, ptr)
-#define common86_jump_disp(op, disp) amd64_jump_disp(op, disp)
-#define common86_jump_disp32(op, disp) amd64_jump_disp32(op, disp)
-#define common86_jump_reg(op, reg) amd64_jump_reg(op, reg)
-#define common86_ret(ptr) amd64_ret(ptr)
-
-#define common86_lea_membase(ptr, reg, basereg, disp) amd64_lea_membase(ptr, reg, basereg, disp)
-#define common86_lea_memindex(ptr, reg, basereg, disp, indexreg, shift) amd64_lea_memindex(ptr, reg, basereg, disp, indexreg, shift)
-
-#define common86_push_reg(ptr, reg) amd64_push_reg(ptr, reg)
-#define common86_pop_reg(ptr, reg) amd64_pop_reg(ptr, reg)
-
-#define common86_nop(ptr) amd64_nop(ptr)
-
-#endif
diff --git a/ext/myjit/myjit/common86-specific.h b/ext/myjit/myjit/common86-specific.h
deleted file mode 100755
index 9c186a2..0000000
--- a/ext/myjit/myjit/common86-specific.h
+++ /dev/null
@@ -1,989 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010 Petr Krajca, <krajcap@inf.upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "common86-codegen.h"
-
-static inline int is_spilled(jit_value arg_id, jit_op * prepare_op, int * reg);
-static int emit_push_callee_saved_regs(struct jit * jit, jit_op * op);
-static int emit_push_caller_saved_regs(struct jit * jit, jit_op * op);
-static int emit_pop_callee_saved_regs(struct jit * jit);
-static int emit_pop_caller_saved_regs(struct jit * jit, jit_op * op);
-
-
-static jit_hw_reg * rmap_is_associated(jit_rmap * rmap, int reg_id, int fp, jit_value * virt_reg);
-static jit_hw_reg * rmap_get(jit_rmap * rmap, jit_value reg);
-
-
-#define JIT_GET_ADDR(jit, imm) (!jit_is_label(jit, (void *)(imm)) ? (imm) : \
- (((jit_value)jit->buf + ((jit_label *)(imm))->pos - (jit_value)jit->ip)))
-
-#include "sse2-specific.h"
-
-#ifdef JIT_ARCH_I386
-#include "x86-specific.h"
-#endif
-
-#ifdef JIT_ARCH_AMD64
-#include "amd64-specific.h"
-#endif
-
-//
-//
-// Registers
-//
-//
-
-/**
- * Emits PUSH instruction for the given GP or FP register
- */
-static void emit_push_reg(struct jit * jit, jit_hw_reg * r)
-{
- if (!r->fp) common86_push_reg(jit->ip, r->id);
- else {
- common86_alu_reg_imm(jit->ip, X86_SUB, COMMON86_SP, 8);
- sse_movlpd_membase_xreg(jit->ip, r->id, COMMON86_SP, 0);
- }
-}
-
-/**
- * Emits PUSH instruction for the given GP or FP register
- */
-static void emit_pop_reg(struct jit * jit, jit_hw_reg * r)
-{
- if (!r->fp) common86_pop_reg(jit->ip, r->id);
- else {
- sse_movlpd_xreg_membase(jit->ip, r->id, COMMON86_SP, 0);
- common86_alu_reg_imm(jit->ip, X86_ADD, COMMON86_SP, 8);
- }
-}
-
-static int uses_hw_reg(struct jit_op * op, jit_value reg, int fp)
-{
- if ((GET_OP(op) == JIT_RENAMEREG) && (op->r_arg[0] == reg)) return 1; // not a regular operation
- for (int i = 0; i < 3; i++)
- if ((ARG_TYPE(op, i + 1) == REG) || (ARG_TYPE(op, i + 1) == TREG)) {
- if (fp && (JIT_REG(op->arg[i]).type == JIT_RTYPE_INT)) continue;
- if (!fp && (JIT_REG(op->arg[i]).type == JIT_RTYPE_FLOAT)) continue;
- if (op->r_arg[i] == reg) return 1;
- }
- return 0;
-}
-
-static int emit_push_callee_saved_regs(struct jit * jit, jit_op * op)
-{
- int count = 0;
- for (int i = 0; i < jit->reg_al->gp_reg_cnt; i++) {
- jit_hw_reg * r = &(jit->reg_al->gp_regs[i]);
- if (r->callee_saved) {
- emit_push_reg(jit, r);
- count++;
- }
- }
- char used[jit->reg_al->fp_reg_cnt];
- memset(used,0,jit->reg_al->fp_reg_cnt);
- op=jit_op_first(jit->ops);
- for(;op;op=op->next) {
- int i=0;
- for(;i!=jit->reg_al->fp_reg_cnt;i++) {
- if(used[i]) continue;
- jit_hw_reg * r = &(jit->reg_al->fp_regs[i]);
- if(uses_hw_reg(op, r->id, 1)) {
- used[i]=1;
- }
- }
- }
-
- int i=0;
- for(;i!=jit->reg_al->fp_reg_cnt;i++) {
- if(!used[i]) continue;
- jit_hw_reg * r = &(jit->reg_al->fp_regs[i]);
- if(r->callee_saved) {
- emit_push_reg(jit, r);
- count++;
- }
- }
- return count;
-}
-
-static int emit_pop_callee_saved_regs(struct jit * jit)
-{
- int count = 0;
- struct jit_op * op = jit->current_func;
- char used[jit->reg_al->fp_reg_cnt];
- memset(used,0,jit->reg_al->fp_reg_cnt);
- op=jit_op_first(jit->ops);
- for(;op;op=op->next) {
- int i=0;
- for(;i!=jit->reg_al->fp_reg_cnt;i++) {
- if(used[i]) continue;
- jit_hw_reg * r = &(jit->reg_al->fp_regs[i]);
- if(uses_hw_reg(op, r->id, 1)) {
- used[i]=1;
- }
- }
- }
- int i;
- for(i=jit->reg_al->fp_reg_cnt-1;i>=0;i--) {
- if(!used[i]) continue;
- jit_hw_reg * r = &(jit->reg_al->fp_regs[i]);
- if(r->callee_saved) {
- emit_pop_reg(jit, r);
- count++;
- }
- }
-
-
- for (int i = jit->reg_al->gp_reg_cnt - 1; i >= 0; i--) {
- jit_hw_reg * r = &(jit->reg_al->gp_regs[i]);
- if (r->callee_saved) {
- emit_pop_reg(jit, r);
- count++;
- }
- }
- return count;
-}
-
-static int generic_push_caller_saved_regs(struct jit * jit, jit_op * op, int reg_count,
- jit_hw_reg * regs, int fp, jit_hw_reg * skip_reg)
-{
- jit_value reg;
- int count = 0;
- int skip_reg_id = (skip_reg ? skip_reg->id :-1);
- for (int i = 0; i < reg_count; i++) {
- if ((regs[i].id == skip_reg_id) || (regs[i].callee_saved)) continue;
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, regs[i].id, fp, &reg);
- if (hreg && jit_set_get(op->live_in, reg)) emit_push_reg(jit, hreg), count++;
- }
- return count;
-}
-
-static int emit_push_caller_saved_regs(struct jit * jit, jit_op * op)
-{
- int count = 0;
- struct jit_reg_allocator * al = jit->reg_al;
- while (op) {
- if (GET_OP(op) == JIT_CALL) break;
- op = op->next;
- }
- count += generic_push_caller_saved_regs(jit, op, al->gp_reg_cnt, al->gp_regs, 0, al->ret_reg);
- count += generic_push_caller_saved_regs(jit, op, al->fp_reg_cnt, al->fp_regs, 1, al->fpret_reg);
- return count;
-}
-
-static int generic_pop_caller_saved_regs(struct jit * jit, jit_op * op, int reg_count,
- jit_hw_reg * regs, int fp, jit_hw_reg * skip_reg)
-{
- jit_value reg;
- int count = 0;
- int skip_reg_id = (skip_reg ? skip_reg->id :-1);
- for (int i = reg_count - 1; i >= 0; i--) {
- if ((regs[i].id == skip_reg_id) || (regs[i].callee_saved)) continue;
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, regs[i].id, fp, &reg);
- if (hreg && jit_set_get(op->live_in, reg)) emit_pop_reg(jit, hreg), count++;
- }
- return count;
-}
-
-static int emit_pop_caller_saved_regs(struct jit * jit, jit_op * op)
-{
- int count = 0;
- struct jit_reg_allocator * al = jit->reg_al;
-
- count += generic_pop_caller_saved_regs(jit, op, al->fp_reg_cnt, al->fp_regs, 1, al->fpret_reg);
- count += generic_pop_caller_saved_regs(jit, op, al->gp_reg_cnt, al->gp_regs, 0, al->ret_reg);
- return count;
-}
-
-/**
- * Emits LREG operation
- *
- * This operation loads value of the virtual register from the stack
- * into its hardware counterpart
- */
-static void emit_lreg(struct jit * jit, int hreg_id, jit_value vreg)
-{
- if (JIT_REG(vreg).spec == JIT_RTYPE_ARG) assert(0);
-
- int stack_pos = GET_REG_POS(jit, vreg) ;
-
- if (JIT_REG(vreg).type == JIT_RTYPE_FLOAT) sse_movlpd_xreg_membase(jit->ip, hreg_id, COMMON86_BP, stack_pos);
- else common86_mov_reg_membase(jit->ip, hreg_id, COMMON86_BP, stack_pos, REG_SIZE);
-}
-
-/**
- * Emits UREG operation
- *
- * This operation unloads value of the virtual register on the stack
- * from its hardware counterpart
- */
-static void emit_ureg(struct jit * jit, jit_value vreg, int hreg_id)
-{
- int stack_pos = GET_REG_POS(jit, vreg);
-
- if (JIT_REG(vreg).type == JIT_RTYPE_FLOAT) sse_movlpd_membase_xreg(jit->ip, hreg_id, COMMON86_BP, stack_pos);
- else common86_mov_membase_reg(jit->ip, COMMON86_BP, stack_pos, hreg_id, REG_SIZE);
-}
-
-static void emit_get_arg_from_stack(struct jit * jit, int type, int size, int dreg, int stack_reg, int stack_pos)
-{
- if (type != JIT_FLOAT_NUM) {
- if (size == REG_SIZE) common86_mov_reg_membase(jit->ip, dreg, stack_reg, stack_pos, REG_SIZE);
- else if (type == JIT_SIGNED_NUM)
- common86_movsx_reg_membase(jit->ip, dreg, stack_reg, stack_pos, size);
- else common86_movzx_reg_membase(jit->ip, dreg, stack_reg, stack_pos, size);
- } else {
- if (size == sizeof(float)) sse_cvtss2sd_reg_membase(jit->ip, dreg, stack_reg, stack_pos);
- else sse_movlpd_xreg_membase(jit->ip, dreg, stack_reg, stack_pos);
- }
-}
-
-/**
- * Emits GETARG operation
- *
- * This function is slightly larger since it takes into account for various calling
- * including that one which is used on AMD64.
- * Information on location of arguments is provided in the jit_init_arg_params function.
- */
-static void emit_get_arg(struct jit * jit, jit_op * op)
-{
- struct jit_func_info * info = jit_current_func_info(jit);
-
- int dreg = op->r_arg[0];
- int arg_id = op->r_arg[1];
-
- struct jit_inp_arg * arg = &(info->args[arg_id]);
-
- int size = arg->size;
- int type = arg->type;
- int reg_id = jit_mkreg(type == JIT_FLOAT_NUM ? JIT_RTYPE_FLOAT : JIT_RTYPE_INT, JIT_RTYPE_ARG, arg_id);
-
- int read_from_stack = 0;
- int stack_pos;
-
- if (!arg->passed_by_reg) {
- read_from_stack = 1;
- stack_pos = arg->location.stack_pos;
-
- // optimization which doesnot require EBP register
- if (!jit_current_func_info(jit)->has_prolog) {
- stack_pos -= REG_SIZE;
- stack_pos += jit->push_count * REG_SIZE;
- emit_get_arg_from_stack(jit, type, size, dreg, COMMON86_SP, stack_pos);
- return;
- }
- }
-
- if (arg->passed_by_reg && rmap_get(op->regmap, reg_id) == NULL) {
- // the register is not associated and the value has to be read from the memory
- read_from_stack = 1;
- stack_pos = arg->spill_pos;
- }
-
- if (read_from_stack) {
- emit_get_arg_from_stack(jit, type, size, dreg, COMMON86_BP, stack_pos);
- return;
- }
-
- int reg = arg->location.reg;
- if (type != JIT_FLOAT_NUM) {
- if (size == REG_SIZE) common86_mov_reg_reg(jit->ip, dreg, reg, REG_SIZE);
- else if (type == JIT_SIGNED_NUM) common86_movsx_reg_reg(jit->ip, dreg, reg, size);
- else common86_movzx_reg_reg(jit->ip, dreg, reg, size);
- } else {
- if (size == sizeof(float)) sse_cvtss2sd_reg_reg(jit->ip, dreg, reg);
- else sse_movsd_reg_reg(jit->ip, dreg, reg);
- }
-}
-
-//
-//
-// Common ALU operation
-//
-//
-
-/**
- * This function emits majority of ALU operations
- */
-static void emit_alu_op(struct jit * jit, struct jit_op * op, int x86_op, int imm)
-{
- if (imm) {
- if (op->r_arg[0] != op->r_arg[1]) common86_mov_reg_reg(jit->ip, op->r_arg[0], op->r_arg[1], REG_SIZE);
- common86_alu_reg_imm(jit->ip, x86_op, op->r_arg[0], op->r_arg[2]);
-
- } else {
- if (op->r_arg[0] == op->r_arg[1]) {
- common86_alu_reg_reg(jit->ip, x86_op, op->r_arg[0], op->r_arg[2]);
- } else if (op->r_arg[0] == op->r_arg[2]) {
- common86_alu_reg_reg(jit->ip, x86_op, op->r_arg[0], op->r_arg[1]);
- } else {
- common86_mov_reg_reg(jit->ip, op->r_arg[0], op->r_arg[1], REG_SIZE);
- common86_alu_reg_reg(jit->ip, x86_op, op->r_arg[0], op->r_arg[2]);
- }
- }
-}
-
-/**
- * Emits the SUB operation, since it is not a commutative operation
- * it needs some extra care for some types of operands
- */
-static void emit_sub_op(struct jit * jit, struct jit_op * op, int imm)
-{
- if (imm) {
- if (op->r_arg[0] != op->r_arg[1]) common86_lea_membase(jit->ip, op->r_arg[0], op->r_arg[1], -op->r_arg[2]);
- else common86_alu_reg_imm(jit->ip, X86_SUB, op->r_arg[0], op->r_arg[2]);
- return;
-
- }
- if (op->r_arg[0] == op->r_arg[1]) {
- common86_alu_reg_reg(jit->ip, X86_SUB, op->r_arg[0], op->r_arg[2]);
- } else if (op->r_arg[0] == op->r_arg[2]) {
- common86_alu_reg_reg(jit->ip, X86_SUB, op->r_arg[0], op->r_arg[1]);
- common86_neg_reg(jit->ip, op->r_arg[0]);
- } else {
- common86_mov_reg_reg(jit->ip, op->r_arg[0], op->r_arg[1], REG_SIZE);
- common86_alu_reg_reg(jit->ip, X86_SUB, op->r_arg[0], op->r_arg[2]);
- }
-}
-/**
- * Emits the SUBX and SUBC operations, since it is not a commutative operation
- * it needs some extra care for some types of operands
- */
-
-static void emit_subx_op(struct jit * jit, struct jit_op * op, int x86_op, int imm)
-{
- if (imm) {
- if (op->r_arg[0] != op->r_arg[1]) common86_mov_reg_reg(jit->ip, op->r_arg[0], op->r_arg[1], REG_SIZE);
- common86_alu_reg_imm(jit->ip, x86_op, op->r_arg[0], op->r_arg[2]);
- return;
-
- }
- if (op->r_arg[0] == op->r_arg[1]) {
- common86_alu_reg_reg(jit->ip, x86_op, op->r_arg[0], op->r_arg[2]);
- } else if (op->r_arg[0] == op->r_arg[2]) {
- common86_mov_membase_reg(jit->ip, COMMON86_SP, -REG_SIZE, op->r_arg[2], REG_SIZE);
- common86_mov_reg_reg(jit->ip, op->r_arg[0], op->r_arg[1], REG_SIZE);
- common86_alu_reg_membase(jit->ip, x86_op, op->r_arg[0], COMMON86_SP, -REG_SIZE);
- } else {
- common86_mov_reg_reg(jit->ip, op->r_arg[0], op->r_arg[1], REG_SIZE);
- common86_alu_reg_reg(jit->ip, x86_op, op->r_arg[0], op->r_arg[2]);
- }
-}
-/**
- * Emits the RSB operation, since it is not a commutative operation
- * it needs some extra care for some types of operands
- */
-static void emit_rsb_op(struct jit * jit, struct jit_op * op, int imm)
-{
- if (imm) {
- if (op->r_arg[0] == op->r_arg[1]) common86_alu_reg_imm(jit->ip, X86_ADD, op->r_arg[0], -op->r_arg[2]);
- else common86_lea_membase(jit->ip, op->r_arg[0], op->r_arg[1], -op->r_arg[2]);
- common86_neg_reg(jit->ip, op->r_arg[0]);
- return;
- }
-
- if (op->r_arg[0] == op->r_arg[1]) { // O1 = O3 - O1
- common86_alu_reg_reg(jit->ip, X86_SUB, op->r_arg[0], op->r_arg[2]);
- common86_neg_reg(jit->ip, op->r_arg[0]);
- } else if (op->r_arg[0] == op->r_arg[2]) { // O1 = O1 - O2
- common86_alu_reg_reg(jit->ip, X86_SUB, op->r_arg[0], op->r_arg[1]);
- } else {
- common86_mov_reg_reg(jit->ip, op->r_arg[0], op->r_arg[2], REG_SIZE);
- common86_alu_reg_reg(jit->ip, X86_SUB, op->r_arg[0], op->r_arg[1]);
- }
-}
-
-/**
- * Emits operations for multiplications
- *
- * @param imm -- indicates whether the multiplier is constant or not
- * @param sign -- if zero, it considers values to be unsigned
- * @param high_bytes -- returns higher bytes of the results
- *
- * This implementation tries to optimize several cases,
- * and converts some types of multiplications into the bit shifts
- * or uses LEA operation to get the result more efficiently
- *
- * Unfortunately, x86 assembler assumes that the result value of the MUL operation
- * is stored into the EDX:EAX pair, and therefore, if these registers are in use,
- * their value have to be saved on the stack for a while and then returned back.
- * TODO: Register allocator should be aware of this issues and should take care
- * of this.
- */
-static void emit_mul_op(struct jit * jit, struct jit_op * op, int imm, int sign, int high_bytes)
-{
- jit_value dest = op->r_arg[0];
- jit_value factor1 = op->r_arg[1];
- jit_value factor2 = op->r_arg[2];
-
- // optimization for special cases
- if ((!high_bytes) && (imm)) {
- switch (factor2) {
- case 2: if (factor1 == dest) common86_shift_reg_imm(jit->ip, X86_SHL, dest, 1);
- else common86_lea_memindex(jit->ip, dest, factor1, 0, factor1, 0);
- return;
-
- case 3: common86_lea_memindex(jit->ip, dest, factor1, 0, factor1, 1); return;
-
- case 4: if (factor1 != dest) common86_mov_reg_reg(jit->ip, dest, factor1, REG_SIZE);
- common86_shift_reg_imm(jit->ip, X86_SHL, dest, 2);
- return;
- case 5: common86_lea_memindex(jit->ip, dest, factor1, 0, factor1, 2);
- return;
- case 8: if (factor1 != dest) common86_mov_reg_reg(jit->ip, dest, factor1, REG_SIZE);
- common86_shift_reg_imm(jit->ip, X86_SHL, dest, 3);
- return;
- case 9: common86_lea_memindex(jit->ip, dest, factor1, 0, factor1, 3);
- return;
- }
- }
-
-
- // generic multiplication
- int ax_in_use = jit_reg_in_use(op, COMMON86_AX, 0);
- int dx_in_use = jit_reg_in_use(op, COMMON86_DX, 0);
-
- if ((dest != COMMON86_AX) && ax_in_use) common86_push_reg(jit->ip, COMMON86_AX);
- if ((dest != COMMON86_DX) && dx_in_use) common86_push_reg(jit->ip, COMMON86_DX);
-
- if (imm) {
- if (factor1 != COMMON86_AX) common86_mov_reg_reg(jit->ip, COMMON86_AX, factor1, REG_SIZE);
- common86_mov_reg_imm(jit->ip, COMMON86_DX, factor2);
- common86_mul_reg(jit->ip, COMMON86_DX, sign);
- } else {
- if (factor1 == COMMON86_AX) common86_mul_reg(jit->ip, factor2, sign);
- else if (factor2 == COMMON86_AX) common86_mul_reg(jit->ip, factor1, sign);
- else {
- common86_mov_reg_reg(jit->ip, COMMON86_AX, factor1, REG_SIZE);
- common86_mul_reg(jit->ip, factor2, sign);
- }
- }
-
- if (!high_bytes) {
- if (dest != COMMON86_AX) common86_mov_reg_reg(jit->ip, dest, COMMON86_AX, REG_SIZE);
- } else {
- if (dest != COMMON86_DX) common86_mov_reg_reg(jit->ip, dest, COMMON86_DX, REG_SIZE);
- }
-
- if ((dest != COMMON86_DX) && dx_in_use) common86_pop_reg(jit->ip, COMMON86_DX);
- if ((dest != COMMON86_AX) && ax_in_use) common86_pop_reg(jit->ip, COMMON86_AX);
-}
-
-/**
- * Emits operations for multiplications
- *
- * @param imm -- indicates whether the divisor is constant or not
- * @param sign -- if zero, it considers values to be unsigned
- * @param modulo -- returns modulo
- *
- * This implementation tries to optimize several cases,
- * and converts some types of multiplications into the bit shifts
- *
- * Unfortunately, x86 assembler assumes that the dividend of the DIV operation
- * is stored into the EDX:EAX pair, and therefore, if these registers are in use,
- * their value have to be saved on the stack for a while and then returned back.
- * TODO: Register allocator should be aware of this issues and should take care
- * of this.
- */
-
-static void emit_div_op(struct jit * jit, struct jit_op * op, int imm, int sign, int modulo)
-{
- jit_value dest = op->r_arg[0];
- jit_value dividend = op->r_arg[1];
- jit_value divisor = op->r_arg[2];
-
- if (imm && ((divisor == 2) || (divisor == 4) || (divisor == 8))) {
- if (dest != dividend) common86_mov_reg_reg(jit->ip, dest, dividend, REG_SIZE);
- if (!modulo) {
- switch (divisor) {
- case 2: common86_shift_reg_imm(jit->ip, sign ? X86_SAR : X86_SHR, dest, 1); break;
- case 4: common86_shift_reg_imm(jit->ip, sign ? X86_SAR : X86_SHR, dest, 2); break;
- case 8: common86_shift_reg_imm(jit->ip, sign ? X86_SAR : X86_SHR, dest, 3); break;
- }
- } else {
- switch (divisor) {
- case 2: common86_alu_reg_imm(jit->ip, X86_AND, dest, 0x1); break;
- case 4: common86_alu_reg_imm(jit->ip, X86_AND, dest, 0x3); break;
- case 8: common86_alu_reg_imm(jit->ip, X86_AND, dest, 0x7); break;
- }
- }
- return;
- }
-
- int ax_in_use = jit_reg_in_use(op, COMMON86_AX, 0);
- int dx_in_use = jit_reg_in_use(op, COMMON86_DX, 0);
-
- if ((dest != COMMON86_AX) && ax_in_use) common86_push_reg(jit->ip, COMMON86_AX);
- if ((dest != COMMON86_DX) && dx_in_use) common86_push_reg(jit->ip, COMMON86_DX);
-
- if (imm) {
- if (dividend != COMMON86_AX) common86_mov_reg_reg(jit->ip, COMMON86_AX, dividend, REG_SIZE);
- common86_cdq(jit->ip);
- if (dest != COMMON86_BX) common86_push_reg(jit->ip, COMMON86_BX);
- common86_mov_reg_imm_size(jit->ip, COMMON86_BX, divisor, REG_SIZE);
- common86_div_reg(jit->ip, COMMON86_BX, sign);
- if (dest != COMMON86_BX) common86_pop_reg(jit->ip, COMMON86_BX);
- } else {
- if ((divisor == COMMON86_AX) || (divisor == COMMON86_DX)) {
- common86_push_reg(jit->ip, divisor);
- }
-
- if (dividend != COMMON86_AX) common86_mov_reg_reg(jit->ip, COMMON86_AX, dividend, REG_SIZE);
-
- common86_cdq(jit->ip);
-
- if ((divisor == COMMON86_AX) || (divisor == COMMON86_DX)) {
- common86_div_membase(jit->ip, COMMON86_SP, 0, sign);
- common86_alu_reg_imm(jit->ip, X86_ADD, COMMON86_SP, REG_SIZE);
- } else {
- common86_div_reg(jit->ip, divisor, sign);
- }
- }
-
- if (!modulo) {
- if (dest != COMMON86_AX) common86_mov_reg_reg(jit->ip, dest, COMMON86_AX, REG_SIZE);
- } else {
- if (dest != COMMON86_DX) common86_mov_reg_reg(jit->ip, dest, COMMON86_DX, REG_SIZE);
- }
-
- if ((dest != COMMON86_DX) && dx_in_use) common86_pop_reg(jit->ip, COMMON86_DX);
- if ((dest != COMMON86_AX) && ax_in_use) common86_pop_reg(jit->ip, COMMON86_AX);
-}
-/**
- * Emits bit shift operations
- *
- * Unfortunately, only constant or register ECX can be used to shift value.
- * This leads to a weird situation if the shifted value is in the ECX register.
- */
-static void emit_shift_op(struct jit * jit, struct jit_op * op, int shift_op, int imm)
-{
- if (imm) {
- if (op->r_arg[0] != op->r_arg[1]) common86_mov_reg_reg(jit->ip, op->r_arg[0], op->r_arg[1], REG_SIZE);
- common86_shift_reg_imm(jit->ip, shift_op, op->r_arg[0], op->r_arg[2]);
- } else {
- int destreg = op->r_arg[0];
- int valreg = op->r_arg[1];
- int shiftreg = op->r_arg[2];
-
- if (destreg != COMMON86_CX) {
-
- int cx_in_use = jit_reg_in_use(op, COMMON86_CX, 0);
-
- if (cx_in_use && (shiftreg != COMMON86_CX)) common86_push_reg(jit->ip, COMMON86_CX);
- if (shiftreg != COMMON86_CX) common86_mov_reg_reg(jit->ip, COMMON86_CX, shiftreg, REG_SIZE);
- if (destreg != valreg) {
- if (valreg != COMMON86_CX) common86_mov_reg_reg(jit->ip, destreg, valreg, REG_SIZE);
- else common86_mov_reg_membase(jit->ip, destreg, COMMON86_SP, 0, REG_SIZE);
- }
- common86_shift_reg(jit->ip, shift_op, destreg);
- if (cx_in_use && (shiftreg != COMMON86_CX)) common86_pop_reg(jit->ip, COMMON86_CX);
- } else {
- // ECX is the destination register
- jit_hw_reg * tmp = jit_get_unused_reg(jit->reg_al, op, 0);
- int tmpreg = (tmp ? tmp->id : COMMON86_AX);
-
- int tmp_in_use = jit_reg_in_use(op, tmpreg, 0);
-
- if (tmp_in_use) common86_push_reg(jit->ip, tmpreg);
-
- if (tmpreg != valreg) common86_mov_reg_reg(jit->ip, tmpreg, valreg, REG_SIZE);
- if (shiftreg != COMMON86_CX) common86_mov_reg_reg(jit->ip, COMMON86_CX, shiftreg, REG_SIZE);
- common86_shift_reg(jit->ip, shift_op, tmpreg);
- common86_mov_reg_reg(jit->ip, destreg, tmpreg, REG_SIZE);
-
- if (tmp_in_use) common86_pop_reg(jit->ip, tmpreg);
- }
- }
-}
-
-static void emit_cond_op(struct jit * jit, struct jit_op * op, int amd64_cond, int imm, int sign)
-{
- if (imm) common86_alu_reg_imm(jit->ip, X86_CMP, op->r_arg[1], op->r_arg[2]);
- else common86_alu_reg_reg(jit->ip, X86_CMP, op->r_arg[1], op->r_arg[2]);
- if ((op->r_arg[0] != COMMON86_SI) && (op->r_arg[0] != COMMON86_DI)) {
- common86_mov_reg_imm(jit->ip, op->r_arg[0], 0);
- common86_set_reg(jit->ip, amd64_cond, op->r_arg[0], sign);
- } else {
- common86_xchg_reg_reg(jit->ip, COMMON86_AX, op->r_arg[0], REG_SIZE);
- common86_mov_reg_imm(jit->ip, COMMON86_AX, 0);
- common86_set_reg(jit->ip, amd64_cond, COMMON86_AX, sign);
- common86_xchg_reg_reg(jit->ip, COMMON86_AX, op->r_arg[0], REG_SIZE);
- }
-}
-
-static void emit_branch_op(struct jit * jit, struct jit_op * op, int cond, int imm, int sign)
-{
- if (imm) common86_alu_reg_imm(jit->ip, X86_CMP, op->r_arg[1], op->r_arg[2]);
- else common86_alu_reg_reg(jit->ip, X86_CMP, op->r_arg[1], op->r_arg[2]);
-
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
-
- common86_branch_disp32(jit->ip, cond, JIT_GET_ADDR(jit, op->r_arg[0]), sign);
-}
-
-static void emit_branch_mask_op(struct jit * jit, struct jit_op * op, int cond, int imm)
-{
- if (imm) common86_test_reg_imm(jit->ip, op->r_arg[1], op->r_arg[2]);
- else common86_test_reg_reg(jit->ip, op->r_arg[1], op->r_arg[2]);
-
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
-
- common86_branch_disp32(jit->ip, cond, JIT_GET_ADDR(jit, op->r_arg[0]), 0);
-}
-
-static void emit_branch_overflow_op(struct jit * jit, struct jit_op * op, int alu_op, int imm, int negation)
-{
- if (imm) common86_alu_reg_imm(jit->ip, alu_op, op->r_arg[1], op->r_arg[2]);
- else common86_alu_reg_reg(jit->ip, alu_op, op->r_arg[1], op->r_arg[2]);
-
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
-
- if (!negation) common86_branch_disp32(jit->ip, X86_CC_O, JIT_GET_ADDR(jit, op->r_arg[0]), 0);
- else common86_branch_disp32(jit->ip, X86_CC_NO, JIT_GET_ADDR(jit, op->r_arg[0]), 0);
-}
-
-/* determines whether the argument value was spilled out or not,
- * if the register is associated with the hardware register
- * it is returned through the reg argument
- */
-// FIXME: reports as spilled also argument which contains appropriate value
-static int is_spilled(jit_value arg_id, jit_op * prepare_op, int * reg)
-{
- jit_hw_reg * hreg = rmap_get(prepare_op->regmap, arg_id);
-
- if (hreg) {
- *reg = hreg->id;
- return 0;
- } else return 1;
-}
-
-/**
- * Emits all LD operations
- */
-static void emit_ld_op(struct jit * jit, jit_op * op, jit_value a1, jit_value a2)
-{
- if (op->arg_size == REG_SIZE) {
- if (IS_IMM(op)) common86_mov_reg_mem(jit->ip, a1, a2, op->arg_size);
- else common86_mov_reg_membase(jit->ip, a1, a2, 0, op->arg_size);
- return;
- }
-
- switch (op->code) {
- case (JIT_LD | IMM | SIGNED): common86_movsx_reg_mem(jit->ip, a1, a2, op->arg_size); break;
- case (JIT_LD | IMM | UNSIGNED): common86_movzx_reg_mem(jit->ip, a1, a2, op->arg_size); break;
- case (JIT_LD | REG | SIGNED): common86_movsx_reg_membase(jit->ip, a1, a2, 0, op->arg_size); break;
- case (JIT_LD | REG | UNSIGNED): common86_movzx_reg_membase(jit->ip, a1, a2, 0, op->arg_size); break;
- default: assert(0);
- }
-}
-
-/**
- * Emits all LD operations
- */
-static void emit_ldx_op(struct jit * jit, jit_op * op, jit_value a1, jit_value a2, jit_value a3)
-{
- if (op->arg_size == REG_SIZE) {
- if (IS_IMM(op)) common86_mov_reg_membase(jit->ip, a1, a2, a3, op->arg_size);
- else common86_mov_reg_memindex(jit->ip, a1, a2, 0, a3, 0, op->arg_size);
- return;
- }
-
- switch (op->code) {
- case (JIT_LDX | IMM | SIGNED): common86_movsx_reg_membase(jit->ip, a1, a2, a3, op->arg_size); break;
- case (JIT_LDX | IMM | UNSIGNED): common86_movzx_reg_membase(jit->ip, a1, a2, a3, op->arg_size); break;
- case (JIT_LDX | REG | SIGNED): common86_movsx_reg_memindex(jit->ip, a1, a2, 0, a3, 0, op->arg_size); break;
- case (JIT_LDX | REG | UNSIGNED): common86_movzx_reg_memindex(jit->ip, a1, a2, 0, a3, 0, op->arg_size); break;
- default: assert(0);
- }
-}
-
-int jit_allocai(struct jit * jit, int size)
-{
- if(!jit) return 0;
- jit_value real_size = jit_value_align(size, JIT_STACK_ALIGNMENT);
-
- jit_add_op(jit, JIT_ALLOCA | IMM, SPEC(IMM, NO, NO), real_size, 0, 0, 0, NULL);
- jit_current_func_info(jit)->allocai_mem += real_size;
-
- return -(jit_current_func_info(jit)->allocai_mem);
-}
-
-void jit_patch_local_addrs(struct jit *jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if ((GET_OP(op) == JIT_REF_CODE) || (GET_OP(op) == JIT_REF_DATA)) {
- unsigned char *buf = jit->buf + (int64_t) op->patch_addr;
- jit_value addr = jit_is_label(jit, (void *)op->arg[1]) ? ((jit_label *)op->arg[1])->pos : op->arg[1];
- *(int32_t*)buf=((addr+jit->buf)-(buf+4)); //32 bit displacement
- }
-
- if(GET_OP(op)==JIT_RELOCATION) {
- jit_value reg=op->r_arg[0];
- unsigned char *buf = jit->buf + (int64_t) op->patch_addr;
- amd64_emit_rex(buf, 8, 0, 0, (reg));
- *(buf)++ = (unsigned char)0xb8 + ((reg) & 0x7);
- *((void**)op->arg[1])=buf;
- buf+=8;
- }
-
- if ((GET_OP(op) == JIT_DATA_REF_CODE) || (GET_OP(op) == JIT_DATA_REF_DATA)) {
- unsigned char *buf = jit->buf + (int64_t) op->patch_addr;
- jit_value addr = jit_is_label(jit, (void *)op->arg[0]) ? ((jit_label *)op->arg[0])->pos : op->arg[0];
- *((jit_value *)buf) = (jit_value) (jit->buf + addr);
- }
-
- if(GET_OP(op)==JIT_DATA_CODE_OFFSET) {
- unsigned char *buf = jit->buf + (int64_t) op->patch_addr;
- jit_value addr = jit_is_label(jit, (void *)op->arg[0]) ? ((jit_label *)op->arg[0])->pos : op->arg[0];
- addr+=(int64_t)op->arg[1];
- *((int32_t*)buf) = (jit_value) (addr-op->patch_addr);
- }
- }
-}
-
-//
-//
-// Main switch
-//
-//
-void jit_gen_op(struct jit * jit, struct jit_op * op)
-{
- jit_value a1 = op->r_arg[0];
- jit_value a2 = op->r_arg[1];
- jit_value a3 = op->r_arg[2];
- int imm = IS_IMM(op);
- int sign = IS_SIGNED(op);
-
- int found = 1;
-
- switch (GET_OP(op)) {
- case JIT_BREAKPOINT:
- op->bp_ptr=jit->ip-jit->buf;
- jit_insert_breakpoint(jit,(void*)op->arg[0],(void*)op->arg[1],op->arg[2]);
- break;
- case JIT_ADD:
- if ((a1 != a2) && (a1 != a3)) {
- if (imm) common86_lea_membase(jit->ip, a1, a2, a3);
- else common86_lea_memindex(jit->ip, a1, a2, 0, a3, 0);
- } else emit_alu_op(jit, op, X86_ADD, imm);
- break;
-
- case JIT_ADDC: emit_alu_op(jit, op, X86_ADD, imm); break;
- case JIT_ADDX: emit_alu_op(jit, op, X86_ADC, imm); break;
- case JIT_SUB: emit_sub_op(jit, op, imm); break;
- case JIT_SUBC: emit_subx_op(jit, op, X86_SUB, imm); break;
- case JIT_SUBX: emit_subx_op(jit, op, X86_SBB, imm); break;
- case JIT_RSB: emit_rsb_op(jit, op, imm); break;
- case JIT_NEG:
- if (a1 != a2) common86_mov_reg_reg(jit->ip, a1, a2, REG_SIZE);
- common86_neg_reg(jit->ip, a1);
- break;
- case JIT_OR: emit_alu_op(jit, op, X86_OR, imm); break;
- case JIT_XOR: emit_alu_op(jit, op, X86_XOR, imm); break;
- case JIT_AND: emit_alu_op(jit, op, X86_AND, imm); break;
- case JIT_NOT: if (a1 != a2) common86_mov_reg_reg(jit->ip, a1, a2, REG_SIZE);
- common86_not_reg(jit->ip, a1);
- break;
- case JIT_LSH: emit_shift_op(jit, op, X86_SHL, imm); break;
- case JIT_RSH: emit_shift_op(jit, op, sign ? X86_SAR : X86_SHR, imm); break;
-
- case JIT_LT: emit_cond_op(jit, op, X86_CC_LT, imm, sign); break;
- case JIT_LE: emit_cond_op(jit, op, X86_CC_LE, imm, sign); break;
- case JIT_GT: emit_cond_op(jit, op, X86_CC_GT, imm, sign); break;
- case JIT_GE: emit_cond_op(jit, op, X86_CC_GE, imm, sign); break;
- case JIT_EQ: emit_cond_op(jit, op, X86_CC_EQ, imm, sign); break;
- case JIT_NE: emit_cond_op(jit, op, X86_CC_NE, imm, sign); break;
-
- case JIT_BLT: emit_branch_op(jit, op, X86_CC_LT, imm, sign); break;
- case JIT_BLE: emit_branch_op(jit, op, X86_CC_LE, imm, sign); break;
- case JIT_BGT: emit_branch_op(jit, op, X86_CC_GT, imm, sign); break;
- case JIT_BGE: emit_branch_op(jit, op, X86_CC_GE, imm, sign); break;
- case JIT_BEQ: emit_branch_op(jit, op, X86_CC_EQ, imm, sign); break;
- case JIT_BNE: emit_branch_op(jit, op, X86_CC_NE, imm, sign); break;
-
- case JIT_BMS: emit_branch_mask_op(jit, op, X86_CC_NZ, imm); break;
- case JIT_BMC: emit_branch_mask_op(jit, op, X86_CC_Z, imm); break;
-
- case JIT_BOADD: emit_branch_overflow_op(jit, op, X86_ADD, imm, 0); break;
- case JIT_BOSUB: emit_branch_overflow_op(jit, op, X86_SUB, imm, 0); break;
-
- case JIT_BNOADD: emit_branch_overflow_op(jit, op, X86_ADD, imm, 1); break;
- case JIT_BNOSUB: emit_branch_overflow_op(jit, op, X86_SUB, imm, 1); break;
-
- case JIT_MUL: emit_mul_op(jit, op, imm, sign, 0); break;
- case JIT_HMUL: emit_mul_op(jit, op, imm, sign, 1); break;
- case JIT_DIV: emit_div_op(jit, op, imm, sign, 0); break;
- case JIT_MOD: emit_div_op(jit, op, imm, sign, 1); break;
-
- case JIT_CALL: emit_funcall(jit, op, imm); break;
- case JIT_PATCH: do {
- struct jit_op *target = (struct jit_op *) a1;
- switch (GET_OP(target)) {
- case JIT_REF_CODE:
- case JIT_REF_DATA:
- target->arg[1] = JIT_BUFFER_OFFSET(jit);
- break;
- case JIT_DATA_REF_CODE:
- case JIT_DATA_REF_DATA:
- case JIT_DATA_CODE_OFFSET:
- target->arg[0] = JIT_BUFFER_OFFSET(jit);
- break;
- default: {
- jit_value pa = target->patch_addr;
- common86_patch(jit->buf + pa, jit->ip);
- }
-
- }
- } while (0);
- break;
- case JIT_JMP:
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- if (op->code & REG) common86_jump_reg(jit->ip, a1);
- else common86_jump_disp32(jit->ip, JIT_GET_ADDR(jit, a1));
- break;
- case JIT_RET:
- if (!imm && (a1 != COMMON86_AX)) common86_mov_reg_reg(jit->ip, COMMON86_AX, a1, REG_SIZE);
- if (imm) common86_mov_reg_imm(jit->ip, COMMON86_AX, a1);
- emit_pop_callee_saved_regs(jit);
- if (jit_current_func_info(jit)->has_prolog) {
- common86_mov_reg_reg(jit->ip, COMMON86_SP, COMMON86_BP, REG_SIZE);
- common86_pop_reg(jit->ip, COMMON86_BP);
- }
- common86_ret(jit->ip);
- break;
-
- case JIT_PUTARG: funcall_put_arg(jit, op); break;
- case JIT_FPUTARG: funcall_fput_arg(jit, op); break;
- case JIT_GETARG: emit_get_arg(jit, op); break;
- case JIT_MSG: emit_msg_op(jit, op); break;
-
- case JIT_LD: emit_ld_op(jit, op, a1, a2); break;
- case JIT_LDX: emit_ldx_op(jit, op, a1, a2, a3); break;
- case JIT_FST: emit_sse_fst_op(jit, op, a1, a2); break;
- case JIT_FSTX: emit_sse_fstx_op(jit, op, a1, a2, a3); break;
- case JIT_FLD: emit_sse_fld_op(jit, op, a1, a2); break;
- case JIT_FLDX: emit_sse_fldx_op(jit, op, a1, a2, a3); break;
-
- case JIT_ALLOCA: break;
- case JIT_DECL_ARG: break;
- case JIT_RETVAL:
- common86_mov_reg_reg(jit->ip, a1, AMD64_RAX, REG_SIZE);
- break;
- case JIT_LABEL: ((jit_label *)a1)->pos = JIT_BUFFER_OFFSET(jit); break;
-
- case JIT_CODE_ALIGN_FILL:
- while (((int64_t) jit->ip) % op->arg[0])
- *jit->ip++=op->arg[1];
- break;
- case JIT_CODE_ALIGN:
- while (((int64_t) jit->ip) % op->arg[0])
- common86_nop(jit->ip);
- break;
-
- case JIT_REF_CODE:
- case JIT_REF_DATA:
- amd64_emit_rex(jit->ip, 8, (a1), 0, (AMD64_RIP));
- *(jit->ip++)=0x8D; //LEA
- x86_membase_emit ((jit->ip), (a1) & 0x7, (AMD64_RIP), (0x112233)); //0x112233 Forces a 32bit displacement
- op->patch_addr = JIT_BUFFER_OFFSET(jit)-4;
- break;
- case JIT_RELOCATION:
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- common86_mov_reg_imm_size(jit->ip, a1, 0xdeadbeefcafebabe, sizeof(void *));
- break;
-
- // platform independent opcodes handled in the jitlib-core.c
- case JIT_DATA_BYTE: break;
- case JIT_FULL_SPILL: break;
-
-
- default: found = 0;
- }
-
- if (found) return;
-
-
- switch (op->code) {
- case (JIT_MOV | REG): if (a1 != a2) common86_mov_reg_reg(jit->ip, a1, a2, REG_SIZE); break;
- case (JIT_MOV | IMM):
- if (a2 == 0) common86_alu_reg_reg(jit->ip, X86_XOR, a1, a1);
- else common86_mov_reg_imm_size(jit->ip, a1, a2, 8);
- break;
-
- case JIT_PREPARE: funcall_prepare(jit, op, a1 + a2);
- jit->push_count += emit_push_caller_saved_regs(jit, op);
- break;
-
- case JIT_PROLOG: emit_prolog_op(jit, op); break;
- case (JIT_ST | IMM): common86_mov_mem_reg(jit->ip, a1, a2, op->arg_size); break;
- case (JIT_ST | REG): common86_mov_membase_reg(jit->ip, a1, 0, a2, op->arg_size); break;
- case (JIT_STX | IMM): common86_mov_membase_reg(jit->ip, a2, a1, a3, op->arg_size); break;
- case (JIT_STX | REG): common86_mov_memindex_reg(jit->ip, a1, 0, a2, 0, a3, op->arg_size); break;
-
- //
- // Floating-point operations;
- //
- case (JIT_FMOV | REG): sse_movsd_reg_reg(jit->ip, a1, a2); break;
- case (JIT_FMOV | IMM): sse_mov_reg_safeimm(jit, op, a1, &op->flt_imm); break;
- case (JIT_FADD | REG): emit_sse_alu_op(jit, op, X86_SSE_ADD); break;
- case (JIT_FSUB | REG): emit_sse_sub_op(jit, op, a1, a2, a3); break;
- case (JIT_FRSB | REG): emit_sse_sub_op(jit, op, a1, a3, a2); break;
- case (JIT_FMUL | REG): emit_sse_alu_op(jit, op, X86_SSE_MUL); break;
- case (JIT_FDIV | REG): emit_sse_div_op(jit, a1, a2, a3); break;
- case (JIT_FNEG | REG): emit_sse_neg_op(jit, op, a1, a2); break;
- case (JIT_FBLT | REG): emit_sse_branch(jit, op, a1, a2, a3, X86_CC_LT); break;
- case (JIT_FBGT | REG): emit_sse_branch(jit, op, a1, a2, a3, X86_CC_GT); break;
- case (JIT_FBGE | REG): emit_sse_branch(jit, op, a1, a2, a3, X86_CC_GE); break;
- case (JIT_FBLE | REG): emit_sse_branch(jit, op, a1, a3, a2, X86_CC_GE); break;
- case (JIT_FBEQ | REG): emit_sse_branch(jit, op, a1, a3, a2, X86_CC_EQ); break;
- case (JIT_FBNE | REG): emit_sse_branch(jit, op, a1, a3, a2, X86_CC_NE); break;
-
- case (JIT_EXT | REG): sse_cvtsi2sd_reg_reg(jit->ip, a1, a2); break;
- case (JIT_TRUNC | REG): sse_cvttsd2si_reg_reg(jit->ip, a1, a2); break;
- case (JIT_CEIL | REG): emit_sse_floor(jit, a1, a2, 0); break;
- case (JIT_FLOOR | REG): emit_sse_floor(jit, a1, a2, 1); break;
- case (JIT_ROUND | REG): emit_sse_round(jit, op, a1, a2); break;
-
- case (JIT_FRET | REG): emit_fret_op(jit, op); break;
- case JIT_FRETVAL: emit_fretval_op(jit, op); break;
-
- case (JIT_UREG): emit_ureg(jit, a1, a2); break;
- case (JIT_LREG): emit_lreg(jit, a1, a2); break;
- case (JIT_SYNCREG): emit_ureg(jit, a1, a2); break;
- case JIT_RENAMEREG: common86_mov_reg_reg(jit->ip, a1, a2, REG_SIZE); break;
-
- case JIT_CODESTART: break;
- case JIT_NOP: break;
-
-
- // platform specific opcodes; used by optimizer
- case (JIT_X86_STI | IMM): common86_mov_mem_imm(jit->ip, a1, a2, op->arg_size); break;
- case (JIT_X86_STI | REG): common86_mov_membase_imm(jit->ip, a1, 0, a2, op->arg_size); break;
- case (JIT_X86_STXI | IMM): common86_mov_membase_imm(jit->ip, a2, a1, a3, op->arg_size); break;
- case (JIT_X86_STXI | REG): common86_mov_memindex_imm(jit->ip, a1, 0, a2, 0, a3, op->arg_size); break;
- case (JIT_X86_ADDMUL | REG): common86_lea_memindex(jit->ip, a1, a2, 0, a3, op->arg_size); break;
- case (JIT_X86_ADDMUL | IMM): common86_lea_memindex(jit->ip, a1, X86_NOBASEREG, a3, a2, op->arg_size); break;
- case (JIT_X86_ADDIMM): {
- jit_value tmp;
- memcpy(&tmp, &op->flt_imm, sizeof(double));
- common86_lea_memindex(jit->ip, a1, a2, tmp, a3, 0); break;
- }
-
- default: printf("common86: unknown operation (opcode: 0x%x)\n", GET_OP(op) >> 3);
- }
-}
diff --git a/ext/myjit/myjit/cpu-detect.h b/ext/myjit/myjit/cpu-detect.h
deleted file mode 100755
index 4f8b44c..0000000
--- a/ext/myjit/myjit/cpu-detect.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Detects CPU and setups platform specific constants and macros used across the library
- */
-
- #if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
- #define TARGET_WIN32
- #endif
-
-#ifndef CPU_DETECT_H
-#define CPU_DETECT_H
-#include <stdint.h>
-// pretty lousy processor detection
-#ifdef __i386__
- #define JIT_ARCH_I386
- #define JIT_ARCH_COMMON86
-#else
- #ifdef __sparc__
- #define JIT_ARCH_SPARC
- #else
- #define JIT_ARCH_AMD64
- #define JIT_ARCH_COMMON86
- #endif
-#endif
-
-// enable this to test register allocation
-#define JIT_REGISTER_TEST
-#undef JIT_REGISTER_TEST
-
-/*
- * i386 related macros
- */
-#ifdef JIT_ARCH_I386
-
-// maximum size of value (in bits) that can be used as an immediate value without the ``sign bit''
-// (i386 does not need to transform large immediates values)
-#define JIT_IMM_BITS (-1)
-
-// stack alignment (in bytes)
-#define JIT_STACK_ALIGNMENT (4)
-
-#endif
-
-/*
- * AMD64 related macros
- */
-#ifdef JIT_ARCH_AMD64
-
-// maximum size of value (in bits) that can be used as an immediate value without the ``sign bit''
-// (i386 does not need to transform large immediates values)
-#define JIT_IMM_BITS (31)
-
-// stack alignment (in bytes)
-#define JIT_STACK_ALIGNMENT (16)
-
-#endif
-
-/*
- * SPARC related macros
- */
-#ifdef JIT_ARCH_SPARC
-// maximum size of value (in bits) that can be used as an immediate value without the ``sign bit''
-// (i386 does not need to transform large immediates values)
-#define JIT_IMM_BITS (12)
-#endif
-
-
-
-/*
- * Common platform specific macros
- */
-
-#define INT_SIZE (sizeof(int))
-#define PTR_SIZE (sizeof(void *))
-#define REG_SIZE (sizeof(void *))
-
-typedef int64_t jit_value;
-typedef uint64_t jit_unsigned_value;
-typedef double jit_float;
-
-#endif
diff --git a/ext/myjit/myjit/flow-analysis.h b/ext/myjit/myjit/flow-analysis.h
deleted file mode 100755
index 727c4bc..0000000
--- a/ext/myjit/myjit/flow-analysis.h
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "set.h"
-#define FLOW_UNCHANGED (0)
-#define FLOW_CHANGED (1)
-#define FLOW_INITIAL (2)
-
-#define R_FP_POS (0)
-#define R_OUT_POS (1)
-#define R_IMM_POS (2)
-
-#define R_FIMM_POS (0)
-
-static inline void jit_flw_initialize(struct jit * jit)
-{
- jit_op * op = jit_op_first(jit->ops);
- long icnt=3+jit_current_func_info(jit)->gp_reg_count+jit_current_func_info(jit)->general_arg_cnt; //First 3 are R_FP,R_OUT,R_IMM
- long fcnt=1+jit_current_func_info(jit)->fp_reg_count+jit_current_func_info(jit)->float_arg_cnt; //First is R_FIMM
- while (op) {
- op->live_in = jit_set_new();
- op->live_out = jit_set_new();
- op->bi_live_in=TD_CALLOC(sizeof(long),1+icnt/sizeof(long));
- op->bi_live_out=TD_CALLOC(sizeof(long),1+icnt/sizeof(long));
- op->bf_live_in=TD_CALLOC(sizeof(long),1+fcnt/sizeof(long));
- op->bf_live_out=TD_CALLOC(sizeof(long),1+fcnt/sizeof(long));
- op->bi_live_kill=TD_CALLOC(sizeof(long),1+icnt/sizeof(long));
- op->bf_live_kill=TD_CALLOC(sizeof(long),1+fcnt/sizeof(long));
- op = op->next;
- }
-}
-static inline void add_ibset_to_set(struct jit *jit,jit_set *set,long *bits,long bytes) {
- if(bytes%sizeof(long))
- bytes+=sizeof(long)-bytes%sizeof(long);
- bytes/=sizeof(long);
- if(bits[0]&(1<<R_FP_POS)) {
- jit_set_add(set,R_FP);
- } else if(bits[0]&(1<<R_OUT_POS)) {
- jit_set_add(set,R_OUT);
- } else if(bits[0]&(1<<R_IMM_POS)) {
- jit_set_add(set,R_IMM);
- }
- bits[0]&=~0b111l;
- while(--bytes>=0) {
- long find,idx;
- //find is 0 if none is found,other it is 1+idx
- while(find=__builtin_ffsl(bits[bytes])) {
- idx=find-1-3+bytes*sizeof(long)*8;
- if(idx>=jit_current_func_info(jit)->gp_reg_count)
- jit_set_add(set, jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, idx-jit_current_func_info(jit)->gp_reg_count));
- else
- jit_set_add(set,R(idx));
- bits[bytes]&=~(1l<<(find-1));
- }
- }
-}
-static inline void add_fbset_to_set(struct jit *jit,jit_set *set,long *bits,long bytes) {
- if(bytes%sizeof(long))
- bytes+=sizeof(long)-bytes%sizeof(long);
- bytes/=sizeof(long);
- if(bits[0]&(1<<R_FIMM_POS)) {
- jit_set_add(set,FR_IMM);
- }
- bits[0]&=~0b1l;
- while(--bytes>=0) {
- long find,idx;
- //find is 0 if none is found,other it is 1+idx
- while(find=__builtin_ffsl(bits[bytes])) {
- idx=find-1-1+bytes*sizeof(long)*8;
- if(idx>=jit_current_func_info(jit)->fp_reg_count)
- jit_set_add(set, jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, idx-jit_current_func_info(jit)->fp_reg_count));
- else
- jit_set_add(set,FR(idx));
- bits[bytes]&=~(1l<<(find-1));
- }
- }
-}
-static inline void bset_merge(long *dst,long *src,long bytes) {
- bytes/=sizeof(long);
- while(--bytes>=0) {
- dst[bytes]|=src[bytes];
- }
-}
-static inline void bi_set_remove_reg(struct jit *jit,long *bits,jit_value v) {
- switch(v) {
- default:
- if(v==R_FP) {
- bits[0]&=~(1l<<R_FP_POS);
- break;
- }
- if(v==R_IMM) {
- bits[0]&=~(1l<<R_IMM_POS);
- break;
- }
- if(v==R_OUT) {
- bits[0]&=~(1l<<R_OUT_POS);
- break;
- }
- if(v==FR_IMM)
- break;
- if(!JIT_REG(v).type) {
- long id=JIT_REG(v).id+3;
- if(JIT_REG(v).spec==JIT_RTYPE_ARG) {
- id+=jit_current_func_info(jit)->gp_reg_count;
- bits[id/(sizeof(long)*8)]&=~(1l<<(id%(sizeof(long)*8)));
- } else
- bits[id/(sizeof(long)*8)]&=~(1l<<(id%(sizeof(long)*8)));
- }
- }
-}
-static inline void bi_set_add_reg(struct jit *jit,long *bits,jit_value v) {
- switch(v) {
- default:
- if(v==R_FP) {
- bits[0]|=(1l<<R_FP_POS);
- break;
- }
- if(v==R_IMM) {
- bits[0]|=(1l<<R_IMM_POS);
- break;
- }
- if(v==R_OUT) {
- bits[0]|=(1l<<R_OUT_POS);
- break;
- }
- if(v==FR_IMM)
- break;
- if(!JIT_REG(v).type) {
- long id=JIT_REG(v).id+3;
- if(JIT_REG(v).spec==JIT_RTYPE_ARG) {
- id+=jit_current_func_info(jit)->gp_reg_count;
- bits[id/(sizeof(long)*8)]|=(1l<<(id%(sizeof(long)*8)));
- } else
- bits[id/(sizeof(long)*8)]|=(1l<<(id%(sizeof(long)*8)));
- }
- }
-}
-static inline void bf_set_remove_reg(struct jit *jit,long *bits,jit_value v) {
- switch(v) {
- default:
- if(v==R_FP)
- break;
- if(v==R_IMM)
- break;
- if(v==R_OUT)
- break;
- if(v==FR_IMM) {
- bits[0]&=~1;
- break;
- }
- if(JIT_REG(v).type) {
- long id=JIT_REG(v).id+1;
- if(JIT_REG(v).spec==JIT_RTYPE_ARG) {
- id+=jit_current_func_info(jit)->fp_reg_count;
- bits[id/(sizeof(long)*8)]&=~(1l<<(id%(sizeof(long)*8)));
- } else
- bits[id/(sizeof(long)*8)]&=~(1l<<(id%(sizeof(long)*8)));
- }
- }
-}
-static inline void bf_set_add_reg(struct jit *jit,long *bits,jit_value v) {
- switch(v) {
- default:
- if(v==R_FP)
- break;
- if(v==R_IMM)
- break;
- if(v==R_OUT)
- break;
- if(v==FR_IMM) {
- bits[0]|=1;
- break;
- }
- if(JIT_REG(v).type) {
- long id=JIT_REG(v).id+1;
- if(JIT_REG(v).spec==JIT_RTYPE_ARG) {
- id+=jit_current_func_info(jit)->fp_reg_count;
- bits[id/(sizeof(long)*8)]|=(1l<<(id%(sizeof(long)*8)));
- } else
- bits[id/(sizeof(long)*8)]|=(1l<<(id%(sizeof(long)*8)));
- }
- }
-}
-static inline int bset_equal(long *s1,long *s2,long bytes) {
- bytes/=sizeof(long);
- while(--bytes>=0)
- if(s1[bytes]!=s2[bytes])
- return 0;
- return 1;
-}
-static inline int flw_analyze_op(struct jit * jit, jit_op * op, struct jit_func_info * func_info,int initialRun)
-{
- long icnt=3+jit_current_func_info(jit)->gp_reg_count+jit_current_func_info(jit)->general_arg_cnt; //First 3 are R_FP,R_OUT,R_IMM
- long fcnt=1+jit_current_func_info(jit)->fp_reg_count+jit_current_func_info(jit)->float_arg_cnt; //First is R_FIMM
- long fbytes=(fcnt/sizeof(long)+1)*sizeof(long),ibytes=(icnt/sizeof(long)+1)*sizeof(long);
- if(initialRun||op->shadow_flow_analysis_state==FLOW_CHANGED) {
- op->shadow_flow_analysis_state=FLOW_CHANGED;
- goto possibleChange;
- }
- op->shadow_flow_analysis_state=FLOW_UNCHANGED;
- if(op->code == (JIT_JMP | IMM)&&op->jmp_addr)
- if(op->jmp_addr->flow_analysis_state==FLOW_CHANGED)
- goto possibleChange;
- if(op->next) if(op->next->flow_analysis_state==FLOW_CHANGED)
- goto possibleChange;
- if (op->code == (JIT_JMP | REG))
- goto possibleChange;
- if (op->jmp_addr && (GET_OP(op) != JIT_REF_CODE) && (GET_OP(op) != JIT_DATA_REF_CODE))
- if(op->jmp_addr->flow_analysis_state==FLOW_CHANGED) goto possibleChange;
- return 0;
- possibleChange:;
- int result;
- long *i_in1 = TD_CALLOC(1,ibytes);
- long *i_out1 = TD_CALLOC(1,ibytes);
- long *f_in1 = TD_CALLOC(1,fbytes);
- long *f_out1 = TD_CALLOC(1,fbytes);
- memcpy(i_in1,op->bi_live_in,ibytes); //YES
- memcpy(i_out1,op->bi_live_out,ibytes); //YES
- memcpy(f_in1,op->bf_live_in,fbytes); //YES
- memcpy(f_out1,op->bf_live_out,fbytes); //YES
-
- memcpy(op->bi_live_in,op->bi_live_out,ibytes); //YES
- memcpy(op->bf_live_in,op->bf_live_out,fbytes); //YES
- memset(op->bf_live_kill,0,fbytes);
- memset(op->bf_live_kill,0,fbytes);
-
- for (int i = 0; i < 3; i++) {
- if (ARG_TYPE(op, i + 1) == TREG) {
- bi_set_remove_reg(jit,op->bi_live_in,op->arg[i]); //YE
- bf_set_remove_reg(jit,op->bf_live_in,op->arg[i]); //YE
- bi_set_add_reg(jit,op->bi_live_kill,op->arg[i]); //YES
- bf_set_add_reg(jit,op->bf_live_kill,op->arg[i]); //YES
- }
- }
-
-// FIXME: should be generic Yfor all architectures
-// marks registers which are used to pass arguments
-#ifdef JIT_ARCH_AMD64
- if (GET_OP(op) == JIT_PROLOG) {
- func_info = (struct jit_func_info *)op->arg[1];
-
- for (int i = 0; i < func_info->general_arg_cnt + func_info->float_arg_cnt; i++) {
- if (func_info->args[i].type == JIT_FLOAT_NUM) {
- bf_set_remove_reg(jit,op->bf_live_in,jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, i)); //YES
- //bf_set_add_reg(jit,op->bf_live_kill,jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, i));
- } else {
- bi_set_remove_reg(jit,op->bi_live_in,jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, i)); //YES
- //bi_set_add_reg(jit,op->bf_live_kill,jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, i));
- }
- }
-/*
- int argcount = MIN(func_info->general_arg_cnt, jit->reg_al->gp_arg_reg_cnt);
- for (int j = 0; j < argcount; j++)
- jit_set_remove(op->live_in, jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, j));
-
- argcount = MIN(func_info->float_arg_cnt, jit->reg_al->fp_arg_reg_cnt);
- for (int j = 0; j < argcount; j++)
- jit_set_remove(op->live_in, jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, j));
-*/
- }
-#endif
-
-#if defined(JIT_ARCH_SPARC)
- if (GET_OP(op) == JIT_PROLOG) {
- func_info = (struct jit_func_info *)op->arg[1];
- int assoc_gp = 0;
- int argcount = func_info->general_arg_cnt + func_info->float_arg_cnt;
- for (i`nt j = 0; j < argcount; j++) {
- if (assoc_gp >= jit->reg_al->gp_arg_reg_cnt) break;
- if (func_info->args[j].type != JIT_FLOAT_NUM) {
- jit_set_remove(op->live_in, jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, j));
- assoc_gp++;
- } else {
- jit_set_remove(op->live_in, jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, j));
- assoc_gp++;
- if (func_info->args[j].size == sizeof(double)) {
- jit_set_remove(op->live_in, jit_mkreg_ex(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, j));
- assoc_gp++;
- }
- }
- }
- }
-#endif
-
- for (int i = 0; i < 3; i++)
- if (ARG_TYPE(op, i + 1) == REG) {
- bi_set_add_reg(jit,op->bi_live_in,op->arg[i]); //YES
- bf_set_add_reg(jit,op->bf_live_in,op->arg[i]); //YES
- }
-
-#if defined(JIT_ARCH_AMD64) || defined(JIT_ARCH_SPARC)
- if (GET_OP(op) == JIT_GETARG) {
- int arg_id = op->arg[1];
- if (func_info->args[arg_id].type != JIT_FLOAT_NUM) {
- bi_set_add_reg(jit,op->bi_live_in,jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, arg_id)); //YES
- } else {
- bf_set_add_reg(jit,op->bf_live_in, jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, arg_id)); //YES
- }
- }
-#endif
-
- memset(op->bi_live_out,0,ibytes);
- memset(op->bf_live_out,0,fbytes);
-
- if ((GET_OP(op) == JIT_RET) || (GET_OP(op) == JIT_FRET)) {
- goto skip;
- }
-
- if ((op->code == (JIT_JMP | IMM)) && op->jmp_addr) { //YES
- memcpy(op->bi_live_out,op->jmp_addr->bi_live_in,ibytes); //YES
- memcpy(op->bf_live_out,op->jmp_addr->bf_live_in,fbytes); //YES
- goto skip;
- }
-
- if (op->code == (JIT_JMP | REG)||(GET_OP(op)==JIT_END_ASM_BLK)) { //YES
- jit_op *xop = func_info->first_op->next;
- while (xop && (GET_OP(xop) != JIT_PROLOG)) {
- if ((GET_OP(xop) == JIT_TAINT_LABEL)||(GET_OP(xop) == JIT_REF_CODE) || (GET_OP(xop) == JIT_DATA_REF_CODE)||(GET_OP(xop)==JIT_DATA_CODE_OFFSET)) {
- bset_merge(op->bf_live_out, xop->jmp_addr->bf_live_in,fbytes);
- bset_merge(op->bi_live_out, xop->jmp_addr->bi_live_in,ibytes);
- }
- xop = xop->next;
- }
- goto skip;
- }
- if(op->next) {
- bset_merge(op->bi_live_out ,op->next->bi_live_in,ibytes); //YES
- bset_merge(op->bf_live_out ,op->next->bf_live_in,fbytes); //YES
- } else {
- //Already cleared
- }
-
- if (op->jmp_addr && (GET_OP(op) != JIT_REF_CODE) && (GET_OP(op) != JIT_DATA_REF_CODE)&&(GET_OP(op)!=JIT_DATA_CODE_OFFSET)&&(GET_OP(op) != JIT_TAINT_LABEL)) {
- bset_merge(op->bi_live_out ,op->jmp_addr->bi_live_in,ibytes); //YES
- bset_merge(op->bf_live_out ,op->jmp_addr->bf_live_in,fbytes); //YES
- }
-skip:
-
- result = !(
- bset_equal(i_in1, op->bi_live_in,ibytes)
- &&bset_equal(i_out1, op->bi_live_out,ibytes)
- &&bset_equal(f_in1, op->bf_live_in,fbytes)
- &&bset_equal(f_out1, op->bf_live_out,fbytes));
- if(result||initialRun) op->flow_analysis_state=op->shadow_flow_analysis_state=FLOW_CHANGED;
- else op->shadow_flow_analysis_state=FLOW_UNCHANGED;
- TD_FREE(i_in1);
- TD_FREE(i_out1);
- TD_FREE(f_in1);
- TD_FREE(f_out1);
- return result;
-}
-
-static inline void jit_flw_analysis(struct jit * jit)
-{
- jit_flw_initialize(jit);
- int changed;
- struct jit_func_info * func_info = NULL;
- int initialRun=1;
- //Expectes function info to be found
- struct jit_op *first=jit_op_first(jit->ops);
- for(;first;first=first->next) {
- if (GET_OP(first) == JIT_PROLOG)
- func_info = (struct jit_func_info *)first->arg[1];
- first->flow_analysis_state=FLOW_CHANGED;
- first->live_kill=jit_set_new();
- }
- do {
- changed = 0;
- //Do in "reverse" order
- jit_op * op = jit_op_last(jit->ops);
- while (op) {
- changed |= flw_analyze_op(jit, op, func_info,initialRun);
- op = op->prev;
- }
- op = jit_op_last(jit->ops);
- while (op) {
- op->flow_analysis_state=op->shadow_flow_analysis_state;
- op=op->prev;
- }
- initialRun=0;
- } while (changed);
- first=jit_op_first(jit->ops);
- long icnt=3+jit_current_func_info(jit)->gp_reg_count+jit_current_func_info(jit)->general_arg_cnt; //First 3 are R_FP,R_OUT,R_IMM
- long fcnt=1+jit_current_func_info(jit)->fp_reg_count+jit_current_func_info(jit)->float_arg_cnt; //First is R_FIMM
- long fbytes=fcnt/sizeof(long)+sizeof(long),ibytes=icnt/sizeof(long)+sizeof(long);
- for(;first;first=first->next) {
- add_ibset_to_set(jit,first->live_in,first->bi_live_in,ibytes);
- add_fbset_to_set(jit,first->live_in,first->bf_live_in,fbytes);
- add_ibset_to_set(jit,first->live_out,first->bi_live_out,ibytes);
- add_fbset_to_set(jit,first->live_out,first->bf_live_out,fbytes);
- add_ibset_to_set(jit,first->live_kill,first->bi_live_kill,ibytes);
- add_fbset_to_set(jit,first->live_kill,first->bf_live_kill,fbytes);
- JIT_FREE(first->bf_live_in);
- JIT_FREE(first->bf_live_out);
- JIT_FREE(first->bf_live_kill);
- JIT_FREE(first->bi_live_in);
- JIT_FREE(first->bi_live_out);
- JIT_FREE(first->bi_live_kill);
- }
-}
-
-static inline void mark_livecode(jit_op *op)
-{
- while (op) {
- if (op->in_use) return;
- op->in_use = 1;
- if (op->jmp_addr) mark_livecode(op->jmp_addr);
- if (GET_OP(op) == JIT_RET) return;
- if (GET_OP(op) == JIT_FRET) return;
- if (GET_OP(op) == JIT_JMP) return;
- op = op->next;
- }
-}
-
-
-static void jit_dead_code_analysis(struct jit *jit, int remove_dead_code)
-{
- for (jit_op *op = jit_op_first(jit->ops); op; op = op->next)
- op->in_use = 0;
-
- // marks ordinary operations
- for (jit_op *op = jit_op_first(jit->ops); op; op = op->next) {
- if (GET_OP(op) == JIT_PROLOG) mark_livecode(op);
- if (GET_OP(op) == JIT_DATA_REF_CODE) mark_livecode(op->jmp_addr);
- if (GET_OP(op) == JIT_DATA_CODE_OFFSET) mark_livecode(op->jmp_addr);
- }
-
-
- // marks directives
- for (jit_op *op = jit_op_first(jit->ops); op; op = op->next) {
- if (GET_OP(op) == JIT_CODESTART) op->in_use = 1;
- if (GET_OP(op) == JIT_DATA_BYTE) op->in_use = 1;
- if (GET_OP(op) == JIT_DATA_REF_CODE) op->in_use = 1;
- if (GET_OP(op) == JIT_DATA_REF_DATA) op->in_use = 1;
- if (GET_OP(op) == JIT_DATA_CODE_OFFSET) op->in_use = 1;
- if (GET_OP(op) == JIT_DUMP_PTR) op->in_use=1;
- if (GET_OP(op) == JIT_CODE_ALIGN) op->in_use = 1;
- if (GET_OP(op) == JIT_LABEL) op->in_use = 1;
- if (GET_OP(op) == JIT_PATCH) op->in_use = 1;
- if (GET_OP(op) == JIT_COMMENT) op->in_use = 1;
- }
-
- if (!remove_dead_code) return;
-
- jit_op *op = jit_op_first(jit->ops);
-
- while (op) {
- if (!op->in_use) {
- if (GET_OP(op) == JIT_FULL_SPILL) goto skip; /* only marks whether code is accessible or not */
- jit_op *next = op->next;
- jit_op_delete(op);
- op = next;
- continue;
- }
-skip:
- op = op->next;
- }
-
-}
diff --git a/ext/myjit/myjit/graphcoloring.h b/ext/myjit/myjit/graphcoloring.h
deleted file mode 100755
index 598f631..0000000
--- a/ext/myjit/myjit/graphcoloring.h
+++ /dev/null
@@ -1,237 +0,0 @@
-#pragma once
-#include <stdint.h>
-#include <stdlib.h>
-#include "jitlib.h"
-#include "jitlib-core.h"
-typedef struct CMatrix {
- uint8_t **items;
- int itemCount;
- int type:1;
-} CMatrix;
-static CMatrix CreateMatrix(int items) {
- CMatrix mat;
- mat.itemCount=items;
- items+=16; //For extra registes
- mat.items=JIT_MALLOC(sizeof(uint8_t*)*items);
- int iter=items;
- while(--iter>=0) {
- mat.items[iter]=JIT_MALLOC(items);
- memset(mat.items[iter],0,items);
- }
- return mat;
-}
-static void Interfere(CMatrix *mat,int64_t a,int64_t b) {
- if(a>=mat->itemCount) abort();
- if(b>=mat->itemCount) abort();
- mat->items[a][b]=1;
- mat->items[b][a]=1;
-}
-typedef struct {
- uint8_t *found;
- unsigned type:1;
- int len;
-} RFThunk;
-static int ColoringIsBlacklisted(jit_value v) {
- return
- v==R_FP||
- v==R_OUT||
- v==R_IMM||
- v==FR_IMM;
-}
-static void SearchForRegs(int64_t key,void * found) {
- RFThunk *thunk=found;
- if(JIT_REG(key).type!=thunk->type) return;
- if(ColoringIsBlacklisted(key))
- return;
- int id=JIT_REG(key).id;
- if(id>=thunk->len+16) abort();
- thunk->found[id]=1;
-}
-static void GlobRegisters(CMatrix *mat,jit_set *live,int type) {
- uint8_t found[mat->itemCount+16];
- memset(found,0,mat->itemCount+16);
- RFThunk thunk={found,type,mat->itemCount};
- int var,iter;
- vec_foreach(&live->vec, var, iter) SearchForRegs(var, &thunk);
- int a,b;
- for(a=0;a!=mat->itemCount;a++) {
- for(b=0;b!=mat->itemCount;b++) {
- if(a==b) continue;
- if(mat->items[a][b]) continue;
- if(found[a]&&found[b]){
- Interfere(mat,a,b);
- }
- }
- }
-}
-static void CreateInterferenceGraphs(struct jit *jit,CMatrix *_igraph,CMatrix *_fgraph) {
- struct jit_func_info *info=jit_current_func_info(jit);
- CMatrix igraph=CreateMatrix(info->gp_reg_count);
- CMatrix fgraph=CreateMatrix(info->fp_reg_count);
- struct jit_op *ops=jit_op_first(jit->ops);
- for(;ops;ops=ops->next) {
- GlobRegisters(&igraph,ops->live_in,JIT_RTYPE_INT);
- GlobRegisters(&fgraph,ops->live_in,JIT_RTYPE_FLOAT);
- GlobRegisters(&igraph,ops->live_out,JIT_RTYPE_INT);
- GlobRegisters(&fgraph,ops->live_out,JIT_RTYPE_FLOAT);
- jit_set *ko;
- jit_set_addall(ko=jit_set_clone(ops->live_kill),ops->live_out);
- GlobRegisters(&igraph,ko,JIT_RTYPE_INT);
- GlobRegisters(&fgraph,ko,JIT_RTYPE_FLOAT);
- jit_set_free(ko);
- }
- *_igraph=igraph;
- *_fgraph=fgraph;
-}
-//https://www.geeksforgeeks.org/graph-coloring-set-2-greedy-algorithm/
-static void ColorGraph(CMatrix *mat,int *colors) {
- int iter=mat->itemCount;
- if(!iter) return;
- while(--iter>=0) {
- colors[iter]=-1;
- }
- colors[0]=0;
- loop:;
- iter=mat->itemCount;
- int changed=0;
- uint8_t freeColors[mat->itemCount];
- memset(freeColors,1,mat->itemCount);
- for(iter=1;iter<mat->itemCount;iter++) {
- int iter2=0;
- for(;iter2!=mat->itemCount;iter2++) {
- if(!mat->items[iter][iter2]) continue;
- if(colors[iter2]!=-1) {
- freeColors[colors[iter2]]=0;
- }
- }
- //Pick first free
- for(iter2=0;iter2!=mat->itemCount;iter2++){
- if(freeColors[iter2]) {
- break;
- }
- }
- colors[iter]=iter2;
- memset(freeColors,1,mat->itemCount);
- }
- if(changed) goto loop;
- /*for(iter=0;iter!=mat->itemCount;iter++) {
- printf("%i has color %i\n",iter,colors[iter]);
- }*/
- //Validate
- iter=mat->itemCount;
- while(--iter>=0) {
- int iter2=0;
- for(;iter2!=mat->itemCount;iter2++) {
- if(!mat->items[iter][iter2]) continue;
- assert(colors[iter]!=colors[iter2]);
- }
- }
-}
-static void RemapRegisterByColor(struct jit *jit,int *colors,int type) {
- struct jit_op *op=jit_op_first(jit->ops);
- for(;op;op=op->next) {
- int t=3;
- while(--t>=0) {
- int spec=op->spec;
- if(t)
- spec>>=(2*t); //0b11;
- spec&=3;
- switch(spec) {
- case TREG:
- case REG:
- if(JIT_REG(op->arg[t]).type!=type) break;
- if(ColoringIsBlacklisted(op->arg[t])) break;
- int color=colors[JIT_REG(op->arg[t]).id];
- jit_reg reg;
- memcpy(&reg,&op->arg[t],sizeof(reg));
- if(color!=JIT_REG(op->arg[t]).id)
- reg.id=color;
- memcpy(&op->arg[t],&reg,sizeof(reg));
- break;
- }
- }
- }
-}
-static void FreeMatrix(CMatrix *mat) {
- int iter=mat->itemCount+16; //We made more eailier
- while(--iter>=0)
- JIT_FREE(mat->items[iter]);
- JIT_FREE(mat->items);
-}
-#include "../../../3d.h"
-static void ReduceRegisterCount(struct jit *jit,struct CFunction *f) {
- jit_flw_analysis(jit);
- //jit_dump_ops(jit, JIT_DEBUG_OPS);
- CMatrix igraph,fgraph;
- CreateInterferenceGraphs(jit,&igraph,&fgraph);
- int icolors[igraph.itemCount+16];
- ColorGraph(&igraph, icolors);
- RemapRegisterByColor(jit,icolors,JIT_RTYPE_INT);
- FreeMatrix(&igraph);
- int fcolors[fgraph.itemCount+16];
- ColorGraph(&fgraph, fcolors);
- RemapRegisterByColor(jit,fcolors,JIT_RTYPE_FLOAT);
- FreeMatrix(&fgraph);
-
- struct jit_func_info *info=jit_current_func_info(jit);
- CVariable *ilocals[info->gp_reg_count+16];
- CVariable *flocals[info->fp_reg_count+16];
- map_iter_t liter=map_iter(&f->locals);
- const char *key;
- if(f) {
- int iter;
- while(key=map_next(&f->locals, &liter)) {
- CVariable *v=*map_get(&f->locals,key);
- if(!v->isReg) continue;
- if(IsF64(v->type))
- flocals[v->reg]=v;
- else
- ilocals[v->reg]=v;
- }
- }
-
- struct jit_op *op=jit_op_first(jit->ops);
- int64_t index=0;
- static int64_t msgIndex=0;
- for(;op;op=op->next,index++) {
- int iter;
- int *val;
- vec_foreach_ptr(&op->live_in->vec,val,iter) {
- if(ColoringIsBlacklisted(*val)) continue;
- if(JIT_REG(*val).type==JIT_RTYPE_INT) {
- jit_reg reg=JIT_REG(*val);
- reg.id=icolors[JIT_REG(*val).id];
- memcpy(val,&reg,sizeof(*val));
- }
- if(JIT_REG(*val).type==JIT_RTYPE_FLOAT) {
- jit_reg reg=JIT_REG(*val);
- reg.id=fcolors[JIT_REG(*val).id];
- memcpy(val,&reg,sizeof(*val));
- }
- }
- vec_foreach_ptr(&op->live_out->vec,val,iter) {
- if(ColoringIsBlacklisted(*val)) continue;
- if(JIT_REG(*val).type==JIT_RTYPE_INT) {
- jit_reg reg=JIT_REG(*val);
- reg.id=icolors[JIT_REG(*val).id];
- memcpy(val,&reg,sizeof(*val));
- }
- if(JIT_REG(*val).type==JIT_RTYPE_FLOAT) {
- jit_reg reg=JIT_REG(*val);
- reg.id=fcolors[JIT_REG(*val).id];
- memcpy(val,&reg,sizeof(*val));
- }
- }
- }
- int64_t iter=0;
- for(;iter!=info->fp_reg_count;iter++)
- if(fcolors[iter]==-1)
- break;
- info->fp_reg_count=iter+((iter%2)?1:0);
-
- for(iter=0;iter!=info->gp_reg_count;iter++)
- if(icolors[iter]==-1)
- break;
- info->gp_reg_count=iter+((iter%2)?1:0);
- //jit_dump_ops(jit, JIT_DEBUG_OPS);
-}
diff --git a/ext/myjit/myjit/jitlib-core.c b/ext/myjit/myjit/jitlib-core.c
deleted file mode 100755
index e09fa7f..0000000
--- a/ext/myjit/myjit/jitlib-core.c
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License ain't with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "cpu-detect.h"
-#include "jitlib.h"
-#include "jitlib-core.h"
-#include "set.h"
-#ifdef TARGET_WIN32
-#include "memoryapi.h"
-#else
-#endif
-
-#ifdef JIT_ARCH_COMMON86
-#include "common86-specific.h"
-#endif
-
-#ifdef JIT_ARCH_SPARC
-#include "sparc-specific.h"
-#endif
-
-#include "jitlib-debug.c"
-#include "code-check.c"
-#include "flow-analysis.h"
-#include "rmap.h"
-#include "reg-allocator.h"
-
-
-
-#define BUF_SIZE (4096)
-#define MINIMAL_BUF_SPACE (1024)
-
-struct jit_op * jit_add_op(struct jit * jit, unsigned short code, unsigned char spec, jit_value arg1, jit_value arg2, jit_value arg3, unsigned char arg_size, struct jit_debug_info *debug_info)
-{
- if(!jit) return NULL;
- struct jit_op * r = jit_op_new(code, spec, arg1, arg2, arg3, arg_size);
- r->debug_info = debug_info;
- jit_op_append(jit->last_op, r);
- jit->last_op = r;
-
- return r;
-}
-
-struct jit_op * jit_add_fop(struct jit * jit, unsigned short code, unsigned char spec, jit_value arg1, jit_value arg2, jit_value arg3, double flt_imm, unsigned char arg_size, struct jit_debug_info *debug_info)
-{
- if(!jit) return NULL;
- struct jit_op * r = jit_add_op(jit, code, spec, arg1, arg2, arg3, arg_size, debug_info);
- r->fp = 1;
- r->flt_imm = flt_imm;
-
- return r;
-}
-
-struct jit_debug_info *jit_debug_info_new(const char *filename, const char *function, int lineno)
-{
- struct jit_debug_info *r = JIT_MALLOC(sizeof(struct jit_debug_info));
- r->filename = filename;
- r->function = function;
- r->lineno = lineno;
- r->warnings = 0;
- return r;
-}
-
-struct jit * jit_init()
-{
- struct jit * r = JIT_MALLOC(sizeof(struct jit));
-
- r->ops = jit_op_new(JIT_CODESTART, SPEC(NO, NO, NO), 0, 0, 0, 0);
- r->last_op = r->ops;
- r->optimizations = 0;
-
- r->buf = NULL;
- r->labels = NULL;
- r->reg_al = jit_reg_allocator_create();
- jit_enable_optimization(r, JIT_OPT_JOIN_ADDMUL | JIT_OPT_OMIT_FRAME_PTR);
-
- return r;
-}
-
-jit_op *jit_add_prolog(struct jit * jit, void * func, struct jit_debug_info *debug_info)
-{
- if(!jit) return NULL;
- jit_op * op = jit_add_op(jit, JIT_PROLOG , SPEC(IMM, NO, NO), (jit_value)func, 0, 0, 0, NULL);
- struct jit_func_info * info = JIT_MALLOC(sizeof(struct jit_func_info));
- op->arg[1] = (jit_value)info;
- op->debug_info = debug_info;
-
- jit->current_func = op;
-
- info->first_op = op;
- info->allocai_mem = 0;
- info->general_arg_cnt = 0;
- info->float_arg_cnt = 0;
- return op;
-}
-
-jit_label * jit_get_label(struct jit * jit)
-{
- if(!jit) return NULL;
- jit_label * r = JIT_MALLOC(sizeof(jit_label));
- jit_add_op(jit, JIT_LABEL, SPEC(IMM, NO, NO), (jit_value)r, 0, 0, 0, NULL);
- r->next = jit->labels;
- jit->labels = r;
- return r;
-}
-
-
-#if JIT_IMM_BITS > 0
-/**
- * returns 1 if the immediate value has to be transformed into register
- */
-static int jit_imm_overflow(struct jit * jit, int signed_op, int64_t value)
-{
- uint64_t mask = ~((1ULL << JIT_IMM_BITS) - 1);
- uint64_t high_bits = value & mask;
-
- if (signed_op) {
- if ((high_bits != 0) && (high_bits != mask)) return 1;
- } else {
- if (high_bits != 0) return 1;
- }
- return 0;
-}
-
-/**
- * converts int64_t immediates to MOV operation
- */
-static void jit_correct_int64_t_imms(struct jit * jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if (!IS_IMM(op)) continue;
- if (GET_OP(op) == JIT_JMP) continue;
- if (GET_OP(op) == JIT_CALL) continue;
- if (GET_OP(op) == JIT_PATCH) continue;
- if (GET_OP(op) == JIT_MOV) continue;
- if (GET_OP(op) == JIT_PUTARG) continue;
- if (GET_OP(op) == JIT_MSG) continue;
- if (GET_OP(op) == JIT_COMMENT) continue;
- if (GET_OP(op) == JIT_PROLOG) continue;
- if (GET_OP(op) == JIT_DATA_REF_CODE) continue;
- if (GET_OP(op) == JIT_DATA_CODE_OFFSET) continue;
- if (GET_OP(op) == JIT_DATA_REF_DATA) continue;
- if (GET_OP(op) == JIT_REF_DATA) continue;
- if (GET_OP(op) == JIT_REF_CODE) continue;
- if (GET_OP(op) == JIT_RELOCATION) continue;
- if (GET_OP(op) == JIT_FORCE_ASSOC) continue;
- if (GET_OP(op) == JIT_BREAKPOINT) continue;
- int imm_arg;
- for (int i = 1; i < 4; i++)
- if (ARG_TYPE(op, i) == IMM) imm_arg = i - 1;
- int64_t value = op->arg[imm_arg];
-
- if (jit_imm_overflow(jit, IS_SIGNED(op), value)) {
- jit_op * newop = jit_op_new(JIT_MOV | IMM, SPEC(TREG, IMM, NO), R_IMM, value, 0, REG_SIZE);
- jit_op_prepend(op, newop);
-
- op->code &= ~(0x3);
- op->code |= REG;
-
- op->spec &= ~(0x3 << (2 * imm_arg));
- op->spec |= (REG << (2 * imm_arg));
- op->arg[imm_arg] = R_IMM;
- }
- }
-}
-#endif
-
-static inline void jit_correct_float_imms(struct jit * jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if (!IS_IMM(op)) continue;
- if (!op->fp) continue;
- if (GET_OP(op) == JIT_FMOV) continue;
- if (GET_OP(op) == JIT_FPUTARG) continue;
- if (GET_OP(op) == JIT_FLD) continue;
- if (GET_OP(op) == JIT_FLDX) continue;
- if (GET_OP(op) == JIT_FST) continue;
- if (GET_OP(op) == JIT_FSTX) continue;
-// FIXME: TODO if (GET_OP(op) == JIT_FMSG) continue;
- int imm_arg;
- for (int i = 1; i < 4; i++)
- if (ARG_TYPE(op, i) == IMM) imm_arg = i - 1;
-
- jit_op * newop = jit_op_new(JIT_FMOV | IMM, SPEC(TREG, IMM, NO), (jit_value) FR_IMM, 0, 0, 0);
- newop->fp = 1;
- newop->flt_imm = op->flt_imm;
- jit_op_prepend(op, newop);
-
- op->code &= ~(0x3);
- op->code |= REG;
-
- op->spec &= ~(0x3 << (2 * imm_arg));
- op->spec |= (REG << (2 * imm_arg));
- op->arg[imm_arg] = FR_IMM;
- }
-}
-
-static inline void jit_expand_patches_and_labels(struct jit * jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if (GET_OP(op) == JIT_PATCH) {
- ((jit_op *)(op->arg[0]))->jmp_addr = op;
- }
- if (GET_OP(op) == JIT_LABEL) {
- ((jit_label *)(op->arg[0]))->op = op;
- }
-
- if ((GET_OP(op) != JIT_LABEL) && (jit_is_label(jit, (void *)op->arg[0]))) {
- op->jmp_addr = ((jit_label *)(op->arg[0]))->op;
- }
-
- if ((GET_OP(op) != JIT_LABEL) && (jit_is_label(jit, (void *)op->arg[1]))) {
- op->jmp_addr = ((jit_label *)(op->arg[1]))->op;
- }
- }
-}
-
-static inline void jit_prepare_reg_counts(struct jit * jit)
-{
- int declared_args = 0;
- int last_gp = -1;
- int last_fp = -1;
- int gp_args = 0;
- int fp_args = 0;
- struct jit_func_info * info = NULL;
- jit_op * op = jit_op_first(jit->ops);
-
- while (1) {
- if (!op || (GET_OP(op) == JIT_PROLOG)) {
- if (info) {
- info->gp_reg_count = last_gp + 1;
- info->fp_reg_count = last_fp + 1;
- info->general_arg_cnt = gp_args;
- info->float_arg_cnt = fp_args;
-
-#if defined(JIT_ARCH_AMD64)
- // stack has to be aligned to 16 bytes
- while ((info->gp_reg_count + info->fp_reg_count) % 2) info->gp_reg_count ++;
-#endif
- info->args = JIT_MALLOC(sizeof(struct jit_inp_arg) * declared_args);
- }
- if (op) {
- declared_args = 0;
- last_gp = -1;
- last_fp = -1;
- gp_args = 0;
- fp_args = 0;
- info = (struct jit_func_info *)op->arg[1];
- }
- if (!op) break;
- }
-
- for (int i = 0; i < 3; i++)
- if ((ARG_TYPE(op, i + 1) == TREG) || (ARG_TYPE(op, i + 1) == REG)) {
- jit_reg r = JIT_REG(op->arg[i]);
- if ((r.type == JIT_RTYPE_INT) && (r.id > last_gp)) last_gp = r.id;
- if ((r.type == JIT_RTYPE_FLOAT) && (r.id > last_fp)) last_fp = r.id;
- }
-
- if (GET_OP(op) == JIT_DECL_ARG) {
- declared_args++;
- if (op->arg[0] == JIT_FLOAT_NUM) fp_args++;
- else gp_args++;
- }
-
- if (GET_OP(op) == JIT_PREPARE) {
- jit_op * xop = op;
- while (1) {
- if (GET_OP(op->next) == JIT_PUTARG) xop->arg[0]++;
- else if (GET_OP(op->next) == JIT_FPUTARG) xop->arg[1]++;
- else break;
- op = op->next;
- }
- }
- op = op->next;
- }
-
-}
-
-static inline void jit_prepare_arguments(struct jit * jit)
-{
- jit_op * op = jit_op_first(jit->ops);
- struct jit_func_info * info = NULL;
- int gp_arg_pos = 0;
- int fp_arg_pos = 0;
- int argpos = 0;
- int phys_reg = 0;
-
- while (op) {
- if (GET_OP(op) == JIT_PROLOG) {
- info = (struct jit_func_info *)op->arg[1];
- info->has_prolog = 1;
- gp_arg_pos = 0;
- fp_arg_pos = 0;
- argpos = 0;
- phys_reg = 0;
- }
- if (GET_OP(op) == JIT_DECL_ARG) {
- info->args[argpos].type = op->arg[0];
- info->args[argpos].size = op->arg[1];
- if (op->arg[0] == JIT_FLOAT_NUM) {
- info->args[argpos].gp_pos = gp_arg_pos;
- info->args[argpos].fp_pos = fp_arg_pos++;
- } else {
- info->args[argpos].gp_pos = gp_arg_pos++;
- info->args[argpos].fp_pos = fp_arg_pos;
- }
- jit_init_arg_params(jit, info, argpos, &phys_reg);
- argpos++;
- }
- op = op->next;
- }
-
-}
-static inline void jit_prepare_unloads_at_tainted(struct jit *jit) {
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next)
- if(GET_OP(op) == JIT_TAINT_LABEL) {
- jit_op * newop = jit_op_new(JIT_FORCE_UNLOAD_ALL | IMM, SPEC(NO, NO, NO), 0, 0, 0, 0);
- jit_op_prepend(op->jmp_addr, newop);
- }
-}
-static inline void jit_prepare_spills_on_jmpr_targets(struct jit *jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next)
- if ((GET_OP(op) == JIT_REF_CODE) || (GET_OP(op) == JIT_DATA_REF_CODE)|| (GET_OP(op) == JIT_DATA_CODE_OFFSET)) {
- jit_op * newop = jit_op_new(JIT_FULL_SPILL | IMM, SPEC(NO, NO, NO), 0, 0, 0, 0);
- jit_op_prepend(op->jmp_addr, newop);
- }
-}
-
-static inline void jit_buf_expand(struct jit * jit)
-{
- int64_t pos = jit->ip - jit->buf;
- jit->buf_capacity *= 2;
- jit->buf = JIT_REALLOC(jit->buf, jit->buf_capacity);
- jit->ip = jit->buf + pos;
-}
-static void ReleaseFMem(void *_jit,void *data) {
- struct jit *jit=_jit;
- #ifndef TARGET_WIN32
- munmap(jit->buf,jit->ip-jit->buf);
- #else
- VirtualFree(jit->buf,0,MEM_RELEASE);
- #endif
-}
-static void free_labels(jit_label * lab);
-static void free_ops(jit_op * lab);
-//#include "ssa.h"
-void jit_generate_code(struct jit * jit,struct CFunction *func)
-{
- if(!jit) return;
- jit_expand_patches_and_labels(jit);
-#if JIT_IMM_BITS > 0
- jit_correct_int64_t_imms(jit);
-#endif
- jit_correct_float_imms(jit);
- jit_prepare_reg_counts(jit);
- jit_flw_analysis(jit);
- jit_prepare_spills_on_jmpr_targets(jit);
- jit_prepare_unloads_at_tainted(jit);
- jit_prepare_arguments(jit);
-
- //jit_dead_code_analysis(jit, 1);
- //ReduceRegisterCount(jit,func);
-
-
- if (jit->optimizations & JIT_OPT_OMIT_UNUSED_ASSIGNEMENTS) jit_optimize_unused_assignments(jit);
-
-
-#if defined(JIT_ARCH_I386) || defined(JIT_ARCH_AMD64)
- int change = 0;
- jit_optimize_st_ops(jit);
- if (jit->optimizations & JIT_OPT_JOIN_ADDMUL) {
- change |= jit_optimize_join_addmul(jit);
- change |= jit_optimize_join_addimm(jit);
- }
- // oops, we have changed the code structure, we have to do the analysis again
- if (change) jit_flw_analysis(jit);
-#endif
- //jit_dump_ops(jit,1);
- jit_collect_statistics(jit);
- jit_assign_regs(jit);
-
-#ifdef JIT_ARCH_COMMON86
- if (jit->optimizations & JIT_OPT_OMIT_FRAME_PTR) jit_optimize_frame_ptr(jit);
-#endif
-
- jit->buf_capacity = BUF_SIZE;
- jit->buf = JIT_MALLOC(jit->buf_capacity);
- jit->ip = jit->buf;
-
- for (struct jit_op * op = jit->ops; op != NULL; op = op->next) {
- if (jit->buf_capacity - (jit->ip - jit->buf) < MINIMAL_BUF_SPACE) jit_buf_expand(jit);
- // platform unspecific opcodes
- uint64_t offset_1 = (jit->ip - jit->buf);
- switch (GET_OP(op)) {
- case JIT_DATA_BYTE: *(jit->ip)++ = (unsigned char) op->arg[0]; break;
- case JIT_DATA_REF_CODE:
- case JIT_DATA_REF_DATA:
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- for (int i = 0; i < sizeof(void *); i++) {
- *jit->ip = 0;
- jit->ip++;
- }
- break;
- case JIT_DATA_CODE_OFFSET:
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- for (int i = 0; i < sizeof(int32_t); i++) {
- *jit->ip = 0;
- jit->ip++;
- }
- break;
- case JIT_DUMP_PTR:
- op->arg[1]=(jit_value)(jit->ip-jit->buf);
- break;
- case JIT_TAINT_LABEL: break;
- case JIT_END_ASM_BLK: break;
- case JIT_FORCE_SPILL:
- case JIT_FORCE_UNLOAD_ALL:
- case JIT_FORCE_ASSOC:
- case JIT_COMMENT:
- break;
- // platform specific opcodes
- default: jit_gen_op(jit, op);
- }
- uint64_t offset_2 = (jit->ip - jit->buf);
- op->code_offset = offset_1;
- op->code_length = offset_2 - offset_1;
- }
-
- //Add floating points to end of code as they are RIP relative
- jit->ip+=(16-(((int64_t)(jit->ip-jit->buf))%16))%16;
-
- {
- //These are used avoid repeat double values
- typedef vec_t(uint64_t) vec_uint64_t;
- vec_uint64_t values;
- vec_int_t offsets;
- vec_init(&offsets);vec_init(&values);
-
-
- long fiter;
- jit_flt_rip_relloc frelloc;
- vec_foreach(&jit->flt_rellocs,frelloc,fiter) {
- long idx=0,foffset;
- vec_find(&values, frelloc.hex, idx);
- if(idx==-1) {
- if (jit->buf_capacity - (16+jit->ip - jit->buf) < MINIMAL_BUF_SPACE) jit_buf_expand(jit);
- assert(((int64_t)(jit->ip-jit->buf))%16==0);
- *(uint64_t*)(jit->ip)=frelloc.hex;
- vec_push(&values, frelloc.hex);
- vec_push(&offsets, jit->ip-jit->buf);
- jit->ip+=16;
- }
- vec_find(&values, frelloc.hex, idx);
- assert(idx!=-1);
- *(int32_t*)((char*)jit->buf+frelloc.offset)=offsets.data[idx]-frelloc.offset-4; //-4 offset points to displacement,so bytes is subtraced as RIP displacemnets are 32bit here
- }
- vec_deinit(&values);
- vec_deinit(&offsets);
- }
- /* moves the code to its final destination */
- int code_size = jit->ip - jit->buf;
- void * mem;
- #ifndef TARGET_WIN32
- mem=PoopMAlloc(code_size);
- #else
- mem=VirtualAlloc(NULL,code_size,MEM_COMMIT | MEM_RESERVE,PAGE_EXECUTE_READWRITE);
- #endif
- memcpy(mem, jit->buf, code_size);
- JIT_FREE(jit->buf);
- for (struct jit_op * op = jit->ops; op != NULL; op = op->next) {
- if(GET_OP(op)==JIT_DUMP_PTR) {
- *((void**)op->arg[0])=mem+op->arg[1];
- } else if(GET_OP(op)==JIT_BREAKPOINT) {
- ((jit_breakpoint_t*)op->arg[0])->at=op;
- op->bp_ptr+=(int64_t)mem;
- }
- }
-
- // FIXME: duplicitni vypocet?
- int64_t pos = jit->ip - jit->buf;
- jit->buf = mem;
- jit->ip = jit->buf + pos;
- jit->bin_size=pos;
-
- jit_patch_external_calls(jit);
- jit_patch_local_addrs(jit);
-
- /* assigns functions */
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if (GET_OP(op) == JIT_PROLOG)
- *(void **)(op->arg[0]) = jit->buf + (int64_t)op->patch_addr;
- }
-
- //Free IR for more memory
- //jit_reg_allocator_free(jit->reg_al);
- //Remove all data except for breakpoints
- //free_ops(jit_op_first(jit->ops));
- jit_op *first_valid=jit_op_first(jit->ops);
- for(jit_op *op=jit_op_first(jit->ops)->next;op;) {
- jit_op *next=op->next;
- if(GET_OP(op)!=JIT_BREAKPOINT&&GET_OP(op)!=JIT_PROLOG) {
- jit_free_op(op);
- }
- op=next;
- }
- jit->ops=first_valid;
- struct jit oldj=*jit;
- jit->buf=oldj.buf;
- jit->ip =oldj.ip;
- jit->bin_size=pos;
-}
-
-static void free_ops(struct jit_op * op)
-{
- if (op == NULL) return;
- free_ops(op->next);
- jit_free_op(op);
-
-}
-
-static void free_labels(jit_label * lab)
-{
- if (lab == NULL) return;
- free_labels(lab->next);
- JIT_FREE(lab);
-}
-
-static int is_cond_branch_op(jit_op *op)
-{
- jit_opcode code = GET_OP(op);
- return (code == JIT_BLT) || (code == JIT_BLE) || (code == JIT_BGT)
- || (code == JIT_BGE) || (code == JIT_BEQ) || (code == JIT_BNE)
- || (code == JIT_FBLT) || (code == JIT_FBLE) || (code == JIT_FBGT)
- || (code == JIT_FBGE) || (code == JIT_FBEQ) || (code == JIT_FBNE)
- || (code == JIT_BOADD) || (code == JIT_BOSUB);
-}
-
-
-void jit_enable_optimization(struct jit * jit, int opt)
-{
- if(!jit) return;
- jit->optimizations |= opt;
-}
-
-void jit_disable_optimization(struct jit * jit, int opt)
-{
- if(!jit) return;
- jit->optimizations &= ~opt;
-}
-int64_t jit_bin_size(struct jit * jit) {
- return jit->bin_size;
-}
-void jit_free(struct jit * jit)
-{
- if(!jit) return;
- /* Will be handled by destructor
-#ifndef TARGET_WIN32
- munmap(jit->buf,jit->ip-jit->buf);
-#else
- VirtualFree(jit->buf,0,MEM_RELEASE);
-#endif
- */
- free_ops(jit_op_first(jit->ops));
- JIT_FREE(jit);
-}
-jit_breakpoint_t *jit_get_breakpoint_btr_ptr(struct jit *jit,void *at) {
- jit_breakpoint_t *last_bp=NULL;
- if(at>=(void*)jit->buf)
- if((void*)jit->buf+jit->bin_size>=at) {
- struct jit_op *op=jit_op_first(jit->ops);
- for(;op;op=op->next) {
- if(GET_OP(op)==JIT_BREAKPOINT) {
- if(!last_bp) last_bp=op->arg[0];
- if(at<=op->bp_ptr)
- break;
- last_bp=op->arg[0];
- }
- }
- return last_bp;
- }
- return NULL;
-}
diff --git a/ext/myjit/myjit/jitlib-core.h b/ext/myjit/myjit/jitlib-core.h
deleted file mode 100755
index 7742eac..0000000
--- a/ext/myjit/myjit/jitlib-core.h
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#ifndef JITLIB_CORE_H
-#define JITLIB_CORE_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "cpu-detect.h"
-#ifndef TARGET_WIN32
-#include <sys/mman.h>
-#endif
-#include <unistd.h>
-#include <string.h>
-#include "jitlib.h"
-#include "llrb.c"
-
-
-#define FR_IMM (jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_IMM, 0))
-#define R_IMM (jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_IMM, 0)) // used by amd64 and sparc
-
-#define GET_OP(op) ((jit_opcode) (op->code & 0xfff8))
-#define GET_OP_SUFFIX(op) (op->code & 0x0007)
-#define IS_IMM(op) (op->code & IMM)
-#define IS_SIGNED(op) (!(op->code & UNSIGNED))
-#define ARG_TYPE(op, arg) (((op)->spec >> ((arg) - 1) * 2) & 0x03)
-
-#define JIT_BUFFER_OFFSET(jit) ((jit_value)jit->ip - (jit_value)jit->buf)
-
-
-#ifndef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#endif
-#ifndef MAX
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-#include "../../../ext/vec/src/vec.h"
-
-
-typedef struct {
- int id;
- char * name;
- char callee_saved;
- char fp;
- short priority;
-} jit_hw_reg;
-
-struct jit_reg_allocator {
- int gp_reg_cnt; // number of general purpose registers
- int fp_reg_cnt; // number of floating-point registers
- int fp_reg; // frame pointer; register used to access the local variables
- int gp_arg_reg_cnt; // number of GP registers used to pass arguments
- int fp_arg_reg_cnt; // number of FP registers used to pass arguments
- jit_hw_reg * ret_reg; // register used to return value
- jit_hw_reg * fpret_reg; // register used to return FP value
-
- jit_hw_reg * gp_regs; // array of available GP registers
- jit_hw_reg * fp_regs; // array of available floating-point registers
- jit_hw_reg ** gp_arg_regs; // array of GP registers used to pass arguments (in the given order)
- jit_hw_reg ** fp_arg_regs; // array of FP registers used to pass arguments (in the given order)
- struct jit_func_info * current_func_info; // information on currently processed function
-};
-
-typedef struct jit_rmap {
- jit_tree * map; // R/B tree which maps virtual registers to hardware registers
-} jit_rmap;
-
-struct jit_allocator_hint {
- int last_pos;
- int should_be_calleesaved;
- int should_be_eax;
- int refs; // counts number of references to the hint
-};
-
-typedef struct jit_prepared_args {
- int count; // number of arguments to prepare
- int ready; // number of arguments that have been prapared
- int gp_args; // number of prepared GP arguments
- int fp_args; // number od prepared FP arguments
- int stack_size; // size of stack occupied by passed arguments
- jit_op * op; // corresponding ``PREPARE'' operation
- struct jit_out_arg {// array of arguments
- union {
- int64_t generic;
- double fp;
- } value;
- int argpos; // position in the list of GP or FP arguments
- char isreg; // argument is given by value of the register (if zero, the immediate value is used)
- char isfp;
- char size;
- } * args;
-} jit_prepared_args;
-
-typedef struct jit_set {
- vec_t(jit_value) vec;
-} jit_set;
-
-struct jit_func_info { // collection of information related to one function
- int general_arg_cnt; // number of non-FP arguments
- int float_arg_cnt; // number of FP arguments
- int64_t allocai_mem; // size of the locally allocated memory
- int arg_capacity; // size of the `args' array
- struct jit_inp_arg {
- enum jit_inp_type type; // type of the argument
- int size; // its size
- char passed_by_reg; // indicates whether the argument was passed by register
- union {
- int reg;
- int stack_pos;
- } location; // location of the value
- int spill_pos; // location of the argument on the stack, if the value was spilled off
- int gp_pos; // position of the argument in the list of GP/FP
- int fp_pos; // position of the argument in the list of GP/FP
- int overflow; // indicates whether one argument overflow into the adjacent register
- int phys_reg;
- } * args; // collection of all arguments
-
- int gp_reg_count; // total number of GP registers used in the processed function
- int fp_reg_count; // total number of FP registers used in the processed function
- int has_prolog; // flag indicating if the function has a complete prologue and epilogue
- struct jit_op *first_op; // first operation of the function
-};
-typedef struct {
- int64_t offset;
- union {
- double val;
- uint64_t hex;
- };
-} jit_flt_rip_relloc;
-typedef vec_t(jit_flt_rip_relloc) vec_jit_flt_rip_relloc_t;
-struct jit {
- unsigned char * buf; // buffer used to store generated code
- unsigned int buf_capacity; // its capacity
-
- unsigned char * ip; // pointer to the buffer
-
- struct jit_op * ops; // list of operations
- struct jit_op * last_op; // last operation
- struct jit_reg_allocator * reg_al; // register allocatot
- struct jit_op * current_func; // pointer to the PROLOG operation of the currently processed function
- jit_label * labels; // list of labels used in the c
- jit_prepared_args prepared_args; // list of arguments passed between PREPARE-CALL
- int push_count; // number of values pushed on the stack; used by AMD64
- unsigned int optimizations;
- int64_t bin_size;
- vec_jit_flt_rip_relloc_t flt_rellocs;
-};
-
-struct jit_debug_info {
- const char *filename;
- const char *function;
- int lineno;
- int warnings;
-};
-
-//void jit_get_reg_name(char * r, int reg);
-void jit_patch_external_calls(struct jit * jit);
-void jit_patch_local_addrs(struct jit *jit);
-
-void jit_collect_statistics(struct jit * jit);
-
-void jit_optimize_st_ops(struct jit * jit);
-int jit_optimize_join_addmul(struct jit * jit);
-int jit_optimize_join_addimm(struct jit * jit);
-void jit_optimize_frame_ptr(struct jit * jit);
-void jit_optimize_unused_assignments(struct jit * jit);
-static int is_cond_branch_op(jit_op *op); // FIXME: rename to: jit_op_is_cond_branch
-static inline void jit_set_free(jit_set * s);
-
-/**
- * Initialize argpos-th argument.
- * phys_reg indicates how many actual registers have been already used to pass
- * the arguments. This is used to correctly pass arguments which occupies two
- * or more registers
- */
-void jit_init_arg_params(struct jit * jit, struct jit_func_info * info, int argpos, int * phys_reg);
-
-/* FIXME: presunout do generic-reg-allocator.h */
-void jit_assign_regs(struct jit * jit);
-struct jit_reg_allocator * jit_reg_allocator_create();
-void jit_reg_allocator_free(struct jit_reg_allocator * a);
-void jit_gen_op(struct jit * jit, jit_op * op);
-char * jit_reg_allocator_get_hwreg_name(struct jit_reg_allocator * al, int reg);
-int jit_reg_in_use(jit_op * op, int reg, int fp);
-jit_hw_reg * jit_get_unused_reg(struct jit_reg_allocator * al, jit_op * op, int fp);
-void rmap_free(jit_rmap * regmap);
-void jit_allocator_hints_free(jit_tree *);
-
-
-static struct jit_op * jit_op_new(unsigned short code, unsigned char spec, int64_t arg1, int64_t arg2, int64_t arg3, unsigned char arg_size)
-{
- struct jit_op * r = JIT_MALLOC(sizeof(struct jit_op));
- r->code = code;
- r->spec = spec;
- r->fp = 0;
-
- r->arg[0] = arg1;
- r->arg[1] = arg2;
- r->arg[2] = arg3;
-
- r->r_arg[0] = -1;
- r->r_arg[1] = -1;
- r->r_arg[2] = -1;
-
- r->assigned = 0;
- r->arg_size = arg_size;
- r->next = NULL;
- r->prev = NULL;
- r->patch_addr = 0;
- r->jmp_addr = NULL;
- r->regmap = NULL;
- r->live_in = NULL;
- r->live_out = NULL;
- r->allocator_hints = NULL;
- r->debug_info = NULL;
- return r;
-}
-
-static inline void jit_op_append(jit_op * op, jit_op * appended)
-{
- appended->next = op->next;
- if (op->next != NULL) op->next->prev = appended;
- appended->prev = op;
- op->next = appended;
-}
-
-static inline void jit_op_prepend(jit_op * op, jit_op * prepended)
-{
- prepended->prev = op->prev;
- if (op->prev != NULL) op->prev->next = prepended;
- prepended->next = op;
- op->prev = prepended;
-}
-
-static inline jit_op * jit_op_first(jit_op * op)
-{
- while (op->prev != NULL) op = op->prev;
- return op;
-}
-
-static inline jit_op * jit_op_last(jit_op * op)
-{
- while (op->next != NULL) op = op->next;
- return op;
-}
-
-static inline void jit_free_op(struct jit_op *op)
-{
- if (op->live_in) jit_set_free(op->live_in);
- if (op->live_out) jit_set_free(op->live_out);
- rmap_free(op->regmap);
- jit_allocator_hints_free(op->allocator_hints);
- if (op->debug_info) JIT_FREE(op->debug_info);
-
- if (GET_OP(op) == JIT_PROLOG) {
- struct jit_func_info * info = (struct jit_func_info *)op->arg[1];
- JIT_FREE(info->args);
- JIT_FREE(info);
- }
- jit_op *prev=op->prev,*next=op->next;
- if(prev) prev->next=next;
- if(next) next->prev=prev;
- JIT_FREE(op);
-}
-
-static inline void jit_op_delete(jit_op *op)
-{
- op->prev->next = op->next;
- if (op->next) op->next->prev = op->prev;
- jit_free_op(op);
-}
-
-static inline int jit_is_label(struct jit * jit, void * ptr)
-{
- jit_label * lab = jit->labels;
- while (1) {
- if (lab == NULL) return 0;
- if (lab == ptr) return 1;
- lab = lab->next;
- }
-}
-
-static inline struct jit_func_info * jit_current_func_info(struct jit * jit)
-{
- return (struct jit_func_info *)(jit->current_func->arg[1]);
-}
-
-static inline void funcall_prepare(struct jit * jit, jit_op * op, int count)
-{
- jit->prepared_args.args = JIT_MALLOC(sizeof(struct jit_out_arg) * count);
- jit->prepared_args.count = count;
- jit->prepared_args.ready = 0;
- jit->prepared_args.stack_size = 0;
- jit->prepared_args.op = op;
- jit->prepared_args.gp_args = 0;
- jit->prepared_args.fp_args = 0;
-}
-
-static inline void funcall_put_arg(struct jit * jit, jit_op * op)
-{
- int pos = jit->prepared_args.ready;
- struct jit_out_arg * arg = &(jit->prepared_args.args[pos]);
- arg->isreg = !IS_IMM(op);
- arg->isfp = 0;
- arg->value.generic = op->arg[0];
- #ifndef TARGET_WIN32
- arg->argpos = jit->prepared_args.gp_args++;
- #else
- arg->argpos =pos;
- jit->prepared_args.gp_args++;
- #endif
- jit->prepared_args.ready++;
-
- if (jit->prepared_args.ready > jit->reg_al->gp_arg_reg_cnt)
- jit->prepared_args.stack_size += REG_SIZE;
-}
-
-static inline void funcall_fput_arg(struct jit * jit, jit_op * op)
-{
- int pos = jit->prepared_args.ready;
- struct jit_out_arg * arg = &(jit->prepared_args.args[pos]);
- arg->isreg = !IS_IMM(op);
- arg->isfp = 1;
- arg->size = op->arg_size;
- #ifndef TARGET_WIN32
- arg->argpos = jit->prepared_args.fp_args++;
- #else
- arg->argpos =pos;
- jit->prepared_args.fp_args++;
- #endif
- if (IS_IMM(op)) arg->value.fp = op->flt_imm;
- else arg->value.generic = op->arg[0];
- jit->prepared_args.ready++;
-
- if (jit->prepared_args.ready > jit->reg_al->fp_arg_reg_cnt) {
-#ifdef JIT_ARCH_AMD64
- jit->prepared_args.stack_size += REG_SIZE;
-#else
- jit->prepared_args.stack_size += op->arg_size;
-#endif
- }
-}
-
-/**
- * Returns number which is a multiple of the alignment and is the closest
- * greater value than @param value
- */
-static inline jit_value jit_value_align(jit_value value, jit_value alignment)
-{
- return (value + (alignment - 1)) & (- alignment);
-}
-#endif
diff --git a/ext/myjit/myjit/jitlib-debug.c b/ext/myjit/myjit/jitlib-debug.c
deleted file mode 100755
index 7381b0e..0000000
--- a/ext/myjit/myjit/jitlib-debug.c
+++ /dev/null
@@ -1,694 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <unistd.h>
-#include "cpu-detect.h"
-#ifndef TARGET_WIN32
-#include <sys/types.h>
-#include <sys/wait.h>
-#endif
-
-
-#define ABS(x) ((x) < 0 ? - (x) : x)
-
-#include "llrb.c"
-
-#define OUTPUT_BUF_SIZE (8192)
-#define print_padding(buf, size) while (strlen((buf)) < (size)) { strcat((buf), " "); }
-
-static jit_hw_reg * rmap_is_associated(jit_rmap * rmap, int reg_id, int fp, jit_value * virt_reg);
-
-static inline int bufprint(char *buf, const char *format, ...) {
- va_list ap;
- va_start(ap, format);
- int result = vsprintf(buf + strlen(buf), format, ap);
- va_end(ap);
- return result;
-}
-
-static void compiler_based_debugger(struct jit * jit)
-{
- char obj_file_name[] = "myjitXXXXXX";
- int obj_file_fd = mkstemp(obj_file_name);
-
-
-#ifndef __APPLE_CC__
- char * cmd1_fmt = "gcc -x assembler -c -o %s -";
- char * cmd2_fmt = "objdump -d -M intel %s";
-#else
- char * cmd1_fmt = "cc -x assembler -c -o %s -";
- char * cmd2_fmt = "otool -tvVj %s";
-#endif
-
- char cmd1[strlen(cmd1_fmt) + strlen(obj_file_name) + 1];
- char cmd2[strlen(cmd2_fmt) + strlen(obj_file_name) + 1];
-
- sprintf(cmd1, cmd1_fmt, obj_file_name);
-
- FILE * f = popen(cmd1, "w");
-
- int size = jit->ip - jit->buf;
-#ifndef __APPLE_CC__
- fprintf (f, ".text\n.align 4\n.globl main\n.type main,@function\nmain:\n");
- for (int i = 0; i < size; i++)
- fprintf(f, ".byte %d\n", (unsigned int) jit->buf[i]);
-#else
-// clang & OS X
- fprintf (f, ".text\n.align 4\n.globl main\n\nmain:\n");
- for (int i = 0; i < size; i++)
- fprintf(f, ".byte 0x%x\n", (unsigned int) jit->buf[i]);
-#endif
- pclose(f);
-
-
- sprintf(cmd2, cmd2_fmt, obj_file_name);
- system(cmd2);
-
- close(obj_file_fd);
- unlink(obj_file_name);
-}
-
-typedef struct jit_disasm {
- char *indent_template;
- char *reg_template;
- char *freg_template;
- char *arg_template;
- char *farg_template;
- char *reg_fp_template;
- char *reg_out_template;
- char *reg_imm_template;
- char *reg_fimm_template;
- char *reg_unknown_template;
- char *label_template;
- char *label_forward_template;
- char *generic_addr_template;
- char *generic_value_template;
-} jit_disasm;
-
-struct jit_disasm jit_disasm_general = {
- .indent_template = " ",
- .reg_template = "r%i<%i>",
- .freg_template = "fr%i<%i>",
- .arg_template = "arg%i",
- .farg_template = "farg%i",
- .reg_out_template = "out",
- .reg_fp_template = "fp",
- .reg_imm_template = "imm",
- .reg_fimm_template = "fimm",
- .reg_unknown_template = "(unknown reg.)",
- .label_template = "L%i",
- .label_forward_template = "L%i",
- .generic_addr_template = "<addr: 0x%lx>",
- .generic_value_template = "0x%lx",
-};
-
-struct jit_disasm jit_disasm_compilable = {
- .indent_template = " ",
- .reg_template = "R(%i)<%i>",
- .freg_template = "FR(%i)<%i>",
- .arg_template = "arg(%i)",
- .farg_template = "farg(%i)",
- .reg_fp_template = "R_FP",
- .reg_out_template = "R_OUT",
- .reg_imm_template = "R_IMM",
- .reg_fimm_template = "FR_IMM",
- .reg_unknown_template = "(unknown reg.)",
- .label_template = "label_%03i",
- .label_forward_template = "/* label_%03i */ JIT_FORWARD",
- .generic_addr_template = "<addr: 0x%lx>",
- .generic_value_template = "%li",
-};
-
-
-
-char * jit_get_op_name(struct jit_op * op)
-{
- switch (GET_OP(op)) {
- case JIT_MOV: return "mov";
- case JIT_LD: return "ld";
- case JIT_LDX: return "ldx";
- case JIT_ST: return "st";
- case JIT_STX: return "stx";
-
- case JIT_JMP: return "jmp";
- case JIT_PATCH: return ".patch";
- case JIT_PREPARE: return "prepare";
- case JIT_PUTARG: return "putarg";
- case JIT_CALL: return "call";
- case JIT_RET: return "ret";
- case JIT_PROLOG: return "prolog";
- case JIT_GETARG: return "getarg";
- case JIT_RETVAL: return "retval";
- case JIT_ALLOCA: return "alloca";
- case JIT_DECL_ARG: return "declare_arg";
-
- case JIT_ADD: return "add";
- case JIT_ADDC: return "addc";
- case JIT_ADDX: return "addx";
- case JIT_SUB: return "sub";
- case JIT_SUBC: return "subc";
- case JIT_SUBX: return "subx";
- case JIT_RSB: return "rsb";
- case JIT_NEG: return "neg";
- case JIT_MUL: return "mul";
- case JIT_HMUL: return "hmul";
- case JIT_DIV: return "div";
- case JIT_MOD: return "mod";
-
- case JIT_OR: return "or";
- case JIT_XOR: return "xor";
- case JIT_AND: return "and";
- case JIT_LSH: return "lsh";
- case JIT_RSH: return "rsh";
- case JIT_NOT: return "not";
-
- case JIT_LT: return "lt";
- case JIT_LE: return "le";
- case JIT_GT: return "gt";
- case JIT_GE: return "ge";
- case JIT_EQ: return "eq";
- case JIT_NE: return "ne";
-
- case JIT_BLT: return "blt";
- case JIT_BLE: return "ble";
- case JIT_BGT: return "bgt";
- case JIT_BGE: return "bge";
- case JIT_BEQ: return "beq";
- case JIT_BNE: return "bne";
- case JIT_BMS: return "bms";
- case JIT_BMC: return "bmc";
- case JIT_BOADD: return "boadd";
- case JIT_BOSUB: return "bosub";
- case JIT_BNOADD:return "bnoadd";
- case JIT_BNOSUB:return "bnosub";
-
- case JIT_UREG: return ".ureg";
- case JIT_LREG: return ".lreg";
- case JIT_CODESTART: return ".code";
- case JIT_LABEL: return ".label";
- case JIT_SYNCREG: return ".syncreg";
- case JIT_RENAMEREG: return ".renamereg";
- case JIT_MSG: return "msg";
- case JIT_COMMENT: return ".comment";
- case JIT_NOP: return "nop";
- case JIT_CODE_ALIGN: return ".align";
- case JIT_DATA_BYTE: return ".byte";
- case JIT_DATA_REF_CODE: return ".ref_code";
- case JIT_DATA_REF_DATA: return ".ref_data";
- case JIT_DATA_CODE_OFFSET: return "code_offset";
- case JIT_CODE_ALIGN_FILL: return "align_fill";
- case JIT_DUMP_PTR: return "dump_ptr";
- case JIT_TAINT_LABEL:return "taint_label";
- case JIT_END_ASM_BLK:return "end_asm_blk";
- case JIT_REF_CODE: return "ref_code";
- case JIT_RELOCATION: return "relocation";
- case JIT_REF_DATA: return "ref_data";
- case JIT_FULL_SPILL: return ".full_spill";
- case JIT_FORCE_SPILL: return "force_spill";
- case JIT_FORCE_ASSOC: return "force_assoc";
-
- case JIT_FMOV: return "fmov";
- case JIT_FADD: return "fadd";
- case JIT_FSUB: return "fsub";
- case JIT_FRSB: return "frsb";
- case JIT_FMUL: return "fmul";
- case JIT_FDIV: return "fdiv";
- case JIT_FNEG: return "fneg";
- case JIT_FRETVAL: return "fretval";
- case JIT_FPUTARG: return "fputarg";
-
- case JIT_EXT: return "ext";
- case JIT_ROUND: return "round";
- case JIT_TRUNC: return "trunc";
- case JIT_FLOOR: return "floor";
- case JIT_CEIL: return "ceil";
-
- case JIT_FBLT: return "fblt";
- case JIT_FBLE: return "fble";
- case JIT_FBGT: return "fbgt";
- case JIT_FBGE: return "fbge";
- case JIT_FBEQ: return "fbeq";
- case JIT_FBNE: return "fbne";
-
- case JIT_FLD: return "fld";
- case JIT_FLDX: return "fldx";
- case JIT_FST: return "fst";
- case JIT_FSTX: return "fstx";
-
- case JIT_FRET: return "fret";
- default: return "(unknown)";
- }
-}
-
-void jit_get_reg_name(struct jit_disasm *disasm, char * r, int reg)
-{
- if (reg == R_FP) strcpy(r, disasm->reg_fp_template);
- else if (reg == R_OUT) strcpy(r, disasm->reg_out_template);
- else if (reg == R_IMM) strcpy(r, disasm->reg_imm_template);
- else if (reg == FR_IMM) strcpy(r, disasm->reg_fimm_template);
- else {
- if (JIT_REG(reg).spec == JIT_RTYPE_REG) {
- if (JIT_REG(reg).type == JIT_RTYPE_INT) sprintf(r, disasm->reg_template, JIT_REG(reg).id,JIT_REG(reg).ssa);
- else sprintf(r, disasm->freg_template, JIT_REG(reg).id,JIT_REG(reg).ssa);
- }
- else if (JIT_REG(reg).spec == JIT_RTYPE_ARG) {
- if (JIT_REG(reg).type == JIT_RTYPE_INT) sprintf(r, disasm->arg_template, JIT_REG(reg).id,JIT_REG(reg).ssa);
- else sprintf(r, disasm->farg_template, JIT_REG(reg).id,JIT_REG(reg).ssa);
- } else sprintf(r, "%s", disasm->reg_unknown_template);
- }
-}
-
-static void print_rmap_callback(jit_tree_key key, jit_tree_value value, void *disasm)
-{
- char buf[256];
- jit_get_reg_name((struct jit_disasm *)disasm, buf, key);
- printf("%s=%s ", buf, ((jit_hw_reg *)value)->name);
-}
-
-static void print_reg_liveness_callback(jit_tree_key key, jit_tree_value value, void *disasm)
-{
- char buf[256];
- jit_get_reg_name(disasm, buf, key);
- printf("%s ", buf);
-}
-
-#define print_rmap(disasm, n) jit_tree_walk(n, print_rmap_callback, disasm)
-#define print_reg_liveness(disasm, n) {long iter;jit_value r;vec_foreach(&(n)->vec,r,iter) {char buf[256];jit_get_reg_name(disasm, buf, r);printf("%s ", buf);}}
-
-
-static inline int jit_op_is_cflow(jit_op * op)
-{
- if (((GET_OP(op) == JIT_CALL) || (GET_OP(op) == JIT_JMP)||GET_OP(op)==JIT_TAINT_LABEL) && (IS_IMM(op))) return 1;
- if (is_cond_branch_op(op)) return 1;
-
- return 0;
-}
-
-static jit_tree * prepare_labels(struct jit * jit)
-{
- jit_value x = 1;
- jit_tree * n = NULL;
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if (GET_OP(op) == JIT_PATCH) {
- n = jit_tree_insert(n, (jit_value) op, (void *)x, NULL);
- n = jit_tree_insert(n, op->arg[0], (void *) -x, NULL);
- x++;
- }
- if (GET_OP(op) == JIT_LABEL) {
- n = jit_tree_insert(n, op->arg[0], (void *)x, NULL);
- x++;
- }
- }
- return n;
-}
-
-static inline void print_addr(struct jit_disasm *disasm, char *buf, jit_tree *labels, jit_op *op, int arg_pos)
-{
- void *arg = (void *)op->arg[arg_pos];
-
- jit_tree *label_item = jit_tree_search(labels, (jit_value) op);
- if (label_item) bufprint(buf, disasm->label_forward_template, - (jit_value) label_item->value);
- else {
- label_item = jit_tree_search(labels, (jit_value) arg);
- if (label_item) bufprint(buf, disasm->label_template, (jit_value) label_item->value);
- else bufprint(buf, disasm->generic_addr_template, arg);
- }
-}
-
-static inline void print_arg(struct jit_disasm *disasm, char * buf, struct jit_op * op, int arg)
-{
- int64_t a = op->arg[arg - 1];
- if (ARG_TYPE(op, arg) == IMM) bufprint(buf, disasm->generic_value_template, a);
- if ((ARG_TYPE(op, arg) == REG) || (ARG_TYPE(op, arg) == TREG)) {
- char value[256];
- jit_get_reg_name(disasm, value, a);
- strcat(buf, value);
- }
-}
-
-static inline void print_str(char * buf, char * str)
-{
- strcat(buf, " \"");
- for (int i = 0; i < strlen(str); i++) {
- if (str[i] >= 32) {
- int s = strlen(buf);
- buf[s++] = str[i];
- buf[s] = '\0';
- } else {
- char xbuf[16];
- switch (str[i]) {
- case 9: strcpy(xbuf, "\\t"); break;
- case 10: strcpy(xbuf, "\\n"); break;
- case 13: strcpy(xbuf, "\\r"); break;
- default: sprintf(xbuf, "\\x%02x", str[i]);
- }
- strcat(buf, xbuf);
- }
- }
- strcat(buf, "\"");
-}
-
-static void print_args(struct jit_disasm *disasm, char *linebuf, jit_op *op, jit_tree *labels)
-{
- for (int i = 1; i <= 3; i++) {
- if (ARG_TYPE(op, i) == NO) continue;
- strcat(linebuf, i == 1 ? " " : ", ");
- if ((i == 1) && jit_op_is_cflow(op)) print_addr(disasm, linebuf, labels, op, 0);
- else print_arg(disasm, linebuf, op, i);
- }
-}
-
-void print_full_op_name(char *linebuf, jit_op *op)
-{
- char *op_name = jit_get_op_name(op);
- strcat(linebuf, op_name);
- if ((GET_OP(op) == JIT_CALL) && (GET_OP_SUFFIX(op) & IMM)) return;
- if (GET_OP_SUFFIX(op) & IMM) strcat(linebuf, "i");
- if (GET_OP_SUFFIX(op) & REG) strcat(linebuf, "r");
- if (GET_OP_SUFFIX(op) & UNSIGNED) strcat(linebuf, "_u");
-}
-
-static int print_load_op(struct jit_disasm *disasm, char *linebuf, jit_op *op)
-{
-
- switch (GET_OP(op)) {
- case JIT_LREG:
- strcat(linebuf, disasm->indent_template);
- strcat(linebuf, jit_get_op_name(op));
- print_padding(linebuf, 13);
- jit_get_reg_name(disasm, linebuf + strlen(linebuf), op->arg[1]);
- return 1;
- case JIT_UREG:
- case JIT_SYNCREG:
- strcat(linebuf, disasm->indent_template);
- strcat(linebuf, jit_get_op_name(op));
- print_padding(linebuf, 13);
- jit_get_reg_name(disasm, linebuf + strlen(linebuf), op->arg[0]);
- return 1;
- case JIT_RENAMEREG: {
- jit_value reg;
- rmap_is_associated(op->prev->regmap, op->arg[1], 0, &reg);
- strcat(linebuf, disasm->indent_template);
- strcat(linebuf, jit_get_op_name(op));
- strcat(linebuf, " ");
- print_padding(linebuf, 13);
- jit_get_reg_name(disasm, linebuf + strlen(linebuf), reg);
- return 1;
- }
- case JIT_FULL_SPILL:
- strcat(linebuf, disasm->indent_template);
- strcat(linebuf, jit_get_op_name(op));
- return 1;
- default:
- return 0;
-
- }
-}
-
-void print_comment(char *linebuf, jit_op *op)
-{
- char *str = (char *)op->arg[0];
- bufprint(linebuf, "// ");
- for (int i = 0; i < strlen(str); i++) {
- if ((str[i] == '\r') || (str[i] == '\n')) bufprint(linebuf, "\n// ");
- else bufprint(linebuf, "%c", str[i]);
- }
-}
-
-
-int print_op(FILE *f, struct jit_disasm * disasm, struct jit_op *op, jit_tree *labels, int verbosity)
-{
- char linebuf[OUTPUT_BUF_SIZE];
- linebuf[0] = '\0';
-
- if ((GET_OP(op) == JIT_LABEL) || (GET_OP(op) == JIT_PATCH)) {
- jit_tree * lab = jit_tree_search(labels, (int64_t)op->arg[0]);
- if (lab) {
- bufprint(linebuf, disasm->label_template, ABS((int64_t)lab->value));
- bufprint(linebuf, ":");
- }
- goto print;
- }
-
- if (GET_OP(op) == JIT_COMMENT) {
- print_comment(linebuf, op);
- goto print;
- }
-
- char * op_name = jit_get_op_name(op);
- if ((op_name[0] == '.') && (verbosity & JIT_DEBUG_LOADS)) {
- if (print_load_op(disasm, linebuf, op)) goto print;
- }
-
- strcat(linebuf, disasm->indent_template);
- if (op_name[0] == '.') {
- switch (GET_OP(op)) {
- case JIT_DATA_BYTE:
- case JIT_CODE_ALIGN:
- bufprint(linebuf, "%s ", op_name);
- print_padding(linebuf, 13);
- bufprint(linebuf, disasm->generic_value_template, op->arg[0]);
- goto print;
- case JIT_DATA_REF_CODE:
- case JIT_DATA_REF_DATA:
- bufprint(linebuf, "%s ", op_name);
- print_padding(linebuf, 13);
- print_addr(disasm, linebuf, labels, op, 0);
- goto print;
- default:
- goto print;
-
- }
- }
- print_full_op_name(linebuf, op);
-
- print_padding(linebuf, 12);
-
- if (op->arg_size == 1) strcat(linebuf, " (byte)");
- if (op->arg_size == 2) strcat(linebuf, " (word)");
- if (op->arg_size == 4) strcat(linebuf, " (dword)");
- if (op->arg_size == 8) strcat(linebuf, " (qword)");
-
- switch (GET_OP(op)) {
- case JIT_PREPARE: break;
- case JIT_MSG:
- print_str(linebuf, (char *)op->arg[0]);
- if (!IS_IMM(op)) strcat(linebuf, ", "), print_arg(disasm, linebuf, op, 2);
- break;
- case JIT_REF_CODE:
- case JIT_REF_DATA:
- strcat(linebuf, " ");
- print_arg(disasm, linebuf, op, 1);
- strcat(linebuf, ", ");
- print_addr(disasm, linebuf, labels, op, 1);
- break;
- case JIT_DECL_ARG:
- switch (op->arg[0]) {
- case JIT_SIGNED_NUM: strcat(linebuf, " integer"); break;
- case JIT_UNSIGNED_NUM: strcat(linebuf, " uns. integer"); break;
- case JIT_FLOAT_NUM: strcat(linebuf, " float"); break;
- case JIT_PTR: strcat(linebuf, " ptr"); break;
- default: assert(0);
- };
- strcat(linebuf, ", ");
- print_arg(disasm, linebuf, op, 2);
- break;
- default:
- print_args(disasm, linebuf, op, labels);
- }
-print:
- fprintf(f, "%s", linebuf);
- return strlen(linebuf);
-}
-
-
-#define OP_ID(op) (((uint64_t) (op)) >> 4)
-
-int print_op_compilable(struct jit_disasm *disasm, struct jit_op * op, jit_tree * labels)
-{
- char linebuf[OUTPUT_BUF_SIZE];
- linebuf[0] = '\0';
-
- jit_tree * lab = jit_tree_search(labels, (int64_t)op);
- if (lab && ((int64_t) lab->value > 0)) {
- bufprint(linebuf, "// ");
- bufprint(linebuf, disasm->label_template, (int64_t)lab->value);
- bufprint(linebuf, ":\n");
- }
-
- if (GET_OP(op) == JIT_COMMENT) {
- print_comment(linebuf, op);
- goto direct_print;
- }
-
-
- strcat(linebuf, disasm->indent_template);
-
- if ((jit_op_is_cflow(op) && ((void *)op->arg[0] == JIT_FORWARD))
- || (GET_OP(op) == JIT_REF_CODE) || (GET_OP(op) == JIT_REF_DATA)
- || (GET_OP(op) == JIT_DATA_REF_CODE) || (GET_OP(op) == JIT_DATA_REF_DATA))
- bufprint(linebuf, "jit_op * op_%li = ", OP_ID(op));
-
- switch (GET_OP(op)) {
- case JIT_LABEL: {
- bufprint(linebuf, "jit_label * ");
-
- jit_tree * lab = jit_tree_search(labels, (int64_t)op->arg[0]);
- if (lab) bufprint(linebuf, disasm->label_template, (int64_t) lab->value);
- bufprint(linebuf, " = jit_get_label(p");
- goto print;
- }
- case JIT_PATCH:
- bufprint(linebuf, "jit_patch (p, op_%li", OP_ID(op->arg[0]));
- goto print;
-
- case JIT_DATA_BYTE:
- bufprint(linebuf, "jit_data_byte(p, ");
- bufprint(linebuf, disasm->generic_value_template, op->arg[0]);
- goto print;
- case JIT_REF_CODE:
- case JIT_REF_DATA:
- bufprint(linebuf, "jit_%s(p, ", jit_get_op_name(op));
- print_arg(disasm, linebuf, op, 1);
- strcat(linebuf, ", ");
- print_addr(disasm, linebuf, labels, op, 1);
- goto print;
- case JIT_DATA_REF_CODE:
- case JIT_DATA_REF_DATA:
- bufprint(linebuf, "jit_data_%s(p, ", jit_get_op_name(op) + 1); // +1 skips leading '.'
- print_addr(disasm, linebuf, labels, op, 0);
- goto print;
- case JIT_CODE_ALIGN:
- bufprint(linebuf, "jit_code_align (p, ");
- bufprint(linebuf, disasm->generic_value_template, op->arg[0]);
- goto print;
- case JIT_PREPARE:
- bufprint(linebuf, "jit_prepare(p");
- goto print;
- default:
- break;
- }
-
- if (jit_get_op_name(op)[0] == '.') goto direct_print;
-
- strcat(linebuf, "jit_");
- print_full_op_name(linebuf, op);
-
- print_padding(linebuf, 15);
-
- strcat(linebuf, "(p,");
-
- switch (GET_OP(op)) {
- case JIT_MSG:
- print_str(linebuf, (char *)op->arg[0]);
- if (!IS_IMM(op)) strcat(linebuf, ", "), print_arg(disasm, linebuf, op, 2);
- break;
- case JIT_DECL_ARG:
- switch (op->arg[0]) {
- case JIT_SIGNED_NUM: strcat(linebuf, "JIT_SIGNED_NUM"); break;
- case JIT_UNSIGNED_NUM: strcat(linebuf, "JIT_UNSIGNED_NUM"); break;
- case JIT_FLOAT_NUM: strcat(linebuf, "JIT_FLOAT_NUM"); break;
- case JIT_PTR: strcat(linebuf, "JIT_PTR"); break;
- default: assert(0);
- };
- strcat(linebuf, ", ");
- print_arg(disasm, linebuf, op, 2);
- break;
- default:
- print_args(disasm, linebuf, op, labels);
- }
-
- if (op->arg_size) bufprint(linebuf, ", %i", op->arg_size);
-
-print:
- strcat(linebuf, ");");
-direct_print:
- printf("%s", linebuf);
- return strlen(linebuf);
-}
-
-static void jit_dump_ops_compilable(struct jit *jit, jit_tree *labels)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- print_op_compilable(&jit_disasm_compilable, op, labels);
- printf("\n");
- }
-}
-
-static void jit_dump_ops_general(struct jit *jit, jit_tree *labels, int verbosity)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- int size = print_op(stdout, &jit_disasm_general, op, labels, verbosity);
-
- if (size == 0) return;
-
- for (; size < 35; size++)
- printf(" ");
-
- if ((verbosity & JIT_DEBUG_LIVENESS) && (op->live_in) && (op->live_out)) {
- printf("In: ");
- print_reg_liveness(&jit_disasm_general, op->live_in);
- printf("\tOut: ");
- print_reg_liveness(&jit_disasm_general, op->live_out);
- }
-
- if ((verbosity & JIT_DEBUG_ASSOC) && (op->regmap)) {
- printf("\tAssoc: ");
- print_rmap(&jit_disasm_general, op->regmap->map);
- }
-
- printf("\n");
- }
-}
-
-static char *platform_id()
-{
-#ifdef JIT_ARCH_AMD64
- return "amd64";
-#elif defined(JIT_ARCH_I386)
- return "i386";
-#else
- return "sparc";
-#endif
-}
-
-static inline void print_op_bytes(FILE *f, struct jit *jit, jit_op *op) {
- for (int i = 0; i < op->code_length; i++)
- fprintf(f, " %02x", jit->buf[op->code_offset + i]);
- fprintf(f, "\n.nl\n");
-}
-void jit_dump_ops(struct jit * jit, int verbosity)
-{
- if(!jit) return;
- if (!(verbosity & (JIT_DEBUG_CODE | JIT_DEBUG_COMPILABLE | JIT_DEBUG_COMBINED)))
- verbosity |= JIT_DEBUG_OPS;
-
- jit_tree * labels = prepare_labels(jit);
- if (verbosity & JIT_DEBUG_OPS) jit_dump_ops_general(jit, labels, verbosity);
- if (verbosity & JIT_DEBUG_CODE) compiler_based_debugger(jit);
- if (verbosity & JIT_DEBUG_COMPILABLE) jit_dump_ops_compilable(jit, labels);
- jit_tree_free(labels);
-}
diff --git a/ext/myjit/myjit/jitlib.h b/ext/myjit/myjit/jitlib.h
deleted file mode 100755
index fb20164..0000000
--- a/ext/myjit/myjit/jitlib.h
+++ /dev/null
@@ -1,712 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#ifndef JITLIB_H
-#define JITLIB_H
-
-#define _XOPEN_SOURCE 600
-
-#include <stdint.h>
-#include <string.h> // FIXME: get rid of memcpy
-#include "cpu-detect.h"
-
-/*
- * Memory management
- */
-#include "../../../alloc.h"
-#ifndef JIT_MALLOC
-#define JIT_MALLOC TD_MALLOC
-#endif
-
-#ifndef JIT_REALLOC
-#define JIT_REALLOC TD_REALLOC
-#endif
-
-#ifndef JIT_FREE
-#define JIT_FREE TD_FREE
-#endif
-
-struct jit_op;
-typedef struct jit_breakpoint_t {
- uint8_t enabled;
- struct jit_op *at;
- int8_t user_data[0];
-} jit_breakpoint_t;
-typedef struct jit_debugger_ctrl {
- //Dont change these
- #define JIT_DBG_STEP 1
- #define JIT_DBG_NEXT 2
- #define JIT_DBG_FIN 3
- int64_t code;
- void *prev_stack_ptr;
- jit_breakpoint_t *last_hit_rip;
-} jit_debugger_ctrl ;
-typedef struct jit_debugger_regs{
- int64_t RAX;
- int64_t RBX;
- int64_t RCX;
- int64_t RDX;
- int64_t RSI;
- int64_t RDI;
- int64_t RSP;
- int64_t RBP;
- int64_t R8;
- int64_t R9;
- int64_t R10;
- int64_t R11;
- int64_t R12;
- int64_t R13;
- int64_t R15;
- double XMM0;
- double XMM1;
- double XMM2;
- double XMM3;
- double XMM4;
- double XMM5;
- double XMM6;
- double XMM7;
- int64_t R14;
-} jit_debugger_regs;
-/*
- * Data structures
- */
-struct jit_tree;
-struct jit_set;
-struct jit_op;
-struct jit_rmap;
-struct jit_debug_info;
-typedef struct jit_op {
- unsigned short code; // operation code
- unsigned char spec; // argument types, e.g REG+REG+IMM
- unsigned char arg_size; // used by ld, st
- unsigned char assigned;
- unsigned char fp; // FP if it's a floating-point operation
- unsigned char in_use; // used be dead-code analyzer
- double flt_imm; // floating point immediate value
- jit_value arg[3]; // arguments passed by user
- jit_value r_arg[3]; // arguments transformed by register allocator
- int64_t patch_addr;
- struct jit_op * jmp_addr;
- struct jit_op * next;
- struct jit_op * prev;
- struct jit_set * live_in;
- struct jit_set * live_out;
- struct jit_set * live_kill;
- long *bi_live_in; //Binary representation for integer registers,first 3 are R_FP,R_OUT,R_IMM
- long *bi_live_out;
- long *bi_live_kill;
- long *bf_live_in; //Binary representation for floating registers,first is FR_IMM
- long *bf_live_out;
- long *bf_live_kill;
- long *b_dominators;
- long inst_idx;
- //Breakpoint pointer for JIT_BREAKPOINT
- void *bp_ptr;
- struct jit_set *outgoing,*incoming;
- struct jit_set *dominators,*ssa_frontiers,*dominates;
- struct jit_set *ssa_cans;
- struct jit_op *idom; //immediate dominator
- struct jit_rmap * regmap; // register mappings
- int normalized_pos; // number of operations from the end of the function
- struct jit_tree * allocator_hints; // reg. allocator to collect statistics on used registers
- struct jit_debug_info *debug_info;
- uint64_t code_offset; // offset in the output buffer
- uint64_t code_length; // offset in the output buffer
- uint64_t flow_analysis_state:3; //Used to detirmine if the item was changed
- uint64_t shadow_flow_analysis_state:3; //Used to detirmine if the item was changed
-} jit_op;
-struct jit;
-jit_breakpoint_t *jit_get_breakpoint_btr_ptr(struct jit *jit,void *at);
-typedef struct jit_label {
- int64_t pos;
- jit_op * op;
- struct jit_label * next;
-} jit_label;
-
-typedef struct {
- unsigned type: 1; // INT / FP
- unsigned spec: 2; // register, alias, immediate, argument's shadow space
- unsigned part: 1; // allows to split one virtual register into two hw. registers (implicitly 0)
- unsigned id: 16;
- unsigned ssa:12; //Single static assignemt
-#ifndef JIT_ARCH_AMD64
-#else
- unsigned reserved: 32;
-#endif
-} jit_reg;
-struct jit;
-int64_t jit_bin_size(struct jit * jit);
-
-/*
- * internal auxiliary functions
- */
-
-// FIXME: replace memcpy with union
-static inline jit_value JIT_REG_TO_JIT_VALUE(jit_reg r)
-{
- jit_value v;
- memcpy(&v, &r, sizeof(jit_reg));
- return v;
-}
-
-static inline jit_reg JIT_REG(jit_value v)
-{
- jit_reg r;
- memcpy(&r, &v, sizeof(jit_value));
- return r;
-}
-
-static inline jit_value jit_mkreg(int type, int spec, int id)
-{
- jit_reg r;
- r.type = type;
- r.spec = spec;
- r.id = id;
- r.part = 0;
- r.ssa=0;
-#ifdef JIT_ARCH_AMD64
- r.reserved = 0;
-#endif
- return JIT_REG_TO_JIT_VALUE(r);
-}
-
-static inline jit_value jit_mkreg_ex(int type, int spec, int id)
-{
- jit_reg r;
- r.type = type;
- r.spec = spec;
- r.id = id;
- r.part = 1;
- r.ssa=0;
-#ifdef JIT_ARCH_AMD64
- r.reserved = 0;
-#endif
- return JIT_REG_TO_JIT_VALUE(r);
-}
-
-
-/*
- * Registers
- */
-
-#define JIT_RTYPE_REG (0)
-#define JIT_RTYPE_IMM (1)
-#define JIT_RTYPE_ALIAS (2)
-#define JIT_RTYPE_ARG (3)
-
-#define JIT_RTYPE_INT (0)
-#define JIT_RTYPE_FLOAT (1)
-
-#define R(x) (jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_REG, (x)))
-#define FR(x) (jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_REG, (x)))
-
-#define R_FP (jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ALIAS, 0))
-#define R_OUT (jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ALIAS, 1))
-
-#define JIT_FORWARD (NULL)
-
-/*
- * Opcodes
- */
-typedef enum {
- JIT_NOP = (0x00 << 3),
- JIT_CODESTART = (0x01 << 3),
- JIT_UREG = (0x02 << 3),
- JIT_LREG = (0x03 << 3),
- JIT_SYNCREG = (0x04 << 3),
- JIT_RENAMEREG = (0x05 << 3),
- JIT_FULL_SPILL = (0x06 << 3),
-
- JIT_PROLOG = (0x10 << 3),
- JIT_LABEL = (0x11 << 3),
- JIT_PATCH = (0x12 << 3),
- JIT_DECL_ARG = (0x13 << 3),
- JIT_ALLOCA = (0x14 << 3),
-
- JIT_MOV = (0x20 << 3),
- JIT_LD = (0x21 << 3),
- JIT_LDX = (0x22 << 3),
- JIT_ST = (0x23 << 3),
- JIT_STX = (0x24 << 3),
-
- JIT_JMP = (0x30 << 3),
- JIT_PREPARE = (0x31 << 3),
- JIT_PUTARG = (0x32 << 3),
- JIT_FPUTARG = (0x33 << 3),
- JIT_CALL = (0x34 << 3),
- JIT_RET = (0x35 << 3),
- JIT_GETARG = (0x36 << 3),
- JIT_RETVAL = (0x37 << 3),
- JIT_FRETVAL = (0x88 << 3),
-
- JIT_ADD = (0x40 << 3),
- JIT_ADDC = (0x41 << 3),
- JIT_ADDX = (0x42 << 3),
- JIT_SUB = (0x43 << 3),
- JIT_SUBC = (0x44 << 3),
- JIT_SUBX = (0x45 << 3),
- JIT_RSB = (0x46 << 3),
- JIT_NEG = (0x47 << 3),
- JIT_MUL = (0x48 << 3),
- JIT_HMUL = (0x49 << 3),
- JIT_DIV = (0x4a << 3),
- JIT_MOD = (0x4b << 3),
-
- JIT_OR = (0x50 << 3),
- JIT_XOR = (0x51 << 3),
- JIT_AND = (0x52 << 3),
- JIT_LSH = (0x53 << 3),
- JIT_RSH = (0x54 << 3),
- JIT_NOT = (0x55 << 3),
-
- JIT_LT = (0x60 << 3),
- JIT_LE = (0x61 << 3),
- JIT_GT = (0x62 << 3),
- JIT_GE = (0x63 << 3),
- JIT_EQ = (0x64 << 3),
- JIT_NE = (0x65 << 3),
-
- JIT_BLT = (0x70 << 3),
- JIT_BLE = (0x71 << 3),
- JIT_BGT = (0x72 << 3),
- JIT_BGE = (0x73 << 3),
- JIT_BEQ = (0x74 << 3),
- JIT_BNE = (0x75 << 3),
- JIT_BMS = (0x76 << 3),
- JIT_BMC = (0x77 << 3),
- JIT_BOADD = (0x78 << 3),
- JIT_BOSUB = (0x79 << 3),
- JIT_BNOADD = (0x7a << 3),
- JIT_BNOSUB = (0x7b << 3),
-
- JIT_FMOV = (0x80 << 3),
- JIT_FADD = (0x81 << 3),
- JIT_FSUB = (0x82 << 3),
- JIT_FRSB = (0x83 << 3),
- JIT_FMUL = (0x84 << 3),
- JIT_FDIV = (0x85 << 3),
- JIT_FNEG = (0x86 << 3),
-
- JIT_EXT = (0x89 << 3),
- JIT_ROUND = (0x8a << 3),
- JIT_TRUNC = (0x8b << 3),
- JIT_FLOOR = (0x8c << 3),
- JIT_CEIL = (0x8d << 3),
-
- JIT_FBLT = (0x90 << 3),
- JIT_FBLE = (0x91 << 3),
- JIT_FBGT = (0x92 << 3),
- JIT_FBGE = (0x93 << 3),
- JIT_FBEQ = (0x94 << 3),
- JIT_FBNE = (0x95 << 3),
-
- JIT_FLD = (0xa0 << 3),
- JIT_FLDX = (0xa1 << 3),
- JIT_FST = (0xa2 << 3),
- JIT_FSTX = (0xa3 << 3),
-
- JIT_FRET = (0xa5 << 3),
-
- JIT_DATA_BYTE = (0xb0 << 3),
- JIT_DATA_REF_CODE = (0xb1 << 3),
- JIT_DATA_REF_DATA = (0xb2 << 3),
- JIT_CODE_ALIGN = (0xb3 << 3),
- JIT_REF_CODE = (0xb4 << 3),
- JIT_REF_DATA = (0xb5 << 3),
- /* (label,offset,none)*/
- JIT_DATA_CODE_OFFSET =(0xb6<<3),
- JIT_CODE_ALIGN_FILL= (0xb7<<3),
- /* This dumps the ptr at arg[0] to the location in code*/
- JIT_DUMP_PTR =(0xb8<<3),
- JIT_TAINT_LABEL =(0xb9<<3), //Marks for fullspill
- JIT_END_ASM_BLK =(0xba<<3), //Says to the allocator we can jump anywhere
- JIT_RELOCATION =(0xbb<<3), //This dumps the ptr to arg[1] and stores in register arg[0]
-
- JIT_MSG = (0xf0 << 3),
- JIT_COMMENT = (0xf1 << 3),
- JIT_BREAKPOINT = (0xf2<<3),
-
- // platform specific opcodes, for optimization purposes only
- JIT_X86_STI = (0x0100 << 3),
- JIT_X86_STXI = (0x0101 << 3),
- JIT_X86_ADDMUL = (0x0102 << 3),
- JIT_X86_ADDIMM = (0x0103 << 3),
-
- // opcodes for testing and debugging purposes only
- JIT_FORCE_SPILL = (0x0200 << 3),
- JIT_FORCE_ASSOC = (0x0201 << 3),
- JIT_FORCE_UNLOAD_ALL=(0x0202<<3),
-} jit_opcode;
-
-enum jit_inp_type {
- JIT_SIGNED_NUM,
- JIT_UNSIGNED_NUM,
- JIT_FLOAT_NUM,
- JIT_PTR
-};
-
-enum jit_warning {
- JIT_WARN_DEAD_CODE = 0x00000001,
- JIT_WARN_OP_WITHOUT_EFFECT = 0x00000002,
- JIT_WARN_INVALID_DATA_SIZE = 0x00000004,
- JIT_WARN_UNINITIALIZED_REG = 0x00000008,
- JIT_WARN_UNALIGNED_CODE = 0x00000010,
- JIT_WARN_INVALID_CODE_REFERENCE = 0x00000020,
- JIT_WARN_INVALID_DATA_REFERENCE = 0x00000040,
- JIT_WARN_MISSING_PATCH = 0x00000080,
- JIT_WARN_REGISTER_TYPE_MISMATCH = 0x00000100,
- JIT_WARN_ALL = 0x7fffffff
-};
-
-
-/*
- * Public interface
- */
-
-#define JIT_DEBUG_OPS (0x01)
-#define JIT_DEBUG_CODE (0x02)
-#define JIT_DEBUG_COMBINED (0x04)
-#define JIT_DEBUG_COMPILABLE (0x08)
-
-
-#define JIT_DEBUG_LOADS (0x100)
-#define JIT_DEBUG_ASSOC (0x200)
-#define JIT_DEBUG_LIVENESS (0x400)
-
-#define JIT_OPT_OMIT_FRAME_PTR (0x01)
-#define JIT_OPT_OMIT_UNUSED_ASSIGNEMENTS (0x02)
-#define JIT_OPT_JOIN_ADDMUL (0x04)
-#define JIT_OPT_ALL (0xff)
-
-struct CFunction;
-struct jit * jit_init();
-struct jit_op * jit_add_op(struct jit * jit, unsigned short code, unsigned char spec, jit_value arg1, jit_value arg2, jit_value arg3, unsigned char arg_sizee, struct jit_debug_info *debug_info);
-struct jit_op * jit_add_fop(struct jit * jit, unsigned short code, unsigned char spec, jit_value arg1, jit_value arg2, jit_value arg3, double flt_imm, unsigned char arg_sizee, struct jit_debug_info *debug_info);
-struct jit_debug_info *jit_debug_info_new(const char *filename, const char *function, int lineno);
-void jit_generate_code(struct jit * jit,struct CFunction *func);
-void jit_free(struct jit * jit);
-
-void jit_dump_ops(struct jit * jit, int verbosity);
-void jit_check_code(struct jit *jit, int warnings);
-
-void jit_enable_optimization(struct jit * jit, int opt);
-void jit_disable_optimization(struct jit * jit, int opt);
-
-#define NO 0x00
-#define REG 0x01
-#define IMM 0x02
-#define TREG 0x03 /* target register */
-#define SPEC(ARG1, ARG2, ARG3) (((ARG3) << 4) | ((ARG2) << 2) | (ARG1))
-#define UNSIGNED 0x04
-#define SIGNED 0x00
-
-jit_op * jit_add_prolog(struct jit *, void *, struct jit_debug_info *);
-jit_label * jit_get_label(struct jit * jit);
-int jit_allocai(struct jit * jit, int size);
-
-#define jit_prolog(jit, _func) jit_add_prolog(jit, _func, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_movr(jit, a, b) jit_add_op(jit, JIT_MOV | REG, SPEC(TREG, REG, NO), a, b, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_movi(jit, a, b) jit_add_op(jit, JIT_MOV | IMM, SPEC(TREG, IMM, NO), a, (jit_value)(b), 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/* functions, call, jumps, etc. */
-
-#define jit_jmpr(jit, a) jit_add_op(jit, JIT_JMP | REG, SPEC(REG, NO, NO), a, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_jmpi(jit, a) jit_add_op(jit, JIT_JMP | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_patch(jit, a) jit_add_op(jit, JIT_PATCH | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_prepare(jit) jit_add_op(jit, JIT_PREPARE, SPEC(IMM, IMM, NO), 0, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_putargr(jit, a) jit_add_op(jit, JIT_PUTARG | REG, SPEC(REG, NO, NO), a, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_putargi(jit, a) jit_add_op(jit, JIT_PUTARG | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_call(jit, a) jit_add_op(jit, JIT_CALL | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_callr(jit, a) jit_add_op(jit, JIT_CALL | REG, SPEC(REG, NO, NO), a, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_declare_arg(jit, a, b) jit_add_op(jit, JIT_DECL_ARG, SPEC(IMM, IMM, NO), a, b, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_retr(jit, a) jit_add_op(jit, JIT_RET | REG, SPEC(REG, NO, NO), a, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_reti(jit, a) jit_add_op(jit, JIT_RET | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_retval(jit, a) jit_add_op(jit, JIT_RETVAL, SPEC(TREG, NO, NO), a, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_getarg(jit, a, b) jit_add_op(jit, JIT_GETARG, SPEC(TREG, IMM, NO), a, (jit_value)(b), 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/* arithmetics */
-
-#define jit_addr(jit, a, b, c) jit_add_op(jit, JIT_ADD | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_addi(jit, a, b, c) jit_add_op(jit, JIT_ADD | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_addcr(jit, a, b, c) jit_add_op(jit, JIT_ADDC | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_addci(jit, a, b, c) jit_add_op(jit, JIT_ADDC | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_addxr(jit, a, b, c) jit_add_op(jit, JIT_ADDX | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_addxi(jit, a, b, c) jit_add_op(jit, JIT_ADDX | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_subr(jit, a, b, c) jit_add_op(jit, JIT_SUB | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_subi(jit, a, b, c) jit_add_op(jit, JIT_SUB | IMM, SPEC(TREG, REG, IMM), a, b, (jit_value)(c), 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_subcr(jit, a, b, c) jit_add_op(jit, JIT_SUBC | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_subci(jit, a, b, c) jit_add_op(jit, JIT_SUBC | IMM, SPEC(TREG, REG, IMM), a, b, (jit_value)(c), 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_subxr(jit, a, b, c) jit_add_op(jit, JIT_SUBX | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_subxi(jit, a, b, c) jit_add_op(jit, JIT_SUBX | IMM, SPEC(TREG, REG, IMM), a, b, (jit_value)(c), 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_rsbr(jit, a, b, c) jit_add_op(jit, JIT_RSB | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_rsbi(jit, a, b, c) jit_add_op(jit, JIT_RSB | IMM, SPEC(TREG, REG, IMM), a, b, (jit_value)(c), 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_negr(jit, a, b) jit_add_op(jit, JIT_NEG, SPEC(TREG, REG, NO), a, b, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_mulr(jit, a, b, c) jit_add_op(jit, JIT_MUL | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_muli(jit, a, b, c) jit_add_op(jit, JIT_MUL | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_mulr_u(jit, a, b, c) jit_add_op(jit, JIT_MUL | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_muli_u(jit, a, b, c) jit_add_op(jit, JIT_MUL | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_hmulr(jit, a, b, c) jit_add_op(jit, JIT_HMUL | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_hmuli(jit, a, b, c) jit_add_op(jit, JIT_HMUL | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_hmulr_u(jit, a, b, c) jit_add_op(jit, JIT_HMUL | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_hmuli_u(jit, a, b, c) jit_add_op(jit, JIT_HMUL | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_divr(jit, a, b, c) jit_add_op(jit, JIT_DIV | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_divi(jit, a, b, c) jit_add_op(jit, JIT_DIV | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_divr_u(jit, a, b, c) jit_add_op(jit, JIT_DIV | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_divi_u(jit, a, b, c) jit_add_op(jit, JIT_DIV | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_modr(jit, a, b, c) jit_add_op(jit, JIT_MOD | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_modi(jit, a, b, c) jit_add_op(jit, JIT_MOD | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_modr_u(jit, a, b, c) jit_add_op(jit, JIT_MOD | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_modi_u(jit, a, b, c) jit_add_op(jit, JIT_MOD | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/* bitwise arithmetics */
-
-#define jit_orr(jit, a, b, c) jit_add_op(jit, JIT_OR | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ori(jit, a, b, c) jit_add_op(jit, JIT_OR | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_xorr(jit, a, b, c) jit_add_op(jit, JIT_XOR | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_xori(jit, a, b, c) jit_add_op(jit, JIT_XOR | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_andr(jit, a, b, c) jit_add_op(jit, JIT_AND | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_andi(jit, a, b, c) jit_add_op(jit, JIT_AND | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_lshr(jit, a, b, c) jit_add_op(jit, JIT_LSH | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_lshi(jit, a, b, c) jit_add_op(jit, JIT_LSH | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_rshr(jit, a, b, c) jit_add_op(jit, JIT_RSH | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_rshi(jit, a, b, c) jit_add_op(jit, JIT_RSH | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_rshr_u(jit, a, b, c) jit_add_op(jit, JIT_RSH | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_rshi_u(jit, a, b, c) jit_add_op(jit, JIT_RSH | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_notr(jit, a, b) jit_add_op(jit, JIT_NOT, SPEC(TREG, REG, NO), a, b, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/* branches */
-
-#define jit_bltr(jit, a, b, c) jit_add_op(jit, JIT_BLT | REG | SIGNED, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_blti(jit, a, b, c) jit_add_op(jit, JIT_BLT | IMM | SIGNED, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bltr_u(jit, a, b, c) jit_add_op(jit, JIT_BLT | REG | UNSIGNED, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_blti_u(jit, a, b, c) jit_add_op(jit, JIT_BLT | IMM | UNSIGNED, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bler(jit, a, b, c) jit_add_op(jit, JIT_BLE | REG | SIGNED, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_blei(jit, a, b, c) jit_add_op(jit, JIT_BLE | IMM | SIGNED, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bler_u(jit, a, b, c) jit_add_op(jit, JIT_BLE | REG | UNSIGNED, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_blei_u(jit, a, b, c) jit_add_op(jit, JIT_BLE | IMM | UNSIGNED, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bgtr(jit, a, b, c) jit_add_op(jit, JIT_BGT | REG | SIGNED, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bgti(jit, a, b, c) jit_add_op(jit, JIT_BGT | IMM | SIGNED, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bgtr_u(jit, a, b, c) jit_add_op(jit, JIT_BGT | REG | UNSIGNED, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bgti_u(jit, a, b, c) jit_add_op(jit, JIT_BGT | IMM | UNSIGNED, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bger(jit, a, b, c) jit_add_op(jit, JIT_BGE | REG | SIGNED, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bgei(jit, a, b, c) jit_add_op(jit, JIT_BGE | IMM | SIGNED, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bger_u(jit, a, b, c) jit_add_op(jit, JIT_BGE | REG | UNSIGNED, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bgei_u(jit, a, b, c) jit_add_op(jit, JIT_BGE | IMM | UNSIGNED, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_beqr(jit, a, b, c) jit_add_op(jit, JIT_BEQ | REG, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_beqi(jit, a, b, c) jit_add_op(jit, JIT_BEQ | IMM, SPEC(IMM, REG, IMM), (jit_value)(a), b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bner(jit, a, b, c) jit_add_op(jit, JIT_BNE | REG, SPEC(IMM, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bnei(jit, a, b, c) jit_add_op(jit, JIT_BNE | IMM, SPEC(IMM, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bmsr(jit, a, b, c) jit_add_op(jit, JIT_BMS | REG, SPEC(IMM, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bmsi(jit, a, b, c) jit_add_op(jit, JIT_BMS | IMM, SPEC(IMM, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bmcr(jit, a, b, c) jit_add_op(jit, JIT_BMC | REG, SPEC(IMM, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bmci(jit, a, b, c) jit_add_op(jit, JIT_BMC | IMM, SPEC(IMM, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_boaddr(jit, a, b, c) jit_add_op(jit, JIT_BOADD | REG | SIGNED, SPEC(IMM, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_boaddi(jit, a, b, c) jit_add_op(jit, JIT_BOADD | IMM | SIGNED, SPEC(IMM, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bosubr(jit, a, b, c) jit_add_op(jit, JIT_BOSUB | REG | SIGNED, SPEC(IMM, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bosubi(jit, a, b, c) jit_add_op(jit, JIT_BOSUB | IMM | SIGNED, SPEC(IMM, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bnoaddr(jit, a, b, c) jit_add_op(jit, JIT_BNOADD | REG | SIGNED, SPEC(IMM, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bnoaddi(jit, a, b, c) jit_add_op(jit, JIT_BNOADD | IMM | SIGNED, SPEC(IMM, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_bnosubr(jit, a, b, c) jit_add_op(jit, JIT_BNOSUB | REG | SIGNED, SPEC(IMM, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_bnosubi(jit, a, b, c) jit_add_op(jit, JIT_BNOSUB | IMM | SIGNED, SPEC(IMM, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/* conditions */
-
-#define jit_ltr(jit, a, b, c) jit_add_op(jit, JIT_LT | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_lti(jit, a, b, c) jit_add_op(jit, JIT_LT | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ltr_u(jit, a, b, c) jit_add_op(jit, JIT_LT | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_lti_u(jit, a, b, c) jit_add_op(jit, JIT_LT | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_ler(jit, a, b, c) jit_add_op(jit, JIT_LE | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_lei(jit, a, b, c) jit_add_op(jit, JIT_LE | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ler_u(jit, a, b, c) jit_add_op(jit, JIT_LE | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_lei_u(jit, a, b, c) jit_add_op(jit, JIT_LE | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_gtr(jit, a, b, c) jit_add_op(jit, JIT_GT | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_gti(jit, a, b, c) jit_add_op(jit, JIT_GT | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_gtr_u(jit, a, b, c) jit_add_op(jit, JIT_GT | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_gti_u(jit, a, b, c) jit_add_op(jit, JIT_GT | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_ger(jit, a, b, c) jit_add_op(jit, JIT_GE | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_gei(jit, a, b, c) jit_add_op(jit, JIT_GE | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ger_u(jit, a, b, c) jit_add_op(jit, JIT_GE | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_gei_u(jit, a, b, c) jit_add_op(jit, JIT_GE | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_eqr(jit, a, b, c) jit_add_op(jit, JIT_EQ | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_eqi(jit, a, b, c) jit_add_op(jit, JIT_EQ | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_ner(jit, a, b, c) jit_add_op(jit, JIT_NE | REG, SPEC(TREG, REG, REG), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_nei(jit, a, b, c) jit_add_op(jit, JIT_NE | IMM, SPEC(TREG, REG, IMM), a, b, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/* memory operations */
-
-#define jit_ldr(jit, a, b, c) jit_add_op(jit, JIT_LD | REG | SIGNED, SPEC(TREG, REG, NO), a, b, 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ldi(jit, a, b, c) jit_add_op(jit, JIT_LD | IMM | SIGNED, SPEC(TREG, IMM, NO), a, (jit_value)(b), 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ldxr(jit, a, b, c, d) jit_add_op(jit, JIT_LDX | REG | SIGNED, SPEC(TREG, REG, REG), a, b, c, d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ldxi(jit, a, b, c, d) jit_add_op(jit, JIT_LDX | IMM | SIGNED, SPEC(TREG, REG, IMM), a, b, (jit_value)(c), d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ldr_u(jit, a, b, c) jit_add_op(jit, JIT_LD | REG | UNSIGNED, SPEC(TREG, REG, NO), a, b, 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ldi_u(jit, a, b, c) jit_add_op(jit, JIT_LD | IMM | UNSIGNED, SPEC(TREG, IMM, NO), a, (jit_value)(b), 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ldxr_u(jit, a, b, c, d) jit_add_op(jit, JIT_LDX | REG | UNSIGNED, SPEC(TREG, REG, REG), a, b, c, d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ldxi_u(jit, a, b, c, d) jit_add_op(jit, JIT_LDX | IMM | UNSIGNED, SPEC(TREG, REG, IMM), a, b, (jit_value)(c), d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-
-#define jit_str(jit, a, b, c) jit_add_op(jit, JIT_ST | REG, SPEC(REG, REG, NO), a, b, 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_sti(jit, a, b, c) jit_add_op(jit, JIT_ST | IMM, SPEC(IMM, REG, NO), (jit_value)(a), b, 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_stxr(jit, a, b, c, d) jit_add_op(jit, JIT_STX | REG, SPEC(REG, REG, REG), a, b, c, d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_stxi(jit, a, b, c, d) jit_add_op(jit, JIT_STX | IMM, SPEC(IMM, REG, REG), (jit_value)(a), b, c, d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/* debugging */
-
-#define jit_msg(jit, a) jit_add_op(jit, JIT_MSG | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_msgr(jit, a, b) jit_add_op(jit, JIT_MSG | REG, SPEC(IMM, REG, NO), (jit_value)(a), b, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_comment(jit, a) jit_add_op(jit, JIT_COMMENT, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_breakpoint(jit, bp,routine,dbg_ctrl) jit_add_op(jit, JIT_BREAKPOINT, SPEC(IMM, IMM, IMM), (jit_value)(bp), (jit_value)(routine),(jit_value)(dbg_ctrl), 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/* FPU */
-
-#define jit_fmovr(jit, a, b) jit_add_fop(jit, JIT_FMOV | REG, SPEC(TREG, REG, NO), a, b, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fmovi(jit, a, b) jit_add_fop(jit, JIT_FMOV | IMM, SPEC(TREG, IMM, NO), a, 0, 0, b, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_faddr(jit, a, b, c) jit_add_fop(jit, JIT_FADD | REG, SPEC(TREG, REG, REG), a, b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_faddi(jit, a, b, c) jit_add_fop(jit, JIT_FADD | IMM, SPEC(TREG, REG, IMM), a, b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fsubr(jit, a, b, c) jit_add_fop(jit, JIT_FSUB | REG, SPEC(TREG, REG, REG), a, b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fsubi(jit, a, b, c) jit_add_fop(jit, JIT_FSUB | IMM, SPEC(TREG, REG, IMM), a, b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_frsbr(jit, a, b, c) jit_add_fop(jit, JIT_FRSB | REG, SPEC(TREG, REG, REG), a, b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_frsbi(jit, a, b, c) jit_add_fop(jit, JIT_FRSB | IMM, SPEC(TREG, REG, IMM), a, b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fmulr(jit, a, b, c) jit_add_fop(jit, JIT_FMUL | REG, SPEC(TREG, REG, REG), a, b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fmuli(jit, a, b, c) jit_add_fop(jit, JIT_FMUL | IMM, SPEC(TREG, REG, IMM), a, b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fdivr(jit, a, b, c) jit_add_fop(jit, JIT_FDIV | REG, SPEC(TREG, REG, REG), a, b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fdivi(jit, a, b, c) jit_add_fop(jit, JIT_FDIV | IMM, SPEC(TREG, REG, IMM), a, b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fnegr(jit, a, b) jit_add_fop(jit, JIT_FNEG | REG, SPEC(TREG, REG, NO), a, b, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_extr(jit, a, b) jit_add_fop(jit, JIT_EXT | REG, SPEC(TREG, REG, NO), a, b, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_truncr(jit, a, b) jit_add_fop(jit, JIT_TRUNC | REG, SPEC(TREG, REG, NO), a, b, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_floorr(jit, a, b) jit_add_fop(jit, JIT_FLOOR | REG, SPEC(TREG, REG, NO), a, b, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ceilr(jit, a, b) jit_add_fop(jit, JIT_CEIL | REG, SPEC(TREG, REG, NO), a, b, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_roundr(jit, a, b) jit_add_fop(jit, JIT_ROUND | REG, SPEC(TREG, REG, NO), a, b, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fbltr(jit, a, b, c) jit_add_fop(jit, JIT_FBLT | REG, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fblti(jit, a, b, c) jit_add_fop(jit, JIT_FBLT | IMM, SPEC(IMM, REG, IMM), (jit_value)(a), b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fbgtr(jit, a, b, c) jit_add_fop(jit, JIT_FBGT | REG, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fbgti(jit, a, b, c) jit_add_fop(jit, JIT_FBGT | IMM, SPEC(IMM, REG, IMM), (jit_value)(a), b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fbler(jit, a, b, c) jit_add_fop(jit, JIT_FBLE | REG, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fblei(jit, a, b, c) jit_add_fop(jit, JIT_FBLE | IMM, SPEC(IMM, REG, IMM), (jit_value)(a), b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fbger(jit, a, b, c) jit_add_fop(jit, JIT_FBGE | REG, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fbgei(jit, a, b, c) jit_add_fop(jit, JIT_FBGE | IMM, SPEC(IMM, REG, IMM), (jit_value)(a), b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fbeqr(jit, a, b, c) jit_add_fop(jit, JIT_FBEQ | REG, SPEC(IMM, REG, REG), (jit_value)(a), b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fbeqi(jit, a, b, c) jit_add_fop(jit, JIT_FBEQ | IMM, SPEC(IMM, REG, IMM), (jit_value)(a), b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fbner(jit, a, b, c) jit_add_fop(jit, JIT_FBNE | REG, SPEC(IMM, REG, REG), a, b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fbnei(jit, a, b, c) jit_add_fop(jit, JIT_FBNE | IMM, SPEC(IMM, REG, IMM), a, b, 0, c, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fstr(jit, a, b, c) jit_add_op(jit, JIT_FST | REG, SPEC(REG, REG, NO), a, b, 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fsti(jit, a, b, c) jit_add_op(jit, JIT_FST | IMM, SPEC(IMM, REG, NO), (jit_value)(a), b, 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fstxr(jit, a, b, c, d) jit_add_op(jit, JIT_FSTX | REG, SPEC(REG, REG, REG), a, b, c, d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fstxi(jit, a, b, c, d) jit_add_op(jit, JIT_FSTX | IMM, SPEC(IMM, REG, REG), (jit_value)(a), b, c, d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fldr(jit, a, b, c) jit_add_op(jit, JIT_FLD | REG, SPEC(TREG, REG, NO), a, b, 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fldi(jit, a, b, c) jit_add_op(jit, JIT_FLD | IMM, SPEC(TREG, IMM, NO), a, (jit_value)(b), 0, c, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fldxr(jit, a, b, c, d) jit_add_op(jit, JIT_FLDX | REG, SPEC(TREG, REG, REG), a, b, c, d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fldxi(jit, a, b, c, d) jit_add_op(jit, JIT_FLDX | IMM, SPEC(TREG, REG, IMM), a, b, (jit_value)(c), d, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fputargr(jit, a, b) jit_add_fop(jit, JIT_FPUTARG | REG, SPEC(REG, NO, NO), (a), 0, 0, 0, (b), jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_fputargi(jit, a, b) jit_add_fop(jit, JIT_FPUTARG | IMM, SPEC(IMM, NO, NO), 0, 0, 0, (a), (b), jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fretr(jit, a, b) jit_add_fop(jit, JIT_FRET | REG, SPEC(REG, NO, NO), a, 0, 0, 0, b, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_freti(jit, a, b) jit_add_fop(jit, JIT_FRET | IMM, SPEC(IMM, NO, NO), 0, 0, 0, a, b, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_fretval(jit, a, b) jit_add_fop(jit, JIT_FRETVAL, SPEC(TREG, NO, NO), a, 0, 0, 0, b, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-/*
- * direct data and code emission
- */
-
-#define jit_ref_code(jit, a, b) jit_add_op(jit, JIT_REF_CODE, SPEC(TREG, IMM, NO), a, (jit_value)(b), 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_ref_data(jit, a, b) jit_add_op(jit, JIT_REF_DATA, SPEC(TREG, IMM, NO), a, (jit_value)(b), 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_taint_label(jit, a) jit_add_op(jit, JIT_TAINT_LABEL, SPEC(IMM, NO, NO), a, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_end_asm_blk(jit) jit_add_op(jit, JIT_END_ASM_BLK, SPEC(NO, NO, NO), 0, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_code_align(jit, a) jit_add_op(jit, JIT_CODE_ALIGN| IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_align_fill(jit, a,fill) jit_add_op(jit, JIT_CODE_ALIGN_FILL| IMM, SPEC(IMM, IMM, NO), (jit_value)(a), (jit_value)fill, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_data_byte(jit, a) jit_add_op(jit, JIT_DATA_BYTE | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_data_str(jit, a) jit_data_bytes(jit, strlen(a) + 1, ((unsigned char *)a))
-
-#define jit_data(jit, a) do { jit_value _x = (jit_value)(a); jit_data_bytes(jit, sizeof(jit_value), (unsigned char*) &_x); } while(0)
-#define jit_data_word(jit, a) do { short _x = (a); jit_data_bytes(jit, 2, (unsigned char*) &_x); } while(0)
-#define jit_data_dword(jit, a) do { int _x = (a); jit_data_bytes(jit, 4, (unsigned char*) &_x); } while(0)
-#define jit_data_qword(jit, a) do { int64_t _x = (a); jit_data_bytes(jit, 8, (unsigned char*) &_x); } while(0)
-#define jit_data_ptr(jit, a) do { void * _x = (void *)(a); jit_data_bytes(jit, sizeof(void *), (unsigned char*) &_x); } while(0)
-#define jit_data_ref_code(jit, a) jit_add_op(jit, JIT_DATA_REF_CODE | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_data_ref_data(jit, a) jit_add_op(jit, JIT_DATA_REF_DATA | IMM, SPEC(IMM, NO, NO), (jit_value)(a), 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_data_code_offset(jit,a,b) jit_add_op(jit, JIT_DATA_CODE_OFFSET, SPEC(IMM, IMM, NO), a, (jit_value)(b), 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_dump_ptr(jit,a) jit_add_op(jit, JIT_DUMP_PTR, SPEC(IMM, NO, NO), (jit_value)a ,0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_relocation(jit,a,b) jit_add_op(jit, JIT_RELOCATION, SPEC(TREG, IMM, NO), (jit_value)a ,(jit_value)b, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-
-#define jit_data_emptyarea(jit, count) \
- do { \
- for (int i = 0; i < count; i++) jit_data_byte(jit, 0x00);\
- } while(0)
-
-#define jit_data_bytes(jit, count, data) \
-do {\
- unsigned char *_data = (unsigned char *) (data);\
- for (int i = 0; i < count; i++, _data++)\
- jit_data_byte(jit, *(_data));\
-} while (0)
-
-/*
- * testing and debugging
- */
-#define jit_force_spill(jit, a) jit_add_fop(jit, JIT_FORCE_SPILL, SPEC(REG, NO, NO), a, 0, 0, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-#define jit_force_assoc(jit, a, b, c) jit_add_fop(jit, JIT_FORCE_ASSOC, SPEC(REG, IMM, NO), a, b, c, 0, 0, jit_debug_info_new(__FILE__, __func__, __LINE__))
-void *jit_debugger_get_reg_ptr(struct jit *jit,jit_debugger_regs *regs,struct jit_op *op,jit_value r);
-/**
- * This grabs a virtual register from a function that is a owns the current function being debugged.
- * It may return NULL if the virtual register isnt available for debugging.
- */
-void *jit_debugger_get_vreg_ptr_from_parent(struct jit *jit,void *fptr,struct jit_op *op,jit_value r);
-#endif
diff --git a/ext/myjit/myjit/llrb.c b/ext/myjit/myjit/llrb.c
deleted file mode 100755
index 70e27cf..0000000
--- a/ext/myjit/myjit/llrb.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#ifndef LLRB_C
-#define LLRB_C
-
-#define RED (1)
-#define BLACK (0)
-
-typedef jit_value jit_tree_key;
-typedef void * jit_tree_value;
-
-typedef struct jit_tree {
- struct jit_tree * left;
- struct jit_tree * right;
- int color;
- jit_tree_key key;
- jit_tree_value value;
-} jit_tree;
-
-
-static inline int is_red(jit_tree * n)
-{
- if (n == NULL) return 0;
- return (n->color == RED);
-}
-
-static inline jit_tree * rotate_left(jit_tree * h)
-{
- jit_tree * x = h->right;
- h->right = x->left;
- x->left = h;
- x->color = x->left->color;
- x->left->color = RED;
- return x;
-}
-
-static inline jit_tree * rotate_right(jit_tree * h)
-{
- jit_tree * x = h->left;
- h->left = x->right;
- x->right = h;
- x->color = x->right->color;
- x->right->color = RED;
- return x;
-}
-
-static inline void color_flip(jit_tree * h)
-{
- h->color = !h->color;
- h->left->color = !h->left->color;
- h->right->color = !h->right->color;
-}
-
-static inline jit_tree * fixup(jit_tree * h)
-{
- if (is_red(h->right)) h = rotate_left(h);
-
- if (is_red(h->left) && (is_red(h->left->left))) {
- h = rotate_right(h);
- color_flip(h);
- }
-
- if (is_red(h->left) && is_red(h->right)) color_flip(h);
-
- return h;
-}
-
-
-
-static inline jit_tree * node_new(jit_tree_key key, jit_tree_value value)
-{
- jit_tree * res = JIT_MALLOC(sizeof(jit_tree));
- res->key = key;
- res->value = value;
- res->color = RED;
- res->left = NULL;
- res->right = NULL;
- return res;
-}
-
-static jit_tree * node_insert(jit_tree * h, jit_tree_key key, jit_tree_value value, int * found)
-{
- if (h == NULL) return node_new(key, value);
- if (is_red(h->left) && is_red(h->right)) color_flip(h);
-
-
- if (h->key == key) {
- h->value = value;
- if (found) *found = 1;
- } else if (h->key > key) h->left = node_insert(h->left, key, value, found);
- else h->right = node_insert(h->right, key, value, found);
-
- //if (is_red(h->right) && !is_red(h->left)) h = rotate_left(h);
- //if (is_red(h->left) && is_red(h->left->left)) h = rotate_right(h);
- ////if (is_red(h->right)/* && !is_red(h->left)*/) h = rotate_left(h);
- //if (is_red(h->right)/* && !is_red(h->left)*/) h = rotate_left(h);
- return fixup(h);
-}
-
-static jit_tree * jit_tree_insert(jit_tree * root, jit_tree_key key, jit_tree_value value, int * found)
-{
- if (found) *found = 0;
- root = node_insert(root, key, value, found);
- root->color = BLACK;
- return root;
-}
-
-
-static jit_tree * jit_tree_search(jit_tree * h, jit_tree_key key)
-{
- if ((h == NULL) || (h->key == key)) return h;
- if (h->key > key) return jit_tree_search(h->left, key);
- return jit_tree_search(h->right, key);
-}
-// delete stuff
-static inline jit_tree * move_red_left(jit_tree * h)
-{
- color_flip(h);
- if (is_red(h->right->left)) {
- h->right = rotate_right(h->right);
- h = rotate_left(h);
- color_flip(h);
- }
- return h;
-}
-
-static inline jit_tree * move_red_right(jit_tree * h)
-{
-// if (!h->left) return h; // workaround not present in the sedgewick's implementation;
- // fixing seg. fault while deleting nodes
- color_flip(h);
- if (is_red(h->left->left)) {
- h = rotate_right(h);
- color_flip(h);
- }
- return h;
-}
-
-static inline jit_tree_key node_min(jit_tree * x)
-{
- if (x->left == NULL) return x->key;
- else return node_min(x->left);
-}
-
-static jit_tree * delete_min(jit_tree * h)
-{
- if (h->left == NULL) {
- JIT_FREE(h);
- return NULL;
- }
-
- if ((!is_red(h->left)) && (!is_red(h->left->left)))
- h = move_red_left(h);
-
- h->left = delete_min(h->left);
-
- return fixup(h);
-}
-
-static jit_tree * delete_node(jit_tree * h, jit_tree_key key, int * found)
-{
- if (h == NULL) {
- if (found) *found = 0;
- return NULL;
- }
-
- if (key < h->key) {
- // XXX: if ((!is_red(h->left)) && (!is_red(h->left->left)))
- if ((!is_red(h->left)) && (h->left) && (!is_red(h->left->left)))
- h = move_red_left(h);
- h->left = delete_node(h->left, key, found);
- } else {
- if (is_red(h->left)) h = rotate_right(h);
- if ((key == h->key) && (h->right == NULL)) {
- JIT_FREE(h);
- if (found) *found = 1;
- return NULL;
- }
-
- // XXX: if (!is_red(h->right) && !is_red(h->right->left)) h = move_red_right(h);
- if (!is_red(h->right) && (h->right) && !is_red(h->right->left)) h = move_red_right(h);
- if (key == h->key) {
- h->value = jit_tree_search(h->right, node_min(h->right))->value;
- h->key = node_min(h->right);
- h->right = delete_min(h->right);
- if (found) *found = 1;
- }
- else h->right = delete_node(h->right, key, found);
- }
- return fixup(h);
-}
-
-static inline jit_tree * jit_tree_delete(jit_tree * root, jit_tree_key key, int * found)
-{
- root = delete_node(root, key, found);
- if (root) root->color = BLACK;
- return root;
-}
-
-
-/////////////////
-
-static inline jit_tree * jit_tree_addall(jit_tree * target, jit_tree * n)
-{
- if (n == NULL) return target;
- target = jit_tree_addall(target, n->left);
- target = jit_tree_insert(target, n->key, n->value, NULL);
- target = jit_tree_addall(target, n->right);
- return target;
-}
-
-static inline jit_tree * jit_tree_clone(jit_tree * root)
-{
- return jit_tree_addall(NULL, root);
-}
-
-/////////////////
-
-static void jit_tree_walk(jit_tree *h, void (*func)(jit_tree_key key, jit_tree_value value, void *thunk), void *thunk)
-{
- if (!h) return;
- jit_tree_walk(h->left, func, thunk);
- func(h->key, h->value, thunk);
- jit_tree_walk(h->right, func, thunk);
-}
-
-static inline void jit_print_tree(jit_tree * h, int level)
-{
- if (h == NULL) return;
- for (int i = 0; i < level; i++)
- printf(" ");
-
- printf("%i:%li\n", (int)h->key, (int64_t)h->value);
- jit_print_tree(h->left, level + 1);
- jit_print_tree(h->right, level + 1);
-}
-
-static void jit_tree_free(jit_tree * h)
-{
- if (h == NULL) return;
- jit_tree_free(h->left);
- jit_tree_free(h->right);
- JIT_FREE(h);
-}
-
-static int jit_tree_subset(jit_tree * root, jit_tree * n)
-{
- if (n == NULL) return 1;
- return jit_tree_search(root, n->key) && jit_tree_subset(root, n->left) && jit_tree_subset(root, n->right);
-}
-
-static int jit_tree_equal(jit_tree * r1, jit_tree * r2)
-{
- return jit_tree_subset(r1, r2) && jit_tree_subset(r2, r1);
-}
-
-#endif
diff --git a/ext/myjit/myjit/reg-allocator.h b/ext/myjit/myjit/reg-allocator.h
deleted file mode 100755
index 25c7c80..0000000
--- a/ext/myjit/myjit/reg-allocator.h
+++ /dev/null
@@ -1,680 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2011, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <string.h>
-
-//
-// Auxiliary functions which are used to insert operations
-// moving values from/to registers
-//
-
-/**
- * Prepends given LREG/UREG/etc. operation before `op' operation
- */
-static void insert_reg_op(int opcode, jit_op * op, jit_value r1, jit_value r2)
-{
- jit_op * o = jit_op_new(opcode, SPEC(IMM, IMM, NO), r1, r2, 0, 0);
- o->r_arg[0] = o->arg[0];
- o->r_arg[1] = o->arg[1];
- jit_op_prepend(op, o);
-}
-static void unload_reg(jit_op * op, jit_hw_reg * hreg, jit_value virt_reg)
-{
- insert_reg_op(JIT_UREG, op, virt_reg, hreg->id);
-}
-
-static void sync_reg(jit_op * op, jit_hw_reg * hreg, jit_value virt_reg)
-{
- insert_reg_op(JIT_SYNCREG, op, virt_reg, hreg->id);
-}
-
-static void load_reg(jit_op * op, jit_hw_reg * hreg, jit_value reg)
-{
- insert_reg_op(JIT_LREG, op, hreg->id, reg);
-}
-
-/**
- * Renames register (actually, it assigns value from r2 to r1)
- */
-static void rename_reg(jit_op * op, int r1, int r2)
-{
- insert_reg_op(JIT_RENAMEREG, op, r1, r2);
-}
-
-static jit_hw_reg * make_free_reg(struct jit_reg_allocator * al, jit_op * op, jit_value for_reg)
-{
- int spill = 0;
- jit_value spill_candidate = -1;
- jit_hw_reg * hreg = rmap_spill_candidate(al, op, for_reg, &spill, &spill_candidate, 0);
-
- if (spill) {
- if (jit_set_get(op->live_in, spill_candidate))
- unload_reg(op, hreg, spill_candidate);
- rmap_unassoc(op->regmap, spill_candidate);
- }
- return hreg;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-#ifdef JIT_ARCH_COMMON86
-/**
- * Assigns registers which are used to pass arguments
- */
-static void assign_regs_for_args(struct jit_reg_allocator * al, jit_op * op)
-{
- struct jit_func_info * info = (struct jit_func_info *) op->arg[1];
- #ifndef TARGET_WIN32
- int assoc_gp_regs = 0;
- int assoc_fp_regs = 0;
- for (int i = 0; i < info->general_arg_cnt + info->float_arg_cnt; i++) {
- int isfp_arg = (info->args[i].type == JIT_FLOAT_NUM);
- if (!isfp_arg && (assoc_gp_regs < al->gp_arg_reg_cnt)) {
- rmap_assoc(op->regmap, jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, i), al->gp_arg_regs[assoc_gp_regs]);
- assoc_gp_regs++;
- }
- if (isfp_arg && (assoc_fp_regs < al->fp_arg_reg_cnt)) {
- rmap_assoc(op->regmap, jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, i), al->fp_arg_regs[assoc_fp_regs]);
- assoc_fp_regs++;
- }
- }
- #else
- int assoc_gp_regs = 0;
- int assoc_fp_regs = 0;
- for (int i = 0; i < info->general_arg_cnt + info->float_arg_cnt; i++) {
- int isfp_arg = (info->args[i].type == JIT_FLOAT_NUM);
- if (!isfp_arg && (assoc_gp_regs+assoc_fp_regs < 4)) {
- rmap_assoc(op->regmap, jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, i), al->gp_arg_regs[i]);
- assoc_gp_regs++;
- }
- if (isfp_arg && (assoc_gp_regs+assoc_fp_regs < 4)) {
- rmap_assoc(op->regmap, jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, i), al->fp_arg_regs[i]);
- assoc_fp_regs++;
- }
- }
- #endif
-}
-#endif
-
-#ifdef JIT_ARCH_SPARC
-/**
- * Assigns registers which are used to pass arguments
- *
- * This function has to consider that SPARC is using GPR to pass
- * FP values. Doubles are passed using two GPR's
- */
-static void assign_regs_for_args(struct jit_reg_allocator * al, jit_op * op)
-{
- // counts howmany registers are really used to pass FP arguments
- int fp_arg_cnt = 0;
- struct jit_func_info * info = (struct jit_func_info *) op->arg[1];
- for (int i = 0; i < info->general_arg_cnt + info->float_arg_cnt; i++) {
- struct jit_inp_arg a = info->args[i];
- if (a.type == JIT_FLOAT_NUM) fp_arg_cnt += a.size / sizeof(float);
- }
-
- int assoc_gp_regs = 0;
- for (int i = 0; i < info->general_arg_cnt + info->float_arg_cnt; i++) {
- if (assoc_gp_regs >= al->gp_arg_reg_cnt) break;
- int isfp_arg = (info->args[i].type == JIT_FLOAT_NUM);
-
- if (!isfp_arg) {
- rmap_assoc(op->regmap, jit_mkreg(JIT_RTYPE_INT, JIT_RTYPE_ARG, i), al->gp_arg_regs[assoc_gp_regs]);
- assoc_gp_regs++;
- }
- if (isfp_arg) {
- rmap_assoc(op->regmap, jit_mkreg(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, i), al->gp_arg_regs[assoc_gp_regs]);
- assoc_gp_regs++;
- // initializes the second part of the register
- if ((info->args[i].size == sizeof(double)) && (assoc_gp_regs < al->gp_reg_cnt)) {
- jit_value r = jit_mkreg_ex(JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, i);
- rmap_assoc(op->regmap, (int)r, al->gp_arg_regs[assoc_gp_regs]);
- assoc_gp_regs++;
- }
- }
- }
-
-}
-#endif
-
-static void prepare_registers_for_call(struct jit_reg_allocator * al, jit_op * op)
-{
- jit_value r, reg;
- jit_hw_reg * hreg = NULL;
-#ifdef JIT_ARCH_COMMON86
- if (al->ret_reg) hreg = rmap_is_associated(op->regmap, al->ret_reg->id, 0, &r);
- if (hreg) {
- // checks whether there is a free callee-saved register
- // that can be used to take over content from eax register
-
- int alive = (jit_set_get(op->live_out, r) || (jit_set_get(op->live_in, r)));
- if (!alive) goto skip;
- int spill;
- jit_value spill_reg;
- jit_hw_reg * freereg = rmap_spill_candidate(al, op, r, &spill, &spill_reg, 1);
- if (freereg && !spill) {
- // FIXME: works only for GP registers
- rename_reg(op, freereg->id, al->ret_reg->id);
-
- rmap_unassoc(op->regmap, r);
- rmap_assoc(op->regmap, r, freereg);
- } else {
- sync_reg(op, hreg, r);
- }
- }
-skip:;
-
-#endif
- // spills registers which are used to pass the arguments
- // FIXME: duplicities
- int args = MIN(op->arg[0], al->gp_arg_reg_cnt);
- for (int q = 0; q < args; q++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->gp_arg_regs[q]->id, 0, &reg);
- if (hreg) {
- if (jit_set_get(op->live_out, reg)) unload_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- }
- args = MIN(op->arg[1], al->fp_arg_reg_cnt);
- for (int q = 0; q < args; q++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->fp_arg_regs[q]->id, 1, &reg);
- if (hreg) {
- if ((hreg->id != al->fpret_reg->id) && jit_set_get(op->live_out, reg)) unload_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- }
-}
-
-static int assign_getarg(jit_op * op, struct jit_reg_allocator * al)
-{
- // optimization which eliminates undesirable assignments
- int arg_id = op->arg[1];
- struct jit_inp_arg * arg = &(al->current_func_info->args[arg_id]);
- int reg_id = jit_mkreg(arg->type == JIT_FLOAT_NUM ? JIT_RTYPE_FLOAT : JIT_RTYPE_INT, JIT_RTYPE_ARG, arg_id);
- if (!jit_set_get(op->live_out, reg_id)) {
- if (((arg->type != JIT_FLOAT_NUM) && (arg->size == REG_SIZE))
-#ifdef JIT_ARCH_AMD64
- || ((arg->type == JIT_FLOAT_NUM) && (arg->size == sizeof(double)))
-#endif
- ) {
- jit_hw_reg * hreg = rmap_get(op->regmap, reg_id);
- if (hreg) {
- rmap_unassoc(op->regmap, reg_id);
- rmap_assoc(op->regmap, op->arg[0], hreg);
- op->r_arg[0] = hreg->id;
- op->r_arg[1] = op->arg[1];
- // FIXME: should have its own name
- op->code = JIT_NOP;
- //Dont store items in XMM0(Used as acccumaltor)
- if(hreg->fp&&hreg->id==0) {
- unload_reg(op, hreg, op->arg[0]);
- rmap_unassoc(op->regmap, op->arg[0]);
- }
- return 1;
- }
- }
- }
- return 0;
-}
-
-/**
- * Spills registers that are in use before JMPR is performed
- */
-static int assign_jmp(jit_op * op, struct jit_reg_allocator * al)
-{
- if (op->code == (JIT_JMP | IMM)) return 0;
- jit_value reg;
- for (int i = 0; i < al->gp_reg_cnt; i++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->gp_regs[i].id, 0, &reg);
- if (hreg && jit_set_get(op->live_out, reg)) sync_reg(op, hreg, reg);
- }
-
- for (int i = 0; i < al->fp_reg_cnt; i++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->fp_regs[i].id, 1, &reg);
- if (hreg && jit_set_get(op->live_out, reg)) sync_reg(op, hreg, reg);
- }
- return 0;
-}
-
-static int assign_call(jit_op * op, struct jit_reg_allocator * al)
-{
-#ifdef JIT_ARCH_SPARC
- jit_value reg;
- // unloads all FP registers
- for (int q = 0; q < al->fp_reg_cnt; q++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->fp_regs[q].id, 1, &reg);
- if (hreg) {
- unload_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- }
-#endif
-#ifdef JIT_ARCH_AMD64
- // since the CALLR may use the given register also to pass an argument,
- // code genarator has to take care of the register value itself
-
- //XMM0 is used as an acculator and it is the first argument passed to functions; unload it to avoid wierdness
- jit_value reg;
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->fp_regs[0].id, 1, &reg);
- if (hreg) {
- unload_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- return 1;
-#else
- return 0;
-#endif
-}
-
-static int spill_all_registers(jit_op *op, struct jit_reg_allocator * al)
-{
- jit_value reg;
- for (int i = 0; i < al->gp_reg_cnt; i++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->gp_regs[i].id, 0, &reg);
- if (hreg && (jit_set_get(op->live_out, reg))) {
- if (op->in_use) unload_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- }
-
- for (int i = 0; i < al->fp_reg_cnt; i++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->fp_regs[i].id, 1, &reg);
- if (hreg && (jit_set_get(op->live_out, reg))) {
- if (op->in_use) unload_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- }
-
- return 1;
-}
-static int force_unload_all(jit_op *op, struct jit_reg_allocator * al)
-{
- jit_value reg;
- for (int i = 0; i < al->gp_reg_cnt; i++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->gp_regs[i].id, 0, &reg);
- if (hreg) {
- sync_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- }
-
- for (int i = 0; i < al->fp_reg_cnt; i++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->fp_regs[i].id, 1, &reg);
- if (hreg) {
- sync_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- }
- return 1;
-}
-static int force_spill(jit_op *op)
-{
- jit_value reg = op->arg[0];
- jit_hw_reg *hreg = rmap_get(op->regmap, reg);
- if (hreg) {
- unload_reg(op, hreg, reg);
- rmap_unassoc(op->regmap, reg);
- }
- return 1;
-}
-
-static int force_assoc(jit_op *op, struct jit_reg_allocator *al)
-{
- jit_hw_reg *hreg = (op->arg[1] == 0 ? &al->gp_regs[op->arg[2]] : &al->fp_regs[op->arg[2]]);
- rmap_assoc(op->regmap, op->arg[0], hreg);
-
- load_reg(op, hreg, op->arg[0]);
- return 1;
-}
-
-static void associate_register_alias(struct jit_reg_allocator * al, jit_op * op, int i)
-{
- if ((int)op->arg[i] == (int)R_OUT) op->r_arg[i] = al->ret_reg->id;
- else if ((int)op->arg[i] == (int)R_FP) op->r_arg[i] = al->fp_reg;
- else assert(0);
-}
-
-static void associate_register(struct jit_reg_allocator * al, jit_op * op, int i)
-{
- jit_hw_reg * reg = rmap_get(op->regmap, op->arg[i]);
- if (reg) op->r_arg[i] = reg->id;
- else {
- reg = make_free_reg(al, op, op->arg[i]);
- rmap_assoc(op->regmap, op->arg[i], reg);
-
- op->r_arg[i] = reg->id;
- if (jit_set_get(op->live_in, op->arg[i]))
- load_reg(op, rmap_get(op->regmap, op->arg[i]), op->arg[i]);
- }
-}
-
-static void assign_regs(struct jit * jit, struct jit_op * op)
-{
- int i;
- int skip = 0;
- struct jit_reg_allocator * al = jit->reg_al;
-
- // initialize mappings
- // PROLOG needs some special care
- if (GET_OP(op) == JIT_PROLOG) {
-
- struct jit_func_info * info = (struct jit_func_info *) op->arg[1];
- al->current_func_info = info;
-
- //op->regmap = rmap_init();
-
- assign_regs_for_args(al, op);
- } else {
- // initializes register mappings for standard operations
- if (op->prev) {
- rmap_free(op->regmap);
- op->regmap = rmap_clone(op->prev->regmap);
- }
- }
-
- // operations reuqiring some special core
- switch (GET_OP(op)) {
- case JIT_PREPARE: prepare_registers_for_call(al, op); break;
- // PUTARG have to take care of the register allocation by itself
- case JIT_PUTARG: skip = 1; break;
- case JIT_FPUTARG: skip = 1; break;
- case JIT_GETARG: skip = assign_getarg(op, al); break;
- case JIT_CALL: skip = assign_call(op, al); break;
- case JIT_JMP: skip = assign_jmp(op, al); break;
- case JIT_END_ASM_BLK: {
- skip=1;
- jit_value reg;
- for (int i = 0; i < al->gp_reg_cnt; i++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->gp_regs[i].id, 0, &reg);
- if (hreg && (jit_set_get(op->live_out, reg))) {
- rmap_unassoc(op->regmap, reg);
- }
- }
-
- for (int i = 0; i < al->fp_reg_cnt; i++) {
- jit_hw_reg * hreg = rmap_is_associated(op->regmap, al->fp_regs[i].id, 1, &reg);
- if (hreg && (jit_set_get(op->live_out, reg))) {
- rmap_unassoc(op->regmap, reg);
- }
- }
- break;
- }
- case JIT_FORCE_UNLOAD_ALL: skip=force_unload_all(op,al); break;
- case JIT_FULL_SPILL: skip = spill_all_registers(op, al); break;
- case JIT_FORCE_SPILL: skip = force_spill(op); break;
- case JIT_FORCE_ASSOC: skip = force_assoc(op, al); break;
- default: break;
- }
-
- if (skip) return;
-
- // associates virtual registers with their hardware counterparts
- for (i = 0; i < 3; i++) {
- if ((ARG_TYPE(op, i + 1) == REG) || (ARG_TYPE(op, i + 1) == TREG)) {
- jit_reg virt_reg = JIT_REG(op->arg[i]);
- if (virt_reg.spec == JIT_RTYPE_ALIAS) associate_register_alias(al, op, i);
- else associate_register(al, op, i);
- } else if (ARG_TYPE(op, i + 1) == IMM) {
- // assigns immediate values
- op->r_arg[i] = op->arg[i];
- }
- }
-}
-
-static void mark_calleesaved_regs(jit_tree * hint, jit_op * op)
-{
- if (hint == NULL) return;
- struct jit_allocator_hint * h = (struct jit_allocator_hint *) hint->value;
- jit_value reg = (jit_value) hint->key;
- if (jit_set_get(op->live_out, reg)) h->should_be_calleesaved++;
-
- mark_calleesaved_regs(hint->left, op);
- mark_calleesaved_regs(hint->right, op);
-}
-
-/**
- * Collects statistics on used registers
- */
-static void hints_refcount_inc(jit_tree * hints);
-void jit_collect_statistics(struct jit * jit)
-{
- int i, j;
- int ops_from_return = 0;
- jit_tree * last_hints = NULL;
-
- for (jit_op * op = jit_op_last(jit->ops); op != NULL; op = op->prev) {
- jit_tree * new_hints = jit_tree_clone(last_hints);
- op->normalized_pos = ops_from_return;
-
- // determines used registers
- // FIXME: should be a separate function
- jit_value regs[3];
- int found_regs = 0;
- for (i = 0; i < 3; i++)
- if ((ARG_TYPE(op, i + 1) == REG) || (ARG_TYPE(op, i + 1) == TREG)) {
- int found = 0;
- jit_value reg = op->arg[i];
- for (j = 0; j < found_regs; j++) {
- if (regs[j] == reg) {
- found = 1;
- break;
- }
- }
- if (!found) regs[found_regs++] = reg;
- }
-
- // marks register usage
- for (i = 0; i < found_regs; i++) {
- jit_value reg = regs[i];
-
- jit_tree * hint = jit_tree_search(new_hints, reg);
- struct jit_allocator_hint * new_hint = JIT_MALLOC(sizeof(struct jit_allocator_hint));
- if (hint) memcpy(new_hint, hint->value, sizeof(struct jit_allocator_hint));
- else {
- new_hint->last_pos = 0;
- new_hint->should_be_calleesaved = 0;
- new_hint->should_be_eax = 0;
- }
- new_hint->refs = 0;
-
- new_hint->last_pos = ops_from_return;
-#ifdef JIT_ARCH_COMMON86
- if ((GET_OP(op) == JIT_RETVAL) || (GET_OP(op) == JIT_RET))
- new_hint->should_be_eax++;
-#endif
- new_hints = jit_tree_insert(new_hints, reg, new_hint, NULL);
- }
-#ifdef JIT_ARCH_COMMON86
- if (GET_OP(op) == JIT_CALL) mark_calleesaved_regs(new_hints, op);
-#endif
- hints_refcount_inc(new_hints);
- op->allocator_hints = new_hints;
-
- if (GET_OP(op) == JIT_PROLOG) {
- last_hints = NULL;
- ops_from_return = 0;
- } else {
- last_hints = new_hints;
- ops_from_return++;
- }
- }
-}
-
-static void hints_refcount_inc(jit_tree * hints)
-{
- if (hints == NULL) return;
- ((struct jit_allocator_hint*) hints->value)->refs++;
- hints_refcount_inc(hints->left);
- hints_refcount_inc(hints->right);
-}
-
-void jit_allocator_hints_free(jit_tree * hints)
-{
- if (hints == NULL) return;
- jit_allocator_hints_free(hints->left);
- jit_allocator_hints_free(hints->right);
-
- int refs = --((struct jit_allocator_hint*) hints->value)->refs;
- if (refs == 0) JIT_FREE(hints->value);
-
- JIT_FREE(hints);
-}
-//////////////////////////////////////////////////////////////////
-
-/**
- * This function adjusts association of registers to the state
- * which is expected at the destination address of the jump
- * operation
- */
-static inline void jump_adjustment(struct jit * jit, jit_op * op)
-{
- if (op->code == (JIT_JMP | IMM)) {
- jit_rmap * cur_regmap = op->regmap;
- jit_rmap * tgt_regmap = op->jmp_addr->regmap;
-
- rmap_sync(op, cur_regmap, tgt_regmap, RMAP_UNLOAD);
- rmap_sync(op, tgt_regmap, cur_regmap, RMAP_LOAD);
- }
-}
-
-/**
- * There must be same register mappings at both ends of the conditional jump.
- * If this condition is not met, contents of registers have to be moved
- * appropriately. This can be achieved with the jump_adjustment function.
- *
- * This function converts conditional jumps as follows:
- * beq(succ, ..., ...);
- * fail
- * ==>
- * bne(fail:, ..., ...);
- * register reorganization
- * jmp succ
- * fail:
- */
-static inline void branch_adjustment(struct jit * jit, jit_op * op)
-{
- if (!is_cond_branch_op(op)) return;
- jit_rmap * cur_regmap = op->regmap;
- jit_rmap * tgt_regmap = op->jmp_addr->regmap;
-
- if (!rmap_equal(op, cur_regmap, tgt_regmap)) {
- switch (GET_OP(op)) {
- case JIT_BEQ: op->code = JIT_BNE | (op->code & 0x7); break;
- case JIT_BGT: op->code = JIT_BLE | (op->code & 0x7); break;
- case JIT_BGE: op->code = JIT_BLT | (op->code & 0x7); break;
- case JIT_BNE: op->code = JIT_BEQ | (op->code & 0x7); break;
- case JIT_BLT: op->code = JIT_BGE | (op->code & 0x7); break;
- case JIT_BLE: op->code = JIT_BGT | (op->code & 0x7); break;
-
- case JIT_BOADD: op->code = JIT_BNOADD | (op->code & 0x7); break;
- case JIT_BOSUB: op->code = JIT_BNOSUB | (op->code & 0x7); break;
- case JIT_BNOADD: op->code = JIT_BOADD | (op->code & 0x7); break;
- case JIT_BNOSUB: op->code = JIT_BOSUB | (op->code & 0x7); break;
-
- case JIT_FBEQ: op->code = JIT_FBNE | (op->code & 0x7); break;
- case JIT_FBGT: op->code = JIT_FBLE | (op->code & 0x7); break;
- case JIT_FBGE: op->code = JIT_FBLT | (op->code & 0x7); break;
- case JIT_FBNE: op->code = JIT_FBEQ | (op->code & 0x7); break;
- case JIT_FBLT: op->code = JIT_FBGE | (op->code & 0x7); break;
- case JIT_FBLE: op->code = JIT_FBGT | (op->code & 0x7); break;
- default: break;
- }
-
- jit_op * o = jit_op_new(JIT_JMP | IMM, SPEC(IMM, NO, NO), op->arg[0], 0, 0, 0);
- o->r_arg[0] = op->r_arg[0];
-
- o->regmap = rmap_clone(op->regmap);
-
- o->live_in = jit_set_clone(op->live_in);
- o->live_out = jit_set_clone(op->live_out);
- o->jmp_addr = op->jmp_addr;
-
- if (!jit_is_label(jit, (void *)op->r_arg[0])) {
- op->jmp_addr->arg[0] = (jit_value) o;
- op->jmp_addr->r_arg[0] = (jit_value) o;
- }
-
- jit_op_append(op, o);
-
- jit_op * o2 = jit_op_new(JIT_PATCH, SPEC(IMM, NO, NO), (jit_value) op, 0, 0, 0);
- o2->r_arg[0] = o2->arg[0];
- jit_op_append(o, o2);
-
- op->arg[0] = (jit_value) o2;
- op->r_arg[0] = (jit_value) o2;
- op->jmp_addr = o2;
- }
-}
-
-void jit_assign_regs(struct jit * jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next)
- op->regmap = rmap_init();
-
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next)
- assign_regs(jit, op);
-
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next)
- branch_adjustment(jit, op);
-
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next)
- jump_adjustment(jit, op);
-}
-
-void jit_reg_allocator_free(struct jit_reg_allocator * a)
-{
- if (a->fp_regs) JIT_FREE(a->fp_regs);
- JIT_FREE(a->gp_regs);
- if (a->fp_arg_regs) JIT_FREE(a->fp_arg_regs);
- if (a->gp_arg_regs) JIT_FREE(a->gp_arg_regs);
- JIT_FREE(a);
-}
-
-/**
- * returns 1 if the given hw. register (e.g., X86_EAX) is in use
- */
-int jit_reg_in_use(jit_op * op, int reg, int fp)
-{
- jit_value virt_reg;
- if (rmap_is_associated(op->regmap, reg, fp, &virt_reg)
- && ((jit_set_get(op->live_in, virt_reg) || (jit_set_get(op->live_out, virt_reg))))) return 1;
- else return 0;
-}
-
-/**
- * returns a register which is unused, otherwise returns NULL
- */
-jit_hw_reg * jit_get_unused_reg(struct jit_reg_allocator * al, jit_op * op, int fp)
-{
- jit_hw_reg * regs;
- int reg_count;
-
- if (!fp) {
- regs = al->gp_regs;
- reg_count = al->gp_reg_cnt;
- } else {
- regs = al->fp_regs;
- reg_count = al->fp_reg_cnt;
- }
- for (int i = 0; i < reg_count; i++)
- if (!jit_reg_in_use(op, regs[i].id, fp))
- if(!regs[i].callee_saved)
- return &(regs[i]);
- return NULL;
-}
diff --git a/ext/myjit/myjit/rmap.h b/ext/myjit/myjit/rmap.h
deleted file mode 100755
index a5ce069..0000000
--- a/ext/myjit/myjit/rmap.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <string.h>
-#include <limits.h>
-/*
- * Register mappings
- */
-
-#define RMAP_UNLOAD (1)
-#define RMAP_LOAD (2)
-
-static inline void unload_reg(jit_op * op, jit_hw_reg * hreg, jit_value virt_reg);
-static inline void load_reg(struct jit_op * op, jit_hw_reg * hreg, jit_value reg);
-
-///////////////////////////////////////////////////////////////////////
-
-static inline jit_rmap * rmap_init()
-{
- jit_rmap * res = JIT_MALLOC(sizeof(jit_rmap));
- res->map = NULL;
- return res;
-}
-
-jit_hw_reg * rmap_get(jit_rmap * rmap, jit_value reg)
-{
- jit_tree * found = jit_tree_search(rmap->map, reg);
- if (found) return (jit_hw_reg *) found->value;
-
- return NULL;
-}
-
-static inline jit_hw_reg * rmap_is_associated_aux(jit_tree * n, int reg_id, int fp, jit_value * virt_reg)
-{
- if (n == NULL) return NULL;
- jit_hw_reg * r = (jit_hw_reg *) n->value;
-
- if ((r->fp == fp) && (r->id == reg_id)) {
- if (virt_reg) *virt_reg = (jit_value) n->key;
- return r;
- }
-
- r = rmap_is_associated_aux(n->left, reg_id, fp, virt_reg);
- if (r) return r;
- else return rmap_is_associated_aux(n->right, reg_id, fp, virt_reg);
-}
-
-/**
- * Checks whether the hardware register reg_is is associated with some virtual register
- * If so, returns a pointer to this register and sets the id of the virtual
- * register
- */
-static jit_hw_reg * rmap_is_associated(jit_rmap * rmap, int reg_id, int fp, jit_value * virt_reg)
-{
- return rmap_is_associated_aux(rmap->map, reg_id, fp, virt_reg);
-}
-
-static void rmap_assoc(jit_rmap * rmap, jit_value reg, jit_hw_reg * hreg)
-{
- rmap->map = jit_tree_insert(rmap->map, reg, hreg, NULL);
-}
-
-static void rmap_unassoc(jit_rmap * rmap, jit_value reg)
-{
- rmap->map = jit_tree_delete(rmap->map, reg, NULL);
-}
-
-static jit_rmap * rmap_clone(jit_rmap * rmap)
-{
- jit_rmap * res = JIT_MALLOC(sizeof(jit_rmap));
- res->map = jit_tree_clone(rmap->map);
- return res;
-}
-
-static int rmap_subset(jit_op * op, jit_tree * current, jit_tree * target)
-{
- if (current == NULL) return 1;
-
- // ignores mappings of register which are not live
- jit_set * tgt_livein = op->jmp_addr->live_in;
- if (!jit_set_get(tgt_livein, current->key) && !jit_set_get(op->live_out, current->key)) goto skip;
-
- jit_tree * found = jit_tree_search(target, current->key);
- if ((!found) || (current->value != found->value)) return 0;
-
-skip:
- return rmap_subset(op, current->left, target) && rmap_subset(op, current->right, target);
-}
-
-/**
- * Compares whether register mappings in the target destination
- * are the same as the current
- */
-static int rmap_equal(jit_op * op, jit_rmap * current, jit_rmap * target)
-{
- return rmap_subset(op, current->map, target->map) && rmap_subset(op, target->map, current->map);
-}
-
-/**
- * Synchronizes two register mappings
- * if (mode == LOAD): then it loads registers which are not present in the current mapping,
- * however, are in the target mapping
- * if (mode == UNLOAD): then it unloads registers which are in the current mapping,
- * however, which are not in the target mapping
- */
-static void rmap_sync_aux(jit_tree * current, jit_tree * target, jit_op * op, int mode)
-{
- if (current == NULL) return;
-
- // if the given register does not have relevant content, then ignore it
- if ((mode == RMAP_LOAD) && (!jit_set_get(op->live_out, current->key))) goto skip;
-
- // if the register is not used in the destination, then ignore it
- if ((mode == RMAP_UNLOAD) && (!jit_set_get(op->jmp_addr->live_in, current->key))) goto skip;
-
- jit_tree * found = jit_tree_search(target, current->key);
- int i = current->key;
-
- if ((!found) || (current->value != found->value)) {
- jit_hw_reg * hreg = (jit_hw_reg *) current->value;
- switch (mode) {
- case RMAP_UNLOAD: unload_reg(op, hreg, i); break;
- case RMAP_LOAD: load_reg(op, hreg, i); break;
- default: assert(0);
- }
- }
-skip:
- rmap_sync_aux(current->left, target, op, mode);
- rmap_sync_aux(current->right, target, op, mode);
-}
-
-static void rmap_sync(jit_op * op, jit_rmap * current, jit_rmap * target, int mode)
-{
- rmap_sync_aux(current->map, target->map, op, mode);
-}
-
-static int candidate_score(jit_op * op, jit_value virtreg, jit_hw_reg * hreg, int * spill, jit_value * associated_virtreg)
-{
- int score = 0;
- score -= hreg->priority;
-
- jit_value x;
- int hw_associated = (rmap_is_associated(op->regmap, hreg->id, hreg->fp, &x) != NULL);
-
- int alive = 0;
- if (hw_associated) {
- alive = (jit_set_get(op->live_in, x) || jit_set_get(op->live_out, x));
- }
- if (!alive) score += 10000; // prefers registers which are not live
-
- *spill = 0;
- if (hw_associated) {
-
- score -= 100000; // suppress registers which are in use
- *spill = 1;
-
- *associated_virtreg = x;
-
- jit_tree * hint_node = jit_tree_search(op->allocator_hints, x);
- int is_to_be_used = (hint_node != NULL);
-
- if (!is_to_be_used) score += 50000; // if it's not to be used it is not so bad candidate
- else {
- struct jit_allocator_hint * hint = (struct jit_allocator_hint *)hint_node->value;
- int used_in_steps = -(hint->last_pos - op->normalized_pos);
- if (hw_associated && (used_in_steps == 0)) return INT_MIN; // register is used in the current function (it's not a good candidate for spilling)
- else score += (used_in_steps * 5);
- }
- }
-
-
-#ifdef JIT_ARCH_COMMON86
- jit_tree * hint_node = jit_tree_search(op->allocator_hints, virtreg);
- if (hint_node) {
- struct jit_allocator_hint * hint = (struct jit_allocator_hint *)hint_node->value;
- if ((hreg->fp == 0) && (hreg->id == COMMON86_AX)) {
- score += hint->should_be_eax * 5;
- }
- if (hreg->callee_saved) score += (hint->should_be_calleesaved - 1) * 15;
- }
-#endif
- return score;
-}
-
-/**
- * Returns suitable register which can be associated to registers virtreg in the operation op
- * Paramater spill indicates whether the content of the register has to be spilled out and if so,
- * it returns currently associated value throught the reg_to_spill argument.
- *
- * Parameter callee_saved indicates whether, the argument have to be callee-saved or not.
- */
-static jit_hw_reg * rmap_spill_candidate(struct jit_reg_allocator * al, jit_op * op, jit_value virtreg, int * spill, jit_value * reg_to_spill, int callee_saved)
-{
- jit_reg r = JIT_REG(virtreg);
- jit_hw_reg * regs;
- int reg_count;
- jit_hw_reg * result = NULL;
- int best_score = INT_MIN;
-
- if (r.type == JIT_RTYPE_INT) {
- regs = al->gp_regs;
- reg_count = al->gp_reg_cnt;
- } else {
- regs = al->fp_regs;
- reg_count = al->fp_reg_cnt;
- }
-
- int sp = 0;
- for (int i = 0; i < reg_count; i++) {
- if (callee_saved && !regs[i].callee_saved) continue;
- jit_value assoc = 0;
- int score = candidate_score(op, virtreg, &(regs[i]), &sp, &assoc);
- if (score > best_score) {
- if (sp) {
- *reg_to_spill = assoc;
- *spill = sp;
- } else {
- *reg_to_spill = -1;
- *spill = 0;
- }
- result = &(regs[i]);
- best_score = score;
- }
- }
- return result;
-}
-
-void rmap_free(jit_rmap * regmap)
-{
- if (!regmap) return;
- jit_tree_free(regmap->map);
- JIT_FREE(regmap);
-}
diff --git a/ext/myjit/myjit/set.h b/ext/myjit/myjit/set.h
deleted file mode 100755
index 6b647f8..0000000
--- a/ext/myjit/myjit/set.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef SET_H
-#define SET_H
-
-#include <assert.h>
-
-#include "jitlib-core.h"
-#include "../../../ext/vec/src/vec.h"
-static jit_set * jit_set_new()
-{
- jit_set * s = JIT_MALLOC(sizeof(vec_int_t));
- vec_init(&s->vec);
- return s;
-}
-static jit_set * jit_set_clone(jit_set * s)
-{
- jit_set * clone = jit_set_new();
- vec_extend(&clone->vec, &s->vec);
- return clone;
-}
-
-static void jit_set_free(jit_set * s)
-{
- vec_deinit(&s->vec);
- JIT_FREE(s);
-}
-
-static int jit_set_get(jit_set * s, jit_value value)
-{
- int iter;
- vec_find(&s->vec, value, iter);
- return iter!=-1;
-}
-
-static void jit_set_add(jit_set * s, jit_value value)
-{
- if(!jit_set_get(s, value))
- vec_push(&s->vec,value);
-}
-
-static void jit_set_addall(jit_set * target, jit_set * s)
-{
- int iter;
- int v;
- vec_foreach(&s->vec, v, iter) jit_set_add(target,v);
-}
-
-static void jit_set_remove(jit_set * s, jit_value value)
-{
- vec_remove(&s->vec,value);
-}
-static int IntCmp(const void*a,const void *b) {
- return *(int*)a-*(int*)b;
-}
-static int ContainsAll(jit_set * super, jit_set * sub) {
- jit_value v,iter;
- vec_foreach(&super->vec,v,iter) {
- int iter2;
- vec_find(&sub->vec, v, iter2);
- if(iter2==-1) return 0;
- }
- return 1;
-}
-static int jit_set_equal(jit_set * s1, jit_set * s2)
-{
- return ContainsAll(s1, s2)&&ContainsAll(s2, s1);
-}
-static jit_set *jit_set_intersect(jit_set * a,jit_set * b) {
- struct jit_set *ret=jit_set_new();
- jit_value v;
- long i;
- vec_foreach(&a->vec,v,i) {
- if(jit_set_get(b,v))
- jit_set_add(ret,v);
- }
- return ret;
-}
-#endif
diff --git a/ext/myjit/myjit/sparc-codegen.h b/ext/myjit/myjit/sparc-codegen.h
deleted file mode 100755
index 397babe..0000000
--- a/ext/myjit/myjit/sparc-codegen.h
+++ /dev/null
@@ -1,983 +0,0 @@
-#ifndef __SPARC_CODEGEN_H__
-#define __SPARC_CODEGEN_H__
-
-#if SIZEOF_VOID_P == 8
-#define SPARCV9 1
-#else
-#endif
-
-#include <stdint.h>
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-#ifndef TRUE
-#define TRUE (1)
-#endif
-//////////////////////
-
-typedef enum {
- sparc_r0 = 0,
- sparc_r1 = 1,
- sparc_r2 = 2,
- sparc_r3 = 3,
- sparc_r4 = 4,
- sparc_r5 = 5,
- sparc_r6 = 6,
- sparc_r7 = 7,
- sparc_r8 = 8,
- sparc_r9 = 9,
- sparc_r10 = 10,
- sparc_r11 = 11,
- sparc_r12 = 12,
- sparc_r13 = 13,
- sparc_r14 = 14,
- sparc_r15 = 15,
- sparc_r16 = 16,
- sparc_r17 = 17,
- sparc_r18 = 18,
- sparc_r19 = 19,
- sparc_r20 = 20,
- sparc_r21 = 21,
- sparc_r22 = 22,
- sparc_r23 = 23,
- sparc_r24 = 24,
- sparc_r25 = 25,
- sparc_r26 = 26,
- sparc_r27 = 27,
- sparc_r28 = 28,
- sparc_r29 = 29,
- sparc_r30 = 30,
- sparc_r31 = 31,
- /* aliases */
- /* global registers */
- sparc_g0 = 0, sparc_zero = 0,
- sparc_g1 = 1,
- sparc_g2 = 2,
- sparc_g3 = 3,
- sparc_g4 = 4,
- sparc_g5 = 5,
- sparc_g6 = 6,
- sparc_g7 = 7,
- /* out registers */
- sparc_o0 = 8,
- sparc_o1 = 9,
- sparc_o2 = 10,
- sparc_o3 = 11,
- sparc_o4 = 12,
- sparc_o5 = 13,
- sparc_o6 = 14, sparc_sp = 14,
- sparc_o7 = 15, sparc_callsite = 15,
- /* local registers */
- sparc_l0 = 16,
- sparc_l1 = 17,
- sparc_l2 = 18,
- sparc_l3 = 19,
- sparc_l4 = 20,
- sparc_l5 = 21,
- sparc_l6 = 22,
- sparc_l7 = 23,
- /* in registers */
- sparc_i0 = 24,
- sparc_i1 = 25,
- sparc_i2 = 26,
- sparc_i3 = 27,
- sparc_i4 = 28,
- sparc_i5 = 29,
- sparc_i6 = 30, sparc_fp = 30,
- sparc_i7 = 31,
- sparc_nreg = 32,
- /* floating point registers */
- sparc_f0 = 0,
- sparc_f1 = 1,
- sparc_f2 = 2,
- sparc_f3 = 3,
- sparc_f4 = 4,
- sparc_f5 = 5,
- sparc_f6 = 6,
- sparc_f7 = 7,
- sparc_f8 = 8,
- sparc_f9 = 9,
- sparc_f10 = 10,
- sparc_f11 = 11,
- sparc_f12 = 12,
- sparc_f13 = 13,
- sparc_f14 = 14,
- sparc_f15 = 15,
- sparc_f16 = 16,
- sparc_f17 = 17,
- sparc_f18 = 18,
- sparc_f19 = 19,
- sparc_f20 = 20,
- sparc_f21 = 21,
- sparc_f22 = 22,
- sparc_f23 = 23,
- sparc_f24 = 24,
- sparc_f25 = 25,
- sparc_f26 = 26,
- sparc_f27 = 27,
- sparc_f28 = 28,
- sparc_f29 = 29,
- sparc_f30 = 30,
- sparc_f31 = 31,
-} SparcRegister;
-
-typedef enum {
- sparc_bn = 0, sparc_bnever = 0,
- sparc_be = 1,
- sparc_ble = 2,
- sparc_bl = 3,
- sparc_bleu = 4,
- sparc_bcs = 5, sparc_blu = 5,
- sparc_bneg = 6,
- sparc_bvs = 7, sparc_boverflow = 7,
- sparc_ba = 8, sparc_balways = 8,
- sparc_bne = 9,
- sparc_bg = 10,
- sparc_bge = 11,
- sparc_bgu = 12,
- sparc_bcc = 13, sparc_bgeu = 13,
- sparc_bpos = 14,
- sparc_bvc = 15, sparc_bnoverflow = 15
-} SparcCond;
-
-typedef enum {
- /* with fcmp */
- sparc_feq = 0,
- sparc_fl = 1,
- sparc_fg = 2,
- sparc_unordered = 3,
- /* branch ops */
- sparc_fba = 8,
- sparc_fbn = 0,
- sparc_fbu = 7,
- sparc_fbg = 6,
- sparc_fbug = 5,
- sparc_fbl = 4,
- sparc_fbul = 3,
- sparc_fblg = 2,
- sparc_fbne = 1,
- sparc_fbe = 9,
- sparc_fbue = 10,
- sparc_fbge = 11,
- sparc_fbuge = 12,
- sparc_fble = 13,
- sparc_fbule = 14,
- sparc_fbo = 15
-} SparcFCond;
-
-typedef enum {
- sparc_icc = 4,
- sparc_xcc = 6,
- sparc_fcc0 = 0,
- sparc_fcc1 = 1,
- sparc_fcc2 = 2,
- sparc_fcc3 = 3
-} SparcCC;
-
-typedef enum {
- sparc_icc_short = 0,
- sparc_xcc_short = 2
-} SparcCCShort;
-
-typedef enum {
- /* fop1 format */
- sparc_fitos_val = 196,
- sparc_fitod_val = 200,
- sparc_fitoq_val = 204,
- sparc_fxtos_val = 132,
- sparc_fxtod_val = 136,
- sparc_fxtoq_val = 140,
- sparc_fstoi_val = 209,
- sparc_fdtoi_val = 210,
- sparc_fqtoi_val = 211,
- sparc_fstod_val = 201,
- sparc_fstoq_val = 205,
- sparc_fdtos_val = 198,
- sparc_fdtoq_val = 206,
- sparc_fqtos_val = 199,
- sparc_fqtod_val = 203,
- sparc_fmovs_val = 1,
- sparc_fmovd_val = 2,
- sparc_fnegs_val = 5,
- sparc_fnegd_val = 6,
- sparc_fabss_val = 9,
- sparc_fabsd_val = 10,
- sparc_fsqrts_val = 41,
- sparc_fsqrtd_val = 42,
- sparc_fsqrtq_val = 43,
- sparc_fadds_val = 65,
- sparc_faddd_val = 66,
- sparc_faddq_val = 67,
- sparc_fsubs_val = 69,
- sparc_fsubd_val = 70,
- sparc_fsubq_val = 71,
- sparc_fmuls_val = 73,
- sparc_fmuld_val = 74,
- sparc_fmulq_val = 75,
- sparc_fsmuld_val = 105,
- sparc_fdmulq_val = 111,
- sparc_fdivs_val = 77,
- sparc_fdivd_val = 78,
- sparc_fdivq_val = 79,
- /* fop2 format */
- sparc_fcmps_val = 81,
- sparc_fcmpd_val = 82,
- sparc_fcmpq_val = 83,
- sparc_fcmpes_val = 85,
- sparc_fcmped_val = 86,
- sparc_fcmpeq_val = 87
-} SparcFOp;
-
-typedef enum {
- sparc_membar_load_load = 0x1,
- sparc_membar_store_load = 0x2,
- sparc_membar_load_store = 0x4,
- sparc_membar_store_store = 0x8,
-
- sparc_membar_lookaside = 0x10,
- sparc_membar_memissue = 0x20,
- sparc_membar_sync = 0x40,
-
- sparc_membar_all = 0x4f
-} SparcMembarFlags;
-
-typedef struct {
- unsigned int op : 2; /* always 1 */
- unsigned int disp : 30;
-} sparc_format1;
-
-typedef struct {
- unsigned int op : 2; /* always 0 */
- unsigned int rd : 5;
- unsigned int op2 : 3;
- unsigned int disp : 22;
-} sparc_format2a;
-
-typedef struct {
- unsigned int op : 2; /* always 0 */
- unsigned int a : 1;
- unsigned int cond : 4;
- unsigned int op2 : 3;
- unsigned int disp : 22;
-} sparc_format2b;
-
-typedef struct {
- unsigned int op : 2; /* always 0 */
- unsigned int a : 1;
- unsigned int cond : 4;
- unsigned int op2 : 3;
- unsigned int cc01 : 2;
- unsigned int p : 1;
- unsigned int d19 : 19;
-} sparc_format2c;
-
-typedef struct {
- unsigned int op : 2; /* always 0 */
- unsigned int a : 1;
- unsigned int res : 1;
- unsigned int rcond: 3;
- unsigned int op2 : 3;
- unsigned int d16hi: 2;
- unsigned int p : 1;
- unsigned int rs1 : 5;
- unsigned int d16lo: 14;
-} sparc_format2d;
-
-typedef struct {
- unsigned int op : 2; /* 2 or 3 */
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int rs1 : 5;
- unsigned int i : 1;
- unsigned int asi : 8;
- unsigned int rs2 : 5;
-} sparc_format3a;
-
-typedef struct {
- unsigned int op : 2; /* 2 or 3 */
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int rs1 : 5;
- unsigned int i : 1;
- unsigned int x : 1;
- unsigned int asi : 7;
- unsigned int rs2 : 5;
-} sparc_format3ax;
-
-typedef struct {
- unsigned int op : 2; /* 2 or 3 */
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int rs1 : 5;
- unsigned int i : 1;
- unsigned int imm : 13;
-} sparc_format3b;
-
-typedef struct {
- unsigned int op : 2; /* 2 or 3 */
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int rs1 : 5;
- unsigned int i : 1;
- unsigned int x : 1;
- unsigned int imm : 12;
-} sparc_format3bx;
-
-typedef struct {
- unsigned int op : 2; /* 2 or 3 */
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int rs1 : 5;
- unsigned int opf : 9;
- unsigned int rs2 : 5;
-} sparc_format3c;
-
-typedef struct {
- unsigned int op : 2;
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int rs1 : 5;
- unsigned int i : 1;
- unsigned int cc01 : 2;
- unsigned int res : 6;
- unsigned int rs2 : 5;
-} sparc_format4a;
-
-typedef struct {
- unsigned int op : 2;
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int rs1 : 5;
- unsigned int i : 1;
- unsigned int cc01 : 2;
- unsigned int simm : 11;
-} sparc_format4b;
-
-typedef struct {
- unsigned int op : 2;
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int cc2 : 1;
- unsigned int cond : 4;
- unsigned int i : 1;
- unsigned int cc01 : 2;
- unsigned int res : 6;
- unsigned int rs2 : 5;
-} sparc_format4c;
-
-typedef struct {
- unsigned int op : 2;
- unsigned int rd : 5;
- unsigned int op3 : 6;
- unsigned int cc2 : 1;
- unsigned int cond : 4;
- unsigned int i : 1;
- unsigned int cc01 : 2;
- unsigned int simm : 11;
-} sparc_format4d;
-
-/* for use in logical ops, use 0 to not set flags */
-#define sparc_cc 16
-
-#define sparc_is_imm13(val) ((gint64_t)val >= (gint64_t)-(1<<12) && (gint64_t)val <= (gint64_t)((1<<12)-1))
-#define sparc_is_imm22(val) ((gint64_t)val >= (gint64_t)-(1<<21) && (gint64_t)val <= (gint64_t)((1<<21)-1))
-#define sparc_is_imm16(val) ((gint64_t)val >= (gint64_t)-(1<<15) && (gint64_t)val <= (gint64_t)((1<<15)-1))
-#define sparc_is_imm19(val) ((gint64_t)val >= (gint64_t)-(1<<18) && (gint64_t)val <= (gint64_t)((1<<18)-1))
-#define sparc_is_imm30(val) ((gint64_t)val >= (gint64_t)-(1<<29) && (gint64_t)val <= (gint64_t)((1<<29)-1))
-
-/* disassembly */
-#define sparc_inst_op(inst) ((inst) >> 30)
-#define sparc_inst_op2(inst) (((inst) >> 22) & 0x7)
-#define sparc_inst_rd(inst) (((inst) >> 25) & 0x1f)
-#define sparc_inst_op3(inst) (((inst) >> 19) & 0x3f)
-#define sparc_inst_i(inst) (((inst) >> 13) & 0x1)
-#define sparc_inst_rs1(inst) (((inst) >> 14) & 0x1f)
-#define sparc_inst_rs2(inst) (((inst) >> 0) & 0x1f)
-#define sparc_inst_imm(inst) (((inst) >> 13) & 0x1)
-#define sparc_inst_imm13(inst) (((inst) >> 0) & 0x1fff)
-
-#define sparc_encode_call(ins,addr) \
- do { \
- sparc_format1 *__f = (sparc_format1*)(ins); \
- __f->op = 1; \
- __f->disp = ((unsigned int)(addr) >> 2); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format2a(ins,val,oper,dest) \
- do { \
- sparc_format2a *__f = (sparc_format2a*)(ins); \
- __f->op = 0; \
- __f->rd = (dest); \
- __f->op2 = (oper); \
- __f->disp = (val) & 0x3fffff; \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format2b(ins,aval,bcond,oper,disp22) \
- do { \
- sparc_format2b *__f = (sparc_format2b*)(ins); \
- __f->op = 0; \
- __f->a = (aval); \
- __f->cond = (bcond); \
- __f->op2 = (oper); \
- __f->disp = (disp22); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format2c(ins,aval,bcond,oper,xcc,predict,disp19) \
- do { \
- sparc_format2c *__f = (sparc_format2c*)(ins); \
- __f->op = 0; \
- __f->a = (aval); \
- __f->cond = (bcond); \
- __f->op2 = (oper); \
- __f->cc01 = (xcc); \
- __f->p = (predict); \
- __f->d19 = (disp19); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format2d(ins,aval,bcond,oper,predict,r1,disp16) \
- do { \
- sparc_format2d *__f = (sparc_format2d*)(ins); \
- __f->op = 0; \
- __f->a = (aval); \
- __f->res = 0; \
- __f->rcond = (bcond); \
- __f->op2 = (oper); \
- __f->d16hi = ((disp16) >> 14); \
- __f->p = (predict); \
- __f->rs1 = (r1); \
- __f->d16lo = ((disp16) & 0x3fff); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format3a(ins,opval,asival,r1,r2,oper,dest) \
- do { \
- sparc_format3a *__f = (sparc_format3a*)(ins); \
- __f->op = (opval); \
- __f->asi = (asival); \
- __f->i = 0; \
- __f->rd = (dest); \
- __f->rs1 = (r1); \
- __f->rs2 = (r2); \
- __f->op3 = (oper); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format3ax(ins,opval,asival,r1,r2,oper,dest) \
- do { \
- sparc_format3ax *__f = (sparc_format3ax*)(ins); \
- __f->op = (opval); \
- __f->asi = (asival); \
- __f->i = 0; \
- __f->x = 1; \
- __f->rd = (dest); \
- __f->rs1 = (r1); \
- __f->rs2 = (r2); \
- __f->op3 = (oper); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format3b(ins,opval,r1,val,oper,dest) \
- do { \
- sparc_format3b *__f = (sparc_format3b*)(ins); \
- __f->op = (opval); \
- __f->imm = (val); \
- __f->i = 1; \
- __f->rd = (dest); \
- __f->rs1 = (r1); \
- __f->op3 = (oper); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format3bx(ins,opval,r1,val,oper,dest) \
- do { \
- sparc_format3bx *__f = (sparc_format3bx*)(ins); \
- __f->op = (opval); \
- __f->imm = (val); \
- __f->i = 1; \
- __f->x = 1; \
- __f->rd = (dest); \
- __f->rs1 = (r1); \
- __f->op3 = (oper); \
- (ins) = (unsigned char *) ((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format3c(ins,opval,opfval,r1,oper,r2,dest) \
- do { \
- sparc_format3c *__f = (sparc_format3c*)(ins); \
- __f->op = (opval); \
- __f->opf = (opfval); \
- __f->rd = (dest); \
- __f->rs1 = (r1); \
- __f->rs2 = (r2); \
- __f->op3 = (oper); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format4a(ins,opval,oper,cc,r1,r2,dest) \
- do { \
- sparc_format4a *__f = (sparc_format4a*)(ins); \
- __f->op = (opval); \
- __f->rd = (dest); \
- __f->op3 = (oper); \
- __f->rs1 = (r1); \
- __f->i = 0; \
- __f->cc01= (cc) & 0x3; \
- __f->res = 0; \
- __f->rs2 = (r2); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format4b(ins,opval,oper,cc,r1,imm,dest) \
- do { \
- sparc_format4b *__f = (sparc_format4b*)(ins); \
- __f->op = (opval); \
- __f->rd = (dest); \
- __f->op3 = (oper); \
- __f->rs1 = (r1); \
- __f->i = 1; \
- __f->cc01= (cc) & 0x3; \
- __f->simm = (imm); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format4c(ins,opval,oper,xcc,bcond,r2,dest) \
- do { \
- sparc_format4c *__f = (sparc_format4c*)(ins); \
- __f->op = (opval); \
- __f->rd = (dest); \
- __f->op3 = (oper); \
- __f->cc2 = ((xcc) >> 2) & 0x1; \
- __f->cond = bcond; \
- __f->i = 0; \
- __f->cc01= (xcc) & 0x3; \
- __f->res = 0; \
- __f->rs2 = (r2); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-#define sparc_encode_format4d(ins,opval,oper,xcc,bcond,imm,dest) \
- do { \
- sparc_format4d *__f = (sparc_format4d*)(ins); \
- __f->op = (opval); \
- __f->rd = (dest); \
- __f->op3 = (oper); \
- __f->cc2 = ((xcc) >> 2) & 0x1; \
- __f->cond = bcond; \
- __f->i = 1; \
- __f->cc01= (xcc) & 0x3; \
- __f->simm = (imm); \
- (ins) = (unsigned char *)((unsigned int*)__f + 1); \
- } while (0)
-
-/* is it useful to provide a non-default value? */
-#define sparc_asi 0x0
-
-/* load */
-#define sparc_ldsb(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),9,(dest))
-#define sparc_ldsb_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),9,(dest))
-
-#define sparc_ldsh(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),10,(dest))
-#define sparc_ldsh_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),10,(dest))
-
-#define sparc_ldub(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),1,(dest))
-#define sparc_ldub_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),1,(dest))
-
-#define sparc_lduh(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),2,(dest))
-#define sparc_lduh_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),2,(dest))
-
-#define sparc_ld(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),0,(dest))
-#define sparc_ld_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),0,(dest))
-
-/* Sparc V9 */
-#define sparc_ldx(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),11,(dest))
-#define sparc_ldx_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),11,(dest))
-
-#define sparc_ldsw(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),8,(dest))
-#define sparc_ldsw_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),8,(dest))
-
-#define sparc_ldd(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),3,(dest))
-#define sparc_ldd_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),3,(dest))
-
-#define sparc_ldf(ins,base,disp,dest) sparc_encode_format3a((ins),3,0,(base),(disp),32,(dest))
-#define sparc_ldf_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),32,(dest))
-
-#define sparc_lddf(ins,base,disp,dest) sparc_encode_format3a((ins),3,0,(base),(disp),35,(dest))
-#define sparc_lddf_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),35,(dest))
-
-/* store */
-#define sparc_stb(ins,src,base,disp) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),5,(src))
-#define sparc_stb_imm(ins,src,base,disp) sparc_encode_format3b((ins),3,(base),(disp),5,(src))
-
-#define sparc_sth(ins,src,base,disp) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),6,(src))
-#define sparc_sth_imm(ins,src,base,disp) sparc_encode_format3b((ins),3,(base),(disp),6,(src))
-
-#define sparc_st(ins,src,base,disp) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),4,(src))
-#define sparc_st_imm(ins,src,base,disp) sparc_encode_format3b((ins),3,(base),(disp),4,(src))
-
-/* Sparc V9 */
-#define sparc_stx(ins,src,base,disp) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),14,(src))
-#define sparc_stx_imm(ins,src,base,disp) sparc_encode_format3b((ins),3,(base),(disp),14,(src))
-
-#define sparc_std(ins,src,base,disp) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),7,(src))
-#define sparc_std_imm(ins,src,base,disp) sparc_encode_format3b((ins),3,(base),(disp),7,(src))
-
-#define sparc_stf(ins,src,base,disp) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),36,(src))
-#define sparc_stf_imm(ins,src,base,disp) sparc_encode_format3b((ins),3,(base),(disp),36,(src))
-
-#define sparc_stdf(ins,src,base,disp) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),39,(src))
-#define sparc_stdf_imm(ins,src,base,disp) sparc_encode_format3b((ins),3,(base),(disp),39,(src))
-
-/* swap */
-#define sparc_ldstub(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),13,(dest))
-#define sparc_ldstub_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),13,(dest))
-
-#define sparc_swap(ins,base,disp,dest) sparc_encode_format3a((ins),3,sparc_asi,(base),(disp),15,(dest))
-#define sparc_swap_imm(ins,base,disp,dest) sparc_encode_format3b((ins),3,(base),(disp),15,(dest))
-
-/* misc */
-/* note: with sethi val is the full 32 bit value (think of it as %hi(val)) */
-#define sparc_sethi(ins,val,dest) sparc_encode_format2a((ins),((val)>>10),4,(dest))
-
-#define sparc_nop(ins) sparc_sethi((ins),0,sparc_zero)
-
-#define sparc_save(ins,src,disp,dest) sparc_encode_format3a((ins),2,0,(src),(disp),60,(dest))
-#define sparc_save_imm(ins,src,disp,dest) sparc_encode_format3b((ins),2,(src),(disp),60,(dest))
-
-#define sparc_restore(ins,src,disp,dest) sparc_encode_format3a((ins),2,0,(src),(disp),61,(dest))
-#define sparc_restore_imm(ins,src,disp,dest) sparc_encode_format3b((ins),2,(src),(disp),61,(dest))
-
-#define sparc_rett(ins,src,disp) sparc_encode_format3a((ins),2,0,(src),(disp),0x39,0)
-#define sparc_rett_imm(ins,src,disp) sparc_encode_format3b((ins),2,(src),(disp),0x39,0)
-
-#define sparc_jmpl(ins,base,disp,dest) sparc_encode_format3a((ins),2,0,(base),(disp),56,(dest))
-#define sparc_jmpl_imm(ins,base,disp,dest) sparc_encode_format3b((ins),2,(base),(disp),56,(dest))
-
-#define sparc_call_simple(ins,disp) sparc_encode_call((ins),((unsigned int)(disp)))
-
-#define sparc_rdy(ins,dest) sparc_encode_format3a((ins),2,0,0,0,40,(dest))
-
-#define sparc_wry(ins,base,disp) sparc_encode_format3a((ins),2,0,(base),(disp),48,0)
-#define sparc_wry_imm(ins,base,disp) sparc_encode_format3b((ins),2,(base),(disp),48,0)
-
-/* stbar, unimp, flush */
-#define sparc_stbar(ins) sparc_encode_format3a((ins),2,0,15,0,40,0)
-#define sparc_unimp(ins,val) sparc_encode_format2b((ins),0,0,0,(val))
-
-#define sparc_flush(ins,base,disp) sparc_encode_format3a((ins),2,0,(base),(disp),59,0)
-#define sparc_flush_imm(ins,base,disp) sparc_encode_format3b((ins),2,(base),(disp),59,0)
-
-#define sparc_flushw(ins) sparc_encode_format3a((ins),2,0,0,0,43,0)
-
-#define sparc_membar(ins,flags) sparc_encode_format3b ((ins), 2, 0xf, (flags), 0x28, 0)
-
-/* trap */
-
-#define sparc_ta(ins,tt) sparc_encode_format3b((ins),2,0,(tt),58,0x8)
-
-/* alu fop */
-/* provide wrappers for: fitos, fitod, fstoi, fdtoi, fstod, fdtos, fmov, fneg, fabs */
-
-#define sparc_fop(ins,r1,op,r2,dest) sparc_encode_format3c((ins),2,(op),(r1),52,(r2),(dest))
-#define sparc_fcmp(ins,r1,op,r2) sparc_encode_format3c((ins),2,(op),(r1),53,(r2),0)
-
-/* format 1 fops */
-#define sparc_fadds(ins, r1, r2, dest) sparc_fop( ins, r1, sparc_fadds_val, r2, dest )
-#define sparc_faddd(ins, r1, r2, dest) sparc_fop( ins, r1, sparc_faddd_val, r2, dest )
-#define sparc_faddq(ins, r1, r2, dest) sparc_fop( ins, r1, sparc_faddq_val, r2, dest )
-
-#define sparc_fsubs(ins, r1, r2, dest) sparc_fop( ins, r1, sparc_fsubs_val, r2, dest )
-#define sparc_fsubd(ins, r1, r2, dest) sparc_fop( ins, r1, sparc_fsubd_val, r2, dest )
-#define sparc_fsubq(ins, r1, r2, dest) sparc_fop( ins, r1, sparc_fsubq_val, r2, dest )
-
-#define sparc_fmuls( ins, r1, r2, dest ) sparc_fop( ins, r1, sparc_fmuls_val, r2, dest )
-#define sparc_fmuld( ins, r1, r2, dest ) sparc_fop( ins, r1, sparc_fmuld_val, r2, dest )
-#define sparc_fmulq( ins, r1, r2, dest ) sparc_fop( ins, r1, sparc_fmulq_val, r2, dest )
-
-#define sparc_fsmuld( ins, r1, r2, dest ) sparc_fop( ins, r1, sparc_fsmuld_val, r2, dest )
-#define sparc_fdmulq( ins, r1, r2, dest ) sparc_fop( ins, r1, sparc_fdmulq_val, r2, dest )
-
-#define sparc_fdivs( ins, r1, r2, dest ) sparc_fop( ins, r1, sparc_fdivs_val, r2, dest )
-#define sparc_fdivd( ins, r1, r2, dest ) sparc_fop( ins, r1, sparc_fdivd_val, r2, dest )
-#define sparc_fdivq( ins, r1, r2, dest ) sparc_fop( ins, r1, sparc_fdivq_val, r2, dest )
-
-#define sparc_fitos( ins, r2, dest ) sparc_fop( ins, 0, sparc_fitos_val, r2, dest )
-#define sparc_fitod( ins, r2, dest ) sparc_fop( ins, 0, sparc_fitod_val, r2, dest )
-#define sparc_fitoq( ins, r2, dest ) sparc_fop( ins, 0, sparc_fitoq_val, r2, dest )
-
-#define sparc_fxtos( ins, r2, dest) sparc_fop( ins, 0, sparc_fxtos_val, r2, dest )
-#define sparc_fxtod( ins, r2, dest) sparc_fop( ins, 0, sparc_fxtod_val, r2, dest )
-#define sparc_fxtoq( ins, r2, dest) sparc_fop( ins, 0, sparc_fxtoq_val, r2, dest )
-
-#define sparc_fstoi( ins, r2, dest ) sparc_fop( ins, 0, sparc_fstoi_val, r2, dest )
-#define sparc_fdtoi( ins, r2, dest ) sparc_fop( ins, 0, sparc_fdtoi_val, r2, dest )
-#define sparc_fqtoi( ins, r2, dest ) sparc_fop( ins, 0, sparc_fqtoi_val, r2, dest )
-
-#define sparc_fstod( ins, r2, dest ) sparc_fop( ins, 0, sparc_fstod_val, r2, dest )
-#define sparc_fstoq( ins, r2, dest ) sparc_fop( ins, 0, sparc_fstoq_val, r2, dest )
-
-#define sparc_fdtos( ins, r2, dest ) sparc_fop( ins, 0, sparc_fdtos_val, r2, dest )
-#define sparc_fdtoq( ins, r2, dest ) sparc_fop( ins, 0, sparc_fdtoq_val, r2, dest )
-
-#define sparc_fqtos( ins, r2, dest ) sparc_fop( ins, 0, sparc_fqtos_val, r2, dest )
-#define sparc_fqtod( ins, r2, dest ) sparc_fop( ins, 0, sparc_fqtod_val, r2, dest )
-
-#define sparc_fmovs( ins, r2, dest ) sparc_fop( ins, 0, sparc_fmovs_val, r2, dest )
-#define sparc_fnegs( ins, r2, dest ) sparc_fop( ins, 0, sparc_fnegs_val, r2, dest )
-#define sparc_fabss( ins, r2, dest ) sparc_fop( ins, 0, sparc_fabss_val, r2, dest )
-
-#define sparc_fmovd( ins, r2, dest) sparc_fop (ins, 0, sparc_fmovd_val, r2, dest);
-#define sparc_fnegd( ins, r2, dest) sparc_fop (ins, 0, sparc_fnegd_val, r2, dest);
-#define sparc_fabsd( ins, r2, dest) sparc_fop (ins, 0, sparc_fabsd_val, r2, dest);
-
-#define sparc_fsqrts( ins, r2, dest ) sparc_fop( ins, 0, sparc_fsqrts_val, r2, dest )
-#define sparc_fsqrtd( ins, r2, dest ) sparc_fop( ins, 0, sparc_fsqrtd_val, r2, dest )
-#define sparc_fsqrtq( ins, r2, dest ) sparc_fop( ins, 0, sparc_fsqrtq_val, r2, dest )
-
-/* format 2 fops */
-
-#define sparc_fcmps( ins, r1, r2 ) sparc_fcmp( ins, r1, sparc_fcmps_val, r2 )
-#define sparc_fcmpd( ins, r1, r2 ) sparc_fcmp( ins, r1, sparc_fcmpd_val, r2 )
-#define sparc_fcmpq( ins, r1, r2 ) sparc_fcmp( ins, r1, sparc_fcmpq_val, r2 )
-#define sparc_fcmpes( ins, r1, r2 ) sparc_fcmpes( ins, r1, sparc_fcmpes_val, r2 )
-#define sparc_fcmped( ins, r1, r2 ) sparc_fcmped( ins, r1, sparc_fcmped_val, r2 )
-#define sparc_fcmpeq( ins, r1, r2 ) sparc_fcmpeq( ins, r1, sparc_fcmpeq_val, r2 )
-
-/* logical */
-
-/* FIXME: condense this using macros */
-/* FIXME: the setcc stuff is wrong in lots of places */
-
-#define sparc_logic(ins,op,setcc,r1,r2,dest) sparc_encode_format3a((ins),2,0,(r1),(r2),((setcc) ? 0x10 : 0) | (op), (dest))
-#define sparc_logic_imm(ins,op,setcc,r1,imm,dest) sparc_encode_format3b((ins),2,(r1),(imm),((setcc) ? 0x10 : 0) | (op), (dest))
-
-#define sparc_and(ins,setcc,r1,r2,dest) sparc_logic(ins,1,setcc,r1,r2,dest)
-#define sparc_and_imm(ins,setcc,r1,imm,dest) sparc_logic_imm(ins,1,setcc,r1,imm,dest)
-
-#define sparc_andn(ins,setcc,r1,r2,dest) sparc_encode_format3a((ins),2,0,(r1),(r2),(setcc)|5,(dest))
-#define sparc_andn_imm(ins,setcc,r1,imm,dest) sparc_encode_format3b((ins),2,(r1),(imm),(setcc)|5,(dest))
-
-#define sparc_or(ins,setcc,r1,r2,dest) sparc_encode_format3a((ins),2,0,(r1),(r2),(setcc)|2,(dest))
-#define sparc_or_imm(ins,setcc,r1,imm,dest) sparc_encode_format3b((ins),2,(r1),(imm),(setcc)|2,(dest))
-
-#define sparc_orn(ins,setcc,r1,r2,dest) sparc_encode_format3a((ins),2,0,(r1),(r2),(setcc)|6,(dest))
-#define sparc_orn_imm(ins,setcc,r1,imm,dest) sparc_encode_format3b((ins),2,(r1),(imm),(setcc)|6,(dest))
-
-#define sparc_xor(ins,setcc,r1,r2,dest) sparc_encode_format3a((ins),2,0,(r1),(r2),(setcc)|3,(dest))
-#define sparc_xor_imm(ins,setcc,r1,imm,dest) sparc_encode_format3b((ins),2,(r1),(imm), (setcc)|3,(dest))
-
-#define sparc_xnor(ins,setcc,r1,r2,dest) sparc_encode_format3a((ins),2,0,(r1),(r2),(setcc)|7,(dest))
-#define sparc_xnor_imm(ins,setcc,r1,imm,dest) sparc_encode_format3b((ins),2,(r1),(imm),(setcc)|7,(dest))
-
-/* shift */
-#define sparc_sll(ins,src,disp,dest) sparc_encode_format3a((ins),2,0,(src),(disp),37,(dest))
-#define sparc_sll_imm(ins,src,disp,dest) sparc_encode_format3b((ins),2,(src),(disp),37,(dest))
-
-/* Sparc V9 */
-#define sparc_sllx(ins,src,disp,dest) sparc_encode_format3ax((ins),2,0,(src),(disp),37,(dest))
-#define sparc_sllx_imm(ins,src,disp,dest) sparc_encode_format3bx((ins),2,(src),(disp),37,(dest))
-
-#define sparc_srl(ins,src,disp,dest) sparc_encode_format3a((ins),2,0,(src),(disp),38,(dest))
-#define sparc_srl_imm(ins,src,disp,dest) sparc_encode_format3b((ins),2,(src),(disp),38,(dest))
-
-/* Sparc V9 */
-#define sparc_srlx(ins,src,disp,dest) sparc_encode_format3ax((ins),2,0,(src),(disp),38,(dest))
-#define sparc_srlx_imm(ins,src,disp,dest) sparc_encode_format3bx((ins),2,(src),(disp),38,(dest))
-
-#define sparc_sra(ins,src,disp,dest) sparc_encode_format3a((ins),2,0,(src),(disp),39,(dest))
-#define sparc_sra_imm(ins,src,disp,dest) sparc_encode_format3b((ins),2,(src),(disp),39,(dest))
-
-/* Sparc V9 */
-#define sparc_srax(ins,src,disp,dest) sparc_encode_format3ax((ins),2,0,(src),(disp),39,(dest))
-#define sparc_srax_imm(ins,src,disp,dest) sparc_encode_format3bx((ins),2,(src),(disp),39,(dest))
-
-/* alu */
-
-#define sparc_alu_reg(ins,op,setcc,r1,r2,dest) sparc_encode_format3a((ins),2,0,(r1),(r2),op|((setcc) ? 0x10 : 0),(dest))
-#define sparc_alu_imm(ins,op,setcc,r1,imm,dest) sparc_encode_format3b((ins),2,(r1),(imm),op|((setcc) ? 0x10 : 0),(dest))
-
-#define sparc_add(ins,setcc,r1,r2,dest) sparc_alu_reg((ins),0,(setcc),(r1),(r2),(dest))
-#define sparc_add_imm(ins,setcc,r1,imm,dest) sparc_alu_imm((ins),0,(setcc),(r1),(imm),(dest))
-
-#define sparc_addx(ins,setcc,r1,r2,dest) sparc_alu_reg((ins),0x8,(setcc),(r1),(r2),(dest))
-#define sparc_addx_imm(ins,setcc,r1,imm,dest) sparc_alu_imm((ins),0x8,(setcc),(r1),(imm),(dest))
-
-#define sparc_sub(ins,setcc,r1,r2,dest) sparc_alu_reg((ins),0x4,(setcc),(r1),(r2),(dest))
-#define sparc_sub_imm(ins,setcc,r1,imm,dest) sparc_alu_imm((ins),0x4,(setcc),(r1),(imm),(dest))
-
-#define sparc_subx(ins,setcc,r1,r2,dest) sparc_alu_reg((ins),0xc,(setcc),(r1),(r2),(dest))
-#define sparc_subx_imm(ins,setcc,r1,imm,dest) sparc_alu_imm((ins),0xc,(setcc),(r1),(imm),(dest))
-
-#define sparc_muls(ins,r1,r2,dest) sparc_encode_format3a((ins),2,0,(r1),(r2),36,(dest))
-#define sparc_muls_imm(ins,r1,imm,dest) sparc_encode_format3b((ins),2,(r1),(imm),36,(dest))
-
-#define sparc_umul(ins,setcc,r1,r2,dest) sparc_alu_reg((ins),0xa,(setcc),(r1),(r2),(dest))
-#define sparc_umul_imm(ins,setcc,r1,imm,dest) sparc_alu_imm((ins),0xa,(setcc),(r1),(imm),(dest))
-
-#define sparc_smul(ins,setcc,r1,r2,dest) sparc_alu_reg((ins),0xb,(setcc),(r1),(r2),(dest))
-#define sparc_smul_imm(ins,setcc,r1,imm,dest) sparc_alu_imm((ins),0xb,(setcc),(r1),(imm),(dest))
-
-#define sparc_udiv(ins,setcc,r1,r2,dest) sparc_alu_reg((ins),0xe,(setcc),(r1),(r2),(dest))
-#define sparc_udiv_imm(ins,setcc,r1,imm,dest) sparc_alu_imm((ins),0xe,(setcc),(r1),(imm),(dest))
-
-#define sparc_sdiv(ins,setcc,r1,r2,dest) sparc_alu_reg((ins),0xf,(setcc),(r1),(r2),(dest))
-#define sparc_sdiv_imm(ins,setcc,r1,imm,dest) sparc_alu_imm((ins),0xf,(setcc),(r1),(imm),(dest))
-
-
-/* branch */
-#define sparc_branch(ins,aval,condval,displ) sparc_encode_format2b((ins),(aval),(condval),2,(displ))
-/* FIXME: float condition codes are different: unify. */
-#define sparc_fbranch(ins,aval,condval,displ) sparc_encode_format2b((ins),(aval),(condval),6,(displ))
-#define sparc_branchp(ins,aval,condval,xcc,predict,displ) sparc_encode_format2c((ins),(aval),(condval),0x1,(xcc),(predict),(displ))
-
-#define sparc_brz(ins,aval,predict,rs1,disp) sparc_encode_format2d((ins), (aval),0x1,0x3,(predict),(rs1),(disp))
-#define sparc_brlez(ins,aval,predict,rs1,disp) sparc_encode_format2d((ins), (aval),0x2,0x3,(predict),(rs1),(disp))
-#define sparc_brlz(ins,aval,predict,rs1,disp) sparc_encode_format2d((ins), (aval),0x3,0x3,(predict),(rs1),(disp))
-#define sparc_brnz(ins,aval,predict,rs1,disp) sparc_encode_format2d((ins), (aval),0x5,0x3,(predict),(rs1),(disp))
-#define sparc_brgz(ins,aval,predict,rs1,disp) sparc_encode_format2d((ins), (aval),0x6,0x3,(predict),(rs1),(disp))
-#define sparc_brgez(ins,aval,predict,rs1,disp) sparc_encode_format2d((ins), (aval),0x7,0x3,(predict),(rs1),(disp))
-
-/* conditional moves */
-#define sparc_movcc(ins,cc,condval,r1,dest) sparc_encode_format4c((ins), 0x2, 0x2c, cc, condval, r1, dest)
-
-#define sparc_movcc_imm(ins,cc,condval,imm,dest) sparc_encode_format4d((ins), 0x2, 0x2c, cc, condval, imm, dest)
-
-/* synthetic instructions */
-#define sparc_cmp(ins,r1,r2) sparc_sub((ins),sparc_cc,(r1),(r2),sparc_g0)
-#define sparc_cmp_imm(ins,r1,imm) sparc_sub_imm((ins),sparc_cc,(r1),(imm),sparc_g0)
-#define sparc_jmp(ins,base,disp) sparc_jmpl((ins),(base),(disp),sparc_g0)
-#define sparc_jmp_imm(ins,base,disp) sparc_jmpl_imm((ins),(base),(disp),sparc_g0)
-#define sparc_call(ins,base,disp) sparc_jmpl((ins),(base),(disp),sparc_o7)
-#define sparc_call_imm(ins,base,disp) sparc_jmpl_imm((ins),(base),(disp),sparc_o7)
-
-#define sparc_test(ins,reg) sparc_or ((ins),sparc_cc,sparc_g0,(reg),sparc_g0)
-
-#define sparc_ret(ins) sparc_jmpl_imm((ins),sparc_i7,8,sparc_g0)
-#define sparc_retl(ins) sparc_jmpl_imm((ins),sparc_o7,8,sparc_g0)
-#define sparc_restore_simple(ins) sparc_restore((ins),sparc_g0,sparc_g0,sparc_g0)
-#define sparc_rett_simple(ins) sparc_rett_imm((ins),sparc_i7,8)
-
-#define sparc_set32x(ins,val,reg) do { \
- sparc_sethi((ins),(uint32_t)(val),(reg)); \
- sparc_or_imm((ins),FALSE,(reg),(uint32_t)(val)&0x3ff,(reg)); \
- } while (0)
-
-#define sparc_set32(ins,val,reg) \
- do { \
- if ((val) == 0) \
- sparc_clr_reg((ins),(reg)); \
- else if (((uint32_t)(val) & 0x3ff) == 0) \
- sparc_sethi((ins),(uint32_t)(val),(reg)); \
- else if (((int32_t)(val) >= -4096) && ((int32_t)(val) <= 4095)) \
- sparc_or_imm((ins),FALSE,sparc_g0,(int32_t)(val),(reg)); \
- else sparc_set32x(ins,val,reg); \
- } while (0)
-
-#ifdef SPARCV9
-#define SPARC_SET_MAX_SIZE (6 * 4)
-#else
-#define SPARC_SET_MAX_SIZE (2 * 4)
-#endif
-
-#if SPARCV9
-#define sparc_set(ins,ptr,reg) \
- do { \
- g_assert ((reg) != sparc_g1); \
- gint64 val = (gint64)ptr; \
- uint32_t top_word = (val) >> 32; \
- uint32_t bottom_word = (val) & 0xffffffff; \
- if (val == 0) \
- sparc_clr_reg ((ins), reg); \
- else if ((val >= -4096) && ((val) <= 4095)) \
- sparc_or_imm((ins),FALSE,sparc_g0,bottom_word,(reg)); \
- else if ((val >= 0) && (val <= 4294967295L)) { \
- sparc_sethi((ins),bottom_word,(reg)); \
- if (bottom_word & 0x3ff) \
- sparc_or_imm((ins),FALSE,(reg),bottom_word&0x3ff,(reg)); \
- } \
- else if ((val >= 0) && (val <= (1L << 44) - 1)) { \
- sparc_sethi ((ins), (val >> 12), (reg)); \
- sparc_or_imm ((ins), FALSE, (reg), (val >> 12) & 0x3ff, (reg)); \
- sparc_sllx_imm ((ins),(reg), 12, (reg)); \
- sparc_or_imm ((ins), FALSE, (reg), (val) & 0xfff, (reg)); \
- } \
- else if (top_word == 0xffffffff) { \
- sparc_xnor ((ins), FALSE, sparc_g0, sparc_g0, sparc_g1); \
- sparc_sethi((ins),bottom_word,(reg)); \
- sparc_sllx_imm((ins),sparc_g1,32,sparc_g1); \
- sparc_or_imm((ins),FALSE,(reg),bottom_word&0x3ff,(reg)); \
- sparc_or((ins),FALSE,(reg),sparc_g1,(reg)); \
- } \
- else { \
- sparc_sethi((ins),top_word,sparc_g1); \
- sparc_sethi((ins),bottom_word,(reg)); \
- sparc_or_imm((ins),FALSE,sparc_g1,top_word&0x3ff,sparc_g1); \
- sparc_or_imm((ins),FALSE,(reg),bottom_word&0x3ff,(reg)); \
- sparc_sllx_imm((ins),sparc_g1,32,sparc_g1); \
- sparc_or((ins),FALSE,(reg),sparc_g1,(reg)); \
- } \
- } while (0)
-#else
-#define sparc_set(ins,val,reg) \
- do { \
- if ((val) == 0) \
- sparc_clr_reg((ins),(reg)); \
- else if (((uint32_t)(val) & 0x3ff) == 0) \
- sparc_sethi((ins),(uint32_t)(val),(reg)); \
- else if (((int32_t)(val) >= -4096) && ((int32_t)(val) <= 4095)) \
- sparc_or_imm((ins),FALSE,sparc_g0,(int32_t)(val),(reg)); \
- else { \
- sparc_sethi((ins),(uint32_t)(val),(reg)); \
- sparc_or_imm((ins),FALSE,(reg),(uint32_t)(val)&0x3ff,(reg)); \
- } \
- } while (0)
-#endif
-
-#define sparc_set_ptr(ins,val,reg) sparc_set(ins,val,reg)
-
-#ifdef SPARCV9
-#define sparc_set_template(ins,reg) sparc_set (ins,0x7fffffff7fffffff, reg)
-#else
-#define sparc_set_template(ins,reg) sparc_set (ins,0x7fffffff, reg)
-#endif
-
-#define sparc_not(ins,reg) sparc_xnor((ins),FALSE,(reg),sparc_g0,(reg))
-#define sparc_neg(ins,reg) sparc_sub((ins),FALSE,sparc_g0,(reg),(reg))
-#define sparc_clr_reg(ins,reg) sparc_or((ins),FALSE,sparc_g0,sparc_g0,(reg))
-
-#define sparc_mov_reg_reg(ins,src,dest) sparc_or((ins),FALSE,sparc_g0,(src),(dest))
-
-#ifdef SPARCV9
-#define sparc_sti_imm sparc_stx_imm
-#define sparc_ldi_imm sparc_ldx_imm
-#define sparc_sti sparc_stx
-#define sparc_ldi sparc_ldx
-#else
-#define sparc_sti_imm sparc_st_imm
-#define sparc_ldi_imm sparc_ld_imm
-#define sparc_sti sparc_st
-#define sparc_ldi sparc_ld
-#endif
-
-#define sparc_patch(target, pos) do { \
- int64_t __p = ((int64_t)(pos)) >> 2; \
- int64_t __t = ((int64_t)(target)) >> 2; \
- int64_t __location = (__p - __t); \
- sparc_format2a *__f = (sparc_format2a*)(target); \
- if (__f->op == 0) {\
- /* branch */ \
- *(int *)(target) &= ~(0x03fffff); /* 22 bits */\
- *(int *)(target) |= (0x03fffff & __location); /* 22 bits */\
- } else { \
- /* call */ \
- *(int *)(target) &= ~(0x3fffffff); /* 30 bits */\
- *(int *)(target) |= (0x3fffffff & __location); /* 30 bits */\
- } \
-} while (0);
-
-#endif /* __SPARC_CODEGEN_H__ */
-
diff --git a/ext/myjit/myjit/sparc-specific.h b/ext/myjit/myjit/sparc-specific.h
deleted file mode 100755
index b05f28b..0000000
--- a/ext/myjit/myjit/sparc-specific.h
+++ /dev/null
@@ -1,1074 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2011, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "sparc-codegen.h"
-#include "x86-common-stuff.c"
-
-#define JIT_GET_ADDR(jit, imm) (!jit_is_label(jit, (void *)(imm)) ? (imm) : \
- ((((int64_t)jit->buf + (int64_t)((jit_label *)(imm))->pos - (int64_t)jit->ip)) / 4))
-
-#define EXTRA_SPACE (16)
-
-inline jit_hw_reg * rmap_get(jit_rmap * rmap, jit_value reg);
-
-static inline int GET_REG_POS(struct jit * jit, int r)
-{
- struct jit_func_info * info = jit_current_func_info(jit);
- if (JIT_REG(r).spec == JIT_RTYPE_REG) {
- if (JIT_REG(r).type == JIT_RTYPE_INT) {
- return - (info->allocai_mem + EXTRA_SPACE + JIT_REG(r).id * REG_SIZE + REG_SIZE);
- } else {
- return - (info->allocai_mem + EXTRA_SPACE + info->gp_reg_count * REG_SIZE + JIT_REG(r).id * sizeof(double) + sizeof(double));
- }
- }
- if (JIT_REG(r).spec == JIT_RTYPE_ARG) {
- int arg_id = JIT_REG(r).id;
- struct jit_inp_arg * a = &(jit_current_func_info(jit)->args[arg_id]);
- return a->spill_pos;
- }
- assert(0);
-}
-
-static inline int space_for_outgoing_args(struct jit *jit, jit_op *op) {
- int passed_gp_args = 0;
- int passed_fp_args = 0;
- op = op->next;
- while (op && (GET_OP(op) != JIT_PROLOG)) {
- if (GET_OP(op) == JIT_PREPARE) {
- passed_gp_args = MAX(passed_gp_args, op->arg[0]);
- passed_fp_args = MAX(passed_fp_args, op->arg[1]);
- }
- op = op->next;
- }
- int stack_gp_args = MAX(0, passed_gp_args - jit->reg_al->gp_arg_reg_cnt);
- int stack_fp_args = MAX(0, passed_fp_args - jit->reg_al->fp_arg_reg_cnt);
- return stack_gp_args * REG_SIZE + stack_fp_args * sizeof(double);
-}
-
-int jit_allocai(struct jit * jit, int size)
-{
- if(!jit) return 0;
- int real_size = jit_value_align(size, 16);
- jit_add_op(jit, JIT_ALLOCA | IMM, SPEC(IMM, NO, NO), (int64_t)real_size, 0, 0, 0, NULL);
- jit_current_func_info(jit)->allocai_mem += real_size;
- return -(jit_current_func_info(jit)->allocai_mem + EXTRA_SPACE);
-}
-
-static inline void init_arg(struct jit_inp_arg * arg, int p)
-{
- static const int in_regs[] = { sparc_i0, sparc_i1, sparc_i2, sparc_i3, sparc_i4, sparc_i5 };
-
- if (p < 6) {
- arg->passed_by_reg = 1;
- arg->location.reg = in_regs[p];
- //arg->spill_pos = 68 + (p - 6) * 4;
- arg->spill_pos = 92 + (p - 6) * 4;
- } else {
- arg->passed_by_reg = 0;
- arg->location.stack_pos = 92 + (p - 6) * 4;
- arg->spill_pos = arg->location.stack_pos;
- }
- arg->overflow = 0;
- arg->phys_reg = p;
-}
-
-void jit_init_arg_params(struct jit * jit, struct jit_func_info * info, int p, int * phys_reg)
-{
- struct jit_inp_arg * a = &(info->args[p]);
- init_arg(a, *phys_reg);
- *phys_reg = *phys_reg + 1;
- if ((a->type == JIT_FLOAT_NUM) && (a->size == sizeof(double))) {
- a->overflow = 1;
- *phys_reg = *phys_reg + 1;
- }
-}
-
-static inline void emit_cond_op_op(struct jit * jit, struct jit_op * op, int cond, int imm)
-{
- if (imm) {
- if (op->r_arg[2] != 0) sparc_cmp_imm(jit->ip, op->r_arg[1], op->r_arg[2]);
- else sparc_cmp(jit->ip, op->r_arg[1], sparc_g0);
- } else sparc_cmp(jit->ip, op->r_arg[1], op->r_arg[2]);
- sparc_or_imm(jit->ip, FALSE, sparc_g0, 0, op->r_arg[0]); // clear
- sparc_movcc_imm(jit->ip, sparc_xcc, cond, 1, op->r_arg[0]);
-}
-
-static inline void emit_branch_op(struct jit * jit, struct jit_op * op, int cond, int imm)
-{
- if (imm) {
- if (op->r_arg[2] != 0) sparc_cmp_imm(jit->ip, op->r_arg[1], op->r_arg[2]);
- else sparc_cmp(jit->ip, op->r_arg[1], sparc_g0);
- } else sparc_cmp(jit->ip, op->r_arg[1], op->r_arg[2]);
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- sparc_branch (jit->ip, FALSE, cond, JIT_GET_ADDR(jit, op->r_arg[0]));
- sparc_nop(jit->ip);
-}
-
-static inline void emit_branch_mask_op(struct jit * jit, struct jit_op * op, int cond, int imm)
-{
- if (imm) {
- if (op->r_arg[2] != 0) sparc_and_imm(jit->ip, sparc_cc, op->r_arg[1], op->r_arg[2], sparc_g0);
- else sparc_and(jit->ip, sparc_cc, op->r_arg[1], sparc_g0, sparc_g0);
- } else sparc_and(jit->ip, sparc_cc, op->r_arg[1], op->r_arg[2], sparc_g0);
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- sparc_branch (jit->ip, FALSE, cond, JIT_GET_ADDR(jit, op->r_arg[0]));
- sparc_nop(jit->ip);
-}
-
-static inline void emit_op_and_overflow_branch(struct jit * jit, struct jit_op * op, int alu_op, int imm, int negation)
-{
- int64_t a1 = op->r_arg[0];
- int64_t a2 = op->r_arg[1];
- int64_t a3 = op->r_arg[2];
- if (imm) {
- switch (alu_op) {
- case JIT_ADD: sparc_add_imm(jit->ip, sparc_cc, a2, a3, a2); break;
- case JIT_SUB: sparc_sub_imm(jit->ip, sparc_cc, a2, a3, a2); break;
- default: assert(0);
- }
- } else {
- switch (alu_op) {
- case JIT_ADD: sparc_add(jit->ip, sparc_cc, a2, a3, a2); break;
- case JIT_SUB: sparc_sub(jit->ip, sparc_cc, a2, a3, a2); break;
- default: assert(0);
- }
- }
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- if (!negation) sparc_branch (jit->ip, FALSE, sparc_boverflow, JIT_GET_ADDR(jit, a1));
- else sparc_branch (jit->ip, FALSE, sparc_bnoverflow, JIT_GET_ADDR(jit, a1));
- sparc_nop(jit->ip);
-}
-
-static inline void emit_fpbranch_op(struct jit * jit, struct jit_op * op, int cond, int arg1, int arg2)
-{
- sparc_fcmpd(jit->ip, arg1, arg2);
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- sparc_fbranch (jit->ip, FALSE, cond, JIT_GET_ADDR(jit, op->r_arg[0]));
- sparc_nop(jit->ip);
-}
-
-/* determines whether the argument value was spilled out or not,
- * if the register is associated with the hardware register
- * it is returned through the reg argument
- */
-// FIXME: more general, should use information from the reg. allocator
-static inline int is_spilled(int arg_id, jit_op * prepare_op, int * reg)
-{
- jit_hw_reg * hreg = rmap_get(prepare_op->regmap, arg_id);
- if (hreg) {
- *reg = hreg->id;
- return 0;
- }
- return 1;
-}
-
-static const int OUT_REGS[] = { sparc_o0, sparc_o1, sparc_o2, sparc_o3, sparc_o4, sparc_o5 };
-
-static inline void emit_set_arg_imm(struct jit * jit, int value, int slot)
-{
- if (slot < 6) sparc_set32(jit->ip, value, OUT_REGS[slot]);
- else {
- sparc_set32(jit->ip, value, sparc_g1);
- sparc_st_imm(jit->ip, sparc_g1, sparc_sp, 92 + (slot - 6) * 4);
- }
-}
-
-static inline void emit_set_arg_reg(struct jit * jit, int sreg, int slot)
-{
- if (slot < 6) sparc_mov_reg_reg(jit->ip, sreg, OUT_REGS[slot]);
- else sparc_st_imm(jit->ip, sreg, sparc_sp, 92 + (slot - 6) * 4);
-}
-
-static inline void emit_set_arg_freg(struct jit * jit, int sreg, int slot)
-{
- if (slot < 6) {
- sparc_stf_imm(jit->ip, sreg, sparc_fp, -8);
- sparc_ld_imm(jit->ip, sparc_fp, -8, OUT_REGS[slot]);
- } else sparc_stf_imm(jit->ip, sreg, sparc_sp, 92 + (slot - 6) * 4);
-}
-
-static inline void emit_set_arg_mem(struct jit * jit, int disp, int slot)
-{
- if (slot < 6) sparc_ld_imm(jit->ip, sparc_fp, disp, OUT_REGS[slot]);
- else {
- sparc_ld_imm(jit->ip, sparc_fp, disp, sparc_g1);
- sparc_st_imm(jit->ip, sparc_g1, sparc_sp, 92 + (slot - 6) * 4);
- }
-}
-
-static inline void emit_arguments(struct jit * jit)
-{
- int assoc_gp = 0;
- int sreg = 0;
-
- for (int i = 0; i < jit->prepared_args.count; i++) {
- struct jit_out_arg * arg = &(jit->prepared_args.args[i]);
- int64_t value = arg->value.generic;
- // integers
- if (!arg->isfp) {
- if (arg->isreg) {
- if (is_spilled(value, jit->prepared_args.op, &sreg))
- emit_set_arg_mem(jit, GET_REG_POS(jit, value), assoc_gp++);
- else emit_set_arg_reg(jit, sreg, assoc_gp++);
- } else emit_set_arg_imm(jit, value, assoc_gp++);
- continue;
- }
-
- // floats
- if (arg->size == sizeof(float)) {
- if (arg->isreg) {
- if (is_spilled(value, jit->prepared_args.op, &sreg)) {
- sparc_lddf_imm(jit->ip, sparc_fp, GET_REG_POS(jit, value), sparc_f30);
- sreg = sparc_f30;
- }
- sparc_fdtos(jit->ip, sreg, sparc_f30);
- emit_set_arg_freg(jit, sparc_f30, assoc_gp++);
- } else {
- float fl = (float)arg->value.fp;
- int fl_val;
- memcpy(&fl_val, &fl, sizeof(float));
- emit_set_arg_imm(jit, fl_val, assoc_gp++);
- }
- } else {
- // doubles
- if (arg->isreg) {
- int64_t value = arg->value.generic;
- if (is_spilled(value, jit->prepared_args.op, &sreg)) {
- sparc_lddf_imm(jit->ip, sparc_fp, GET_REG_POS(jit, value), sparc_f30);
- sreg = sparc_f30;
- }
- emit_set_arg_freg(jit, sreg, assoc_gp++);
- emit_set_arg_freg(jit, sreg + 1, assoc_gp++);
- } else {
- int fl_val[2];
- memcpy(fl_val, &(arg->value.fp), sizeof(double));
- emit_set_arg_imm(jit, fl_val[0], assoc_gp++);
- emit_set_arg_imm(jit, fl_val[1], assoc_gp++);
- }
- }
- }
-}
-
-static inline void emit_funcall(struct jit * jit, struct jit_op * op, int imm)
-{
- emit_arguments(jit);
- if (!imm) {
- sparc_call(jit->ip, op->r_arg[0], sparc_g0);
- } else {
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- if (op->r_arg[0] == (int64_t)JIT_FORWARD) {
- sparc_call_simple(jit->ip, 0);
- } else if (jit_is_label(jit, (void *)op->r_arg[0]))
-
- sparc_call_simple(jit->ip, ((int64_t)jit->buf - (int64_t)jit->ip) + (int64_t)((jit_label *)(op->r_arg[0]))->pos);
- else {
- sparc_call_simple(jit->ip, (int64_t)op->r_arg[0] - (int64_t)jit->ip);
- }
- }
- sparc_nop(jit->ip);
-}
-
-static void emit_get_arg_int(struct jit * jit, struct jit_inp_arg * arg, int dest_reg, int associated)
-{
- int read_from_stack = 0;
- int stack_pos;
-
- if (!arg->passed_by_reg) {
- read_from_stack = 1;
- stack_pos = arg->location.stack_pos;
- }
-
- if (arg->passed_by_reg && !associated) {
- // the register is not associated and the value has to be read from the memory
- read_from_stack = 1;
- stack_pos = arg->spill_pos;
- }
-
- if (read_from_stack) sparc_ld_imm(jit->ip, sparc_fp, stack_pos, dest_reg);
- else sparc_mov_reg_reg(jit->ip, arg->location.reg, dest_reg);
-}
-
-static void emit_get_arg_float(struct jit * jit, struct jit_inp_arg * arg, int dest_reg, int associated)
-{
- if (associated) {
- sparc_st_imm(jit->ip, arg->location.reg, sparc_fp, -8);
- sparc_ldf_imm(jit->ip, sparc_fp, -8, sparc_f30);
- sparc_fstod(jit->ip, sparc_f30, dest_reg);
- } else {
- sparc_ldf_imm(jit->ip, sparc_fp, arg->location.stack_pos, sparc_f30);
- sparc_fstod(jit->ip, sparc_f30, dest_reg);
- }
-}
-
-static void emit_get_arg_double(struct jit * jit, jit_op * op, struct jit_inp_arg * arg, int dest_reg, int associated)
-{
- int arg_id = op->r_arg[1];
-
- // moves the first part of the register
- if (associated) {
- sparc_st_imm(jit->ip, arg->location.reg, sparc_fp, -8);
- sparc_ldf_imm(jit->ip, sparc_fp, -8, dest_reg);
- } else {
- sparc_ldf_imm(jit->ip, sparc_fp, arg->location.stack_pos, dest_reg);
- }
-
- // moves the second part
- int reg_id = jit_mkreg_ex(arg->type == JIT_RTYPE_FLOAT, JIT_RTYPE_ARG, arg_id);
- associated = (rmap_get(op->regmap, reg_id) == NULL);
-
- struct jit_inp_arg arg2;
- init_arg(&arg2, arg->phys_reg + 1);
-
- if (associated && arg2.passed_by_reg) {
- sparc_st_imm(jit->ip, arg2.location.reg, sparc_fp, -4);
- sparc_ldf_imm(jit->ip, sparc_fp, -4, dest_reg + 1);
- } else {
- sparc_ldf_imm(jit->ip, sparc_fp, arg2.spill_pos, dest_reg + 1);
- }
-}
-
-static void emit_get_arg(struct jit * jit, jit_op * op)
-{
- int dreg = op->r_arg[0];
- int arg_id = op->r_arg[1];
-
- struct jit_inp_arg * arg = &(jit_current_func_info(jit)->args[arg_id]);
- int reg_id = jit_mkreg(arg->type == JIT_FLOAT_NUM ? JIT_RTYPE_FLOAT : JIT_RTYPE_INT, JIT_RTYPE_ARG, arg_id);
-
- int associated = (rmap_get(op->regmap, reg_id) != NULL);
-
- if (arg->type != JIT_FLOAT_NUM) emit_get_arg_int(jit, arg, dreg, associated);
- else {
- if (arg->size == sizeof(float)) emit_get_arg_float(jit, arg, dreg, associated);
- if (arg->size == sizeof(double)) emit_get_arg_double(jit, op, arg, dreg, associated);
-
- }
-}
-
-void jit_patch_external_calls(struct jit * jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if ((op->code == (JIT_CALL | IMM)) && (!jit_is_label(jit, (void *)op->arg[0])))
- sparc_patch(jit->buf + (int64_t)op->patch_addr, (int64_t)op->r_arg[0]);
- if (GET_OP(op) == JIT_MSG)
- sparc_patch(jit->buf + (int64_t)op->patch_addr, printf);
- }
-}
-
-void jit_patch_local_addrs(struct jit *jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
-
- if ((GET_OP(op) == JIT_REF_CODE) || (GET_OP(op) == JIT_REF_DATA)) {
- unsigned char *buf = jit->buf + (int64_t) op->patch_addr;
- jit_value addr = jit_is_label(jit, (void *)op->arg[1]) ? ((jit_label *)op->arg[1])->pos : op->arg[1];
- sparc_set32x(buf, jit->buf + addr, op->r_arg[0]);
- }
-
- if ((GET_OP(op) == JIT_DATA_REF_CODE) || (GET_OP(op) == JIT_DATA_REF_DATA)) {
- unsigned char *buf = jit->buf + (int64_t) op->patch_addr;
- jit_value addr = jit_is_label(jit, (void *)op->arg[0]) ? ((jit_label *)op->arg[0])->pos : op->arg[0];
- *((jit_value *)buf) = (jit_value) (jit->buf + addr);
- }
- }
-}
-
-/**
- * computes number of 1's in the given binary number
- * this was taken from the Hacker's Delight book by Henry S. Warren
- */
-static inline int _bit_pop(unsigned int x) {
- x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F);
- x = (x & 0x00FF00FF) + ((x >> 8) & 0x00FF00FF);
- x = (x & 0x0000FFFF) + ((x >>16) & 0x0000FFFF);
- return x;
-}
-
-/**
- * Generates multiplication using only the shift left and add operations
- */
-void emit_optimized_multiplication(struct jit * jit, int64_t a1, int64_t a2, int64_t a3)
-{
- int bits = _bit_pop(a3);
- uint64_t ar = (uint64_t)a3;
- int in_tmp = 0; // 1 if there's something the temporary registers g1, g2
- for (int i = 0; i < 32; i++) {
- if (ar & 0x1) {
- bits--;
- if (bits == 0) {
- // last and the only one bit to multiply with
- if (!in_tmp) sparc_sll_imm(jit->ip, a2, i, a1);
- else {
- sparc_sll_imm(jit->ip, a2, i, sparc_g2);
- sparc_add(jit->ip, FALSE, sparc_g1, sparc_g2, a1);
- }
- } else {
- if (!in_tmp) {
- sparc_sll_imm(jit->ip, a2, i, sparc_g1);
- in_tmp = 1;
- } else {
- sparc_sll_imm(jit->ip, a2, i, sparc_g2);
- sparc_add(jit->ip, FALSE, sparc_g1, sparc_g2, sparc_g1);
- }
- }
- }
- ar >>= 1;
- if (bits == 0) break;
- }
-}
-
-
-void emit_mul(struct jit * jit, jit_op * op)
-{
- int64_t a1 = op->r_arg[0];
- int64_t a2 = op->r_arg[1];
- int64_t a3 = op->r_arg[2];
- if (IS_IMM(op)) {
- if (a3 == 0) {
- sparc_mov_reg_reg(jit->ip, sparc_g0, a1);
- return;
- }
- if (a3 == 1) {
- if (a1 != a2) sparc_mov_reg_reg(jit->ip, a2, a1);
- return;
- }
- if ((a3 > 0) && (_bit_pop(a3) <= 5)) {
- emit_optimized_multiplication(jit, a1, a2, a3);
- return;
- }
- if ((a3 < 0) && (_bit_pop(-a3) <= 5)) {
- emit_optimized_multiplication(jit, a1, a2, -a3);
- sparc_neg(jit->ip, a1);
- return;
- }
- sparc_smul_imm(jit->ip, FALSE, a2, a3, a1);
- } else sparc_smul(jit->ip, FALSE, a2, a3, a1);
-}
-
-// common function for floor & ceil ops
-static void emit_sparc_round(struct jit * jit, int64_t a1, int64_t a2)
-{
- static double zero_point_5 = 0.5;
- sparc_set32(jit->ip, 0, sparc_g1);
-
- // tests the sign of the value
- sparc_fabss(jit->ip, a2, sparc_f30);
- sparc_fmovs(jit->ip, a2 + 1, sparc_f31);
- sparc_fcmpd(jit->ip, a2, sparc_f30);
-
- sparc_set32(jit->ip, (int64_t)&zero_point_5, sparc_g1);
- sparc_lddf(jit->ip, sparc_g1, sparc_g0, sparc_f30);
-
- // if a2 is greater than 0 -> skip negation
- unsigned char * br1 = jit->ip;
- sparc_fbranch(jit->ip, FALSE, sparc_fbge, 0);
- sparc_nop(jit->ip);
- sparc_fnegs(jit->ip, sparc_f30, sparc_f30);
-
- sparc_patch(br1, jit->ip);
-
- // conversion
- sparc_faddd(jit->ip, a2, sparc_f30, sparc_f30);
- sparc_fdtoi(jit->ip, sparc_f30, sparc_f30);
- sparc_stdf_imm(jit->ip, sparc_f30, sparc_fp, -8);
- sparc_ld_imm(jit->ip, sparc_fp, -8, a1);
-}
-
-// common function for floor & ceil ops
-static void emit_sparc_floor(struct jit * jit, int64_t a1, int64_t a2, int floor)
-{
- sparc_set32(jit->ip, 0, sparc_g1);
-
- // tests the sign of the value
- sparc_fabss(jit->ip, a2, sparc_f30);
- sparc_fmovs(jit->ip, a2 + 1, sparc_f31);
- sparc_fcmpd(jit->ip, a2, sparc_f30);
-
- unsigned char * br1 = jit->ip;
- sparc_fbranch(jit->ip, FALSE, (floor ? sparc_fbe : sparc_fbne), 0);
- sparc_nop(jit->ip);
-
- // branch1: conversion with correction
- sparc_fdtoi(jit->ip, a2, sparc_f30);
- sparc_fitod(jit->ip, sparc_f30, sparc_f30);
-
- sparc_fcmpd(jit->ip, a2, sparc_f30);
-
- unsigned char * br2 = jit->ip;
- sparc_fbranch(jit->ip, FALSE, sparc_fbe, 0); // skip correction if not desired
- sparc_nop(jit->ip);
-
- sparc_set32(jit->ip, (floor ? -1 : 1), sparc_g1);
-
- sparc_patch(br1, jit->ip);
- sparc_patch(br2, jit->ip);
-
- // branch2: direct conversion
- sparc_fdtoi(jit->ip, a2, sparc_f30);
- sparc_stdf_imm(jit->ip, sparc_f30, sparc_fp, -8);
- sparc_ld_imm(jit->ip, sparc_fp, -8, a1);
-
- // adds correction
- sparc_add(jit->ip, FALSE, a1, sparc_g1, a1);
-}
-
-static inline void emit_ureg(struct jit * jit, int64_t vreg, int64_t hreg_id)
-{
- if (JIT_REG(vreg).spec == JIT_RTYPE_ARG) {
- if (JIT_REG(vreg).type == JIT_RTYPE_INT) sparc_st_imm(jit->ip, hreg_id, sparc_fp, GET_REG_POS(jit, vreg));
- else {
- int arg_id = JIT_REG(vreg).id;
- struct jit_inp_arg * a = &(jit_current_func_info(jit)->args[arg_id]);
- if (a->passed_by_reg) sparc_st_imm(jit->ip, hreg_id, sparc_fp, a->spill_pos);
- }
- }
- if (JIT_REG(vreg).spec == JIT_RTYPE_REG) {
- if (JIT_REG(vreg).type != JIT_RTYPE_FLOAT)
- sparc_st_imm(jit->ip, hreg_id, sparc_fp, GET_REG_POS(jit, vreg));
- else sparc_stdf_imm(jit->ip, hreg_id, sparc_fp, GET_REG_POS(jit, vreg));
- }
-}
-
-#define emit_alu_op(cc, reg_op, imm_op) \
- if (IS_IMM(op)) {\
- if (a3 != 0) imm_op(jit->ip, cc, a2, a3, a1); \
- else reg_op(jit->ip, cc, a2, sparc_g0, a1); \
- } else reg_op(jit->ip, cc, a2, a3, a1); \
- break;
-
-void jit_gen_op(struct jit * jit, struct jit_op * op)
-{
- int64_t a1 = op->r_arg[0];
- int64_t a2 = op->r_arg[1];
- int64_t a3 = op->r_arg[2];
-
- int found = 1;
- switch (GET_OP(op)) {
- case JIT_ADD: emit_alu_op(FALSE, sparc_add, sparc_add_imm);
- case JIT_ADDC: emit_alu_op(sparc_cc, sparc_add, sparc_add_imm);
- case JIT_ADDX: emit_alu_op(FALSE, sparc_addx, sparc_addx_imm);
- case JIT_SUB: emit_alu_op(FALSE, sparc_sub, sparc_sub_imm);
- case JIT_SUBC: emit_alu_op(sparc_cc, sparc_sub, sparc_sub_imm);
- case JIT_SUBX: emit_alu_op(FALSE, sparc_subx, sparc_subx_imm);
- case JIT_RSB:
- if (IS_IMM(op)) {
- sparc_set32(jit->ip, a3, sparc_g1);
- sparc_sub(jit->ip, FALSE, sparc_g1, a2, a1);
- } else sparc_sub(jit->ip, FALSE, a3, a2, a1);
- break;
-
- case JIT_NEG: if (a1 != a2) sparc_mov_reg_reg(jit->ip, a2, a1);
- sparc_neg(jit->ip, a1);
- break;
-
- case JIT_NOT: if (a1 != a2) sparc_mov_reg_reg(jit->ip, a2, a1);
- sparc_not(jit->ip, a1);
- break;
- case JIT_OR: emit_alu_op(FALSE, sparc_or, sparc_or_imm);
- case JIT_AND: emit_alu_op(FALSE, sparc_and, sparc_and_imm);
- case JIT_XOR: emit_alu_op(FALSE, sparc_xor, sparc_xor_imm);
- case JIT_LSH: if (IS_IMM(op)) sparc_sll_imm(jit->ip, a2, a3, a1);
- else sparc_sll(jit->ip, a2, a3, a1);
- break;
- case JIT_RSH:
- if (IS_SIGNED(op)) {
- if (IS_IMM(op)) sparc_sra_imm(jit->ip, a2, a3, a1);
- else sparc_sra(jit->ip, a2, a3, a1);
- } else {
- if (IS_IMM(op)) sparc_srl_imm(jit->ip, a2, a3, a1);
- else sparc_srl(jit->ip, a2, a3, a1);
- }
- break;
-
- case JIT_MUL: emit_mul(jit, op); break;
-
- case JIT_HMUL:
- if (IS_IMM(op)) sparc_smul_imm(jit->ip, FALSE, a2, a3, sparc_g0);
- else sparc_smul(jit->ip, FALSE, a2, a3, sparc_g0);
- sparc_nop(jit->ip);
- sparc_rdy(jit->ip, a1);
- break;
-
- case JIT_DIV:
- if (IS_IMM(op)) {
- switch (a3) {
- case 2: sparc_sra_imm(jit->ip, a2, 1, a1); goto op_complete;
- case 4: sparc_sra_imm(jit->ip, a2, 2, a1); goto op_complete;
- case 8: sparc_sra_imm(jit->ip, a2, 3, a1); goto op_complete;
- case 16: sparc_sra_imm(jit->ip, a2, 4, a1); goto op_complete;
- case 32: sparc_sra_imm(jit->ip, a2, 5, a1); goto op_complete;
- }
- }
- sparc_sra_imm(jit->ip, a2, 31, sparc_g1);
- sparc_wry(jit->ip, sparc_g1, sparc_g0);
- sparc_nop(jit->ip);
- sparc_nop(jit->ip);
- sparc_nop(jit->ip);
-
- if (IS_IMM(op)) sparc_sdiv_imm(jit->ip, FALSE, a2, a3, a1);
- else sparc_sdiv(jit->ip, FALSE, a2, a3, a1);
- break;
-
- case JIT_MOD:
- if (IS_IMM(op)) {
- switch (a3) {
- case 2: sparc_and_imm(jit->ip, FALSE, a2, 0x01, a1); goto op_complete;
- case 4: sparc_and_imm(jit->ip, FALSE, a2, 0x03, a1); goto op_complete;
- case 8: sparc_and_imm(jit->ip, FALSE, a2, 0x07, a1); goto op_complete;
- case 16: sparc_and_imm(jit->ip, FALSE, a2, 0x0f, a1); goto op_complete;
- case 32: sparc_and_imm(jit->ip, FALSE, a2, 0x1f, a1); goto op_complete;
- }
- }
- sparc_sra_imm(jit->ip, a2, 31, sparc_g1);
- sparc_wry(jit->ip, sparc_g1, sparc_g0);
- sparc_nop(jit->ip);
- sparc_nop(jit->ip);
- sparc_nop(jit->ip);
- if (IS_IMM(op)) {
- sparc_sdiv_imm(jit->ip, FALSE, a2, a3, sparc_g1);
- sparc_smul_imm(jit->ip, FALSE, sparc_g1, a3, sparc_g1);
- } else {
- sparc_sdiv(jit->ip, FALSE, a2, a3, sparc_g1);
- sparc_smul(jit->ip, FALSE, sparc_g1, a3, sparc_g1);
- }
- sparc_sub(jit->ip, FALSE, a2, sparc_g1, a1);
- break;
- case JIT_LT: emit_cond_op_op(jit, op, IS_SIGNED(op) ? sparc_bl : sparc_blu, IS_IMM(op)); break;
- case JIT_LE: emit_cond_op_op(jit, op, IS_SIGNED(op) ? sparc_ble : sparc_bleu, IS_IMM(op)); break;
- case JIT_GT: emit_cond_op_op(jit, op, IS_SIGNED(op) ? sparc_bg : sparc_bgu, IS_IMM(op)); break;
- case JIT_GE: emit_cond_op_op(jit, op, IS_SIGNED(op) ? sparc_bge : sparc_bgeu, IS_IMM(op)); break;
- case JIT_EQ: emit_cond_op_op(jit, op, sparc_be, IS_IMM(op)); break;
- case JIT_NE: emit_cond_op_op(jit, op, sparc_bne, IS_IMM(op)); break;
- case JIT_BLT: emit_branch_op(jit, op, IS_SIGNED(op) ? sparc_bl : sparc_blu, IS_IMM(op)); break;
- case JIT_BGT: emit_branch_op(jit, op, IS_SIGNED(op) ? sparc_bg : sparc_bgu, IS_IMM(op)); break;
- case JIT_BLE: emit_branch_op(jit, op, IS_SIGNED(op) ? sparc_ble : sparc_bleu, IS_IMM(op)); break;
- case JIT_BGE: emit_branch_op(jit, op, IS_SIGNED(op) ? sparc_bge : sparc_bgeu, IS_IMM(op)); break;
- case JIT_BEQ: emit_branch_op(jit, op, sparc_be, IS_IMM(op)); break;
- case JIT_BNE: emit_branch_op(jit, op, sparc_bne, IS_IMM(op)); break;
- case JIT_BMS: emit_branch_mask_op(jit, op, sparc_bne, IS_IMM(op)); break;
- case JIT_BMC: emit_branch_mask_op(jit, op, sparc_be, IS_IMM(op)); break;
- case JIT_BOADD: emit_op_and_overflow_branch(jit, op, JIT_ADD, IS_IMM(op), 0); break;
- case JIT_BOSUB: emit_op_and_overflow_branch(jit, op, JIT_SUB, IS_IMM(op), 0); break;
- case JIT_BNOADD: emit_op_and_overflow_branch(jit, op, JIT_ADD, IS_IMM(op), 1); break;
- case JIT_BNOSUB: emit_op_and_overflow_branch(jit, op, JIT_SUB, IS_IMM(op), 1); break;
-
- case JIT_CALL: emit_funcall(jit, op, IS_IMM(op)); break;
-
- case JIT_PATCH: do {
- struct jit_op *target = (struct jit_op *) a1;
- switch (GET_OP(target)) {
- case JIT_REF_CODE:
- case JIT_REF_DATA:
- target->arg[1] = JIT_BUFFER_OFFSET(jit);
- break;
- case JIT_DATA_REF_CODE:
- case JIT_DATA_REF_DATA:
- target->arg[0] = JIT_BUFFER_OFFSET(jit);
- break;
- default: {
- int64_t pa = ((struct jit_op *)a1)->patch_addr;
- sparc_patch(jit->buf + pa, jit->ip);
- }
- }
- } while (0);
- break;
-
- case JIT_JMP:
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- if (op->code & REG) sparc_jmp(jit->ip, a1, sparc_g0);
- else sparc_branch(jit->ip, FALSE, sparc_balways, JIT_GET_ADDR(jit, op->r_arg[0]));
- sparc_nop(jit->ip);
- break;
- case JIT_RET:
- if (!IS_IMM(op) && (a1 != sparc_i0)) sparc_mov_reg_reg(jit->ip, a1, sparc_i0);
- if (IS_IMM(op)) sparc_set32(jit->ip, a1, sparc_i0);
- sparc_ret(jit->ip);
- sparc_restore_imm(jit->ip, sparc_g0, 0, sparc_g0);
- break;
-
- case JIT_PUTARG: funcall_put_arg(jit, op); break;
- case JIT_FPUTARG: funcall_fput_arg(jit, op); break;
- case JIT_GETARG: emit_get_arg(jit, op); break;
- case JIT_MSG:
- sparc_set(jit->ip, a1, sparc_o0);
- if (!IS_IMM(op)) sparc_mov_reg_reg(jit->ip, a2, sparc_o1);
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- sparc_call_simple(jit->ip, printf);
- sparc_nop(jit->ip);
- break;
-
- case JIT_ALLOCA: break;
-
- case JIT_CODE_ALIGN: {
- int count = op->arg[0];
- assert(!(count % 4));
- while ((uint64_t)jit->ip % count) {
- if ((uint64_t)jit->ip % 4) {
- *jit->ip = 0;
- jit->ip++;
- }
- else sparc_nop(jit->ip);
- }
- }
- break;
-
- case JIT_REF_CODE:
- case JIT_REF_DATA:
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- sparc_set32x(jit->ip, 0xdeadbeef, a1);
- break;
-
-
- // platform independent opcodes handled in the jitlib-core.c
- case JIT_DATA_BYTE: break;
- case JIT_FULL_SPILL: break;
-
- default: found = 0;
- }
-
-op_complete:
- if (found) return;
-
- switch (op->code) {
- case (JIT_MOV | REG): if (a1 != a2) sparc_mov_reg_reg(jit->ip, a2, a1); break;
- case (JIT_MOV | IMM): sparc_set32(jit->ip, a2, a1); break;
- case JIT_PREPARE: funcall_prepare(jit, op, a1 + a2); break;
- case JIT_PROLOG:
- do {
- jit->current_func = op;
- struct jit_func_info * info = jit_current_func_info(jit);
- int stack_mem = 96;
-
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- stack_mem += info->allocai_mem;
- stack_mem += info->gp_reg_count * REG_SIZE;
- stack_mem += info->fp_reg_count * sizeof(double);
- stack_mem += info->float_arg_cnt * sizeof(double);
- stack_mem += space_for_outgoing_args(jit, op);
-
- stack_mem = jit_value_align(stack_mem, 16);
- sparc_save_imm(jit->ip, sparc_sp, -stack_mem, sparc_sp);
- } while (0);
- break;
- case JIT_RETVAL:
- // o0 is not a part of the reg. pool and thus
- // reg. allocator can not take care of the proper register assignment
- if (a1 != sparc_o0) sparc_mov_reg_reg(jit->ip, sparc_o0, a1);
- break;
-
- case JIT_DECL_ARG: break;
-
- case JIT_LABEL: ((jit_label *)a1)->pos = JIT_BUFFER_OFFSET(jit); break;
-
- case (JIT_LD | REG | SIGNED):
- switch (op->arg_size) {
- case 1: sparc_ldsb(jit->ip, a2, sparc_g0, a1); break;
- case 2: sparc_ldsh(jit->ip, a2, sparc_g0, a1); break;
- case 4: sparc_ld(jit->ip, a2, sparc_g0, a1); break;
- default: abort();
- } break;
-
- case (JIT_LD | REG | UNSIGNED):
- switch (op->arg_size) {
- case 1: sparc_ldub(jit->ip, a2, sparc_g0, a1); break;
- case 2: sparc_lduh(jit->ip, a2, sparc_g0, a1); break;
- case 4: sparc_ld(jit->ip, a2, sparc_g0, a1); break;
- default: abort();
- } break;
-
- case (JIT_LD | IMM | SIGNED):
- switch (op->arg_size) {
- case 1: sparc_ldsb_imm(jit->ip, sparc_g0, a2, a1); break;
- case 2: sparc_ldsh_imm(jit->ip, sparc_g0, a2, a1); break;
- case 4: sparc_ld_imm(jit->ip, sparc_g0, a2, a1); break;
- default: abort();
- } break;
-
- case (JIT_LD | IMM | UNSIGNED):
- switch (op->arg_size) {
- case 1: sparc_ldub_imm(jit->ip, sparc_g0, a2, a1); break;
- case 2: sparc_lduh_imm(jit->ip, sparc_g0, a2, a1); break;
- case 4: sparc_ld_imm(jit->ip, sparc_g0, a2, a1); break;
- default: abort();
- } break;
-
- case (JIT_LDX | IMM | SIGNED):
- switch (op->arg_size) {
- case 1: sparc_ldsb_imm(jit->ip, a2, a3, a1); break;
- case 2: sparc_ldsh_imm(jit->ip, a2, a3, a1); break;
- case 4: sparc_ld_imm(jit->ip, a2, a3, a1); break;
- default: abort();
- } break;
-
- case (JIT_LDX | IMM | UNSIGNED):
- switch (op->arg_size) {
- case 1: sparc_ldub_imm(jit->ip, a2, a3, a1); break;
- case 2: sparc_lduh_imm(jit->ip, a2, a3, a1); break;
- case 4: sparc_ld_imm(jit->ip, a2, a3, a1); break;
- default: abort();
- } break;
-
- case (JIT_LDX | REG | SIGNED):
- switch (op->arg_size) {
- case 1: sparc_ldsb(jit->ip, a2, a3, a1); break;
- case 2: sparc_ldsh(jit->ip, a2, a3, a1); break;
- case 4: sparc_ld(jit->ip, a2, a3, a1); break;
- default: abort();
- } break;
-
- case (JIT_LDX | REG | UNSIGNED):
- switch (op->arg_size) {
- case 1: sparc_ldub(jit->ip, a2, a3, a1); break;
- case 2: sparc_lduh(jit->ip, a2, a3, a1); break;
- case 4: sparc_ld(jit->ip, a2, a3, a1); break;
- default: abort();
- } break;
-
- case (JIT_ST | REG):
- switch (op->arg_size) {
- case 1: sparc_stb(jit->ip, a2, sparc_g0, a1); break;
- case 2: sparc_sth(jit->ip, a2, sparc_g0, a1); break;
- case 4: sparc_st(jit->ip, a2, sparc_g0, a1); break;
- default: abort();
- } break;
-
- case (JIT_ST | IMM):
- switch (op->arg_size) {
- case 1: sparc_stb_imm(jit->ip, sparc_g0, a2, a1); break;
- case 2: sparc_sth_imm(jit->ip, sparc_g0, a2, a1); break;
- case 4: sparc_st_imm(jit->ip, sparc_g0, a2, a1); break;
- default: abort();
- } break;
-
-
- case (JIT_STX | REG):
- switch (op->arg_size) {
- case 1: sparc_stb(jit->ip, a3, a2, a1); break;
- case 2: sparc_sth(jit->ip, a3, a2, a1); break;
- case 4: sparc_st(jit->ip, a3, a2, a1); break;
- default: abort();
- } break;
-
- case (JIT_STX | IMM):
- switch (op->arg_size) {
- case 1: sparc_stb_imm(jit->ip, a3, a2, a1); break;
- case 2: sparc_sth_imm(jit->ip, a3, a2, a1); break;
- case 4: sparc_st_imm(jit->ip, a3, a2, a1); break;
- default: abort();
- } break;
-
- //
- // Floating-point operations;
- //
- case (JIT_FMOV | REG):
- sparc_fmovs(jit->ip, a2, a1);
- sparc_fmovs(jit->ip, a2 + 1, a1 + 1);
- break;
- case (JIT_FMOV | IMM):
- sparc_set32(jit->ip, (int64_t)&op->flt_imm, sparc_g1);
- sparc_lddf(jit->ip, sparc_g1, sparc_g0, a1);
- break;
- case (JIT_FADD | REG): sparc_faddd(jit->ip, a2, a3, a1); break;
- case (JIT_FSUB | REG): sparc_fsubd(jit->ip, a2, a3, a1); break;
- case (JIT_FRSB | REG): sparc_fsubd(jit->ip, a3, a2, a1); break;
- case (JIT_FMUL | REG): sparc_fmuld(jit->ip, a2, a3, a1); break;
- case (JIT_FDIV | REG): sparc_fdivd(jit->ip, a2, a3, a1); break;
- case (JIT_FNEG | REG): sparc_fnegs(jit->ip, a2, a1); break;
-
- case (JIT_FBLT | REG): emit_fpbranch_op(jit, op, sparc_fbl, a2, a3); break;
- case (JIT_FBGT | REG): emit_fpbranch_op(jit, op, sparc_fbg, a2, a3); break;
- case (JIT_FBLE | REG): emit_fpbranch_op(jit, op, sparc_fble, a2, a3); break;
- case (JIT_FBGE | REG): emit_fpbranch_op(jit, op, sparc_fbge, a2, a3); break;
- case (JIT_FBEQ | REG): emit_fpbranch_op(jit, op, sparc_fbe, a2, a3); break;
- case (JIT_FBNE | REG): emit_fpbranch_op(jit, op, sparc_fbne, a2, a3); break;
- case (JIT_TRUNC | REG):
- sparc_fdtoi(jit->ip, a2, sparc_f30);
- sparc_stdf_imm(jit->ip, sparc_f30, sparc_fp, -8);
- sparc_ld_imm(jit->ip, sparc_fp, -8, a1);
- break;
- case (JIT_EXT | REG):
- sparc_st_imm(jit->ip, a2, sparc_fp, -8);
- sparc_ldf_imm(jit->ip, sparc_fp, -8, sparc_f30);
- sparc_fitod(jit->ip, sparc_f30, a1);
- break;
-
- case (JIT_FLOOR | REG): emit_sparc_floor(jit, a1, a2, 1); break;
- case (JIT_CEIL | REG): emit_sparc_floor(jit, a1, a2, 0); break;
- case (JIT_ROUND | REG): emit_sparc_round(jit, a1, a2); break;
-
- case (JIT_FRET | REG):
- if (op->arg_size == sizeof(float)) {
- sparc_fdtos(jit->ip, a1, sparc_f0);
- } else {
- sparc_fmovs(jit->ip, a1, sparc_f0);
- sparc_fmovs(jit->ip, a1 + 1, sparc_f1);
- }
- sparc_ret(jit->ip);
- sparc_restore_imm(jit->ip, sparc_g0, 0, sparc_g0);
- break;
-
- case (JIT_FRETVAL):
- // reg. allocator takes care of proper assignment of the register
- if (op->arg_size == sizeof(float)) sparc_fstod(jit->ip, sparc_f0, sparc_f0);
- break;
-
- case (JIT_FLD | REG):
- if (op->arg_size == sizeof(double)) sparc_lddf(jit->ip, a2, sparc_g0, a1);
- else {
- sparc_ldf(jit->ip, a2, sparc_g0, a1);
- sparc_fstod(jit->ip, a1, a1);
- }
- break;
-
- case (JIT_FLD | IMM):
- if (op->arg_size == sizeof(double)) sparc_lddf_imm(jit->ip, sparc_g0, a2, a1);
- else {
- sparc_ldf_imm(jit->ip, sparc_g0, a2, a1);
- sparc_fstod(jit->ip, a1, a1);
- }
- break;
-
- case (JIT_FLDX | REG):
- if (op->arg_size == sizeof(double)) sparc_lddf(jit->ip, a2, a3, a1);
- else {
- sparc_ldf(jit->ip, a2, a3, a1);
- sparc_fstod(jit->ip, a1, a1);
- }
- break;
-
- case (JIT_FLDX | IMM):
- if (op->arg_size == sizeof(double)) sparc_lddf_imm(jit->ip, a2, a3, a1);
- else {
- sparc_ldf_imm(jit->ip, a2, a3, a1);
- sparc_fstod(jit->ip, a1, a1);
- }
- break;
-
- case (JIT_FST | REG):
- if (op->arg_size == sizeof(double)) sparc_stdf(jit->ip, a2, a1, sparc_g0);
- else {
- sparc_fdtos(jit->ip, a2, sparc_f30);
- sparc_stf(jit->ip, sparc_f30, a1, sparc_g0);
- }
- break;
-
- case (JIT_FST | IMM):
- if (op->arg_size == sizeof(double)) sparc_stdf_imm(jit->ip, a2, sparc_g0, a1);
- else {
- sparc_fdtos(jit->ip, a2, sparc_f30);
- sparc_stdf_imm(jit->ip, sparc_f30, sparc_g0, a1);
- }
- break;
-
- case (JIT_FSTX | REG):
- if (op->arg_size == sizeof(double)) sparc_stdf(jit->ip, a3, a2, a1);
- else {
- sparc_fdtos(jit->ip, a3, sparc_f30);
- sparc_stf(jit->ip, sparc_f30, a2, a1);
- }
- break;
-
- case (JIT_FSTX | IMM):
- if (op->arg_size == sizeof(double)) sparc_stdf_imm(jit->ip, a3, a2, a1);
- else {
- sparc_fdtos(jit->ip, a3, sparc_f30);
- sparc_stf_imm(jit->ip, sparc_f30, a2, a1);
- }
- break;
-
- case (JIT_UREG): emit_ureg(jit, a1, a2); break;
- case (JIT_SYNCREG): emit_ureg(jit, a1, a2); break;
- case (JIT_LREG):
- if (JIT_REG(a2).spec == JIT_RTYPE_ARG) assert(0);
- if (JIT_REG(a2).type == JIT_RTYPE_INT)
- sparc_ld_imm(jit->ip, sparc_fp, GET_REG_POS(jit, a2), a1);
- else sparc_lddf_imm(jit->ip, sparc_fp, GET_REG_POS(jit, a2), a1);
- break;
- case JIT_RENAMEREG: sparc_mov_reg_reg(jit->ip, a2, a1); break;
- case JIT_CODESTART: break;
- case JIT_NOP: break;
- default: printf("sparc: unknown operation (opcode: 0x%x)\n", GET_OP(op) >> 3);
- }
-}
-
-struct jit_reg_allocator * jit_reg_allocator_create()
-{
- struct jit_reg_allocator * a = JIT_MALLOC(sizeof(struct jit_reg_allocator));
- a->gp_reg_cnt = 14;
-#ifdef JIT_REGISTER_TEST
- a->gp_reg_cnt -= 5;
-#endif
- a->gp_regs = JIT_MALLOC(sizeof(jit_hw_reg) * (a->gp_reg_cnt + 1));
-
- /* only the l0-l7 and i0-i5 registers are used
- * all these registers are callee-saved withou special care
- * register o0-o5 are used only for argument passing
- * all g1-g3 are free for use in the codegenarator
- */
- int i = 0;
- a->gp_regs[i++] = (jit_hw_reg) { sparc_i0, "i0", 1, 0, 11 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_i1, "i1", 1, 0, 12 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_i2, "i2", 1, 0, 13 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_i3, "i3", 1, 0, 14 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_i4, "i4", 1, 0, 15 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_i5, "i5", 1, 0, 16 };
-
- a->gp_regs[i++] = (jit_hw_reg) { sparc_l0, "l0", 1, 0, 1 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_l1, "l1", 1, 0, 2 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_l2, "l2", 1, 0, 3 };
-#ifndef JIT_REGISTER_TEST
- a->gp_regs[i++] = (jit_hw_reg) { sparc_l3, "l3", 1, 0, 4 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_l4, "l4", 1, 0, 5 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_l5, "l5", 1, 0, 6 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_l6, "l6", 1, 0, 7 };
- a->gp_regs[i++] = (jit_hw_reg) { sparc_l7, "l7", 1, 0, 8 };
-#endif
-
- a->gp_regs[i++] = (jit_hw_reg) { sparc_fp, "fp", 0, 0, 0 };
-
- a->fp_reg_cnt = 4;
- a->fp_regs = JIT_MALLOC(sizeof(jit_hw_reg) * a->fp_reg_cnt);
-
- i = 0;
- a->fp_regs[i++] = (jit_hw_reg) { sparc_f0, "f0", 0, 1, 1 };
- a->fp_regs[i++] = (jit_hw_reg) { sparc_f2, "f2", 0, 1, 2 };
- a->fp_regs[i++] = (jit_hw_reg) { sparc_f4, "f4", 0, 1, 3 };
- a->fp_regs[i++] = (jit_hw_reg) { sparc_f6, "f6", 0, 1, 4 };
-
- jit_hw_reg * reg_i7 = malloc(sizeof(jit_hw_reg));
-
- *reg_i7 = (jit_hw_reg) { sparc_i7, "iX", 1, 0, 0 };
-
- a->fp_reg = sparc_fp;
- a->ret_reg = NULL;
- a->fpret_reg = &(a->fp_regs[0]);
-
-
- a->gp_arg_reg_cnt = 6;
- a->gp_arg_regs = JIT_MALLOC(sizeof(jit_hw_reg *) * 6);
- for (int i = 0; i < 6; i++)
- a->gp_arg_regs[i] = &(a->gp_regs[i]);
-
- a->fp_arg_reg_cnt = 0;
- a->fp_arg_regs = NULL;
-
- return a;
-}
diff --git a/ext/myjit/myjit/sse2-specific.h b/ext/myjit/myjit/sse2-specific.h
deleted file mode 100755
index 6c5b1a9..0000000
--- a/ext/myjit/myjit/sse2-specific.h
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-//
-//
-// Provides aliases for SSE operation accordingly to the hardware platform
-//
-//
-
-//
-// I386 support
-//
-
-#ifdef JIT_ARCH_I386
-#define sse_movsd_reg_reg(ip, r1, r2) x86_movsd_reg_reg(ip, r1, r2)
-#define sse_movsd_reg_mem(ip, r1, mem) x86_movsd_reg_mem(ip, r1, mem)
-#define sse_movlpd_membase_xreg(ip, dreg, basereg, disp) x86_movlpd_membase_xreg(ip, dreg, basereg, disp)
-#define sse_movlpd_xreg_membase(ip, dreg, basereg, disp) x86_movlpd_xreg_membase(ip, dreg, basereg, disp)
-#define sse_movlpd_mem_reg(ip, mem, reg) x86_movlpd_mem_xreg(ip, mem, reg)
-#define sse_movlpd_xreg_memindex(ip, dreg, basereg, disp, indexreg, shift) x86_movlpd_xreg_memindex(ip, dreg, basereg, disp, indexreg, shift)
-#define sse_movss_membase_reg(ip, basereg, disp, reg) x86_movss_membase_xreg(ip, reg, basereg, disp)
-#define sse_movss_mem_reg(ip, mem, reg) x86_movss_mem_xreg(ip, reg, mem)
-#define sse_movss_memindex_xreg(ip, basereg, disp, indexreg, shift, reg) x86_movss_memindex_xreg(ip, reg, basereg, disp, indexreg, shift)
-#define sse_movlpd_memindex_xreg(ip, basereg, disp, indexreg, shift, reg) x86_movlpd_memindex_xreg(ip, reg, basereg, disp, indexreg, shift)
-
-#define sse_alu_sd_reg_reg(ip, op, r1, r2) x86_sse_alu_sd_reg_reg(ip, op, r1, r2)
-#define sse_mov_reg_safeimm(jit, xop, reg, imm) x86_movsd_reg_mem(jit->ip, reg, imm)
-#define sse_alu_sd_reg_safeimm(jit, xop, op, reg, imm) x86_sse_alu_sd_reg_mem(jit->ip, op, reg, imm)
-
-#define sse_alu_pd_reg_reg(ip, op, r1, r2) x86_sse_alu_pd_reg_reg(ip, op, r1, r2)
-#define sse_alu_pd_reg_reg_imm(ip, op, r1, r2, imm) x86_sse_alu_pd_reg_reg_imm(ip, op, r1, r2, imm)
-#define sse_alu_pd_reg_safeimm(jit, xop, op, reg, imm) x86_sse_alu_pd_reg_mem(jit->ip, op, reg, imm)
-
-#define sse_comisd_reg_reg(ip, r1, r2) x86_sse_alu_pd_reg_reg(ip, X86_SSE_COMI, r1, r2)
-
-#define sse_cvttsd2si_reg_reg(ip, r1, r2) x86_cvttsd2si(ip, r1, r2)
-#define sse_cvtsi2sd_reg_reg(ip, r1, r2) x86_cvtsi2sd(ip, r1, r2)
-#define sse_cvtsd2ss_reg_reg(ip, r1, r2) x86_cvtsd2ss(ip, r1, r2)
-#define sse_cvtss2sd_reg_reg(ip, r1, r2) x86_cvtss2sd(ip, r1, r2)
-#define sse_cvtss2sd_reg_mem(ip, r1, mem) x86_cvtss2sd_reg_mem(ip, r1, mem)
-#define sse_cvtss2sd_reg_membase(ip, r1, basereg, disp) x86_cvtss2sd_reg_membase(ip, r1, basereg, disp)
-#define sse_cvtss2sd_reg_memindex(ip, r1, basereg, disp, indexreg, shift) x86_cvtss2sd_reg_memindex(ip, r1, basereg, disp, indexreg, shift)
-
-#endif
-
-//
-// AMD64 support
-//
-
-#ifdef JIT_ARCH_AMD64
-
-#define sse_alu_sd_reg_reg(ip,op,r1,r2) amd64_sse_alu_sd_reg_reg(ip,op,r1,r2)
-#define sse_alu_pd_reg_reg(ip,op,r1,r2) amd64_sse_alu_pd_reg_reg(ip,op,r1,r2)
-#define sse_movsd_reg_reg(ip,r1,r2) amd64_sse_movsd_reg_reg(ip,r1,r2)
-#define sse_movsd_reg_mem(ip, r1, mem) amd64_movsd_reg_mem(ip,r1,mem)
-#define sse_movsd_reg_membase(ip, r1, basereg, disp) amd64_movsd_reg_membase(ip, r1, basereg, disp)
-#define sse_movlpd_membase_xreg(ip,dreg,basereg,disp) amd64_sse_movlpd_membase_xreg(ip,dreg,basereg,disp)
-#define sse_movlpd_xreg_membase(ip,dreg,basereg,disp) amd64_sse_movlpd_xreg_membase(ip,dreg,basereg,disp)
-#define sse_movlpd_memindex_xreg(ip, basereg, disp, indexreg, shift, reg) amd64_sse_movlpd_memindex_xreg(ip, basereg, disp, indexreg, shift, reg)
-
-
-#define sse_movlpd_mem_reg(ip, mem, reg) amd64_movlpd_mem_reg(ip, mem, reg)
-#define sse_movlpd_xreg_memindex(ip, dreg, basereg, disp, indexreg, shift) amd64_sse_movlpd_xreg_memindex(ip, dreg, basereg, disp, indexreg, shift)
-
-#define sse_movss_membase_reg(ip, basereg, disp, reg) amd64_movss_membase_reg(ip, basereg, disp, reg)
-#define sse_movss_mem_reg(ip, mem, reg) amd64_movss_mem_reg(ip, mem, reg)
-#define sse_movss_memindex_xreg(ip, basereg, disp, indexreg, shift, reg) amd64_sse_movss_memindex_xreg(ip, basereg,disp, indexreg,shift, reg)
-
-#define sse_comisd_reg_reg(ip, r1, r2) amd64_sse_comisd_reg_reg(ip, r1, r2)
-#define sse_alu_pd_reg_reg_imm(ip, op, r1, r2, imm) amd64_sse_alu_pd_reg_reg_imm(ip, op, r1, r2, imm)
-
-#define sse_cvttsd2si_reg_reg(ip, r1, r2) amd64_sse_cvttsd2si_reg_reg(ip, r1, r2)
-#define sse_cvtsi2sd_reg_reg(ip, r1, r2) amd64_sse_cvtsi2sd_reg_reg(ip, r1, r2)
-#define sse_cvtsd2ss_reg_reg(ip, r1, r2) amd64_sse_cvtsd2ss_reg_reg(ip, r1, r2)
-#define sse_cvtss2sd_reg_reg(ip, r1, r2) amd64_sse_cvtss2sd_reg_reg(ip, r1, r2)
-#define sse_cvtss2sd_reg_mem(ip, r1, mem) amd64_sse_cvtss2sd_reg_mem(ip, r1, mem)
-#define sse_cvtss2sd_reg_membase(ip, r1, basereg, disp) amd64_sse_cvtss2sd_reg_membase(ip, r1, basereg, disp)
-#define sse_cvtss2sd_reg_memindex(ip, r1, basereg, disp, indexreg, shift) amd64_sse_cvtss2sd_reg_memindex(ip, r1, basereg, disp, indexreg, shift)
-
-
-/**
- * This function emits SSE code which assigns value value which resides in the memory
- * in to the XMM register If the value is not addressable with 32bit address, unused
- * register from the register pool is used to access this value.
- */
-static void sse_mov_reg_safeimm(struct jit * jit, jit_op * op, jit_value reg, double * imm)
-{
- *(jit->ip)++ = (unsigned char)0xf2;
- amd64_emit_rex(jit->ip, 8, (reg), 0, (AMD64_RIP));
- *(jit->ip)++ = (unsigned char)0x0f;
- *(jit->ip)++ = (unsigned char)0x10;
- x86_membase_emit ((jit->ip), (reg) & 0x7, (AMD64_RIP), (0x112233)); //0x112233 Forces a 32bit displacement
- jit_flt_rip_relloc reloc={(jit->ip-jit->buf)-4,*imm};
- vec_push(&jit->flt_rellocs,reloc);
-}
-
-/**
- * This function emits SSE code involving arithmetic (packed) operation and immediate
- * value which resides in the memory. If the value is not addressable with 32bit
- * address, unused register from the register pool is used to access
- * this value.
- */
-static void sse_alu_pd_reg_safeimm(struct jit * jit, jit_op * op, int op_id, int reg, double * imm)
-{
- jit_hw_reg * r = jit_get_unused_reg(jit->reg_al, op, 0);
- if (r) {
- amd64_emit_rex(jit->ip, 8, (r->id), 0, (AMD64_RIP));
- *(jit->ip)++ = (unsigned char)0x8d;
- x86_membase_emit ((jit->ip), (r->id) & 0x7, (AMD64_RIP), (0x112233)); //0x112233 Forces a 32bit displacement
- jit_flt_rip_relloc reloc={(jit->ip-jit->buf)-4,*imm};
- vec_push(&jit->flt_rellocs,reloc);
- amd64_sse_alu_pd_reg_membase(jit->ip, op_id, reg, r->id, 0);
- } else {
- amd64_emit_rex(jit->ip, 8, (AMD64_RAX), 0, (AMD64_RIP));
- *(jit->ip)++ = (unsigned char)0x8d;
- x86_membase_emit ((jit->ip), (AMD64_RAX) & 0x7, (AMD64_RIP), (0x112233)); //0x112233 Forces a 32bit displacement
- jit_flt_rip_relloc reloc={(jit->ip-jit->buf)-4,*imm};
- vec_push(&jit->flt_rellocs,reloc);
- amd64_sse_alu_pd_reg_membase(jit->ip, op_id, reg, AMD64_RAX, 0);
- }
-}
-
-/**
- * This function emits SSE code involving arithmetic (single) operation and immediate
- * value which resides in the memory. If the value is not addressable with 32bit
- * address, unused register from the register pool is used to access
- * this value.
- */
-static void sse_alu_sd_reg_safeimm(struct jit * jit, jit_op * op, int op_id, int reg, double * imm)
-{
- if (((jit_unsigned_value)imm) > 0xffffffffUL) {
- jit_hw_reg * r = jit_get_unused_reg(jit->reg_al, op, 0);
- if (r) {
- amd64_mov_reg_imm(jit->ip, r->id, (int64_t)imm);
- amd64_sse_alu_sd_reg_membase(jit->ip, op_id, reg, r->id, 0);
- } else {
- amd64_push_reg(jit->ip, AMD64_RAX);
- amd64_mov_reg_imm(jit->ip, AMD64_RAX, (int64_t)imm);
- amd64_sse_alu_sd_reg_membase(jit->ip, op_id, reg, AMD64_RAX, 0);
- amd64_pop_reg(jit->ip, AMD64_RAX);
- }
- } else {
- amd64_sse_alu_sd_reg_mem(jit->ip, op_id, reg, (int64_t)imm);
- }
-}
-
-#else
-#endif
-
-//
-//
-// Implementation of functions emitting high-level floating point operations
-//
-//
-
-static unsigned char * emit_sse_get_sign_mask()
-{
- // gets 16-bytes aligned value
- static unsigned char bufx[32];
- unsigned char * buf = bufx + 1;
- while ((int64_t)buf % 16) buf++;
- uint64_t * bit_mask = (uint64_t *)buf;
-
- // inverts 64th (sing) bit
- *bit_mask = (uint64_t)1 << 63;
- return buf;
-}
-
-static void emit_sse_alu_op(struct jit * jit, jit_op * op, int sse_op)
-{
- if (op->r_arg[0] == op->r_arg[1]) {
- sse_alu_sd_reg_reg(jit->ip, sse_op, op->r_arg[0], op->r_arg[2]);
- } else if (op->r_arg[0] == op->r_arg[2]) {
- sse_alu_sd_reg_reg(jit->ip, sse_op, op->r_arg[0], op->r_arg[1]);
- } else {
- sse_movsd_reg_reg(jit->ip, op->r_arg[0], op->r_arg[1]);
- sse_alu_sd_reg_reg(jit->ip, sse_op, op->r_arg[0], op->r_arg[2]);
- }
-}
-
-static void emit_sse_change_sign(struct jit * jit, jit_op * op, int reg)
-{
- sse_alu_pd_reg_safeimm(jit, op, X86_SSE_XOR, reg, (double *)emit_sse_get_sign_mask());
-}
-
-static void emit_sse_sub_op(struct jit * jit, jit_op * op, int64_t a1, int64_t a2, int64_t a3)
-{
- if (a1 == a2) {
- sse_alu_sd_reg_reg(jit->ip, X86_SSE_SUB, a1, a3);
- } else if (a1 == a3) {
- sse_alu_sd_reg_reg(jit->ip, X86_SSE_SUB, a1, a2);
- emit_sse_change_sign(jit, op, a1);
- } else {
- sse_movsd_reg_reg(jit->ip, a1, a2);
- sse_alu_sd_reg_reg(jit->ip, X86_SSE_SUB, a1, a3);
- }
-}
-
-static void emit_sse_div_op(struct jit * jit, int64_t a1, int64_t a2, int64_t a3)
-{
- if (a1 == a2) {
- sse_alu_sd_reg_reg(jit->ip, X86_SSE_DIV, a1, a3);
- } else if (a1 == a3) {
- // creates a copy of the a2 into high bits of a2
- x86_sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a2, a2, 0);
-
- // divides a2 by a3 and moves to the results
- sse_alu_sd_reg_reg(jit->ip, X86_SSE_DIV, a2, a3);
- sse_movsd_reg_reg(jit->ip, a1, a2);
-
- // returns the the value of a2
- x86_sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a2, a2, 1);
- } else {
- sse_movsd_reg_reg(jit->ip, a1, a2);
- sse_alu_sd_reg_reg(jit->ip, X86_SSE_DIV, a1, a3);
- }
-}
-
-static void emit_sse_neg_op(struct jit * jit, jit_op * op, int64_t a1, int64_t a2)
-{
- if (a1 != a2) sse_movsd_reg_reg(jit->ip, a1, a2);
- emit_sse_change_sign(jit, op, a1);
-}
-
-static void emit_sse_branch(struct jit * jit, jit_op * op, jit_value a1, jit_value a2, jit_value a3, int x86_cond)
-{
- sse_alu_pd_reg_reg(jit->ip, X86_SSE_COMI, a2, a3);
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- x86_branch_disp32(jit->ip, x86_cond, JIT_GET_ADDR(jit, a1), 0);
-}
-
-static void emit_sse_round(struct jit * jit, jit_op * op, jit_value a1, jit_value a2)
-{
- static const double x0 = 0.0;
- static const double x05 = 0.5;
-
- // creates a copy of the a2 and tmp_reg into high bits of a2 and tmp_reg
- sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a2, a2, 0);
-
- sse_alu_pd_reg_safeimm(jit, op, X86_SSE_COMI, a2, (double *)&x0);
-
- unsigned char * branch1 = jit->ip;
- common86_branch_disp(jit->ip, X86_CC_LT, 0, 0);
-
- sse_alu_sd_reg_safeimm(jit, op, X86_SSE_ADD, a2, (double *)&x05);
-
- unsigned char * branch2 = jit->ip;
- common86_jump_disp(jit->ip, 0);
-
- common86_patch(branch1, jit->ip);
-
- sse_alu_sd_reg_safeimm(jit, op, X86_SSE_SUB, a2, (double *)&x05);
- common86_patch(branch2, jit->ip);
-
- sse_cvttsd2si_reg_reg(jit->ip, a1, a2);
-
- // returns values back
- sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a2, a2, 1);
-}
-
-static void emit_sse_floor(struct jit * jit, jit_value a1, jit_value a2, int floor)
-{
- int tmp_reg = (a2 == X86_XMM7 ? X86_XMM0 : X86_XMM7);
-
- // creates a copy of the a2 and tmp_reg into high bits of a2 and tmp_reg
- sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a2, a2, 0);
- // TODO: test if the register is in use or not
- sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, tmp_reg, tmp_reg, 0);
-
- // truncates the value in a2 and stores it into the a1 and tmp_reg
- sse_cvttsd2si_reg_reg(jit->ip, a1, a2);
- sse_cvtsi2sd_reg_reg(jit->ip, tmp_reg, a1);
-
- if (floor) {
- // if a2 < tmp_reg, it substracts 1 (using the carry flag)
- sse_comisd_reg_reg(jit->ip, a2, tmp_reg);
- common86_alu_reg_imm(jit->ip, X86_SBB, a1, 0);
- } else { // ceil
- // if tmp_reg < a2, it adds 1 (using the carry flag)
- sse_comisd_reg_reg(jit->ip, tmp_reg, a2);
- common86_alu_reg_imm(jit->ip, X86_ADC, a1, 0);
- }
-
- // returns values back
- sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a2, a2, 1);
- sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, tmp_reg, tmp_reg, 1);
-}
-
-
-/**
- * Emits SSE instructions representing FST operation
- */
-static void emit_sse_fst_op(struct jit * jit, jit_op * op, jit_value a1, jit_value a2)
-{
- if (op->arg_size == sizeof(float)) {
- // the value has to be converted from double to float
- // we are using the given XMM register for this.
- // however, if the value in the register is supposed to be used later,
- // i.e., it's `live', we store it for a while into the upper half of the XMM register
- int live = jit_set_get(op->live_out, op->arg[1]);
- if (live) sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a2, a2, 0);
- sse_cvtsd2ss_reg_reg(jit->ip, a2, a2);
-
- if (IS_IMM(op)) sse_movss_mem_reg(jit->ip, a1, a2);
- else sse_movss_membase_reg(jit->ip, a1, 0, a2);
-
- if (live) sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a2, a2, 1);
-
- } else {
- if (IS_IMM(op)) sse_movlpd_mem_reg(jit->ip, a2, a1);
- else sse_movlpd_membase_xreg(jit->ip, a2, a1, 0);
- }
-}
-
-static void emit_sse_fld_op(struct jit * jit, jit_op * op, jit_value a1, jit_value a2)
-{
- if (op->arg_size == sizeof(float)) {
- if (IS_IMM(op)) sse_cvtss2sd_reg_mem(jit->ip, a1, a2);
- else sse_cvtss2sd_reg_membase(jit->ip, a1, a2, 0);
- } else {
- if (IS_IMM(op)) sse_movsd_reg_mem(jit->ip, a1, a2);
- else sse_movlpd_xreg_membase(jit->ip, a1, a2, 0);
- }
-}
-
-static void emit_sse_fldx_op(struct jit * jit, jit_op * op, jit_value a1, jit_value a2, jit_value a3)
-{
- if (op->arg_size == sizeof(float)) {
- if (IS_IMM(op)) sse_cvtss2sd_reg_membase(jit->ip, a1, a2, a3);
- else sse_cvtss2sd_reg_memindex(jit->ip, a1, a2, 0, a3, 0);
- } else {
- if (IS_IMM(op)) sse_movlpd_xreg_membase(jit->ip, a1, a2, a3);
- else sse_movlpd_xreg_memindex(jit->ip, a1, a2, 0, a3, 0);
- }
-}
-
-/**
- * Emits SSE instructions representing FSTX operation
- */
-static void emit_sse_fstx_op(struct jit * jit, jit_op * op, jit_value a1, jit_value a2, jit_value a3)
-{
- if (op->arg_size == sizeof(float)) {
- // the value has to be converted from double to float
- // we are using the given XMM register for this.
- // however, if the value in the register is supposed to be used later,
- // i.e., it's `live', we store it for a while into the upper half of the XMM register
-
- int live = jit_set_get(op->live_out, op->arg[2]);
- if (live) sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a3, a3, 0);
- sse_cvtsd2ss_reg_reg(jit->ip, a3, a3);
-
- if (IS_IMM(op)) sse_movss_membase_reg(jit->ip, a2, a1, a3);
- else sse_movss_memindex_xreg(jit->ip, a1, 0, a2, 0, a3);
-
- if (live) sse_alu_pd_reg_reg_imm(jit->ip, X86_SSE_SHUF, a3, a3, 1);
-
- } else {
- if (IS_IMM(op)) sse_movlpd_membase_xreg(jit->ip, a3, a2, a1);
- else sse_movlpd_memindex_xreg(jit->ip, a1, 0, a2, 0, a3);
- }
-}
diff --git a/ext/myjit/myjit/x86-codegen.h b/ext/myjit/myjit/x86-codegen.h
deleted file mode 100755
index b848f8a..0000000
--- a/ext/myjit/myjit/x86-codegen.h
+++ /dev/null
@@ -1,2424 +0,0 @@
-/*
- * x86-codegen.h: Macros for generating x86 code
- *
- * Authors:
- * Petr Krajca (petr.krajca@upol.cz)
- * Paolo Molaro (lupus@ximian.com)
- * Intel Corporation (ORP Project)
- * Sergey Chaban (serge@wildwestsoftware.com)
- * Dietmar Maurer (dietmar@ximian.com)
- * Patrik Torstensson
- *
- * Copyright (C) 2000 Intel Corporation. All rights reserved.
- * Copyright (C) 2001, 2002 Ximian, Inc.
- */
-
-#ifndef X86_H
-#define X86_H
-#include <assert.h>
-#define g_assert(x) assert(x)
-/*
-// x86 register numbers
-*/
-typedef enum jit_x86_gp_regs {
- X86_EAX = 0,
- X86_ECX = 1,
- X86_EDX = 2,
- X86_EBX = 3,
- X86_ESP = 4,
- X86_EBP = 5,
- X86_ESI = 6,
- X86_EDI = 7,
- X86_NREG
-} X86_Reg_No;
-
-typedef enum jit_x86_fp_regs {
- X86_XMM0,
- X86_XMM1,
- X86_XMM2,
- X86_XMM3,
- X86_XMM4,
- X86_XMM5,
- X86_XMM6,
- X86_XMM7,
- X86_XMM_NREG
-} X86_XMM_Reg_No;
-
-/*
-// opcodes for alu instructions
-*/
-typedef enum {
- X86_ADD = 0,
- X86_OR = 1,
- X86_ADC = 2,
- X86_SBB = 3,
- X86_AND = 4,
- X86_SUB = 5,
- X86_XOR = 6,
- X86_CMP = 7,
- X86_NALU
-} X86_ALU_Opcode;
-/*
-// opcodes for shift instructions
-*/
-typedef enum {
- X86_SHLD,
- X86_SHLR,
- X86_ROL = 0,
- X86_ROR = 1,
- X86_RCL = 2,
- X86_RCR = 3,
- X86_SHL = 4,
- X86_SHR = 5,
- X86_SAR = 7,
- X86_NSHIFT = 8
-} X86_Shift_Opcode;
-/*
-// opcodes for floating-point instructions
-*/
-typedef enum {
- X86_FADD = 0,
- X86_FMUL = 1,
- X86_FCOM = 2,
- X86_FCOMP = 3,
- X86_FSUB = 4,
- X86_FSUBR = 5,
- X86_FDIV = 6,
- X86_FDIVR = 7,
- X86_NFP = 8
-} X86_FP_Opcode;
-/*
-// integer conditions codes
-*/
-typedef enum {
- X86_CC_EQ = 0, X86_CC_E = 0, X86_CC_Z = 0,
- X86_CC_NE = 1, X86_CC_NZ = 1,
- X86_CC_LT = 2, X86_CC_B = 2, X86_CC_C = 2, X86_CC_NAE = 2,
- X86_CC_LE = 3, X86_CC_BE = 3, X86_CC_NA = 3,
- X86_CC_GT = 4, X86_CC_A = 4, X86_CC_NBE = 4,
- X86_CC_GE = 5, X86_CC_AE = 5, X86_CC_NB = 5, X86_CC_NC = 5,
- X86_CC_LZ = 6, X86_CC_S = 6,
- X86_CC_GEZ = 7, X86_CC_NS = 7,
- X86_CC_P = 8, X86_CC_PE = 8,
- X86_CC_NP = 9, X86_CC_PO = 9,
- X86_CC_O = 10,
- X86_CC_NO = 11,
- X86_NCC
-} X86_CC;
-
-/* FP status */
-enum {
- X86_FP_C0 = 0x100,
- X86_FP_C1 = 0x200,
- X86_FP_C2 = 0x400,
- X86_FP_C3 = 0x4000,
- X86_FP_CC_MASK = 0x4500
-};
-
-/* FP control word */
-enum {
- X86_FPCW_INVOPEX_MASK = 0x1,
- X86_FPCW_DENOPEX_MASK = 0x2,
- X86_FPCW_ZERODIV_MASK = 0x4,
- X86_FPCW_OVFEX_MASK = 0x8,
- X86_FPCW_UNDFEX_MASK = 0x10,
- X86_FPCW_PRECEX_MASK = 0x20,
- X86_FPCW_PRECC_MASK = 0x300,
- X86_FPCW_ROUNDC_MASK = 0xc00,
-
- /* values for precision control */
- X86_FPCW_PREC_SINGLE = 0,
- X86_FPCW_PREC_DOUBLE = 0x200,
- X86_FPCW_PREC_EXTENDED = 0x300,
-
- /* values for rounding control */
- X86_FPCW_ROUND_NEAREST = 0,
- X86_FPCW_ROUND_DOWN = 0x400,
- X86_FPCW_ROUND_UP = 0x800,
- X86_FPCW_ROUND_TOZERO = 0xc00
-};
-
-/*
-// prefix code
-*/
-typedef enum {
- X86_LOCK_PREFIX = 0xF0,
- X86_REPNZ_PREFIX = 0xF2,
- X86_REPZ_PREFIX = 0xF3,
- X86_REP_PREFIX = 0xF3,
- X86_CS_PREFIX = 0x2E,
- X86_SS_PREFIX = 0x36,
- X86_DS_PREFIX = 0x3E,
- X86_ES_PREFIX = 0x26,
- X86_FS_PREFIX = 0x64,
- X86_GS_PREFIX = 0x65,
- X86_UNLIKELY_PREFIX = 0x2E,
- X86_LIKELY_PREFIX = 0x3E,
- X86_OPERAND_PREFIX = 0x66,
- X86_ADDRESS_PREFIX = 0x67
-} X86_Prefix;
-
-static const unsigned char
-x86_cc_unsigned_map [X86_NCC] = {
- 0x74, /* eq */
- 0x75, /* ne */
- 0x72, /* lt */
- 0x76, /* le */
- 0x77, /* gt */
- 0x73, /* ge */
- 0x78, /* lz */
- 0x79, /* gez */
- 0x7a, /* p */
- 0x7b, /* np */
- 0x70, /* o */
- 0x71, /* no */
-};
-
-static const unsigned char
-x86_cc_signed_map [X86_NCC] = {
- 0x74, /* eq */
- 0x75, /* ne */
- 0x7c, /* lt */
- 0x7e, /* le */
- 0x7f, /* gt */
- 0x7d, /* ge */
- 0x78, /* lz */
- 0x79, /* gez */
- 0x7a, /* p */
- 0x7b, /* np */
- 0x70, /* o */
- 0x71, /* no */
-};
-
-typedef union {
- int val;
- unsigned char b [4];
-} x86_imm_buf;
-
-#define X86_NOBASEREG (-1)
-
-/*
-// bitvector mask for callee-saved registers
-*/
-#define X86_ESI_MASK (1<<X86_ESI)
-#define X86_EDI_MASK (1<<X86_EDI)
-#define X86_EBX_MASK (1<<X86_EBX)
-#define X86_EBP_MASK (1<<X86_EBP)
-
-#define X86_CALLEE_REGS ((1<<X86_EAX) | (1<<X86_ECX) | (1<<X86_EDX))
-#define X86_CALLER_REGS ((1<<X86_EBX) | (1<<X86_EBP) | (1<<X86_ESI) | (1<<X86_EDI))
-#define X86_BYTE_REGS ((1<<X86_EAX) | (1<<X86_ECX) | (1<<X86_EDX) | (1<<X86_EBX))
-
-#define X86_IS_SCRATCH(reg) (X86_CALLER_REGS & (1 << (reg))) /* X86_EAX, X86_ECX, or X86_EDX */
-#define X86_IS_CALLEE(reg) (X86_CALLEE_REGS & (1 << (reg))) /* X86_ESI, X86_EDI, X86_EBX, or X86_EBP */
-
-#define X86_IS_BYTE_REG(reg) ((reg) < 4)
-
-/*
-// Frame structure:
-//
-// +--------------------------------+
-// | in_arg[0] = var[0] |
-// | in_arg[1] = var[1] |
-// | . . . |
-// | in_arg[n_arg-1] = var[n_arg-1] |
-// +--------------------------------+
-// | return IP |
-// +--------------------------------+
-// | saved EBP | <-- frame pointer (EBP)
-// +--------------------------------+
-// | ... | n_extra
-// +--------------------------------+
-// | var[n_arg] |
-// | var[n_arg+1] | local variables area
-// | . . . |
-// | var[n_var-1] |
-// +--------------------------------+
-// | |
-// | |
-// | spill area | area for spilling mimic stack
-// | |
-// +--------------------------------|
-// | ebx |
-// | ebp [ESP_Frame only] |
-// | esi | 0..3 callee-saved regs
-// | edi | <-- stack pointer (ESP)
-// +--------------------------------+
-// | stk0 |
-// | stk1 | operand stack area/
-// | . . . | out args
-// | stkn-1 |
-// +--------------------------------|
-//
-//
-*/
-
-
-/*
- * useful building blocks
- */
-#define x86_modrm_mod(modrm) ((modrm) >> 6)
-#define x86_modrm_reg(modrm) (((modrm) >> 3) & 0x7)
-#define x86_modrm_rm(modrm) ((modrm) & 0x7)
-
-#define x86_address_byte(inst,m,o,r) do { *(inst)++ = ((((m)&0x03)<<6)|(((o)&0x07)<<3)|(((r)&0x07))); } while (0)
-#define x86_imm_emit32(inst,imm) \
- do { \
- x86_imm_buf imb; imb.val = (int) (imm); \
- *(inst)++ = imb.b [0]; \
- *(inst)++ = imb.b [1]; \
- *(inst)++ = imb.b [2]; \
- *(inst)++ = imb.b [3]; \
- } while (0)
-#define x86_imm_emit16(inst,imm) do { *(short*)(inst) = (imm); (inst) += 2; } while (0)
-#define x86_imm_emit8(inst,imm) do { *(inst) = (unsigned char)((imm) & 0xff); ++(inst); } while (0)
-#define x86_is_imm8(imm) (((int)(imm) >= -128 && (int)(imm) <= 127))
-#define x86_is_imm16(imm) (((int)(imm) >= -(1<<16) && (int)(imm) <= ((1<<16)-1)))
-
-#define x86_reg_emit(inst,r,regno) do { x86_address_byte ((inst), 3, (r), (regno)); } while (0)
-#define x86_reg8_emit(inst,r,regno,is_rh,is_rnoh) do {x86_address_byte ((inst), 3, (is_rh)?((r)|4):(r), (is_rnoh)?((regno)|4):(regno));} while (0)
-#define x86_regp_emit(inst,r,regno) do { x86_address_byte ((inst), 0, (r), (regno)); } while (0)
-#define x86_mem_emit(inst,r,disp) do { x86_address_byte ((inst), 0, (r), 5); x86_imm_emit32((inst), (disp)); } while (0)
-
-#define x86_membase_emit(inst,r,basereg,disp) do {\
- if ((basereg) == AMD64_RIP) { \
- x86_address_byte ((inst), 0, (r), (0b101)); \
- x86_imm_emit32 ((inst), (disp)); \
- break; \
- } \
- if ((basereg) == X86_ESP) { \
- if ((disp) == 0) { \
- x86_address_byte ((inst), 0, (r), X86_ESP); \
- x86_address_byte ((inst), 0, X86_ESP, X86_ESP); \
- } else if (x86_is_imm8((disp))) { \
- x86_address_byte ((inst), 1, (r), X86_ESP); \
- x86_address_byte ((inst), 0, X86_ESP, X86_ESP); \
- x86_imm_emit8 ((inst), (disp)); \
- } else { \
- x86_address_byte ((inst), 2, (r), X86_ESP); \
- x86_address_byte ((inst), 0, X86_ESP, X86_ESP); \
- x86_imm_emit32 ((inst), (disp)); \
- } \
- break; \
- } \
- if ((disp) == 0 && (basereg) != X86_EBP) { \
- if(basereg==0b1100) { \
- x86_address_byte ((inst), 0, (r), (basereg)); \
- x86_address_byte ((inst), 0, (basereg), 4); \
- } else \
- x86_address_byte ((inst), 0, (r), (basereg)); \
- break; \
- } \
- if (x86_is_imm8((disp))) { \
- if(basereg==0b1100) { \
- x86_address_byte ((inst), 1, (r), (basereg)); \
- x86_address_byte ((inst), 0, (basereg), 4); \
- } else \
- x86_address_byte ((inst), 1, (r), (basereg)); \
- x86_imm_emit8 ((inst), (disp)); \
- } else { \
- if(basereg==0b1100) { \
- x86_address_byte ((inst), 2, (r), (basereg)); \
- x86_address_byte ((inst), 0, (basereg), 4); \
- } else \
- x86_address_byte ((inst), 2, (r), (basereg)); \
- x86_imm_emit32 ((inst), (disp)); \
- } \
- } while (0)
-
-#define x86_memindex_emit(inst,r,basereg,disp,indexreg,shift) \
- do { \
- if ((basereg) == X86_NOBASEREG) { \
- x86_address_byte ((inst), 0, (r), 4); \
- x86_address_byte ((inst), (shift), (indexreg), 5); \
- x86_imm_emit32 ((inst), (disp)); \
- } else if ((disp) == 0 && (basereg) != X86_EBP) { \
- x86_address_byte ((inst), 0, (r), 4); \
- x86_address_byte ((inst), (shift), (indexreg), ((basereg)&0x7)); \
- } else if (x86_is_imm8((disp))) { \
- x86_address_byte ((inst), 1, (r), 4); \
- x86_address_byte ((inst), (shift), (indexreg), ((basereg)&0x7)); \
- x86_imm_emit8 ((inst), (disp)); \
- } else { \
- x86_address_byte ((inst), 2, (r), 4); \
- x86_address_byte ((inst), (shift), (indexreg), 5); \
- x86_imm_emit32 ((inst), (disp)); \
- } \
- } while (0)
-
-/*
- * target is the position in the code where to jump to:
- * target = code;
- * .. output loop code...
- * x86_mov_reg_imm (code, X86_EAX, 0);
- * loop = code;
- * x86_loop (code, -1);
- * ... finish method
- *
- * patch displacement
- * x86_patch (loop, target);
- *
- * ins should point at the start of the instruction that encodes a target.
- * the instruction is inspected for validity and the correct displacement
- * is inserted.
- */
-#define x86_patch(ins,target) \
- do { \
- unsigned char* pos = (ins) + 1; \
- int disp, size = 0; \
- switch (*(unsigned char*)(ins)) { \
- case 0xe8: case 0xe9: ++size; break; /* call, jump32 */ \
- case 0x0f: if (!(*pos >= 0x70 && *pos <= 0x8f)) assert (0); \
- ++size; ++pos; break; /* prefix for 32-bit disp */ \
- case 0xe0: case 0xe1: case 0xe2: /* loop */ \
- case 0xeb: /* jump8 */ \
- /* conditional jump opcodes */ \
- case 0x70: case 0x71: case 0x72: case 0x73: \
- case 0x74: case 0x75: case 0x76: case 0x77: \
- case 0x78: case 0x79: case 0x7a: case 0x7b: \
- case 0x7c: case 0x7d: case 0x7e: case 0x7f: \
- break; \
- default: assert (0); \
- } \
- disp = (target) - pos; \
- if (size) x86_imm_emit32 (pos, disp - 4); \
- else if (x86_is_imm8 (disp - 1)) x86_imm_emit8 (pos, disp - 1); \
- else assert (0); \
- } while (0)
-
-#define x86_breakpoint(inst) \
- do { \
- *(inst)++ = 0xcc; \
- } while (0)
-
-#define x86_cld(inst) do { *(inst)++ =(unsigned char)0xfc; } while (0)
-#define x86_stosb(inst) do { *(inst)++ =(unsigned char)0xaa; } while (0)
-#define x86_stosl(inst) do { *(inst)++ =(unsigned char)0xab; } while (0)
-#define x86_stosd(inst) x86_stosl((inst))
-#define x86_movsb(inst) do { *(inst)++ =(unsigned char)0xa4; } while (0)
-#define x86_movsl(inst) do { *(inst)++ =(unsigned char)0xa5; } while (0)
-#define x86_movsd(inst) x86_movsl((inst))
-
-#define x86_prefix(inst,p) do { *(inst)++ =(unsigned char) (p); } while (0)
-
-#define x86_rdtsc(inst) \
- do { \
- *(inst)++ = 0x0f; \
- *(inst)++ = 0x31; \
- } while (0)
-
-#define x86_cmpxchg_reg_reg(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xb1; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- } while (0)
-
-#define x86_cmpxchg_mem_reg(inst,mem,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xb1; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_cmpxchg_membase_reg(inst,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xb1; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_xchg_reg_reg(inst,dreg,reg,size) \
- do { \
- if ((size) == 1) \
- *(inst)++ = (unsigned char)0x86; \
- else \
- *(inst)++ = (unsigned char)0x87; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- } while (0)
-
-#define x86_xchg_mem_reg(inst,mem,reg,size) \
- do { \
- if ((size) == 1) \
- *(inst)++ = (unsigned char)0x86; \
- else \
- *(inst)++ = (unsigned char)0x87; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_xchg_membase_reg(inst,basereg,disp,reg,size) \
- do { \
- if ((size) == 1) \
- *(inst)++ = (unsigned char)0x86; \
- else \
- *(inst)++ = (unsigned char)0x87; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_xadd_reg_reg(inst,dreg,reg,size) \
- do { \
- *(inst)++ = (unsigned char)0x0F; \
- if ((size) == 1) \
- *(inst)++ = (unsigned char)0xC0; \
- else \
- *(inst)++ = (unsigned char)0xC1; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- } while (0)
-
-#define x86_xadd_mem_reg(inst,mem,reg,size) \
- do { \
- *(inst)++ = (unsigned char)0x0F; \
- if ((size) == 1) \
- *(inst)++ = (unsigned char)0xC0; \
- else \
- *(inst)++ = (unsigned char)0xC1; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_xadd_membase_reg(inst,basereg,disp,reg,size) \
- do { \
- *(inst)++ = (unsigned char)0x0F; \
- if ((size) == 1) \
- *(inst)++ = (unsigned char)0xC0; \
- else \
- *(inst)++ = (unsigned char)0xC1; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_inc_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_mem_emit ((inst), 0, (mem)); \
- } while (0)
-
-#define x86_inc_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- } while (0)
-
-#define x86_inc_reg(inst,reg) do { *(inst)++ = (unsigned char)0x40 + (reg); } while (0)
-
-#define x86_dec_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_mem_emit ((inst), 1, (mem)); \
- } while (0)
-
-#define x86_dec_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_membase_emit ((inst), 1, (basereg), (disp)); \
- } while (0)
-
-#define x86_dec_reg(inst,reg) do { *(inst)++ = (unsigned char)0x48 + (reg); } while (0)
-
-#define x86_not_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_mem_emit ((inst), 2, (mem)); \
- } while (0)
-
-#define x86_not_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_membase_emit ((inst), 2, (basereg), (disp)); \
- } while (0)
-
-#define x86_not_reg(inst,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_reg_emit ((inst), 2, (reg)); \
- } while (0)
-
-#define x86_neg_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_mem_emit ((inst), 3, (mem)); \
- } while (0)
-
-#define x86_neg_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_membase_emit ((inst), 3, (basereg), (disp)); \
- } while (0)
-
-#define x86_neg_reg(inst,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_reg_emit ((inst), 3, (reg)); \
- } while (0)
-
-#define x86_nop(inst) do { *(inst)++ = (unsigned char)0x90; } while (0)
-
-#define x86_alu_reg_imm(inst,opc,reg,imm) \
- do { \
- if ((reg) == X86_EAX) { \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 5; \
- x86_imm_emit32 ((inst), (imm)); \
- break; \
- } \
- if (x86_is_imm8((imm))) { \
- *(inst)++ = (unsigned char)0x83; \
- x86_reg_emit ((inst), (opc), (reg)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0x81; \
- x86_reg_emit ((inst), (opc), (reg)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_alu_mem_imm(inst,opc,mem,imm) \
- do { \
- if (x86_is_imm8((imm))) { \
- *(inst)++ = (unsigned char)0x83; \
- x86_mem_emit ((inst), (opc), (mem)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0x81; \
- x86_mem_emit ((inst), (opc), (mem)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_alu_membase_imm(inst,opc,basereg,disp,imm) \
- do { \
- if (x86_is_imm8((imm))) { \
- *(inst)++ = (unsigned char)0x83; \
- x86_membase_emit ((inst), (opc), (basereg), (disp)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0x81; \
- x86_membase_emit ((inst), (opc), (basereg), (disp)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_alu_membase8_imm(inst,opc,basereg,disp,imm) \
- do { \
- *(inst)++ = (unsigned char)0x80; \
- x86_membase_emit ((inst), (opc), (basereg), (disp)); \
- x86_imm_emit8 ((inst), (imm)); \
- } while (0)
-
-#define x86_alu_mem_reg(inst,opc,mem,reg) \
- do { \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 1; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_alu_membase_reg(inst,opc,basereg,disp,reg) \
- do { \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 1; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_alu_reg_reg(inst,opc,dreg,reg) \
- do { \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-/**
- * @x86_alu_reg8_reg8:
- * Supports ALU operations between two 8-bit registers.
- * dreg := dreg opc reg
- * X86_Reg_No enum is used to specify the registers.
- * Additionally is_*_h flags are used to specify what part
- * of a given 32-bit register is used - high (TRUE) or low (FALSE).
- * For example: dreg = X86_EAX, is_dreg_h = TRUE -> use AH
- */
-#define x86_alu_reg8_reg8(inst,opc,dreg,reg,is_dreg_h,is_reg_h) \
- do { \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 2; \
- x86_reg8_emit ((inst), (dreg), (reg), (is_dreg_h), (is_reg_h)); \
- } while (0)
-
-#define x86_alu_reg_mem(inst,opc,reg,mem) \
- do { \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_alu_reg_membase(inst,opc,reg,basereg,disp) \
- do { \
- *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_test_reg_imm(inst,reg,imm) \
- do { \
- if ((reg) == X86_EAX) { \
- *(inst)++ = (unsigned char)0xa9; \
- } else { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_reg_emit ((inst), 0, (reg)); \
- } \
- x86_imm_emit32 ((inst), (imm)); \
- } while (0)
-
-#define x86_test_mem_imm(inst,mem,imm) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_mem_emit ((inst), 0, (mem)); \
- x86_imm_emit32 ((inst), (imm)); \
- } while (0)
-
-#define x86_test_membase_imm(inst,basereg,disp,imm) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- x86_imm_emit32 ((inst), (imm)); \
- } while (0)
-
-#define x86_test_reg_reg(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x85; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- } while (0)
-
-#define x86_test_mem_reg(inst,mem,reg) \
- do { \
- *(inst)++ = (unsigned char)0x85; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_test_membase_reg(inst,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0x85; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_shift_reg_imm(inst,opc,reg,imm) \
- do { \
- if ((imm) == 1) { \
- *(inst)++ = (unsigned char)0xd1; \
- x86_reg_emit ((inst), (opc), (reg)); \
- } else { \
- *(inst)++ = (unsigned char)0xc1; \
- x86_reg_emit ((inst), (opc), (reg)); \
- x86_imm_emit8 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_shift_mem_imm(inst,opc,mem,imm) \
- do { \
- if ((imm) == 1) { \
- *(inst)++ = (unsigned char)0xd1; \
- x86_mem_emit ((inst), (opc), (mem)); \
- } else { \
- *(inst)++ = (unsigned char)0xc1; \
- x86_mem_emit ((inst), (opc), (mem)); \
- x86_imm_emit8 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_shift_membase_imm(inst,opc,basereg,disp,imm) \
- do { \
- if ((imm) == 1) { \
- *(inst)++ = (unsigned char)0xd1; \
- x86_membase_emit ((inst), (opc), (basereg), (disp)); \
- } else { \
- *(inst)++ = (unsigned char)0xc1; \
- x86_membase_emit ((inst), (opc), (basereg), (disp)); \
- x86_imm_emit8 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_shift_reg(inst,opc,reg) \
- do { \
- *(inst)++ = (unsigned char)0xd3; \
- x86_reg_emit ((inst), (opc), (reg)); \
- } while (0)
-
-#define x86_shift_mem(inst,opc,mem) \
- do { \
- *(inst)++ = (unsigned char)0xd3; \
- x86_mem_emit ((inst), (opc), (mem)); \
- } while (0)
-
-#define x86_shift_membase(inst,opc,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xd3; \
- x86_membase_emit ((inst), (opc), (basereg), (disp)); \
- } while (0)
-
-/*
- * Cmp ops
- */
-#define x86_cmp_reg_imm(inst,reg,imm) \
- do { \
- if ((reg) == X86_EAX) { \
- *(inst)++ = (unsigned char)0x3d; \
- } else { \
- *(inst)++ = (unsigned char)0x81; \
- x86_reg_emit ((inst), 7, (reg)); \
- } \
- x86_imm_emit32 ((inst), (imm)); \
- } while (0)
-
-#define x86_cmp_reg_reg(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x39; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- } while (0)
-
-
-/*
- * Multi op shift missing.
- */
-
-#define x86_shrd_reg(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xad; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- } while (0)
-
-#define x86_shrd_reg_imm(inst,dreg,reg,shamt) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xac; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- x86_imm_emit8 ((inst), (shamt)); \
- } while (0)
-
-#define x86_shld_reg(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xa5; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- } while (0)
-
-#define x86_shld_reg_imm(inst,dreg,reg,shamt) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xa4; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- x86_imm_emit8 ((inst), (shamt)); \
- } while (0)
-
-/*
- * EDX:EAX = EAX * rm
- */
-#define x86_mul_reg(inst,reg,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_reg_emit ((inst), 4 + ((is_signed) ? 1 : 0), (reg)); \
- } while (0)
-
-#define x86_mul_mem(inst,mem,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_mem_emit ((inst), 4 + ((is_signed) ? 1 : 0), (mem)); \
- } while (0)
-
-#define x86_mul_membase(inst,basereg,disp,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_membase_emit ((inst), 4 + ((is_signed) ? 1 : 0), (basereg), (disp)); \
- } while (0)
-
-/*
- * r *= rm
- */
-#define x86_imul_reg_reg(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xaf; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_imul_reg_mem(inst,reg,mem) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xaf; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_imul_reg_membase(inst,reg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0xaf; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-/*
- * dreg = rm * imm
- */
-#define x86_imul_reg_reg_imm(inst,dreg,reg,imm) \
- do { \
- if (x86_is_imm8 ((imm))) { \
- *(inst)++ = (unsigned char)0x6b; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0x69; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_imul_reg_mem_imm(inst,reg,mem,imm) \
- do { \
- if (x86_is_imm8 ((imm))) { \
- *(inst)++ = (unsigned char)0x6b; \
- x86_mem_emit ((inst), (reg), (mem)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0x69; \
- x86_reg_emit ((inst), (reg), (mem)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_imul_reg_membase_imm(inst,reg,basereg,disp,imm) \
- do { \
- if (x86_is_imm8 ((imm))) { \
- *(inst)++ = (unsigned char)0x6b; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0x69; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-/*
- * divide EDX:EAX by rm;
- * eax = quotient, edx = remainder
- */
-
-#define x86_div_reg(inst,reg,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_reg_emit ((inst), 6 + ((is_signed) ? 1 : 0), (reg)); \
- } while (0)
-
-#define x86_div_mem(inst,mem,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_mem_emit ((inst), 6 + ((is_signed) ? 1 : 0), (mem)); \
- } while (0)
-
-#define x86_div_membase(inst,basereg,disp,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0xf7; \
- x86_membase_emit ((inst), 6 + ((is_signed) ? 1 : 0), (basereg), (disp)); \
- } while (0)
-
-#define x86_mov_mem_reg(inst,mem,reg,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x88; break; \
- case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \
- case 4: *(inst)++ = (unsigned char)0x89; break; \
- default: assert (0); \
- } \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_mov_regp_reg(inst,regp,reg,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x88; break; \
- case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \
- case 4: *(inst)++ = (unsigned char)0x89; break; \
- default: assert (0); \
- } \
- x86_regp_emit ((inst), (reg), (regp)); \
- } while (0)
-
-#define x86_mov_membase_reg(inst,basereg,disp,reg,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x88; break; \
- case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \
- case 4: *(inst)++ = (unsigned char)0x89; break; \
- default: assert (0); \
- } \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_mov_memindex_reg(inst,basereg,disp,indexreg,shift,reg,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x88; break; \
- case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \
- case 4: *(inst)++ = (unsigned char)0x89; break; \
- default: assert (0); \
- } \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_mov_reg_reg(inst,dreg,reg,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x8a; break; \
- case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \
- case 4: *(inst)++ = (unsigned char)0x8b; break; \
- default: assert (0); \
- } \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_mov_reg_mem(inst,reg,mem,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x8a; break; \
- case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \
- case 4: *(inst)++ = (unsigned char)0x8b; break; \
- default: assert (0); \
- } \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_mov_reg_membase(inst,reg,basereg,disp,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x8a; break; \
- case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \
- case 4: *(inst)++ = (unsigned char)0x8b; break; \
- default: assert (0); \
- } \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_mov_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) \
- do { \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0x8a; break; \
- case 2: *(inst)++ = (unsigned char)0x66; /* fall through */ \
- case 4: *(inst)++ = (unsigned char)0x8b; break; \
- default: assert (0); \
- } \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-/*
- * Note: x86_clear_reg () chacnges the condition code!
- */
-#define x86_clear_reg(inst,reg) x86_alu_reg_reg((inst), X86_XOR, (reg), (reg))
-
-#define x86_mov_reg_imm(inst,reg,imm) \
- do { \
- *(inst)++ = (unsigned char)0xb8 + (reg); \
- x86_imm_emit32 ((inst), (imm)); \
- } while (0)
-
-#define x86_mov_mem_imm(inst,mem,imm,size) \
- do { \
- if ((size) == 1) { \
- *(inst)++ = (unsigned char)0xc6; \
- x86_mem_emit ((inst), 0, (mem)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else if ((size) == 2) { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0xc7; \
- x86_mem_emit ((inst), 0, (mem)); \
- x86_imm_emit16 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0xc7; \
- x86_mem_emit ((inst), 0, (mem)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_mov_membase_imm(inst,basereg,disp,imm,size) \
- do { \
- if ((size) == 1) { \
- *(inst)++ = (unsigned char)0xc6; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else if ((size) == 2) { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0xc7; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- x86_imm_emit16 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0xc7; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_mov_memindex_imm(inst,basereg,disp,indexreg,shift,imm,size) \
- do { \
- if ((size) == 1) { \
- *(inst)++ = (unsigned char)0xc6; \
- x86_memindex_emit ((inst), 0, (basereg), (disp), (indexreg), (shift)); \
- x86_imm_emit8 ((inst), (imm)); \
- } else if ((size) == 2) { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0xc7; \
- x86_memindex_emit ((inst), 0, (basereg), (disp), (indexreg), (shift)); \
- x86_imm_emit16 ((inst), (imm)); \
- } else { \
- *(inst)++ = (unsigned char)0xc7; \
- x86_memindex_emit ((inst), 0, (basereg), (disp), (indexreg), (shift)); \
- x86_imm_emit32 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_lea_mem(inst,reg,mem) \
- do { \
- *(inst)++ = (unsigned char)0x8d; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_lea_membase(inst,reg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x8d; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_lea_memindex(inst,reg,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0x8d; \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_widen_reg(inst,dreg,reg,is_signed,is_half) \
- do { \
- unsigned char op = 0xb6; \
- g_assert (is_half || X86_IS_BYTE_REG (reg)); \
- *(inst)++ = (unsigned char)0x0f; \
- if ((is_signed)) op += 0x08; \
- if ((is_half)) op += 0x01; \
- *(inst)++ = op; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_widen_mem(inst,dreg,mem,is_signed,is_half) \
- do { \
- unsigned char op = 0xb6; \
- *(inst)++ = (unsigned char)0x0f; \
- if ((is_signed)) op += 0x08; \
- if ((is_half)) op += 0x01; \
- *(inst)++ = op; \
- x86_mem_emit ((inst), (dreg), (mem)); \
- } while (0)
-
-#define x86_widen_membase(inst,dreg,basereg,disp,is_signed,is_half) \
- do { \
- unsigned char op = 0xb6; \
- *(inst)++ = (unsigned char)0x0f; \
- if ((is_signed)) op += 0x08; \
- if ((is_half)) op += 0x01; \
- *(inst)++ = op; \
- x86_membase_emit ((inst), (dreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_widen_memindex(inst,dreg,basereg,disp,indexreg,shift,is_signed,is_half) \
- do { \
- unsigned char op = 0xb6; \
- *(inst)++ = (unsigned char)0x0f; \
- if ((is_signed)) op += 0x08; \
- if ((is_half)) op += 0x01; \
- *(inst)++ = op; \
- x86_memindex_emit ((inst), (dreg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_cdq(inst) do { *(inst)++ = (unsigned char)0x99; } while (0)
-#define x86_wait(inst) do { *(inst)++ = (unsigned char)0x9b; } while (0)
-
-#define x86_fp_op_mem(inst,opc,mem,is_double) \
- do { \
- *(inst)++ = (is_double) ? (unsigned char)0xdc : (unsigned char)0xd8; \
- x86_mem_emit ((inst), (opc), (mem)); \
- } while (0)
-
-#define x86_fp_op_membase(inst,opc,basereg,disp,is_double) \
- do { \
- *(inst)++ = (is_double) ? (unsigned char)0xdc : (unsigned char)0xd8; \
- x86_membase_emit ((inst), (opc), (basereg), (disp)); \
- } while (0)
-
-#define x86_fp_op(inst,opc,index) \
- do { \
- *(inst)++ = (unsigned char)0xd8; \
- *(inst)++ = (unsigned char)0xc0+((opc)<<3)+((index)&0x07); \
- } while (0)
-
-#define x86_fp_op_reg(inst,opc,index,pop_stack) \
- do { \
- static const unsigned char map[] = { 0, 1, 2, 3, 5, 4, 7, 6, 8}; \
- *(inst)++ = (pop_stack) ? (unsigned char)0xde : (unsigned char)0xdc; \
- *(inst)++ = (unsigned char)0xc0+(map[(opc)]<<3)+((index)&0x07); \
- } while (0)
-
-/**
- * @x86_fp_int_op_membase
- * Supports FPU operations between ST(0) and integer operand in memory.
- * Operation encoded using X86_FP_Opcode enum.
- * Operand is addressed by [basereg + disp].
- * is_int specifies whether operand is int32 (TRUE) or int16 (FALSE).
- */
-#define x86_fp_int_op_membase(inst,opc,basereg,disp,is_int) \
- do { \
- *(inst)++ = (is_int) ? (unsigned char)0xda : (unsigned char)0xde; \
- x86_membase_emit ((inst), opc, (basereg), (disp)); \
- } while (0)
-
-#define x86_fstp(inst,index) \
- do { \
- *(inst)++ = (unsigned char)0xdd; \
- *(inst)++ = (unsigned char)0xd8+(index); \
- } while (0)
-
-#define x86_fcompp(inst) \
- do { \
- *(inst)++ = (unsigned char)0xde; \
- *(inst)++ = (unsigned char)0xd9; \
- } while (0)
-
-#define x86_fucompp(inst) \
- do { \
- *(inst)++ = (unsigned char)0xda; \
- *(inst)++ = (unsigned char)0xe9; \
- } while (0)
-
-#define x86_fnstsw(inst) \
- do { \
- *(inst)++ = (unsigned char)0xdf; \
- *(inst)++ = (unsigned char)0xe0; \
- } while (0)
-
-#define x86_fnstcw(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- x86_mem_emit ((inst), 7, (mem)); \
- } while (0)
-
-#define x86_fnstcw_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- x86_membase_emit ((inst), 7, (basereg), (disp)); \
- } while (0)
-
-#define x86_fldcw(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- x86_mem_emit ((inst), 5, (mem)); \
- } while (0)
-
-#define x86_fldcw_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- x86_membase_emit ((inst), 5, (basereg), (disp)); \
- } while (0)
-
-#define x86_fchs(inst) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- *(inst)++ = (unsigned char)0xe0; \
- } while (0)
-
-#define x86_frem(inst) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- *(inst)++ = (unsigned char)0xf8; \
- } while (0)
-
-#define x86_fxch(inst,index) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- *(inst)++ = (unsigned char)0xc8 + ((index) & 0x07); \
- } while (0)
-
-#define x86_fcomi(inst,index) \
- do { \
- *(inst)++ = (unsigned char)0xdb; \
- *(inst)++ = (unsigned char)0xf0 + ((index) & 0x07); \
- } while (0)
-
-#define x86_fcomip(inst,index) \
- do { \
- *(inst)++ = (unsigned char)0xdf; \
- *(inst)++ = (unsigned char)0xf0 + ((index) & 0x07); \
- } while (0)
-
-#define x86_fucomi(inst,index) \
- do { \
- *(inst)++ = (unsigned char)0xdb; \
- *(inst)++ = (unsigned char)0xe8 + ((index) & 0x07); \
- } while (0)
-
-#define x86_fucomip(inst,index) \
- do { \
- *(inst)++ = (unsigned char)0xdf; \
- *(inst)++ = (unsigned char)0xe8 + ((index) & 0x07); \
- } while (0)
-
-#define x86_fld(inst,mem,is_double) \
- do { \
- *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \
- x86_mem_emit ((inst), 0, (mem)); \
- } while (0)
-
-#define x86_fld_membase(inst,basereg,disp,is_double) \
- do { \
- *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- } while (0)
-
-#define x86_fld80_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_mem_emit ((inst), 5, (mem)); \
- } while (0)
-
-#define x86_fld80_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_membase_emit ((inst), 5, (basereg), (disp)); \
- } while (0)
-
-#define x86_fild(inst,mem,is_int64_t) \
- do { \
- if ((is_int64_t)) { \
- *(inst)++ = (unsigned char)0xdf; \
- x86_mem_emit ((inst), 5, (mem)); \
- } else { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_mem_emit ((inst), 0, (mem)); \
- } \
- } while (0)
-
-#define x86_fild_membase(inst,basereg,disp,is_int64_t) \
- do { \
- if ((is_int64_t)) { \
- *(inst)++ = (unsigned char)0xdf; \
- x86_membase_emit ((inst), 5, (basereg), (disp)); \
- } else { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- } \
- } while (0)
-
-#define x86_fld_reg(inst,index) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- *(inst)++ = (unsigned char)0xc0 + ((index) & 0x07); \
- } while (0)
-
-#define x86_fldz(inst) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- *(inst)++ = (unsigned char)0xee; \
- } while (0)
-
-#define x86_fld1(inst) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- *(inst)++ = (unsigned char)0xe8; \
- } while (0)
-
-#define x86_fldpi(inst) \
- do { \
- *(inst)++ = (unsigned char)0xd9; \
- *(inst)++ = (unsigned char)0xeb; \
- } while (0)
-
-#define x86_fst(inst,mem,is_double,pop_stack) \
- do { \
- *(inst)++ = (is_double) ? (unsigned char)0xdd: (unsigned char)0xd9; \
- x86_mem_emit ((inst), 2 + ((pop_stack) ? 1 : 0), (mem)); \
- } while (0)
-
-#define x86_fst_membase(inst,basereg,disp,is_double,pop_stack) \
- do { \
- *(inst)++ = (is_double) ? (unsigned char)0xdd: (unsigned char)0xd9; \
- x86_membase_emit ((inst), 2 + ((pop_stack) ? 1 : 0), (basereg), (disp)); \
- } while (0)
-
-#define x86_fst80_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_mem_emit ((inst), 7, (mem)); \
- } while (0)
-
-
-#define x86_fst80_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_membase_emit ((inst), 7, (basereg), (disp)); \
- } while (0)
-
-
-#define x86_fist_pop(inst,mem,is_int64_t) \
- do { \
- if ((is_int64_t)) { \
- *(inst)++ = (unsigned char)0xdf; \
- x86_mem_emit ((inst), 7, (mem)); \
- } else { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_mem_emit ((inst), 3, (mem)); \
- } \
- } while (0)
-
-#define x86_fist_pop_membase(inst,basereg,disp,is_int64_t) \
- do { \
- if ((is_int64_t)) { \
- *(inst)++ = (unsigned char)0xdf; \
- x86_membase_emit ((inst), 7, (basereg), (disp)); \
- } else { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_membase_emit ((inst), 3, (basereg), (disp)); \
- } \
- } while (0)
-
-#define x86_fstsw(inst) \
- do { \
- *(inst)++ = (unsigned char)0x9b; \
- *(inst)++ = (unsigned char)0xdf; \
- *(inst)++ = (unsigned char)0xe0; \
- } while (0)
-
-/**
- * @x86_fist_membase
- * Converts content of ST(0) to integer and stores it at memory location
- * addressed by [basereg + disp].
- * is_int specifies whether destination is int32 (TRUE) or int16 (FALSE).
- */
-#define x86_fist_membase(inst,basereg,disp,is_int) \
- do { \
- if ((is_int)) { \
- *(inst)++ = (unsigned char)0xdb; \
- x86_membase_emit ((inst), 2, (basereg), (disp)); \
- } else { \
- *(inst)++ = (unsigned char)0xdf; \
- x86_membase_emit ((inst), 2, (basereg), (disp)); \
- } \
- } while (0)
-
-
-#define x86_push_reg(inst,reg) \
- do { \
- *(inst)++ = (unsigned char)0x50 + (reg); \
- } while (0)
-
-#define x86_push_regp(inst,reg) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_regp_emit ((inst), 6, (reg)); \
- } while (0)
-
-#define x86_push_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_mem_emit ((inst), 6, (mem)); \
- } while (0)
-
-#define x86_push_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_membase_emit ((inst), 6, (basereg), (disp)); \
- } while (0)
-
-#define x86_push_memindex(inst,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_memindex_emit ((inst), 6, (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_push_imm_template(inst) x86_push_imm (inst, 0xf0f0f0f0)
-
-#define x86_push_imm(inst,imm) \
- do { \
- int _imm = (int) (imm); \
- if (x86_is_imm8 (_imm)) { \
- *(inst)++ = (unsigned char)0x6A; \
- x86_imm_emit8 ((inst), (_imm)); \
- } else { \
- *(inst)++ = (unsigned char)0x68; \
- x86_imm_emit32 ((inst), (_imm)); \
- } \
- } while (0)
-
-#define x86_pop_reg(inst,reg) \
- do { \
- *(inst)++ = (unsigned char)0x58 + (reg); \
- } while (0)
-
-#define x86_pop_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0x8f; \
- x86_mem_emit ((inst), 0, (mem)); \
- } while (0)
-
-#define x86_pop_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x87; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- } while (0)
-
-#define x86_pushad(inst) do { *(inst)++ = (unsigned char)0x60; } while (0)
-#define x86_pushfd(inst) do { *(inst)++ = (unsigned char)0x9c; } while (0)
-#define x86_popad(inst) do { *(inst)++ = (unsigned char)0x61; } while (0)
-#define x86_popfd(inst) do { *(inst)++ = (unsigned char)0x9d; } while (0)
-
-#define x86_loop(inst,imm) \
- do { \
- *(inst)++ = (unsigned char)0xe2; \
- x86_imm_emit8 ((inst), (imm)); \
- } while (0)
-
-#define x86_loope(inst,imm) \
- do { \
- *(inst)++ = (unsigned char)0xe1; \
- x86_imm_emit8 ((inst), (imm)); \
- } while (0)
-
-#define x86_loopne(inst,imm) \
- do { \
- *(inst)++ = (unsigned char)0xe0; \
- x86_imm_emit8 ((inst), (imm)); \
- } while (0)
-
-#define x86_jump32(inst,imm) \
- do { \
- *(inst)++ = (unsigned char)0xe9; \
- x86_imm_emit32 ((inst), (imm)); \
- } while (0)
-
-#define x86_jump8(inst,imm) \
- do { \
- *(inst)++ = (unsigned char)0xeb; \
- x86_imm_emit8 ((inst), (imm)); \
- } while (0)
-
-#define x86_jump_reg(inst,reg) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_reg_emit ((inst), 4, (reg)); \
- } while (0)
-
-#define x86_jump_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_mem_emit ((inst), 4, (mem)); \
- } while (0)
-
-#define x86_jump_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_membase_emit ((inst), 4, (basereg), (disp)); \
- } while (0)
-
-/*
- * target is a pointer in our buffer.
- */
-#define x86_jump_code(inst,target) \
- do { \
- int t = (unsigned char*)(target) - (inst) - 2; \
- if (x86_is_imm8(t)) { \
- x86_jump8 ((inst), t); \
- } else { \
- t -= 3; \
- x86_jump32 ((inst), t); \
- } \
- } while (0)
-
-#define x86_jump_disp(inst,disp) \
- do { \
- int t = (disp) - 2; \
- if (x86_is_imm8(t)) { \
- x86_jump8 ((inst), t); \
- } else { \
- t -= 3; \
- x86_jump32 ((inst), t); \
- } \
- } while (0)
-
-#define x86_jump_disp32(inst,disp) \
- do { \
- int t = (disp) - 5; \
- x86_jump32 ((inst), t); \
- } while (0)
-
-
-#define x86_branch8(inst,cond,imm,is_signed) \
- do { \
- if ((is_signed)) \
- *(inst)++ = x86_cc_signed_map [(cond)]; \
- else \
- *(inst)++ = x86_cc_unsigned_map [(cond)]; \
- x86_imm_emit8 ((inst), (imm)); \
- } while (0)
-
-#define x86_branch32(inst,cond,imm,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- if ((is_signed)) \
- *(inst)++ = x86_cc_signed_map [(cond)] + 0x10; \
- else \
- *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x10; \
- x86_imm_emit32 ((inst), (imm)); \
- } while (0)
-
-#define x86_branch(inst,cond,target,is_signed) \
- do { \
- int offset = (target) - (inst) - 2; \
- if (x86_is_imm8 ((offset))) \
- x86_branch8 ((inst), (cond), offset, (is_signed)); \
- else { \
- offset -= 4; \
- x86_branch32 ((inst), (cond), offset, (is_signed)); \
- } \
- } while (0)
-
-#define x86_branch_disp(inst,cond,disp,is_signed) \
- do { \
- int offset = (disp) - 2; \
- if (x86_is_imm8 ((offset))) \
- x86_branch8 ((inst), (cond), offset, (is_signed)); \
- else { \
- offset -= 4; \
- x86_branch32 ((inst), (cond), offset, (is_signed)); \
- } \
- } while (0)
-
-#define x86_branch_disp32(inst,cond,disp,is_signed) \
- do { \
- int offset = (disp) - 6; \
- x86_branch32 ((inst), (cond), offset, (is_signed)); \
- } while (0)
-
-
-
-#define x86_set_reg(inst,cond,reg,is_signed) \
- do { \
- g_assert (X86_IS_BYTE_REG (reg)); \
- *(inst)++ = (unsigned char)0x0f; \
- if ((is_signed)) \
- *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \
- else \
- *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \
- x86_reg_emit ((inst), 0, (reg)); \
- } while (0)
-
-#define x86_set_mem(inst,cond,mem,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- if ((is_signed)) \
- *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \
- else \
- *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \
- x86_mem_emit ((inst), 0, (mem)); \
- } while (0)
-
-#define x86_set_membase(inst,cond,basereg,disp,is_signed) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- if ((is_signed)) \
- *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \
- else \
- *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \
- x86_membase_emit ((inst), 0, (basereg), (disp)); \
- } while (0)
-
-#define x86_call_imm(inst,disp) \
- do { \
- *(inst)++ = (unsigned char)0xe8; \
- x86_imm_emit32 ((inst), (int)(disp)); \
- } while (0)
-
-#define x86_call_reg(inst,reg) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_reg_emit ((inst), 2, (reg)); \
- } while (0)
-
-#define x86_call_mem(inst,mem) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_mem_emit ((inst), 2, (mem)); \
- } while (0)
-
-#define x86_call_membase(inst,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xff; \
- x86_membase_emit ((inst), 2, (basereg), (disp)); \
- } while (0)
-
-#define x86_call_code(inst,target) \
- do { \
- int _x86_offset = (unsigned char*)(target) - (inst); \
- _x86_offset -= 5; \
- x86_call_imm ((inst), _x86_offset); \
- } while (0)
-
-#define x86_ret(inst) do { *(inst)++ = (unsigned char)0xc3; } while (0)
-
-#define x86_ret_imm(inst,imm) \
- do { \
- if ((imm) == 0) { \
- x86_ret ((inst)); \
- } else { \
- *(inst)++ = (unsigned char)0xc2; \
- x86_imm_emit16 ((inst), (imm)); \
- } \
- } while (0)
-
-#define x86_cmov_reg(inst,cond,is_signed,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char) 0x0f; \
- if ((is_signed)) \
- *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \
- else \
- *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_cmov_mem(inst,cond,is_signed,reg,mem) \
- do { \
- *(inst)++ = (unsigned char) 0x0f; \
- if ((is_signed)) \
- *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \
- else \
- *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_cmov_membase(inst,cond,is_signed,reg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char) 0x0f; \
- if ((is_signed)) \
- *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \
- else \
- *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_enter(inst,framesize) \
- do { \
- *(inst)++ = (unsigned char)0xc8; \
- x86_imm_emit16 ((inst), (framesize)); \
- *(inst)++ = 0; \
- } while (0)
-
-#define x86_leave(inst) do { *(inst)++ = (unsigned char)0xc9; } while (0)
-#define x86_sahf(inst) do { *(inst)++ = (unsigned char)0x9e; } while (0)
-
-#define x86_fsin(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xfe; } while (0)
-#define x86_fcos(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xff; } while (0)
-#define x86_fabs(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xe1; } while (0)
-#define x86_ftst(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xe4; } while (0)
-#define x86_fxam(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xe5; } while (0)
-#define x86_fpatan(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xf3; } while (0)
-#define x86_fprem(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xf8; } while (0)
-#define x86_fprem1(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xf5; } while (0)
-#define x86_frndint(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xfc; } while (0)
-#define x86_fsqrt(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xfa; } while (0)
-#define x86_fptan(inst) do { *(inst)++ = (unsigned char)0xd9; *(inst)++ = (unsigned char)0xf2; } while (0)
-
-#define x86_padding(inst,size) \
- do { \
- switch ((size)) { \
- case 1: x86_nop ((inst)); break; \
- case 2: *(inst)++ = 0x8b; \
- *(inst)++ = 0xc0; break; \
- case 3: *(inst)++ = 0x8d; *(inst)++ = 0x6d; \
- *(inst)++ = 0x00; break; \
- case 4: *(inst)++ = 0x8d; *(inst)++ = 0x64; \
- *(inst)++ = 0x24; *(inst)++ = 0x00; \
- break; \
- case 5: *(inst)++ = 0x8d; *(inst)++ = 0x64; \
- *(inst)++ = 0x24; *(inst)++ = 0x00; \
- x86_nop ((inst)); break; \
- case 6: *(inst)++ = 0x8d; *(inst)++ = 0xad; \
- *(inst)++ = 0x00; *(inst)++ = 0x00; \
- *(inst)++ = 0x00; *(inst)++ = 0x00; \
- break; \
- case 7: *(inst)++ = 0x8d; *(inst)++ = 0xa4; \
- *(inst)++ = 0x24; *(inst)++ = 0x00; \
- *(inst)++ = 0x00; *(inst)++ = 0x00; \
- *(inst)++ = 0x00; break; \
- default: assert (0); \
- } \
- } while (0)
-
-#define x86_prolog(inst,frame_size,reg_mask) \
- do { \
- unsigned i, m = 1; \
- x86_enter ((inst), (frame_size)); \
- for (i = 0; i < X86_NREG; ++i, m <<= 1) { \
- if ((reg_mask) & m) \
- x86_push_reg ((inst), i); \
- } \
- } while (0)
-
-#define x86_epilog(inst,reg_mask) \
- do { \
- unsigned i, m = 1 << X86_EDI; \
- for (i = X86_EDI; m != 0; i--, m=m>>1) { \
- if ((reg_mask) & m) \
- x86_pop_reg ((inst), i); \
- } \
- x86_leave ((inst)); \
- x86_ret ((inst)); \
- } while (0)
-
-
-typedef enum {
- X86_SSE_SQRT = 0x51,
- X86_SSE_RSQRT = 0x52,
- X86_SSE_RCP = 0x53,
- X86_SSE_ADD = 0x58,
- X86_SSE_DIV = 0x5E,
- X86_SSE_MUL = 0x59,
- X86_SSE_SUB = 0x5C,
- X86_SSE_MIN = 0x5D,
- X86_SSE_MAX = 0x5F,
- X86_SSE_COMP = 0xC2,
- X86_SSE_AND = 0x54,
- X86_SSE_ANDN = 0x55,
- X86_SSE_OR = 0x56,
- X86_SSE_XOR = 0x57,
- X86_SSE_UNPCKL = 0x14,
- X86_SSE_UNPCKH = 0x15,
-
- X86_SSE_ADDSUB = 0xD0,
- X86_SSE_HADD = 0x7C,
- X86_SSE_HSUB = 0x7D,
- X86_SSE_MOVSHDUP = 0x16,
- X86_SSE_MOVSLDUP = 0x12,
- X86_SSE_MOVDDUP = 0x12,
- X86_SSE_SHUF = 0xC6,
-
- X86_SSE_COMI = 0x2F,
-
- X86_SSE_PAND = 0xDB,
- X86_SSE_POR = 0xEB,
- X86_SSE_PXOR = 0xEF,
-
- X86_SSE_PADDB = 0xFC,
- X86_SSE_PADDW = 0xFD,
- X86_SSE_PADDD = 0xFE,
- X86_SSE_PADDQ = 0xD4,
-
- X86_SSE_PSUBB = 0xF8,
- X86_SSE_PSUBW = 0xF9,
- X86_SSE_PSUBD = 0xFA,
- X86_SSE_PSUBQ = 0xFB,
-
- X86_SSE_PMAXSB = 0x3C, /*sse41*/
- X86_SSE_PMAXSW = 0xEE,
- X86_SSE_PMAXSD = 0x3D, /*sse41*/
-
- X86_SSE_PMAXUB = 0xDE,
- X86_SSE_PMAXUW = 0x3E, /*sse41*/
- X86_SSE_PMAXUD = 0x3F, /*sse41*/
-
- X86_SSE_PMINSB = 0x38, /*sse41*/
- X86_SSE_PMINSW = 0xEA,
- X86_SSE_PMINSD = 0x39,/*sse41*/
-
- X86_SSE_PMINUB = 0xDA,
- X86_SSE_PMINUW = 0x3A, /*sse41*/
- X86_SSE_PMINUD = 0x3B, /*sse41*/
-
- X86_SSE_PAVGB = 0xE0,
- X86_SSE_PAVGW = 0xE3,
-
- X86_SSE_PCMPEQB = 0x74,
- X86_SSE_PCMPEQW = 0x75,
- X86_SSE_PCMPEQD = 0x76,
- X86_SSE_PCMPEQQ = 0x29, /*sse41*/
-
- X86_SSE_PCMPGTB = 0x64,
- X86_SSE_PCMPGTW = 0x65,
- X86_SSE_PCMPGTD = 0x66,
- X86_SSE_PCMPGTQ = 0x37, /*sse42*/
-
- X86_SSE_PSADBW = 0xf6,
-
- X86_SSE_PSHUFD = 0x70,
-
- X86_SSE_PUNPCKLBW = 0x60,
- X86_SSE_PUNPCKLWD = 0x61,
- X86_SSE_PUNPCKLDQ = 0x62,
- X86_SSE_PUNPCKLQDQ = 0x6C,
-
- X86_SSE_PUNPCKHBW = 0x68,
- X86_SSE_PUNPCKHWD = 0x69,
- X86_SSE_PUNPCKHDQ = 0x6A,
- X86_SSE_PUNPCKHQDQ = 0x6D,
-
- X86_SSE_PACKSSWB = 0x63,
- X86_SSE_PACKSSDW = 0x6B,
-
- X86_SSE_PACKUSWB = 0x67,
- X86_SSE_PACKUSDW = 0x2B,/*sse41*/
-
- X86_SSE_PADDUSB = 0xDC,
- X86_SSE_PADDUSW = 0xDD,
- X86_SSE_PSUBUSB = 0xD8,
- X86_SSE_PSUBUSW = 0xD9,
-
- X86_SSE_PADDSB = 0xEC,
- X86_SSE_PADDSW = 0xED,
- X86_SSE_PSUBSB = 0xE8,
- X86_SSE_PSUBSW = 0xE9,
-
- X86_SSE_PMULLW = 0xD5,
- X86_SSE_PMULLD = 0x40,/*sse41*/
- X86_SSE_PMULHUW = 0xE4,
- X86_SSE_PMULHW = 0xE5,
- X86_SSE_PMULUDQ = 0xF4,
-
- X86_SSE_PMOVMSKB = 0xD7,
-
- X86_SSE_PSHIFTW = 0x71,
- X86_SSE_PSHIFTD = 0x72,
- X86_SSE_PSHIFTQ = 0x73,
- X86_SSE_SHR = 2,
- X86_SSE_SAR = 4,
- X86_SSE_SHL = 6,
-
- X86_SSE_PSRLW_REG = 0xD1,
- X86_SSE_PSRAW_REG = 0xE1,
- X86_SSE_PSLLW_REG = 0xF1,
-
- X86_SSE_PSRLD_REG = 0xD2,
- X86_SSE_PSRAD_REG = 0xE2,
- X86_SSE_PSLLD_REG = 0xF2,
-
- X86_SSE_PSRLQ_REG = 0xD3,
- X86_SSE_PSLLQ_REG = 0xF3,
-
- X86_SSE_PREFETCH = 0x18,
- X86_SSE_MOVNTPS = 0x2B,
- X86_SSE_MOVHPD_REG_MEMBASE = 0x16,
- X86_SSE_MOVHPD_MEMBASE_REG = 0x17,
-
- X86_SSE_MOVSD_REG_MEMBASE = 0x10,
- X86_SSE_MOVSD_MEMBASE_REG = 0x11,
-
- X86_SSE_PINSRB = 0x20,/*sse41*/
- X86_SSE_PINSRW = 0xC4,
- X86_SSE_PINSRD = 0x22,/*sse41*/
-
- X86_SSE_PEXTRB = 0x14,/*sse41*/
- X86_SSE_PEXTRW = 0xC5,
- X86_SSE_PEXTRD = 0x16,/*sse41*/
-} X86_SSE_Opcode;
-
-typedef enum {
- X86_SSE_CMP_EQ = 0,
- X86_SSE_CMP_LT = 1,
- X86_SSE_CMP_LE = 2,
- X86_SSE_CMP_UNORD = 3,
- X86_SSE_CMP_NEQ = 4,
- X86_SSE_CMP_NLT = 5,
- X86_SSE_CMP_NLE = 6,
- X86_SSE_CMP_ORD = 7
-} X86_SSE_CmpCode;
-
-
-/* minimal SSE* support */
-#define x86_movsd_reg_membase(inst,dreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_membase_emit ((inst), (dreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movsd_reg_mem(inst,dreg,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_mem_emit ((inst), (dreg), (mem)); \
- } while (0)
-
-
-#define x86_movsd_reg_reg(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_reg_emit ((inst), (reg), (dreg)); \
- } while (0)
-
-#define x86_cvtsd2ss(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x5a; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_cvtss2sd(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x5a; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_cvtss2sd_reg_membase(inst,reg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x5a; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_cvtss2sd_reg_memindex(inst,reg,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x5a; \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_cvtss2sd_reg_mem(inst,reg,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x5a; \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-
-#define x86_cvttsd2si(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x2c; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_cvtsi2sd(inst,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0xf2; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x2a; \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_sse_alu_reg_reg(inst,opc,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0F; \
- *(inst)++ = (unsigned char)(opc); \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_sse_alu_reg_membase(inst,opc,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)(opc); \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_sse_alu_membase_reg(inst,opc,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0F; \
- *(inst)++ = (unsigned char)(opc); \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-
-#define x86_sse_alu_pd_reg_reg(inst,opc,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- x86_sse_alu_reg_reg ((inst), (opc), (dreg), (reg)); \
- } while (0)
-
-#define x86_sse_alu_pd_membase_reg(inst,opc,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- x86_sse_alu_membase_reg ((inst), (opc), (basereg), (disp), (reg)); \
- } while (0)
-
-#define x86_sse_alu_pd_reg_membase(inst,opc,dreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- x86_sse_alu_reg_membase ((inst), (opc), (dreg),(basereg), (disp)); \
- } while (0)
-
-#define x86_sse_alu_pd_reg_mem(inst,opc,dreg,mem) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0F; \
- *(inst)++ = (unsigned char)(opc); \
- x86_mem_emit ((inst), (dreg), (mem)); \
- } while (0)
-
-
-#define x86_sse_alu_pd_reg_reg_imm(inst,opc,dreg,reg,imm) \
- do { \
- x86_sse_alu_pd_reg_reg ((inst), (opc), (dreg), (reg)); \
- *(inst)++ = (unsigned char)(imm); \
- } while (0)
-
-#define x86_sse_alu_sd_reg_reg_imm(inst,opc,dreg,reg,imm) \
- do { \
- x86_sse_alu_sd_reg_reg ((inst), (opc), (dreg), (reg)); \
- *(inst)++ = (unsigned char)(imm); \
- } while (0)
-
-#define x86_sse_alu_pd_reg_membase_imm(inst,opc,dreg,basereg,disp,imm) \
- do { \
- x86_sse_alu_pd_reg_membase ((inst), (opc), (dreg),(basereg), (disp)); \
- *(inst)++ = (unsigned char)(imm); \
- } while (0)
-
-
-#define x86_sse_alu_ps_reg_reg(inst,opc,dreg,reg) \
- do { \
- x86_sse_alu_reg_reg ((inst), (opc), (dreg), (reg)); \
- } while (0)
-
-#define x86_sse_alu_ps_reg_reg_imm(inst,opc,dreg,reg, imm) \
- do { \
- x86_sse_alu_reg_reg ((inst), (opc), (dreg), (reg)); \
- *(inst)++ = (unsigned char)imm; \
- } while (0)
-
-
-#define x86_sse_alu_sd_reg_reg(inst,opc,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0xF2; \
- x86_sse_alu_reg_reg ((inst), (opc), (dreg), (reg)); \
- } while (0)
-
-#define x86_sse_alu_sd_membase_reg(inst,opc,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0xF2; \
- x86_sse_alu_membase_reg ((inst), (opc), (basereg), (disp), (reg)); \
- } while (0)
-
-#define x86_sse_alu_sd_reg_mem(inst,opc,dreg,mem) \
- do { \
- *(inst)++ = (unsigned char)0xF2; \
- *(inst)++ = (unsigned char)0x0F; \
- *(inst)++ = (unsigned char)(opc); \
- x86_mem_emit ((inst), (dreg), (mem)); \
- } while (0)
-
-
-
-#define x86_sse_alu_ss_reg_reg(inst,opc,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0xF3; \
- x86_sse_alu_reg_reg ((inst), (opc), (dreg), (reg)); \
- } while (0)
-
-#define x86_sse_alu_ss_membase_reg(inst,opc,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0xF3; \
- x86_sse_alu_membase_reg ((inst), (opc), (basereg), (disp), (reg)); \
- } while (0)
-
-
-
-#define x86_sse_alu_sse41_reg_reg(inst,opc,dreg,reg) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0F; \
- *(inst)++ = (unsigned char)0x38; \
- *(inst)++ = (unsigned char)(opc); \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_movups_reg_membase(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movups_membase_reg(inst,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movaps_reg_membase(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x28; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movaps_membase_reg(inst,basereg,disp,reg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x29; \
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movaps_reg_reg(inst,dreg,sreg) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x28; \
- x86_reg_emit ((inst), (dreg), (sreg)); \
- } while (0)
-
-
-#define x86_movd_reg_xreg(inst,dreg,sreg) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x7e; \
- x86_reg_emit ((inst), (sreg), (dreg)); \
- } while (0)
-
-#define x86_movd_xreg_reg(inst,dreg,sreg) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x6e; \
- x86_reg_emit ((inst), (dreg), (sreg)); \
- } while (0)
-
-#define x86_movd_xreg_membase(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x6e; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movlpd_xreg_memindex(inst,sreg,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x12; \
- x86_memindex_emit ((inst), (sreg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_movlpd_xreg_membase(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x12; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movlpd_xreg_mem(inst,sreg,mem) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x12; \
- x86_mem_emit ((inst), (sreg), (mem)); \
- } while (0)
-
-#define x86_movhpd_xreg_membase(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x16; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movlpd_membase_xreg(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x13; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movlpd_memindex_xreg(inst,sreg,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x13; \
- x86_memindex_emit ((inst), (sreg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-
-#define x86_movlpd_mem_xreg(inst,sreg,mem) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x13; \
- x86_mem_emit ((inst), (sreg), (mem)); \
- } while (0)
-
-#define x86_movss_mem_xreg(inst,sreg,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_mem_emit ((inst), (sreg), (mem)); \
- } while (0)
-
-#define x86_movss_xreg_mem(inst,sreg,mem) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_mem_emit ((inst), (sreg), (mem)); \
- } while (0)
-
-#define x86_movss_membase_xreg(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movss_xreg_membase(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-
-#define x86_movss_memindex_xreg(inst,sreg,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x11; \
- x86_memindex_emit ((inst), (sreg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_movss_xreg_memindex(inst,sreg,basereg,disp,indexreg,shift) \
- do { \
- *(inst)++ = (unsigned char)0xf3; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x10; \
- x86_memindex_emit ((inst), (sreg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-
-#define x86_movhpd_membase_xreg(inst,sreg,basereg,disp) \
- do { \
- *(inst)++ = (unsigned char)0x66; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x17; \
- x86_membase_emit ((inst), (sreg), (basereg), (disp)); \
- } while (0)
-
-#define x86_pshufw_reg_reg(inst,dreg,sreg,mask,high_words) \
- do { \
- *(inst)++ = (unsigned char)(high_words) ? 0xF3 : 0xF2; \
- *(inst)++ = (unsigned char)0x0f; \
- *(inst)++ = (unsigned char)0x70; \
- x86_reg_emit ((inst), (dreg), (sreg)); \
- *(inst)++ = (unsigned char)mask; \
- } while (0)
-
-#define x86_sse_shift_reg_imm(inst,opc,mode, dreg,imm) \
- do { \
- x86_sse_alu_pd_reg_reg (inst, opc, mode, dreg); \
- x86_imm_emit8 ((inst), (imm)); \
- } while (0)
-
-#define x86_sse_shift_reg_reg(inst,opc,dreg,sreg) \
- do { \
- x86_sse_alu_pd_reg_reg (inst, opc, dreg, sreg); \
- } while (0)
-
-
-/*
- * MOVSX, MOVZX
- */
-
-#define x86_movzx_reg_reg(inst,dreg,reg,size) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xb6; break; \
- case 2: *(inst)++ = (unsigned char)0xb7; break; \
- default: assert (0); \
- } \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_movsx_reg_reg(inst,dreg,reg,size) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xbe; break; \
- case 2: *(inst)++ = (unsigned char)0xbf; break; \
- default: assert (0); \
- } \
- x86_reg_emit ((inst), (dreg), (reg)); \
- } while (0)
-
-#define x86_movsx_reg_mem(inst,reg,mem,size) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xbe; break; \
- case 2: *(inst)++ = (unsigned char)0xbf; break; \
- default: assert (0); \
- } \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-#define x86_movsx_reg_membase(inst,reg,basereg,disp,size) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- switch (size) {\
- case 1: *(inst)++ = (unsigned char)0xbe; break; \
- case 2: *(inst)++ = (unsigned char)0xbf; break; \
- default: assert(0);\
- }\
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movsx_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xbe; break; \
- case 2: *(inst)++ = (unsigned char)0xbf; break; \
- default: assert (0); \
- } \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_movzx_reg_mem(inst,reg,mem,size) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xb6; break; \
- case 2: *(inst)++ = (unsigned char)0xb7; break; \
- default: assert (0); \
- } \
- x86_mem_emit ((inst), (reg), (mem)); \
- } while (0)
-
-
-#define x86_movzx_reg_membase(inst,reg,basereg,disp,size) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- switch (size) {\
- case 1: *(inst)++ = (unsigned char)0xb6; break; \
- case 2: *(inst)++ = (unsigned char)0xb7; break; \
- default: assert(0);\
- }\
- x86_membase_emit ((inst), (reg), (basereg), (disp)); \
- } while (0)
-
-#define x86_movzx_reg_memindex(inst,reg,basereg,disp,indexreg,shift,size) \
- do { \
- *(inst)++ = (unsigned char)0x0f; \
- switch ((size)) { \
- case 1: *(inst)++ = (unsigned char)0xb6; break; \
- case 2: *(inst)++ = (unsigned char)0xb7; break; \
- default: assert (0); \
- } \
- x86_memindex_emit ((inst), (reg), (basereg), (disp), (indexreg), (shift)); \
- } while (0)
-
-#define x86_cmc(inst) \
- do { \
- *(inst)++ = (unsigned char)0xf5; \
- } while (0)
-
-#endif // X86_H
diff --git a/ext/myjit/myjit/x86-common-stuff.c b/ext/myjit/myjit/x86-common-stuff.c
deleted file mode 100755
index 2df2d76..0000000
--- a/ext/myjit/myjit/x86-common-stuff.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * Common stuff for i386 and AMD64 platforms
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-#define IS_32BIT_VALUE(x) ((((int64_t)(x)) >= INT32_MIN) && (((int64_t)(x)) <= INT32_MAX))
-
-//
-//
-// Optimizations
-//
-//
-void jit_optimize_st_ops(struct jit * jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if ((GET_OP(op) == JIT_ST)
- && (op->prev)
- && (op->prev->code == (JIT_MOV | IMM))
- && (op->arg[1] == op->prev->arg[0])
- && (IS_32BIT_VALUE(op->prev->arg[1]))
- && (!jit_set_get(op->live_out, op->arg[1])))
- {
- if (!IS_IMM(op)) {
- op->code = JIT_X86_STI | REG;
- op->spec = SPEC(REG, IMM, NO);
- } else {
- op->code = JIT_X86_STI | IMM;
- op->spec = SPEC(IMM, IMM, NO);
- }
- op->arg[1] = op->prev->arg[1];
- op->prev->code = JIT_NOP;
- op->prev->spec = SPEC(NO, NO, NO);
- }
-
- if ((GET_OP(op) == JIT_STX)
- && (op->prev)
- && (op->prev->code == (JIT_MOV | IMM))
- && (op->arg[2] == op->prev->arg[0])
- && (IS_32BIT_VALUE(op->prev->arg[1]))
- && (!jit_set_get(op->live_out, op->arg[2])))
- {
- if (!IS_IMM(op)) {
- op->code = JIT_X86_STXI | REG;
- op->spec = SPEC(REG, REG, IMM);
- } else {
- op->code = JIT_X86_STXI | IMM;
- op->spec = SPEC(IMM, REG, IMM);
- }
- op->arg[2] = op->prev->arg[1];
- op->prev->code = JIT_NOP;
- op->prev->spec = SPEC(NO, NO, NO);
- }
-
- }
-}
-
-void jit_optimize_frame_ptr(struct jit * jit)
-{
- if (!jit->optimizations & JIT_OPT_OMIT_FRAME_PTR) return;
-
- struct jit_func_info * info = NULL;
- int uses_frame_ptr = 0;
- for (jit_op * op = jit_op_first(jit->ops); ; op = op->next) {
- if (!op || GET_OP(op) == JIT_PROLOG) {
- if (info && !uses_frame_ptr) {
- info->has_prolog = 0;
- uses_frame_ptr = 0;
- }
-
- if (op) info = (struct jit_func_info *) op->arg[1];
- }
- if (!op) break;
- if ((GET_OP(op) == JIT_ALLOCA) || (GET_OP(op) == JIT_UREG) || (GET_OP(op) == JIT_LREG) || (GET_OP(op) == JIT_SYNCREG)) {
- uses_frame_ptr |= 1;
- }
- }
-}
-
-void jit_optimize_unused_assignments(struct jit * jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if (ARG_TYPE(op, 1) == TREG) {
- // we have to skip these operations since, these are setting carry flag
- if ((GET_OP(op) == JIT_ADDC) || (GET_OP(op) == JIT_ADDX)
- || (GET_OP(op) == JIT_SUBC) || (GET_OP(op) == JIT_SUBX)) continue;
-
- if (!jit_set_get(op->live_out, op->arg[0])) {
- op->code = JIT_NOP;
- op->spec = SPEC(NO, NO, NO);
- }
- }
- }
-}
-
-//
-//
-// Optimizations combining mul+add, add+add, and such operations into the one operation
-//
-//
-
-static inline void make_nop(jit_op * op)
-{
- op->code = JIT_NOP;
- op->spec = SPEC(NO, NO, NO);
-}
-
-static jit_op * get_related_op(jit_op * op, int result_reg)
-{
- jit_op * nextop = op->next;
-
- if ((nextop->arg[0] != result_reg) && (jit_set_get(nextop->live_out, result_reg))) return NULL;
-
- int used = 0;
- for (int i = 0; i < 3; i++)
- if ((ARG_TYPE(nextop, i + 1) == REG) && (nextop->arg[i])) {
- used = 1;
- break;
- }
- if (used) return nextop;
- return NULL;
-}
-
-static int join_2ops(jit_op * op, int opcode1, int opcode2, int (* joinfn)(jit_op *, jit_op *))
-{
- if (op->code == opcode1) {
- jit_value result_reg = op->arg[0];
- jit_op * nextop = get_related_op(op, result_reg);
- if (nextop && (nextop->code == opcode2)) return joinfn(op, nextop);
- }
- return 0;
-}
-
-static int shift_index(int arg)
-{
- if (arg == 2) return 1;
- if (arg == 4) return 2;
- if (arg == 8) return 3;
- assert(0);
-}
-
-static inline int pow2(int arg)
-{
- int r = 1;
- for (int i = 0; i < arg; i++)
- r *= 2;
- return r;
-}
-
-static inline int is_suitable_mul(jit_op * op)
-{
- jit_value arg = op->arg[2];
- return ((((op->code == (JIT_MUL | IMM)) && ((arg == 2) || (arg == 4) || (arg == 8))))
- || ((op->code == (JIT_LSH | IMM)) && ((arg == 1) || (arg == 2) || (arg == 3))));
-}
-
-static inline int make_addmuli(jit_op * op, jit_op * nextop)
-{
- nextop->code = JIT_X86_ADDMUL | IMM;
- nextop->spec = SPEC(TREG, REG, IMM);
-
- nextop->arg[1] = op->arg[1];
- nextop->arg_size = (GET_OP(op) == JIT_MUL ? shift_index(op->arg[2]) : op->arg[2]);
-
- make_nop(op);
- return 1;
-}
-
-// combines:
-// muli r1, r2, [2, 4, 8] (or lsh r1, r2, [1, 2, 3])
-// addi r3, r1, imm
-// -->
-// addmuli r3, r2*size, r1 ... lea reg, [reg*size + imm]
-static int join_muli_addi(jit_op * op, jit_op * nextop)
-{
- if (!IS_32BIT_VALUE(nextop->arg[2])) return 0;
- if (!is_suitable_mul(op)) return 0;
- return make_addmuli(op, nextop);
-}
-
-// combines:
-// muli r1, r2, [2, 4, 8] (or lsh r1, r2, [1, 2, 3])
-// ori r3, r1, [0..8]
-// -->
-// addmuli r3, r2*size, r1 ... lea reg, [reg*size + imm]
-static int join_muli_ori(jit_op * op, jit_op * nextop)
-{
- if (!is_suitable_mul(op)) return 0;
- int max = (GET_OP(op) == JIT_MUL) ? max = op->arg[2] : pow2(op->arg[2]);
-
- if ((nextop->arg[2] > 0) && (nextop->arg[2] < max)) return make_addmuli(op, nextop);
- else return 0;
-}
-
-// combines:
-// muli r1, r2, [2, 4, 8] (or lsh r1, r2, [1, 2, 3])
-// addr r3, r1, r4
-// -->
-// addmulr r3, r2*size, r4 ... lea reg, [reg*size + reg]
-static int join_muli_addr(jit_op * op, jit_op * nextop)
-{
- if ((!is_suitable_mul(op) || (nextop->arg[1] == nextop->arg[2]))) return 0;
-
- jit_value add_reg = (nextop->arg[1] == op->arg[0]) ? nextop->arg[2] : nextop->arg[1];
-
- nextop->code = JIT_X86_ADDMUL | REG;
- nextop->spec = SPEC(TREG, REG, REG);
-
- nextop->arg[1] = add_reg;
- nextop->arg[2] = op->arg[1];
- nextop->arg_size = (GET_OP(op) == JIT_MUL ? shift_index(op->arg[2]) : op->arg[2]);
-
- make_nop(op);
- return 1;
-}
-
-int jit_optimize_join_addmul(struct jit * jit)
-{
- int change = 0;
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- change |= join_2ops(op, JIT_MUL | IMM, JIT_ADD | IMM, join_muli_addi);
- change |= join_2ops(op, JIT_LSH | IMM, JIT_ADD | IMM, join_muli_addi);
- change |= join_2ops(op, JIT_MUL | IMM, JIT_ADD | REG, join_muli_addr);
- change |= join_2ops(op, JIT_LSH | IMM, JIT_ADD | REG, join_muli_addr);
- change |= join_2ops(op, JIT_MUL | IMM, JIT_OR | IMM, join_muli_ori);
- change |= join_2ops(op, JIT_LSH | IMM, JIT_OR | IMM, join_muli_ori);
- }
- return change;
-}
-
-// combines:
-// addr r1, r2, r3
-// addi r4, r1, imm
-// -->
-// addimm r4, r2, r3, imm i.e., r4 := r2 + r3 + imm
-static int join_addr_addi(jit_op * op, jit_op * nextop)
-{
- if (!IS_32BIT_VALUE(nextop->arg[2])) return 0;
- make_nop(op);
-
- nextop->code = JIT_X86_ADDIMM;
- nextop->spec = SPEC(TREG, REG, REG);
-
- nextop->arg[2] = nextop->arg[2];
- //nextop->flt_imm = *(double *)&(nextop->arg[2]);
- memcpy(&nextop->flt_imm, &(nextop->arg[2]), sizeof(double));
- nextop->arg[1] = op->arg[1];
- nextop->arg[2] = op->arg[2];
-
- return 1;
-}
-
-// combines:
-// addi r1, r2, imm
-// addr r3, r1, r4 (or addr r3, r4, r1)
-// -->
-// addimm r3, r2, r4, imm i.e., r3 := r2 + r4 + imm
-static int join_addi_addr(jit_op * op, jit_op * nextop)
-{
- if (!IS_32BIT_VALUE(op->arg[2])) return 0;
- if (GET_OP(op) == JIT_SUB) op->arg[2] = -op->arg[2];
-
- make_nop(op);
-
- nextop->code = JIT_X86_ADDIMM;
- nextop->spec = SPEC(TREG, REG, REG);
-
- if (nextop->arg[1] == nextop->arg[2]) op->arg[2] *= 2;
- memcpy(&nextop->flt_imm, &(op->arg[2]), sizeof(double));
-
- if (nextop->arg[1] == op->arg[0]) nextop->arg[1] = op->arg[1];
- if (nextop->arg[2] == op->arg[0]) nextop->arg[2] = op->arg[1];
-
- return 1;
-}
-
-int jit_optimize_join_addimm(struct jit * jit)
-{
- int change = 0;
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- change |= join_2ops(op, JIT_ADD | REG, JIT_ADD | IMM, join_addr_addi);
- change |= join_2ops(op, JIT_ADD | REG, JIT_SUB | IMM, join_addr_addi);
- change |= join_2ops(op, JIT_ADD | IMM, JIT_ADD | REG, join_addi_addr);
- change |= join_2ops(op, JIT_SUB | IMM, JIT_ADD | REG, join_addi_addr);
- }
- return change;
-}
diff --git a/ext/myjit/myjit/x86-specific.h b/ext/myjit/myjit/x86-specific.h
deleted file mode 100755
index 673866e..0000000
--- a/ext/myjit/myjit/x86-specific.h
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * MyJIT
- * Copyright (C) 2010, 2015 Petr Krajca, <petr.krajca@upol.cz>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License aint64_t with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define GET_GPREG_POS(jit, r) (- ((JIT_REG(r).id + 1) * REG_SIZE) - jit_current_func_info(jit)->allocai_mem)
-#define GET_FPREG_POS(jit, r) (- jit_current_func_info(jit)->gp_reg_count * REG_SIZE - (JIT_REG(r).id + 1) * sizeof(jit_float) - jit_current_func_info(jit)->allocai_mem)
-
-static inline int GET_REG_POS(struct jit * jit, int r)
-{
- if (JIT_REG(r).spec == JIT_RTYPE_REG) {
- if (JIT_REG(r). type == JIT_RTYPE_INT) return GET_GPREG_POS(jit, r);
- else return GET_FPREG_POS(jit, r);
- } else assert(0);
-}
-
-#include "x86-common-stuff.c"
-
-void jit_init_arg_params(struct jit * jit, struct jit_func_info * info, int p, int * phys_reg)
-{
- struct jit_inp_arg * a = &(info->args[p]);
-
- if (p == 0) a->location.stack_pos = 8;
- else {
- struct jit_inp_arg * prev_a = &(info->args[p - 1]);
- int stack_shift = jit_value_align(prev_a->size, 4); // 4-bytes aligned
- a->location.stack_pos = prev_a->location.stack_pos + stack_shift;
- }
- a->spill_pos = a->location.stack_pos;
- a->passed_by_reg = 0;
- a->overflow = 0;
-}
-
-static int emit_arguments(struct jit * jit)
-{
- int stack_correction = 0;
- struct jit_out_arg * args = jit->prepared_args.args;
-
-#ifdef __APPLE__
- int alignment = jit->push_count * 4 + jit->prepared_args.stack_size;
-
- while (((alignment + stack_correction) % 16) != 8)
- stack_correction += 4;
-
- if (stack_correction)
- x86_alu_reg_imm(jit->ip, X86_SUB, X86_ESP, stack_correction);
-#endif
-
- int sreg;
- for (int i = jit->prepared_args.ready - 1; i >= 0; i--) {
- int64_t value = args[i].value.generic;
- if (!args[i].isfp) { // integers
- if (!args[i].isreg) x86_push_imm(jit->ip, args[i].value.generic);
- else {
- if (is_spilled(value, jit->prepared_args.op, &sreg))
- x86_push_membase(jit->ip, X86_EBP, GET_REG_POS(jit, args[i].value.generic));
- else x86_push_reg(jit->ip, sreg);
- }
- continue;
- }
- //
- // floats (double)
- //
- if (args[i].size == sizeof(double)) {
- if (args[i].isreg) { // doubles
- if (is_spilled(value, jit->prepared_args.op, &sreg)) {
- int pos = GET_FPREG_POS(jit, args[i].value.generic);
- x86_push_membase(jit->ip, X86_EBP, pos + 4);
- x86_push_membase(jit->ip, X86_EBP, pos);
- } else {
- // ``PUSH sreg'' for XMM regs
- x86_alu_reg_imm(jit->ip, X86_SUB, X86_ESP, 8);
- x86_movlpd_membase_xreg(jit->ip, sreg, X86_ESP, 0);
- }
- } else {
- int fl_val[2];
- memcpy(fl_val, &(args[i].value.fp), sizeof(double));
- x86_push_imm(jit->ip, fl_val[1]);
- x86_push_imm(jit->ip, fl_val[0]);
- }
- continue;
- }
- //
- // single prec. floats
- //
- if (args[i].isreg) {
- if (is_spilled(value, jit->prepared_args.op, &sreg)) {
- int pos = GET_FPREG_POS(jit, args[i].value.generic);
- x86_fld_membase(jit->ip, X86_EBP, pos, 1);
- x86_alu_reg_imm(jit->ip, X86_SUB, X86_ESP, 4);
- x86_fst_membase(jit->ip, X86_ESP, 0, 0, 1);
- } else {
- // pushes the value beyond the top of the stack
- x86_movlpd_membase_xreg(jit->ip, sreg, X86_ESP, -8);
- x86_fld_membase(jit->ip, X86_ESP, -8, 1);
- x86_alu_reg_imm(jit->ip, X86_SUB, X86_ESP, 4);
- x86_fst_membase(jit->ip, X86_ESP, 0, 0, 1);
- }
- } else {
- int fl_val;
- float b = (float)args[i].value.fp;
- memcpy(&fl_val, &b, sizeof(float));
- x86_push_imm(jit->ip, fl_val);
- }
- }
- return stack_correction;
-}
-
-static void emit_funcall(struct jit * jit, struct jit_op * op, int imm)
-{
- int stack_correction = emit_arguments(jit);
-
- if (!imm) {
- x86_call_reg(jit->ip, op->r_arg[0]);
- } else {
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- x86_call_imm(jit->ip, JIT_GET_ADDR(jit, op->r_arg[0]) - 4); /* 4: magic constant */
- }
-
- if (jit->prepared_args.stack_size + stack_correction)
- x86_alu_reg_imm(jit->ip, X86_ADD, X86_ESP, jit->prepared_args.stack_size + stack_correction);
- JIT_FREE(jit->prepared_args.args);
-
- jit->push_count -= emit_pop_caller_saved_regs(jit, op);
-}
-
-void jit_patch_external_calls(struct jit * jit)
-{
- for (jit_op * op = jit_op_first(jit->ops); op != NULL; op = op->next) {
- if ((op->code == (JIT_CALL | IMM)) && (!jit_is_label(jit, (void *)op->arg[0])))
- x86_patch(jit->buf + (int64_t)op->patch_addr, (unsigned char *)op->arg[0]);
- if (GET_OP(op) == JIT_MSG)
- x86_patch(jit->buf + (int64_t)op->patch_addr, (unsigned char *)printf);
- }
-}
-
-static void emit_prolog_op(struct jit * jit, jit_op * op)
-{
- jit->current_func = op;
- struct jit_func_info * info = jit_current_func_info(jit);
- int prolog = jit_current_func_info(jit)->has_prolog;
- //When serializing a function,keep it in it's raw form(to ensure aligment when saving to disk);dont prefix with nops
- //while ((int64_t)jit->ip % 8)
- // x86_nop(jit->ip);
- //op->patch_addr = JIT_BUFFER_OFFSET(jit);
- op->patch_addr=0;
-
- if (prolog) {
- x86_push_reg(jit->ip, X86_EBP);
- x86_mov_reg_reg(jit->ip, X86_EBP, X86_ESP, 4);
- }
- int stack_mem = info->allocai_mem + info->gp_reg_count * REG_SIZE + info->fp_reg_count * sizeof(double);
-
-#ifdef __APPLE__
- stack_mem = jit_value_align(stack_mem, 16);
-#endif
- if (prolog)
- x86_alu_reg_imm(jit->ip, X86_SUB, X86_ESP, stack_mem);
- jit->push_count = emit_push_callee_saved_regs(jit, op);
-}
-
-static void emit_msg_op(struct jit * jit, jit_op * op)
-{
- x86_pushad(jit->ip);
- if (!IS_IMM(op)) x86_push_reg(jit->ip, op->r_arg[1]);
- x86_push_imm(jit->ip, op->r_arg[0]);
- op->patch_addr = JIT_BUFFER_OFFSET(jit);
- x86_call_imm(jit->ip, printf);
- if (IS_IMM(op)) x86_alu_reg_imm(jit->ip, X86_ADD, X86_ESP, 4);
- else x86_alu_reg_imm(jit->ip, X86_ADD, X86_ESP, 8);
- x86_popad(jit->ip);
-}
-
-static void emit_fret_op(struct jit * jit, jit_op * op)
-{
- jit_value arg = op->r_arg[0];
-
- x86_movlpd_membase_xreg(jit->ip, arg, X86_ESP, -8); // pushes the value beyond the top of the stack
- x86_fld_membase(jit->ip, X86_ESP, -8, 1); // transfers the value from the stack to the ST(0)
-
- // common epilogue
- jit->push_count -= emit_pop_callee_saved_regs(jit);
- if (jit_current_func_info(jit)->has_prolog) {
- x86_mov_reg_reg(jit->ip, X86_ESP, X86_EBP, 4);
- x86_pop_reg(jit->ip, X86_EBP);
- }
- x86_ret(jit->ip);
-}
-
-static void emit_fretval_op(struct jit * jit, jit_op * op)
-{
- x86_fst_membase(jit->ip, X86_ESP, -8, 1, 1);
- x86_movlpd_xreg_membase(jit->ip, op->r_arg[0], X86_ESP, -8);
-}
-
-/* register allocator initilization */
-struct jit_reg_allocator * jit_reg_allocator_create()
-{
- int reg = 0;
- struct jit_reg_allocator * a = JIT_MALLOC(sizeof(struct jit_reg_allocator));
-#ifndef JIT_REGISTER_TEST
- a->gp_reg_cnt = 6;
-#else
- a->gp_reg_cnt = 4;
-#endif
- a->gp_regs = JIT_MALLOC(sizeof(jit_hw_reg) * (a->gp_reg_cnt + 1));
-
- a->gp_regs[reg++] = (jit_hw_reg) { X86_EAX, "eax", 0, 0, 5 };
- a->gp_regs[reg++] = (jit_hw_reg) { X86_EBX, "ebx", 1, 0, 0 };
- a->gp_regs[reg++] = (jit_hw_reg) { X86_ECX, "ecx", 0, 0, 3 };
- a->gp_regs[reg++] = (jit_hw_reg) { X86_EDX, "edx", 0, 0, 4 };
-#ifndef JIT_REGISTER_TEST
- a->gp_regs[reg++] = (jit_hw_reg) { X86_ESI, "esi", 1, 0, 1 };
- a->gp_regs[reg++] = (jit_hw_reg) { X86_EDI, "edi", 1, 0, 2 };
-#endif
- a->gp_regs[reg++] = (jit_hw_reg) { X86_EBP, "ebp", 0, 0, 100 };
- a->gp_arg_reg_cnt = 0;
-
- a->fp_reg = X86_EBP;
- a->ret_reg = &(a->gp_regs[0]);
- a->fpret_reg = NULL; // unused
-
-#ifndef JIT_REGISTER_TEST
- a->fp_reg_cnt = 8;
-#else
- a->fp_reg_cnt = 4;
-#endif
-
- reg = 0;
- a->fp_regs = JIT_MALLOC(sizeof(jit_hw_reg) * a->fp_reg_cnt);
-
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM0, "xmm0", 0, 1, 1 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM1, "xmm1", 0, 1, 2 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM2, "xmm2", 0, 1, 3 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM3, "xmm3", 0, 1, 4 };
-#ifndef JIT_REGISTER_TEST
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM4, "xmm4", 0, 1, 5 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM5, "xmm5", 0, 1, 6 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM6, "xmm6", 0, 1, 7 };
- a->fp_regs[reg++] = (jit_hw_reg) { X86_XMM7, "xmm7", 0, 1, 8 };
-#endif
-
- a->fp_arg_reg_cnt = 0;
-
- a->gp_arg_regs = NULL;
- a->fp_arg_regs = NULL;
- return a;
-}
diff --git a/ext/myjit/test/Makefile b/ext/myjit/test/Makefile
deleted file mode 100755
index fd9f29b..0000000
--- a/ext/myjit/test/Makefile
+++ /dev/null
@@ -1,151 +0,0 @@
-all: gp fp misc optim
-
-gp: t001 t002 t003 t004 t005 t006 t007 t008 t009 t010
-
-fp: t101 t102 t103 t104 t105 t107 t108 t109
-
-optim: t301 t302
-
-misc: t200 t201 t202 t301 t401
-
-
-CFLAGS = -g -std=c99 -Wall -pedantic -D_XOPEN_SOURCE=600
-
-t001: t001-basics.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t001 t001-basics.c jitlib-core.o
-
-t002: t002-arithmetic.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t002 t002-arithmetic.c jitlib-core.o
-
-t003: t003-conditions.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t003 t003-conditions.c jitlib-core.o
-
-t004: t004-branches.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t004 t004-branches.c jitlib-core.o
-
-t005: t005-functions.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t005 t005-functions.c jitlib-core.o
-
-t006: t006-misc.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t006 t006-misc.c jitlib-core.o
-
-t007: t007-args.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t007 t007-args.c jitlib-core.o
-
-t008: t008-pushargs.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t008 t008-pushargs.c jitlib-core.o
-
-t009: t009-allocaireg.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t009 t009-allocaireg.c jitlib-core.o
-
-t010: t010-debug.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t010 t010-debug.c jitlib-core.o
-
-t101: t101-fp-basics.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t101 t101-fp-basics.c jitlib-core.o
-
-t102: t102-fp-arithmetic.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t102 t102-fp-arithmetic.c jitlib-core.o
-
-t103: t103-fp-rounding.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t103 -lm t103-fp-rounding.c jitlib-core.o
-
-t104: t104-fp-branches.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t104 t104-fp-branches.c jitlib-core.o
-
-t105: t105-fp-functions.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t105 t105-fp-functions.c jitlib-core.o
-
-t107: t107-fp-args.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t107 t107-fp-args.c jitlib-core.o
-
-t108: t108-fp-pushargs.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t108 t108-fp-pushargs.c jitlib-core.o
-
-t109: t109-fp-allocaireg.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t109 t109-fp-allocaireg.c jitlib-core.o
-
-t200: t200-callr.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t200 t200-callr.c jitlib-core.o
-
-
-t201: t201-functions.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t201 t201-functions.c jitlib-core.o
-
-
-t202: t202-highmem.c jitlib-core.o tests.h
- $(CC) -c $(CFLAGS) -DJIT_MALLOC=xxx_alloc -DJIT_FREE=xxx_free ../myjit/jitlib-core.c -o jitlib-core-highmem.o
- $(CC) $(CFLAGS) -DJIT_MALLOC=xxx_alloc -DJIT_FREE=xxx_free -o t202 t202-highmem.c jitlib-core-highmem.o
-
-t301: t301-optim-adds.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t301 t301-optim-adds.c jitlib-core.o
-
-
-t302: t302-optim-stores.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t302 t302-optim-stores.c jitlib-core.o
-
-t401: t401-data-in-code.c jitlib-core.o tests.h
- $(CC) $(CFLAGS) -o t401 t401-data-in-code.c jitlib-core.o
-
-
-jitlib-core.o: ../myjit/jitlib.h ../myjit/jitlib-core.h ../myjit/jitlib-core.c ../myjit/jitlib-debug.c ../myjit/x86-codegen.h ../myjit/x86-specific.h ../myjit/reg-allocator.h ../myjit/flow-analysis.h ../myjit/set.h ../myjit/amd64-specific.h ../myjit/amd64-codegen.h ../myjit/llrb.c ../myjit/reg-allocator.h ../myjit/rmap.h
- $(CC) -c $(CFLAGS) ../myjit/jitlib-core.c
-
-
-clean:
- rm -f *.o
- rm -f *.gcda
- rm -f *.gcno
- rm -f coverage.info
- rm -fr coverage
- rm -f t001
- rm -f t002
- rm -f t003
- rm -f t004
- rm -f t005
- rm -f t006
- rm -f t007
- rm -f t008
- rm -f t009
- rm -f t010
- rm -f t101
- rm -f t102
- rm -f t103
- rm -f t104
- rm -f t105
- rm -f t107
- rm -f t108
- rm -f t109
- rm -f t200
- rm -f t201
- rm -f t202
- rm -f t301
- rm -f t302
- rm -f t401
-
-coverage: CFLAGS+=--coverage
-coverage: clean coverage-run gen-coverage
-
-gen-coverage:
- lcov --capture --directory ../ --output-file coverage.info
- genhtml coverage.info --output-directory coverage
-
-coverage-run: all
- ./run-tests.sh
- ./t401 -l > /dev/null
- ./t401 --all --code > /dev/null
- ./t401 --all --compilable > /dev/null
- ./t401 --all --compilable > /dev/null
- ./t401 --all --liveness --assoc > /dev/null
- ./t001 --all --liveness --assoc > /dev/null
- ./t002 --all --liveness --assoc > /dev/null
- ./t003 --all --liveness --assoc > /dev/null
- ./t004 --all --liveness --assoc > /dev/null
- ./t005 --all --liveness --assoc > /dev/null
- ./t101 --all --liveness --assoc > /dev/null
- ./t102 --all --liveness --assoc > /dev/null
- ./t103 --all --liveness --assoc > /dev/null
- ./t104 --all --liveness --assoc > /dev/null
- ./t105 --all --liveness --assoc > /dev/null
- ./t401 test11 test12 x
-
diff --git a/ext/myjit/test/run-tests.sh b/ext/myjit/test/run-tests.sh
deleted file mode 100755
index 7359573..0000000
--- a/ext/myjit/test/run-tests.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-./t001
-./t002
-./t003
-./t004
-./t005
-./t006
-./t007
-./t008
-./t009
-./t010
-./t101
-./t102
-./t103
-./t104
-./t105
-./t107
-./t108
-./t109
-./t200
-./t201
-./t202
-./t301
-./t302
-./t401
diff --git a/ext/myjit/test/simple-buffer.c b/ext/myjit/test/simple-buffer.c
deleted file mode 100755
index 0e8228b..0000000
--- a/ext/myjit/test/simple-buffer.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdarg.h>
-
-#define BUFFER_CLEAR 0
-#define BUFFER_PUT 1
-#define BUFFER_GET 2
-
-static char *simple_buffer(int op, char *format_str, ...)
-{
- static char buf[4096];
- va_list ap;
- switch (op) {
- case BUFFER_CLEAR: buf[0] = '\0'; break;
- case BUFFER_PUT:
- va_start(ap, format_str);
- vsprintf(buf + strlen(buf), format_str, ap);
- va_end(ap);
- break;
- }
- return buf;
-}
diff --git a/ext/myjit/test/t001-basics.c b/ext/myjit/test/t001-basics.c
deleted file mode 100755
index a681a5c..0000000
--- a/ext/myjit/test/t001-basics.c
+++ /dev/null
@@ -1,246 +0,0 @@
-#include <limits.h>
-#include "tests.h"
-
-DEFINE_TEST(test1)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_reti(p, 123);
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(123, f1());
- return 0;
-}
-
-DEFINE_TEST(test2)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 100);
- jit_addi(p, R(0), R(0), 200);
- jit_addi(p, R(1), R(0), 200);
- jit_retr(p, R(1));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(500, f1());
- return 0;
-}
-
-DEFINE_TEST(test3)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 100);
- jit_addr(p, R(0), R(0), R(0));
- jit_subi(p, R(1), R(0), 50);
- jit_subr(p, R(2), R(1), R(0));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(-50, f1());
- return 0;
-}
-
-DEFINE_TEST(test4)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 100);
- jit_movi(p, R(1), ULONG_MAX);
- jit_addcr(p, R(2), R(0), R(1));
- jit_addxr(p, R(2), R(0), R(0));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(201, f1());
- return 0;
-}
-
-DEFINE_TEST(test5)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), -100);
- jit_movi(p, R(1), ULONG_MAX);
- jit_subcr(p, R(2), R(0), R(1));
- jit_subxr(p, R(2), R(0), R(0));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(-1, f1());
- return 0;
-}
-
-DEFINE_TEST(test6)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), -100);
- jit_movi(p, R(1), ULONG_MAX);
- jit_movi(p, R(2), 10);
- jit_subcr(p, R(1), R(0), R(1));
-
- jit_subxr(p, R(2), R(2), R(0));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(109, f1());
- return 0;
-}
-
-DEFINE_TEST(test7)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 25);
- jit_movi(p, R(1), 30);
- jit_rsbr(p, R(1), R(1), R(0));
-
- jit_retr(p, R(1));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(-5, f1());
- return 0;
-}
-
-DEFINE_TEST(test10)
-{
- static short y = -2;
-
- plfv f1;
- jit_prolog(p, &f1);
- jit_ldi(p, R(0), &y, sizeof(short));
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(-2, f1());
- return 0;
-}
-
-DEFINE_TEST(test11)
-{
- static short y = -2;
-
- plfv f1;
- jit_prolog(p, &f1);
- jit_ldi_u(p, R(0), &y, sizeof(short));
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(65534, f1());
- return 0;
-}
-
-DEFINE_TEST(test12)
-{
- static short y = -2;
-
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(1), &y);
- jit_ldr(p, R(0), R(1), sizeof(short));
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(-2, f1());
- return 0;
-}
-
-DEFINE_TEST(test13)
-{
- static short y = -2;
-
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(1), &y);
- jit_ldr_u(p, R(0), R(1), sizeof(short));
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(65534, f1());
- return 0;
-}
-
-
-DEFINE_TEST(test14)
-{
- static short y[] = { -2, -3, -5 };
-
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(1), &y);
- jit_ldxi(p, R(0), R(1), sizeof(short) * 1, sizeof(short));
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(-3, f1());
- return 0;
-}
-
-DEFINE_TEST(test15)
-{
- static short y[] = { -2, -3, -4 };
-
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(1), &y);
- jit_ldxi_u(p, R(0), R(1), sizeof(short) * 2, sizeof(short));
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(65532, f1());
- return 0;
-}
-
-DEFINE_TEST(test16)
-{
- static short y[] = { -2, -3, -4, -5, -6 };
-
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(2), 10);
- jit_movi(p, R(1), sizeof(short));
- jit_addi(p, R(1), R(1), sizeof(short));
- jit_stxi(p, &y, R(1), R(2), sizeof(short));
- jit_reti(p, 42);
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(42, f1());
- ASSERT_EQ(10, y[2]);
- return 0;
-}
-
-DEFINE_TEST(test20)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 0xcafe);
- jit_hmuli(p, R(0), R(0), 1L << (REG_SIZE * 8 - 8));
-
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(0xca, f1());
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
- SETUP_TEST(test3);
- SETUP_TEST(test4);
- SETUP_TEST(test5);
- SETUP_TEST(test6);
- SETUP_TEST(test7);
-
- SETUP_TEST(test10);
- SETUP_TEST(test11);
- SETUP_TEST(test12);
- SETUP_TEST(test13);
- SETUP_TEST(test14);
- SETUP_TEST(test15);
- SETUP_TEST(test16);
-
- SETUP_TEST(test20);
-}
diff --git a/ext/myjit/test/t002-arithmetic.c b/ext/myjit/test/t002-arithmetic.c
deleted file mode 100755
index 44575aa..0000000
--- a/ext/myjit/test/t002-arithmetic.c
+++ /dev/null
@@ -1,341 +0,0 @@
-#include "tests.h"
-
-// imm -- same reg
-#define TEST_IMM_SAME_REG(_name, _op, _arg1, _arg2, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- plfv f1; \
- jit_prolog(p, &f1); \
- jit_movi(p, R(0), _arg1); \
- jit_addci(p, R(0), R(0), 0); /* sets carry flag to 0 */ \
- _op(p, R(0), R(0), _arg2); \
- jit_retr(p, R(0)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ(_expected_value, f1());\
- return 0;\
-}
-
-#define TEST_IMM_OTHER_REG(_name, _op, _arg1, _arg2, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- plfv f1; \
- jit_prolog(p, &f1); \
- jit_movi(p, R(0), _arg1); \
- jit_addci(p, R(0), R(0), 0); /* sets carry flag to 0 */ \
- _op(p, R(1), R(0), _arg2); \
- jit_retr(p, R(1)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ(_expected_value, f1());\
- return 0;\
-}
-
-#define TEST_REG_SAME_REG(_name, _op, _arg1, _arg2, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- plfv f1; \
- jit_prolog(p, &f1); \
- jit_movi(p, R(0), _arg1); \
- jit_movi(p, R(1), _arg2); \
- jit_addci(p, R(0), R(0), 0); /* sets carry flag to 0 */ \
- _op(p, R(1), R(0), R(1)); \
- jit_retr(p, R(1)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ(_expected_value, f1());\
- return 0;\
-}
-
-#define TEST_REG_OTHER_REG(_name, _op, _arg1, _arg2, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- plfv f1; \
- jit_prolog(p, &f1); \
- jit_movi(p, R(0), _arg1); \
- jit_movi(p, R(1), _arg2); \
- jit_addci(p, R(0), R(0), 0); /* sets carry flag to 0 */ \
- _op(p, R(2), R(0), R(1)); \
- jit_retr(p, R(2)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ(_expected_value, f1());\
- return 0;\
-}
-
-#define TEST_UNARY_REG_OTHER_REG(_name, _op, _arg1, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- plfv f1; \
- jit_prolog(p, &f1); \
- jit_movi(p, R(0), _arg1); \
- _op(p, R(2), R(0)); \
- jit_retr(p, R(2)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ(_expected_value, f1());\
- return 0;\
-}
-
-#define TEST_UNARY_REG_SAME_REG(_name, _op, _arg1, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- plfv f1; \
- jit_prolog(p, &f1); \
- jit_movi(p, R(0), _arg1); \
- _op(p, R(0), R(0)); \
- jit_retr(p, R(0)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ(_expected_value, f1());\
- return 0;\
-}
-
-
-TEST_IMM_SAME_REG(test10, jit_addi, 42, 28, 70)
-TEST_IMM_OTHER_REG(test11, jit_addi, 42, 28, 70)
-TEST_REG_SAME_REG(test12, jit_addr, 42, 28, 70)
-TEST_REG_OTHER_REG(test13, jit_addr, 42, 28, 70)
-
-TEST_IMM_SAME_REG(test20, jit_subi, 42, 28, 14)
-TEST_IMM_OTHER_REG(test21, jit_subi, 42, 28, 14)
-TEST_REG_SAME_REG(test22, jit_subr, 42, 28, 14)
-TEST_REG_OTHER_REG(test23, jit_subr, 42, 28, 14)
-
-TEST_IMM_SAME_REG(test30, jit_rsbi, 42, 28, -14)
-TEST_IMM_OTHER_REG(test31, jit_rsbi, 42, 28, -14)
-TEST_REG_SAME_REG(test32, jit_rsbr, 42, 28, -14)
-TEST_REG_OTHER_REG(test33, jit_rsbr, 42, 28, -14)
-
-TEST_IMM_SAME_REG(test40, jit_muli, 42, 28, 1176)
-TEST_IMM_OTHER_REG(test41, jit_muli, 42, 28, 1176)
-TEST_REG_SAME_REG(test42, jit_mulr, 42, 28, 1176)
-TEST_REG_OTHER_REG(test43, jit_mulr, 42, 28, 1176)
-
-TEST_IMM_SAME_REG(test44, jit_muli, 42, 4, 168)
-TEST_IMM_OTHER_REG(test45, jit_muli, 42, 4, 168)
-TEST_REG_SAME_REG(test46, jit_mulr, 42, 4, 168)
-TEST_REG_OTHER_REG(test47, jit_mulr, 42, 4, 168)
-
-TEST_IMM_SAME_REG(test48, jit_muli, 42, 5, 210)
-TEST_IMM_OTHER_REG(test49, jit_muli, 42, 5, 210)
-TEST_REG_SAME_REG(test50, jit_mulr, 42, 5, 210)
-TEST_REG_OTHER_REG(test51, jit_mulr, 42, 5, 210)
-
-TEST_IMM_SAME_REG(test52, jit_muli, 42, 2,84)
-TEST_IMM_OTHER_REG(test53, jit_muli, 42, 2, 84)
-TEST_REG_SAME_REG(test54, jit_mulr, 42, 2, 84)
-TEST_REG_OTHER_REG(test55, jit_mulr, 42, 2, 84)
-
-TEST_IMM_SAME_REG(test56, jit_muli, 42, 9, 378)
-TEST_IMM_OTHER_REG(test57, jit_muli, 42, 9, 378)
-TEST_REG_SAME_REG(test58, jit_mulr, 42, 9, 378)
-TEST_REG_OTHER_REG(test59, jit_mulr, 42, 9, 378)
-
-TEST_IMM_SAME_REG(test60, jit_divi, 42, 4, 10)
-TEST_IMM_OTHER_REG(test61, jit_divi, 42, 4, 10)
-TEST_REG_SAME_REG(test62, jit_divr, 42, 4, 10)
-TEST_REG_OTHER_REG(test63, jit_divr, 42, 4, 10)
-
-TEST_IMM_SAME_REG(test64, jit_divi, 42, 9, 4)
-TEST_IMM_OTHER_REG(test65, jit_divi, 42, 9, 4)
-TEST_REG_SAME_REG(test66, jit_divr, 42, 9, 4)
-TEST_REG_OTHER_REG(test67, jit_divr, 42, 9, 4)
-
-TEST_IMM_SAME_REG(test70, jit_modi, 42, 4, 2)
-TEST_IMM_OTHER_REG(test71, jit_modi, 42, 4, 2)
-TEST_REG_SAME_REG(test72, jit_modr, 42, 4, 2)
-TEST_REG_OTHER_REG(test73, jit_modr, 42, 4, 2)
-
-TEST_IMM_SAME_REG(test74, jit_modi, 42, 9, 6)
-TEST_IMM_OTHER_REG(test75, jit_modi, 42, 9, 6)
-TEST_REG_SAME_REG(test76, jit_modr, 42, 9, 6)
-TEST_REG_OTHER_REG(test77, jit_modr, 42, 9, 6)
-
-
-TEST_IMM_SAME_REG(test80, jit_addxi, 42, 28, 70)
-TEST_IMM_OTHER_REG(test81, jit_addxi, 42, 28, 70)
-TEST_REG_SAME_REG(test82, jit_addxr, 42, 28, 70)
-TEST_REG_OTHER_REG(test83, jit_addxr, 42, 28, 70)
-
-TEST_IMM_SAME_REG(test84, jit_addci, 42, 28, 70)
-TEST_IMM_OTHER_REG(test85, jit_addci, 42, 28, 70)
-TEST_REG_SAME_REG(test86, jit_addcr, 42, 28, 70)
-TEST_REG_OTHER_REG(test87, jit_addcr, 42, 28, 70)
-
-TEST_IMM_SAME_REG(test90, jit_subxi, 42, 28, 14)
-TEST_IMM_OTHER_REG(test91, jit_subxi, 42, 28, 14)
-TEST_REG_SAME_REG(test92, jit_subxr, 42, 28, 14)
-TEST_REG_OTHER_REG(test93, jit_subxr, 42, 28, 14)
-
-TEST_IMM_SAME_REG(test94, jit_subci, 42, 28, 14)
-TEST_IMM_OTHER_REG(test95, jit_subci, 42, 28, 14)
-TEST_REG_SAME_REG(test96, jit_subcr, 42, 28, 14)
-TEST_REG_OTHER_REG(test97, jit_subcr, 42, 28, 14)
-
-TEST_IMM_SAME_REG(test100, jit_ori, 42, 28, (42 | 28))
-TEST_IMM_OTHER_REG(test101, jit_ori, 42, 28, (42 | 28))
-TEST_REG_SAME_REG(test102, jit_orr, 42, 28, (42 | 28))
-TEST_REG_OTHER_REG(test103, jit_orr, 42, 28, (42 | 28))
-
-TEST_IMM_SAME_REG(test110, jit_andi, 42, 28, 8)
-TEST_IMM_OTHER_REG(test111, jit_andi, 42, 28, 8)
-TEST_REG_SAME_REG(test112, jit_andr, 42, 28, 8)
-TEST_REG_OTHER_REG(test113, jit_andr, 42, 28, 8)
-
-TEST_IMM_SAME_REG(test120, jit_xori, 42, 28, (42 ^ 28))
-TEST_IMM_OTHER_REG(test121, jit_xori, 42, 28, (42 ^ 28))
-TEST_REG_SAME_REG(test122, jit_xorr, 42, 28, (42 ^ 28))
-TEST_REG_OTHER_REG(test123, jit_xorr, 42, 28, (42 ^ 28))
-
-TEST_IMM_SAME_REG(test130, jit_lshi, 42, 8, 42 << 8)
-TEST_IMM_OTHER_REG(test131, jit_lshi, 42, 8, 42 << 8)
-TEST_REG_SAME_REG(test132, jit_lshr, 42, 8, 42 << 8)
-TEST_REG_OTHER_REG(test133, jit_lshr, 42, 8, 42 << 8)
-
-TEST_IMM_SAME_REG(test140, jit_rshi, 42UL, 2, 42L >> 2)
-TEST_IMM_OTHER_REG(test141, jit_rshi, 42UL, 2, 42L >> 2)
-TEST_REG_SAME_REG(test142, jit_rshr, 42UL, 2, 42L >> 2)
-TEST_REG_OTHER_REG(test143, jit_rshr, 42UL, 2, 42L >> 2)
-
-TEST_IMM_SAME_REG(test144, jit_rshi, -42UL, 2, -42L >> 2)
-TEST_IMM_OTHER_REG(test145, jit_rshi, -42UL, 2, -42L >> 2)
-TEST_REG_SAME_REG(test146, jit_rshr, -42UL, 2, -42L >> 2)
-TEST_REG_OTHER_REG(test147, jit_rshr, -42UL, 2, -42L >> 2)
-
-TEST_IMM_SAME_REG(test150, jit_rshi_u, 42UL, 2, 42UL >> 2)
-TEST_IMM_OTHER_REG(test151, jit_rshi_u, 42UL, 2, 42UL >> 2)
-TEST_REG_SAME_REG(test152, jit_rshr_u, 42UL, 2, 42UL >> 2)
-TEST_REG_OTHER_REG(test153, jit_rshr_u, 42UL, 2, 42UL >> 2)
-
-TEST_IMM_SAME_REG(test154, jit_rshi_u, -42UL, 2, -42UL >> 2)
-TEST_IMM_OTHER_REG(test155, jit_rshi_u, -42UL, 2, -42UL >> 2)
-TEST_REG_SAME_REG(test156, jit_rshr_u, -42UL, 2, -42UL >> 2)
-TEST_REG_OTHER_REG(test157, jit_rshr_u, -42UL, 2, -42UL >> 2)
-
-
-TEST_UNARY_REG_SAME_REG(test160, jit_negr, 42, -42)
-TEST_UNARY_REG_OTHER_REG(test161, jit_negr, 42, -42)
-
-
-TEST_UNARY_REG_SAME_REG(test162, jit_notr, 42, ~42)
-TEST_UNARY_REG_OTHER_REG(test163, jit_notr, 42, ~42)
-
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test10);
- SETUP_TEST(test11);
- SETUP_TEST(test12);
- SETUP_TEST(test13);
- SETUP_TEST(test20);
- SETUP_TEST(test21);
- SETUP_TEST(test22);
- SETUP_TEST(test23);
- SETUP_TEST(test30);
- SETUP_TEST(test31);
- SETUP_TEST(test32);
- SETUP_TEST(test33);
- SETUP_TEST(test40);
- SETUP_TEST(test41);
- SETUP_TEST(test42);
- SETUP_TEST(test43);
- SETUP_TEST(test44);
-
- SETUP_TEST(test45);
- SETUP_TEST(test46);
- SETUP_TEST(test47);
- SETUP_TEST(test48);
- SETUP_TEST(test49);
- SETUP_TEST(test50);
- SETUP_TEST(test51);
- SETUP_TEST(test52);
- SETUP_TEST(test53);
- SETUP_TEST(test54);
- SETUP_TEST(test55);
- SETUP_TEST(test56);
- SETUP_TEST(test57);
- SETUP_TEST(test58);
- SETUP_TEST(test59);
-
- SETUP_TEST(test60);
- SETUP_TEST(test61);
- SETUP_TEST(test62);
- SETUP_TEST(test63);
- SETUP_TEST(test64);
- SETUP_TEST(test65);
- SETUP_TEST(test66);
- SETUP_TEST(test67);
-
- SETUP_TEST(test70);
- SETUP_TEST(test71);
- SETUP_TEST(test72);
- SETUP_TEST(test73);
- SETUP_TEST(test74);
- SETUP_TEST(test75);
- SETUP_TEST(test76);
- SETUP_TEST(test77);
-
- SETUP_TEST(test80);
- SETUP_TEST(test81);
- SETUP_TEST(test82);
- SETUP_TEST(test83);
- SETUP_TEST(test84);
- SETUP_TEST(test85);
- SETUP_TEST(test86);
- SETUP_TEST(test87);
-
- SETUP_TEST(test90);
- SETUP_TEST(test91);
- SETUP_TEST(test92);
- SETUP_TEST(test93);
- SETUP_TEST(test94);
- SETUP_TEST(test95);
- SETUP_TEST(test96);
- SETUP_TEST(test97);
-
- SETUP_TEST(test100);
- SETUP_TEST(test101);
- SETUP_TEST(test102);
- SETUP_TEST(test103);
-
- SETUP_TEST(test110);
- SETUP_TEST(test111);
- SETUP_TEST(test112);
- SETUP_TEST(test113);
-
- SETUP_TEST(test120);
- SETUP_TEST(test121);
- SETUP_TEST(test122);
- SETUP_TEST(test123);
-
- SETUP_TEST(test130);
- SETUP_TEST(test131);
- SETUP_TEST(test132);
- SETUP_TEST(test133);
-
- SETUP_TEST(test140);
- SETUP_TEST(test141);
- SETUP_TEST(test142);
- SETUP_TEST(test143);
-
- SETUP_TEST(test144);
- SETUP_TEST(test145);
- SETUP_TEST(test146);
- SETUP_TEST(test147);
-
- SETUP_TEST(test150);
- SETUP_TEST(test151);
- SETUP_TEST(test152);
- SETUP_TEST(test153);
- SETUP_TEST(test154);
- SETUP_TEST(test155);
- SETUP_TEST(test156);
- SETUP_TEST(test157);
-
- SETUP_TEST(test160);
- SETUP_TEST(test161);
- SETUP_TEST(test162);
- SETUP_TEST(test163);
-}
diff --git a/ext/myjit/test/t003-conditions.c b/ext/myjit/test/t003-conditions.c
deleted file mode 100755
index d45a33a..0000000
--- a/ext/myjit/test/t003-conditions.c
+++ /dev/null
@@ -1,193 +0,0 @@
-#include <limits.h>
-#include "../myjit/jitlib.h"
-#include "tests.h"
-
-#define CREATE_TEST_SUITE_REG(testname, _data_type, _jit_op, _operator) \
- CREATE_TEST_CASE_REG(testname ## 0, _data_type, _jit_op, _operator, 0, 0, 0, 0) \
- CREATE_TEST_CASE_REG(testname ## 1, _data_type, _jit_op, _operator, 0, 0, 0, 1) \
- CREATE_TEST_CASE_REG(testname ## 2, _data_type, _jit_op, _operator, 0, 0, 1, 0) \
- CREATE_TEST_CASE_REG(testname ## 3, _data_type, _jit_op, _operator, 0, 0, 1, 1) \
- CREATE_TEST_CASE_REG(testname ## 4, _data_type, _jit_op, _operator, 0, 1, 0, 0) \
- CREATE_TEST_CASE_REG(testname ## 5, _data_type, _jit_op, _operator, 0, 1, 0, 1) \
- CREATE_TEST_CASE_REG(testname ## 6, _data_type, _jit_op, _operator, 0, 1, 1, 0) \
- CREATE_TEST_CASE_REG(testname ## 7, _data_type, _jit_op, _operator, 0, 1, 1, 1) \
- CREATE_TEST_CASE_REG(testname ## 8, _data_type, _jit_op, _operator, 1, 0, 0, 0) \
- CREATE_TEST_CASE_REG(testname ## 9, _data_type, _jit_op, _operator, 1, 0, 0, 1) \
- CREATE_TEST_CASE_REG(testname ## 10, _data_type, _jit_op, _operator, 1, 0, 1, 0) \
- CREATE_TEST_CASE_REG(testname ## 11, _data_type, _jit_op, _operator, 1, 0, 1, 1) \
- CREATE_TEST_CASE_REG(testname ## 12, _data_type, _jit_op, _operator, 1, 1, 0, 0) \
- CREATE_TEST_CASE_REG(testname ## 13, _data_type, _jit_op, _operator, 1, 1, 0, 1) \
- CREATE_TEST_CASE_REG(testname ## 14, _data_type, _jit_op, _operator, 1, 1, 1, 0) \
- CREATE_TEST_CASE_REG(testname ## 15, _data_type, _jit_op, _operator, 1, 1, 1, 1) \
-
-#define CREATE_TEST_SUITE_IMM(testname, _data_type, _jit_op, _operator) \
- CREATE_TEST_CASE_IMM(testname ## 0, _data_type, _jit_op, _operator, 0, 0, 0, 0) \
- CREATE_TEST_CASE_IMM(testname ## 1, _data_type, _jit_op, _operator, 0, 0, 0, 1) \
- CREATE_TEST_CASE_IMM(testname ## 2, _data_type, _jit_op, _operator, 0, 0, 1, 0) \
- CREATE_TEST_CASE_IMM(testname ## 3, _data_type, _jit_op, _operator, 0, 0, 1, 1) \
- CREATE_TEST_CASE_IMM(testname ## 4, _data_type, _jit_op, _operator, 0, 1, 0, 0) \
- CREATE_TEST_CASE_IMM(testname ## 5, _data_type, _jit_op, _operator, 0, 1, 0, 1) \
- CREATE_TEST_CASE_IMM(testname ## 6, _data_type, _jit_op, _operator, 0, 1, 1, 0) \
- CREATE_TEST_CASE_IMM(testname ## 7, _data_type, _jit_op, _operator, 0, 1, 1, 1) \
- CREATE_TEST_CASE_IMM(testname ## 8, _data_type, _jit_op, _operator, 1, 0, 0, 0) \
- CREATE_TEST_CASE_IMM(testname ## 9, _data_type, _jit_op, _operator, 1, 0, 0, 1) \
- CREATE_TEST_CASE_IMM(testname ## 10, _data_type, _jit_op, _operator, 1, 0, 1, 0) \
- CREATE_TEST_CASE_IMM(testname ## 11, _data_type, _jit_op, _operator, 1, 0, 1, 1) \
- CREATE_TEST_CASE_IMM(testname ## 12, _data_type, _jit_op, _operator, 1, 1, 0, 0) \
- CREATE_TEST_CASE_IMM(testname ## 13, _data_type, _jit_op, _operator, 1, 1, 0, 1) \
- CREATE_TEST_CASE_IMM(testname ## 14, _data_type, _jit_op, _operator, 1, 1, 1, 0) \
- CREATE_TEST_CASE_IMM(testname ## 15, _data_type, _jit_op, _operator, 1, 1, 1, 1) \
-
-
-#define SETUP_TESTS(testname) \
- SETUP_TEST(testname ## 0); \
- SETUP_TEST(testname ## 1); \
- SETUP_TEST(testname ## 2); \
- SETUP_TEST(testname ## 3); \
- SETUP_TEST(testname ## 4); \
- SETUP_TEST(testname ## 5); \
- SETUP_TEST(testname ## 6); \
- SETUP_TEST(testname ## 7); \
- SETUP_TEST(testname ## 8); \
- SETUP_TEST(testname ## 9); \
- SETUP_TEST(testname ## 10); \
- SETUP_TEST(testname ## 11); \
- SETUP_TEST(testname ## 12); \
- SETUP_TEST(testname ## 13); \
- SETUP_TEST(testname ## 14); \
- SETUP_TEST(testname ## 15);
-
-
-#define CREATE_TEST_CASE_REG(testname, _data_type, _jit_op, _operator, _samereg, _equal, _negative, _greater) \
-DEFINE_TEST(testname)\
-{\
- plfv f1;\
- jit_prolog(p, &f1);\
-\
- _data_type firstval = 42;\
- _data_type secval = 28;\
- if (_equal) secval = firstval;\
- if (_greater) secval = 60;\
- if (_negative) secval *= -1;\
-\
- jit_movi(p, R(1), firstval);\
- jit_movi(p, R(2), secval);\
-\
- if (_samereg) {\
- _jit_op(p, R(2), R(1), R(2));\
- jit_retr(p, R(2));\
- } else {\
- _jit_op(p, R(3), R(1), R(2));\
- jit_retr(p, R(3));\
- }\
- JIT_GENERATE_CODE(p);\
-\
- if (firstval _operator secval) ASSERT_EQ(1, f1()); \
- if (!(firstval _operator secval)) ASSERT_EQ(0, f1()); \
- return 0; \
-}
-
-#define CREATE_TEST_CASE_IMM(testname, _data_type, _jit_op, _operator, _samereg, _equal, _negative, _greater) \
-DEFINE_TEST(testname)\
-{\
- plfv f1;\
- jit_prolog(p, &f1);\
-\
- _data_type firstval = 42;\
- _data_type secval = 28;\
- if (_equal) secval = firstval;\
- if (_greater) secval = 60;\
- if (_negative) secval *= -1;\
-\
- jit_movi(p, R(1), firstval);\
-\
- if (_samereg) {\
- _jit_op(p, R(2), R(1), secval);\
- jit_retr(p, R(2));\
- } else {\
- _jit_op(p, R(3), R(1), secval);\
- jit_retr(p, R(3));\
- }\
-\
- JIT_GENERATE_CODE(p);\
-\
- if (firstval _operator secval) ASSERT_EQ(1, f1()); \
- if (!(firstval _operator secval)) ASSERT_EQ(0, f1()); \
- return 0; \
-}
-
-CREATE_TEST_SUITE_REG(test01reg, jit_value, jit_ltr, <)
-CREATE_TEST_SUITE_REG(test02reg, jit_value, jit_ler, <=)
-CREATE_TEST_SUITE_REG(test03reg, jit_value, jit_ger, >=)
-CREATE_TEST_SUITE_REG(test04reg, jit_value, jit_gtr, >)
-CREATE_TEST_SUITE_REG(test05reg, jit_value, jit_eqr, ==)
-CREATE_TEST_SUITE_REG(test06reg, jit_value, jit_ner, !=)
-
-CREATE_TEST_SUITE_REG(test11reg, jit_unsigned_value, jit_ltr_u, <)
-CREATE_TEST_SUITE_REG(test12reg, jit_unsigned_value, jit_ler_u, <=)
-CREATE_TEST_SUITE_REG(test13reg, jit_unsigned_value, jit_ger_u, >=)
-CREATE_TEST_SUITE_REG(test14reg, jit_unsigned_value, jit_gtr_u, >)
-CREATE_TEST_SUITE_REG(test15reg, jit_unsigned_value, jit_eqr, ==)
-CREATE_TEST_SUITE_REG(test16reg, jit_unsigned_value, jit_ner, !=)
-
-CREATE_TEST_SUITE_IMM(test21imm, jit_value, jit_lti, <)
-CREATE_TEST_SUITE_IMM(test22imm, jit_value, jit_lei, <=)
-CREATE_TEST_SUITE_IMM(test23imm, jit_value, jit_gei, >=)
-CREATE_TEST_SUITE_IMM(test24imm, jit_value, jit_gti, >)
-CREATE_TEST_SUITE_IMM(test25imm, jit_value, jit_eqi, ==)
-CREATE_TEST_SUITE_IMM(test26imm, jit_value, jit_nei, !=)
-
-CREATE_TEST_SUITE_IMM(test31imm, jit_unsigned_value, jit_lti_u, <)
-CREATE_TEST_SUITE_IMM(test32imm, jit_unsigned_value, jit_lei_u, <=)
-CREATE_TEST_SUITE_IMM(test33imm, jit_unsigned_value, jit_gei_u, >=)
-CREATE_TEST_SUITE_IMM(test34imm, jit_unsigned_value, jit_gti_u, >)
-CREATE_TEST_SUITE_IMM(test35imm, jit_unsigned_value, jit_eqi, ==)
-CREATE_TEST_SUITE_IMM(test36imm, jit_unsigned_value, jit_nei, !=)
-
-void test_setup()
-{
- test_filename = __FILE__;
-
- SETUP_TESTS(test01reg);
- SETUP_TESTS(test02reg);
- SETUP_TESTS(test03reg);
- SETUP_TESTS(test04reg);
- SETUP_TESTS(test05reg);
- SETUP_TESTS(test06reg);
-
- SETUP_TESTS(test11reg);
- SETUP_TESTS(test12reg);
- SETUP_TESTS(test13reg);
- SETUP_TESTS(test14reg);
- SETUP_TESTS(test15reg);
- SETUP_TESTS(test16reg);
-
- SETUP_TESTS(test01reg);
- SETUP_TESTS(test02reg);
- SETUP_TESTS(test03reg);
- SETUP_TESTS(test04reg);
- SETUP_TESTS(test05reg);
- SETUP_TESTS(test06reg);
-
- SETUP_TESTS(test11reg);
- SETUP_TESTS(test12reg);
- SETUP_TESTS(test13reg);
- SETUP_TESTS(test14reg);
- SETUP_TESTS(test15reg);
- SETUP_TESTS(test16reg);
-
- SETUP_TESTS(test21imm);
- SETUP_TESTS(test22imm);
- SETUP_TESTS(test23imm);
- SETUP_TESTS(test24imm);
- SETUP_TESTS(test25imm);
- SETUP_TESTS(test26imm);
-
- SETUP_TESTS(test31imm);
- SETUP_TESTS(test32imm);
- SETUP_TESTS(test33imm);
- SETUP_TESTS(test34imm);
- SETUP_TESTS(test35imm);
- SETUP_TESTS(test36imm);
-
-}
diff --git a/ext/myjit/test/t004-branches.c b/ext/myjit/test/t004-branches.c
deleted file mode 100755
index 14f81e8..0000000
--- a/ext/myjit/test/t004-branches.c
+++ /dev/null
@@ -1,327 +0,0 @@
-#include <limits.h>
-#include "tests.h"
-#pragma GCC diagnostic ignored "-Woverflow"
-#pragma clang diagnostic ignored "-Winteger-overflow"
-
-#define CREATE_TEST_SUITE_REG(testname, _data_type, _jit_op, _operator) \
- CREATE_TEST_CASE_REG(testname ## 0, _data_type, _jit_op, _operator, 0, 0, 0) \
- CREATE_TEST_CASE_REG(testname ## 1, _data_type, _jit_op, _operator, 0, 0, 1) \
- CREATE_TEST_CASE_REG(testname ## 2, _data_type, _jit_op, _operator, 0, 1, 0) \
- CREATE_TEST_CASE_REG(testname ## 3, _data_type, _jit_op, _operator, 0, 1, 1) \
- CREATE_TEST_CASE_REG(testname ## 4, _data_type, _jit_op, _operator, 1, 0, 0) \
- CREATE_TEST_CASE_REG(testname ## 5, _data_type, _jit_op, _operator, 1, 0, 1) \
- CREATE_TEST_CASE_REG(testname ## 6, _data_type, _jit_op, _operator, 1, 1, 0) \
- CREATE_TEST_CASE_REG(testname ## 7, _data_type, _jit_op, _operator, 1, 1, 1) \
-
-#define CREATE_TEST_SUITE_IMM(testname, _data_type, _jit_op, _operator) \
- CREATE_TEST_CASE_IMM(testname ## 0, _data_type, _jit_op, _operator, 0, 0, 0) \
- CREATE_TEST_CASE_IMM(testname ## 1, _data_type, _jit_op, _operator, 0, 0, 1) \
- CREATE_TEST_CASE_IMM(testname ## 2, _data_type, _jit_op, _operator, 0, 1, 0) \
- CREATE_TEST_CASE_IMM(testname ## 3, _data_type, _jit_op, _operator, 0, 1, 1) \
- CREATE_TEST_CASE_IMM(testname ## 4, _data_type, _jit_op, _operator, 1, 0, 0) \
- CREATE_TEST_CASE_IMM(testname ## 5, _data_type, _jit_op, _operator, 1, 0, 1) \
- CREATE_TEST_CASE_IMM(testname ## 6, _data_type, _jit_op, _operator, 1, 1, 0) \
- CREATE_TEST_CASE_IMM(testname ## 7, _data_type, _jit_op, _operator, 1, 1, 1) \
-
-#define SETUP_TESTS(testname) \
- SETUP_TEST(testname ## 0); \
- SETUP_TEST(testname ## 1); \
- SETUP_TEST(testname ## 2); \
- SETUP_TEST(testname ## 3); \
- SETUP_TEST(testname ## 4); \
- SETUP_TEST(testname ## 5); \
- SETUP_TEST(testname ## 6); \
- SETUP_TEST(testname ## 7);
-
-#define CREATE_TEST_CASE_REG(testname, _data_type, _jit_op, _operator, _equal, _negative, _greater) \
-DEFINE_TEST(testname)\
-{\
- plfv f1;\
- jit_prolog(p, &f1);\
-\
- _data_type firstval = 42;\
- _data_type secval = 28;\
- if (_equal) secval = firstval;\
- if (_greater) secval = 60;\
- if (_negative) secval *= -1;\
-\
- jit_movi(p, R(1), firstval);\
- jit_movi(p, R(2), secval);\
-\
- jit_op * br; \
- br = _jit_op(p, 0, R(1), R(2));\
- jit_movi(p, R(3), -10); \
- jit_op * e = jit_jmpi(p, 0); \
- \
- jit_patch(p, br); \
- jit_movi(p, R(3), 10); \
- jit_patch(p, e); \
- jit_retr(p, R(3)); \
-\
- JIT_GENERATE_CODE(p);\
-\
- if (firstval _operator secval) ASSERT_EQ(10, f1()); \
- if (!(firstval _operator secval)) ASSERT_EQ(-10, f1()); \
- return 0; \
-}
-
-
-#define CREATE_TEST_CASE_IMM(testname, _data_type, _jit_op, _operator, _equal, _negative, _greater) \
-DEFINE_TEST(testname)\
-{\
- plfv f1;\
- jit_prolog(p, &f1);\
-\
- _data_type firstval = 42;\
- _data_type secval = 28;\
- if (_equal) secval = firstval;\
- if (_greater) secval = 60;\
- if (_negative) secval *= -1;\
- \
- jit_movi(p, R(1), firstval);\
-\
- jit_op * br; \
- br = _jit_op(p, 0, R(1), secval);\
- jit_movi(p, R(3), -10); \
- jit_op * e = jit_jmpi(p, 0); \
- \
- jit_patch(p, br); \
- jit_movi(p, R(3), 10); \
- jit_patch(p, e); \
- jit_retr(p, R(3)); \
-\
- JIT_GENERATE_CODE(p);\
-\
- if (firstval _operator secval) ASSERT_EQ(10, f1()); \
- if (!(firstval _operator secval)) ASSERT_EQ(-10, f1()); \
- return 0; \
-}
-
-#define CREATE_TEST_MASK_REG(testname, _jit_op, value, mask, expected_result) \
-DEFINE_TEST(testname) \
-{ \
- plfv f1;\
- jit_prolog(p, &f1);\
-\
- jit_movi(p, R(1), value);\
- jit_movi(p, R(2), mask);\
-\
- jit_op * br; \
- br = _jit_op(p, 0, R(1), R(2));\
- jit_movi(p, R(3), -10); \
- jit_op * e = jit_jmpi(p, 0); \
- \
- jit_patch(p, br); \
- jit_movi(p, R(3), 10); \
- jit_patch(p, e); \
- jit_retr(p, R(3)); \
-\
- JIT_GENERATE_CODE(p);\
-\
- if (expected_result) ASSERT_EQ(10, f1()); \
- if (!expected_result) ASSERT_EQ(-10, f1()); \
- return 0; \
-}
-
-#define CREATE_TEST_MASK_IMM(testname, _jit_op, value, mask, expected_result) \
-DEFINE_TEST(testname) \
-{ \
- plfv f1;\
- jit_prolog(p, &f1);\
-\
- jit_movi(p, R(1), value);\
-\
- jit_op * br; \
- br = _jit_op(p, 0, R(1), mask);\
- jit_movi(p, R(3), -10); \
- jit_op * e = jit_jmpi(p, 0); \
- \
- jit_patch(p, br); \
- jit_movi(p, R(3), 10); \
- jit_patch(p, e); \
- jit_retr(p, R(3)); \
-\
- JIT_GENERATE_CODE(p);\
-\
- if (expected_result) ASSERT_EQ(10, f1()); \
- if (!expected_result) ASSERT_EQ(-10, f1()); \
- return 0; \
-}
-
-
-
-#define CREATE_TEST_OVERFLOW_REG(testname, _jit_op, _c_op, value1, value2, expected_overflow) \
-DEFINE_TEST(testname) \
-{ \
- plfv f1;\
- char overflow_flag = -1;\
- jit_prolog(p, &f1);\
-\
- jit_movi(p, R(1), value1);\
- jit_movi(p, R(2), value2);\
-\
- jit_op * br; \
- br = _jit_op(p, 0, R(1), R(2));\
- jit_movi(p, R(3), 0); \
- jit_op * e = jit_jmpi(p, 0); \
- \
- jit_patch(p, br); \
- jit_movi(p, R(3), 1); \
- jit_patch(p, e); \
- jit_sti(p, &overflow_flag, R(3), 1); \
- jit_retr(p, R(1)); \
-\
- JIT_GENERATE_CODE(p);\
-\
- ASSERT_EQ(((value1) _c_op (value2)), f1()); \
- if (expected_overflow) ASSERT_EQ(1, overflow_flag); \
- if (!expected_overflow) ASSERT_EQ(0, overflow_flag); \
- return 0; \
-}
-
-#define CREATE_TEST_OVERFLOW_IMM(testname, _jit_op, _c_op, value1, value2, expected_overflow) \
-DEFINE_TEST(testname) \
-{ \
- plfv f1;\
- char overflow_flag = -1;\
- jit_prolog(p, &f1);\
-\
- jit_movi(p, R(1), value1);\
-\
- jit_op * br; \
- br = _jit_op(p, 0, R(1), value2);\
- jit_movi(p, R(3), 0); \
- jit_op * e = jit_jmpi(p, 0); \
- \
- jit_patch(p, br); \
- jit_movi(p, R(3), 1); \
- jit_patch(p, e); \
- jit_sti(p, &overflow_flag, R(3), 1); \
- jit_retr(p, R(1)); \
-\
- JIT_GENERATE_CODE(p);\
-\
- ASSERT_EQ(((value1) _c_op (value2)), f1()); \
- if (expected_overflow) ASSERT_EQ(1, overflow_flag); \
- if (!expected_overflow) ASSERT_EQ(0, overflow_flag); \
- return 0; \
-}
-
-
-CREATE_TEST_SUITE_REG(test01reg, jit_value, jit_bltr, <)
-CREATE_TEST_SUITE_REG(test02reg, jit_value, jit_bler, <=)
-CREATE_TEST_SUITE_REG(test03reg, jit_value, jit_bger, >=)
-CREATE_TEST_SUITE_REG(test04reg, jit_value, jit_bgtr, >)
-CREATE_TEST_SUITE_REG(test05reg, jit_value, jit_beqr, ==)
-CREATE_TEST_SUITE_REG(test06reg, jit_value, jit_bner, !=)
-
-CREATE_TEST_SUITE_REG(test11reg, jit_unsigned_value, jit_bltr_u, <)
-CREATE_TEST_SUITE_REG(test12reg, jit_unsigned_value, jit_bler_u, <=)
-CREATE_TEST_SUITE_REG(test13reg, jit_unsigned_value, jit_bger_u, >=)
-CREATE_TEST_SUITE_REG(test14reg, jit_unsigned_value, jit_bgtr_u, >)
-CREATE_TEST_SUITE_REG(test15reg, jit_unsigned_value, jit_beqr, ==)
-CREATE_TEST_SUITE_REG(test16reg, jit_unsigned_value, jit_bner, !=)
-
-CREATE_TEST_SUITE_IMM(test21imm, jit_value, jit_blti, <)
-CREATE_TEST_SUITE_IMM(test22imm, jit_value, jit_blei, <=)
-CREATE_TEST_SUITE_IMM(test23imm, jit_value, jit_bgei, >=)
-CREATE_TEST_SUITE_IMM(test24imm, jit_value, jit_bgti, >)
-CREATE_TEST_SUITE_IMM(test25imm, jit_value, jit_beqi, ==)
-CREATE_TEST_SUITE_IMM(test26imm, jit_value, jit_bnei, !=)
-
-CREATE_TEST_SUITE_IMM(test31imm, jit_unsigned_value, jit_blti_u, <)
-CREATE_TEST_SUITE_IMM(test32imm, jit_unsigned_value, jit_blei_u, <=)
-CREATE_TEST_SUITE_IMM(test33imm, jit_unsigned_value, jit_bgei_u, >=)
-CREATE_TEST_SUITE_IMM(test34imm, jit_unsigned_value, jit_bgti_u, >)
-CREATE_TEST_SUITE_IMM(test35imm, jit_unsigned_value, jit_beqi, ==)
-CREATE_TEST_SUITE_IMM(test36imm, jit_unsigned_value, jit_bnei, !=)
-
-CREATE_TEST_MASK_REG(testmask40reg, jit_bmsr, 0x7f, 0x04, 1)
-CREATE_TEST_MASK_REG(testmask41reg, jit_bmsr, 0x7f, 0x80, 0)
-CREATE_TEST_MASK_REG(testmask42reg, jit_bmcr, 0x7f, 0x04, 0)
-CREATE_TEST_MASK_REG(testmask43reg, jit_bmcr, 0x7f, 0x80, 1)
-
-CREATE_TEST_MASK_IMM(testmask44imm, jit_bmsi, 0x7f, 0x04, 1)
-CREATE_TEST_MASK_IMM(testmask45imm, jit_bmsi, 0x7f, 0x80, 0)
-CREATE_TEST_MASK_IMM(testmask46imm, jit_bmci, 0x7f, 0x04, 0)
-CREATE_TEST_MASK_IMM(testmask47imm, jit_bmci, 0x7f, 0x80, 1)
-
-CREATE_TEST_OVERFLOW_REG(testaddoverflow50reg, jit_boaddr, +, 10, 20, 0)
-CREATE_TEST_OVERFLOW_REG(testaddoverflow51reg, jit_boaddr, +, LONG_MAX, 20, 1)
-CREATE_TEST_OVERFLOW_REG(testsuboverflow52reg, jit_bosubr, -, 10, 20, 0)
-CREATE_TEST_OVERFLOW_REG(testsuboverflow53reg, jit_bosubr, -, -20, LONG_MAX, 1)
-CREATE_TEST_OVERFLOW_REG(testaddoverflow54reg, jit_bnoaddr, +, 10, 20, 1)
-CREATE_TEST_OVERFLOW_REG(testaddoverflow55reg, jit_bnoaddr, +, LONG_MAX, 20, 0)
-CREATE_TEST_OVERFLOW_REG(testsuboverflow56reg, jit_bnosubr, -, 10, 20, 1)
-CREATE_TEST_OVERFLOW_REG(testsuboverflow57reg, jit_bnosubr, -, -20, LONG_MAX, 0)
-
-CREATE_TEST_OVERFLOW_IMM(testaddoverflow50imm, jit_boaddi, +, 10, 20, 0)
-CREATE_TEST_OVERFLOW_IMM(testaddoverflow51imm, jit_boaddi, +, LONG_MAX, 20, 1)
-CREATE_TEST_OVERFLOW_IMM(testsuboverflow52imm, jit_bosubi, -, 10, 20, 0)
-CREATE_TEST_OVERFLOW_IMM(testsuboverflow53imm, jit_bosubi, -, -20, LONG_MAX, 1)
-CREATE_TEST_OVERFLOW_IMM(testaddoverflow54imm, jit_bnoaddi, +, 10, 20, 1)
-CREATE_TEST_OVERFLOW_IMM(testaddoverflow55imm, jit_bnoaddi, +, LONG_MAX, 20, 0)
-CREATE_TEST_OVERFLOW_IMM(testsuboverflow56imm, jit_bnosubi, -, 10, 20, 1)
-CREATE_TEST_OVERFLOW_IMM(testsuboverflow57imm, jit_bnosubi, -, -20, LONG_MAX, 0)
-
-
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TESTS(test01reg);
- SETUP_TESTS(test02reg);
- SETUP_TESTS(test03reg);
- SETUP_TESTS(test04reg);
- SETUP_TESTS(test05reg);
- SETUP_TESTS(test06reg);
-
- SETUP_TESTS(test11reg);
- SETUP_TESTS(test12reg);
- SETUP_TESTS(test13reg);
- SETUP_TESTS(test14reg);
- SETUP_TESTS(test15reg);
- SETUP_TESTS(test16reg);
-
- SETUP_TESTS(test21imm);
- SETUP_TESTS(test22imm);
- SETUP_TESTS(test23imm);
- SETUP_TESTS(test24imm);
- SETUP_TESTS(test25imm);
- SETUP_TESTS(test26imm);
-
- SETUP_TESTS(test31imm);
- SETUP_TESTS(test32imm);
- SETUP_TESTS(test33imm);
- SETUP_TESTS(test34imm);
- SETUP_TESTS(test35imm);
- SETUP_TESTS(test36imm);
-
- SETUP_TEST(testmask40reg);
- SETUP_TEST(testmask41reg);
- SETUP_TEST(testmask42reg);
- SETUP_TEST(testmask43reg);
-
- SETUP_TEST(testmask44imm);
- SETUP_TEST(testmask45imm);
- SETUP_TEST(testmask46imm);
- SETUP_TEST(testmask47imm);
-
- SETUP_TEST(testaddoverflow50reg);
- SETUP_TEST(testaddoverflow51reg);
- SETUP_TEST(testsuboverflow52reg);
- SETUP_TEST(testsuboverflow53reg);
- SETUP_TEST(testaddoverflow54reg);
- SETUP_TEST(testaddoverflow55reg);
- SETUP_TEST(testsuboverflow56reg);
- SETUP_TEST(testsuboverflow57reg);
-
- SETUP_TEST(testaddoverflow50imm);
- SETUP_TEST(testaddoverflow51imm);
- SETUP_TEST(testsuboverflow52imm);
- SETUP_TEST(testsuboverflow53imm);
- SETUP_TEST(testaddoverflow54imm);
- SETUP_TEST(testaddoverflow55imm);
- SETUP_TEST(testsuboverflow56imm);
- SETUP_TEST(testsuboverflow57imm);
-}
diff --git a/ext/myjit/test/t005-functions.c b/ext/myjit/test/t005-functions.c
deleted file mode 100755
index 4a710f5..0000000
--- a/ext/myjit/test/t005-functions.c
+++ /dev/null
@@ -1,353 +0,0 @@
-#include <stddef.h>
-#include "tests.h"
-#include "simple-buffer.c"
-
-typedef jit_value (*plfsss)(short, short, short);
-typedef jit_value (*plfiui)(int, unsigned int);
-typedef jit_value (*plfuc)(unsigned char);
-typedef jit_value (*plfus)(unsigned short);
-typedef jit_value (*plfpcus)(char *, unsigned short);
-
-// function which computes an average of three numbers each occupying 2 bytes
-DEFINE_TEST(test1)
-{
- plfsss f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_getarg(p, R(0), 0);
- jit_getarg(p, R(1), 1);
- jit_addr(p, R(0), R(0), R(1));
- jit_getarg(p, R(1), 2);
- jit_addr(p, R(0), R(0), R(1));
- jit_divi(p, R(0), R(0), 3);
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(10, f1(20, 20, -10));
- return 0;
-}
-
-// function which computes n^m
-DEFINE_TEST(test2)
-{
- plfiui f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(int));
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(int));
- jit_getarg(p, R(0), 0);
- jit_getarg(p, R(1), 1);
-
- jit_movi(p, R(2), 1);
-
- jit_label * loop = jit_get_label(p);
- jit_op * end = jit_beqi(p, JIT_FORWARD, R(1), 0);
- jit_mulr(p, R(2), R(2), R(0));
- jit_subi(p, R(1), R(1), 1);
- jit_jmpi(p, loop);
-
- jit_patch(p, end);
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(81, f1(3, 4));
- ASSERT_EQ(-27, f1(-3, 3));
- return 0;
-}
-
-// function which computes factorial
-DEFINE_TEST(test3)
-{
- plfuc f1;
-
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(char));
- jit_getarg(p, R(0), 0);
-
- jit_movi(p, R(1), 1);
-
- jit_label * loop = jit_get_label(p);
-
- jit_op * end = jit_beqi(p, JIT_FORWARD, R(0), 0);
-
- jit_mulr(p, R(1), R(1), R(0));
- jit_subi(p, R(0), R(0), 1);
-
- jit_jmpi(p, loop);
- jit_patch(p, end);
- jit_retr(p, R(1));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(120, f1(5));
- return 0;
-}
-
-// function which computes fibonacci's number
-DEFINE_TEST(test4)
-{
- plfus f1;
-
- jit_label * fib = jit_get_label(p);
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(short));
-
- jit_getarg(p, R(0), 0);
-
- jit_op * br = jit_blti_u(p, JIT_FORWARD, R(0), 3);
-
- jit_subi(p, R(0), R(0), 1);
-
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_call(p, fib);
-
- jit_retval(p, R(1));
-
- jit_getarg(p, R(0), 0);
- jit_subi(p, R(0), R(0), 2);
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_call(p, fib);
-
- jit_retval(p, R(2));
-
- jit_addr(p, R(0), R(1), R(2));
-
- jit_retr(p, R(0));
-
- jit_patch(p, br);
- jit_reti(p, 1);
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(832040, f1(30));
- return 0;
-}
-
-// function which converts string to number
-DEFINE_TEST(test5)
-{
- plfpcus f1; // string, radix -> long
-
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(long));
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(short));
-
- // R(0): string
- // R(1): radix
- // R(2): position in string
- // R(3): current char
- // R(4): result
- jit_getarg(p, R(0), 0);
- jit_getarg(p, R(1), 1);
- jit_movi(p, R(2), 0);
- jit_movi(p, R(4), 0);
-
- jit_label * loop = jit_get_label(p);
-
- jit_ldxr_u(p, R(3), R(0), R(2), 1);
- jit_op * end = jit_beqi(p, JIT_FORWARD, R(3), 0);
- jit_op * lowercase = jit_bgti_u(p, JIT_FORWARD, R(3), 'Z');
- jit_op * uppercase = jit_bgti_u(p, JIT_FORWARD, R(3), '9');
- jit_subi(p, R(3), R(3), '0');
- jit_op * comput = jit_jmpi(p, JIT_FORWARD);
-
- // is upper case char
- jit_patch(p, uppercase);
- jit_subi(p, R(3), R(3), 'A' - 10);
- jit_op * comput0 = jit_jmpi(p, JIT_FORWARD);
-
- jit_patch(p, lowercase);
- jit_subi(p, R(3), R(3), 'a' - 10);
- jit_op * comput1 = jit_jmpi(p, JIT_FORWARD);
-
- // computations
- jit_patch(p, comput);
- jit_patch(p, comput0);
- jit_patch(p, comput1);
- jit_mulr(p, R(4), R(4), R(1));
- jit_addr(p, R(4), R(4), R(3));
- jit_addi(p, R(2), R(2), 1);
- jit_jmpi(p, loop);
-
- jit_patch(p, end);
- jit_retr(p, R(4));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(31, f1("1f", 16));
- return 0;
-}
-
-// prints ``hello, world!''
-DEFINE_TEST(test6)
-{
- static char *str = "Hello, World! Lucky number for today is %i!!!\n";
- static char buf[120];
- plfv f1;
-
- jit_prolog(p, &f1);
- jit_movi(p, R(0), str);
-
- jit_movi(p, R(1), 100);
- //jit_movi(p, R(2), 200);
- //jit_movi(p, R(3), 300);
- jit_movi(p, R(4), 400);
- //jit_movi(p, R(5), 500);
-
- jit_movi(p, R(2), sprintf);
-
- jit_prepare(p);
- jit_putargi(p, buf);
- jit_putargr(p, R(0));
- jit_putargr(p, R(1));
- jit_callr(p, R(2));
-
- //jit_retval(p, R(3));
-
- jit_retr(p, R(4));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(400, f1());
- ASSERT_EQ_STR("Hello, World! Lucky number for today is 100!!!\n", buf);
- return 0;
-}
-
-// prints numbers 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
-DEFINE_TEST(test7)
-{
- static int ARR_SIZE = 10;
- static char * formatstr = "%i ";
-
- simple_buffer(BUFFER_CLEAR, NULL);
-
- plfv f1;
-
- jit_prolog(p, &f1);
- int arr = jit_allocai(p, ARR_SIZE * REG_SIZE); // allocates an array
-
- jit_movi(p, R(0), 1); // sets up the first element
- jit_stxi(p, arr, R_FP, R(0), REG_SIZE);
-
- jit_addi(p, R(0), R_FP, arr); // pointer to the array
- jit_addi(p, R(1), R(0), REG_SIZE); // position in the array (2nd element)
- jit_movi(p, R(2), ARR_SIZE - 1); // counter
-
- jit_label * loop = jit_get_label(p);
-
- jit_ldxi(p, R(3), R(1), -REG_SIZE, REG_SIZE);
- jit_lshi(p, R(3), R(3), 1);
- jit_str(p, R(1), R(3), REG_SIZE);
-
- jit_addi(p, R(1), R(1), REG_SIZE);
- jit_subi(p, R(2), R(2), 1);
- jit_bgti(p, loop, R(2), 0);
-
- jit_movi(p, R(2), ARR_SIZE - 1);
-
- jit_label * loop2 = jit_get_label(p);
-
- jit_ldr(p, R(1), R(0), REG_SIZE);
- jit_prepare(p);
- jit_putargi(p, BUFFER_PUT);
- jit_putargi(p, formatstr);
- jit_putargr(p, R(1));
- jit_call(p, simple_buffer);
-
- jit_addi(p, R(0), R(0), REG_SIZE);
- jit_subi(p, R(2), R(2), 1);
- jit_bgei(p, loop2, R(2), 0);
-
- jit_reti(p, 0);
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(0, f1());
- ASSERT_EQ_STR("1 2 4 8 16 32 64 128 256 512 ", simple_buffer(BUFFER_GET, NULL));
- return 0;
-}
-
-struct mystruct {
- short * items;
- long count;
- short sum;
- int avg;
-};
-
-// sums integers in a an array and computes their sum and average (uses structs)
-DEFINE_TEST(test8)
-{
- static char * formatstr = "avg: %i\nsum: %i\n";
- simple_buffer(BUFFER_CLEAR, NULL);
-
- static struct mystruct s = { NULL, 0, 0, 0};
- s.items = (short []){1, 2, 3, 4, 5};
- s.count = 5;
- s.sum = 111;
- s.avg = 123;
-
- plfv f1;
-
- jit_prolog(p, &f1);
-
- jit_ldi(p, R(0), (unsigned char *)&s + offsetof(struct mystruct, count), sizeof(long)); // count
-
- //jit_movi(p, R(1), &s); // struct
-
- jit_ldi(p, R(2), (unsigned char *)&s + offsetof(struct mystruct, items), sizeof(void *)); // array
- jit_movi(p, R(3), 0); // index
-
- jit_movi(p, R(5), 0); // sum
- jit_label * loop = jit_get_label(p);
-
-
- jit_ldxr(p, R(4), R(2), R(3), sizeof(short));
- jit_addr(p, R(5), R(5), R(4));
-
- jit_addi(p, R(3), R(3), sizeof(short));
- jit_subi(p, R(0), R(0), 1);
-
- jit_bgti(p, loop, R(0), 0);
- jit_sti(p, (unsigned char *)&s + offsetof(struct mystruct, sum), R(5), sizeof(short));
- jit_ldi(p, R(0), (unsigned char *)&s + offsetof(struct mystruct, count), sizeof(long)); // count
-
- jit_divr(p, R(5), R(5), R(0));
-
- jit_movi(p, R(0), &s);
- jit_movi(p, R(1), offsetof(struct mystruct, avg));
- jit_stxr(p, R(0), R(1), R(5), sizeof(int));
-
- jit_ldi(p, R(0), (unsigned char *)&s + offsetof(struct mystruct, avg), sizeof(int));
- jit_ldi(p, R(1), (unsigned char *)&s + offsetof(struct mystruct, sum), sizeof(short));
-
- jit_prepare(p);
- jit_putargi(p, BUFFER_PUT);
- jit_putargi(p, formatstr);
- jit_putargr(p, R(0));
- jit_putargr(p, R(1));
-
- jit_call(p, simple_buffer);
-
- jit_retr(p, R(1));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15, f1());
- ASSERT_EQ_STR("avg: 3\nsum: 15\n", simple_buffer(BUFFER_GET, NULL));
- ASSERT_EQ(15, s.sum);
- ASSERT_EQ(3, s.avg);
- return 0;
-
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
- SETUP_TEST(test3);
- SETUP_TEST(test4);
- SETUP_TEST(test5);
- SETUP_TEST(test6);
- SETUP_TEST(test7);
- SETUP_TEST(test8);
-}
diff --git a/ext/myjit/test/t006-misc.c b/ext/myjit/test/t006-misc.c
deleted file mode 100755
index 2f7a411..0000000
--- a/ext/myjit/test/t006-misc.c
+++ /dev/null
@@ -1,178 +0,0 @@
-#include "tests.h"
-
-#define LOOP_CNT (10000000)
-int value1 = 666;
-int value2 = 777;
-
-int cond_value = 10;
-
-// implements ternary operator (old-fashioned way); end tests efficiency
-DEFINE_TEST(test1)
-{
- plfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- jit_getarg(p, R(0), 0);
- jit_movi(p, R(1), LOOP_CNT);
-
- jit_label * loop = jit_get_label(p);
-
- jit_op * eq = jit_beqi(p, JIT_FORWARD, R(0), cond_value);
- jit_movi(p, R(2), value2);
- jit_op * end = jit_jmpi(p, JIT_FORWARD);
- jit_patch(p, eq);
- jit_movi(p, R(2), value1);
- jit_patch(p, end);
-
- jit_subi(p, R(1), R(1), 1);
- jit_bgti(p, loop, R(1), 0);
-
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(666, f1(10));
- ASSERT_EQ(777, f1(20));
- return 0;
-}
-
-// implements ternary operator (tricky); end tests efficiency
-DEFINE_TEST(test2)
-{
- plfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- jit_getarg(p, R(0), 0);
- jit_movi(p, R(1), LOOP_CNT);
-
- jit_label * loop = jit_get_label(p);
-
- jit_eqi(p, R(2), R(0), cond_value);
-
- jit_subi(p, R(2), R(2), 1);
- jit_andi(p, R(2), R(2), value2 - value1);
- jit_addi(p, R(2), R(2), value1);
-
-
- jit_subi(p, R(1), R(1), 1);
- jit_bgti(p, loop, R(1), 0);
-
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(666, f1(10));
- ASSERT_EQ(777, f1(20));
-
- return 0;
-}
-
-#ifdef JIT_ARCH_COMMON86
-DEFINE_TEST(test10)
-{
- plfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- jit_getarg(p, R(0), 0);
- jit_movi(p, R(1), 123);
-
- jit_force_spill(p, R(0));
- jit_force_spill(p, R(1));
-
- jit_force_assoc(p, R(1), 0, 0); // AX
- jit_force_assoc(p, R(0), 0, 2); // CX
-
- jit_lshr(p, R(0), R(1), R(0));
-
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(123 * 4, f1(2));
-
- return 0;
-}
-
-DEFINE_TEST(test11)
-{
- plfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- jit_getarg(p, R(0), 0);
- jit_movi(p, R(1), 123);
-
- jit_force_spill(p, R(0));
- jit_force_spill(p, R(1));
-
- jit_force_assoc(p, R(1), 0, 2); // CX
- jit_force_assoc(p, R(0), 0, 0); // AX
-
- jit_lshr(p, R(2), R(1), R(0));
-
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(123 * 4, f1(2));
-
- return 0;
-}
-
-DEFINE_TEST(test12)
-{
- plfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
-
- jit_getarg(p, R(0), 0);
- jit_movi(p, R(1), 123);
- jit_movi(p, R(2), 111);
-
- jit_force_spill(p, R(0));
- jit_force_spill(p, R(1));
-
- jit_force_assoc(p, R(0), 0, 0); // AX
- jit_force_assoc(p, R(1), 0, 2); // CX
- jit_force_assoc(p, R(2), 0, 4); // SI
-
- jit_gtr(p, R(2), R(0), R(1));
-
- jit_addr(p, R(2), R(2), R(0));
-
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(2, f1(2));
- ASSERT_EQ(201, f1(200));
-
- return 0;
-}
-
-#endif
-
-DEFINE_TEST(test20)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 0);
- for (int i = 0; i < 10000; i++)
- jit_addi(p, R(0), R(0), 1);
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(10000, f1());
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
-#ifdef JIT_ARCH_COMMON86
- SETUP_TEST(test10);
- SETUP_TEST(test11);
- SETUP_TEST(test12);
-#endif
- SETUP_TEST(test20);
-}
diff --git a/ext/myjit/test/t007-args.c b/ext/myjit/test/t007-args.c
deleted file mode 100755
index 6972f27..0000000
--- a/ext/myjit/test/t007-args.c
+++ /dev/null
@@ -1,69 +0,0 @@
-#include "tests.h"
-
-typedef long (* plf10s)(short, short, short, short, short, short, short, short, short, short);
-
-DEFINE_TEST(test1)
-{
- plf10s foo;
-
- jit_prolog(p, &foo);
-
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
-
- jit_getarg(p, R(0), 0);
- jit_getarg(p, R(1), 1);
- jit_getarg(p, R(2), 2);
- jit_getarg(p, R(3), 3);
- jit_getarg(p, R(4), 4);
- jit_getarg(p, R(5), 5);
- jit_getarg(p, R(6), 6);
- jit_getarg(p, R(7), 7);
- jit_getarg(p, R(8), 8);
- jit_getarg(p, R(9), 9);
-
-
- jit_movi(p, R(10), 0);
- jit_addr(p, R(10), R(10), R(9));
- jit_addr(p, R(11), R(10), R(8));
- jit_addr(p, R(12), R(11), R(7));
- jit_addr(p, R(13), R(12), R(6));
- jit_addr(p, R(14), R(13), R(5));
- jit_addr(p, R(15), R(14), R(4));
- jit_addr(p, R(16), R(15), R(3));
- jit_addr(p, R(17), R(16), R(2));
- jit_addr(p, R(18), R(17), R(1));
-
- jit_addr(p, R(8), R(8), R(9));
- jit_addr(p, R(7), R(7), R(8));
- jit_addr(p, R(6), R(6), R(7));
- jit_addr(p, R(5), R(5), R(6));
- jit_addr(p, R(4), R(4), R(5));
- jit_addr(p, R(3), R(3), R(4));
- jit_addr(p, R(2), R(2), R(3));
- jit_addr(p, R(1), R(1), R(2));
- jit_addr(p, R(0), R(0), R(1));
-
- jit_addr(p, R(0), R(0), R(18));
-
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(109, foo(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
-}
diff --git a/ext/myjit/test/t008-pushargs.c b/ext/myjit/test/t008-pushargs.c
deleted file mode 100755
index 33c8eca..0000000
--- a/ext/myjit/test/t008-pushargs.c
+++ /dev/null
@@ -1,137 +0,0 @@
-#include "tests.h"
-
-int correct_result;
-
-static int foobar(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10)
-{
- correct_result = 1;
- if (a1 != -1) correct_result = 0;
- if (a2 != 1) correct_result = 0;
- if (a3 != 2) correct_result = 0;
- if (a4 != 4) correct_result = 0;
- if (a5 != 8) correct_result = 0;
- if (a6 != 16) correct_result = 0;
- if (a7 != 32) correct_result = 0;
- if (a8 != 64) correct_result = 0;
- if (a9 != 128) correct_result = 0;
- if (a10 != 256) correct_result = 0;
- return 666;
-}
-
-DEFINE_TEST(test1)
-{
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_movi(p, R(0), -1);
- jit_movi(p, R(1), 1);
- jit_movi(p, R(2), 2);
- jit_movi(p, R(3), 4);
- jit_movi(p, R(4), 8);
- jit_movi(p, R(5), 16);
- jit_movi(p, R(6), 32);
- jit_movi(p, R(7), 64);
- jit_movi(p, R(8), 128);
- jit_movi(p, R(9), 256);
-
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_putargr(p, R(1));
- jit_putargr(p, R(2));
- jit_putargr(p, R(3));
- jit_putargr(p, R(4));
- jit_putargr(p, R(5));
- jit_putargr(p, R(6));
- jit_putargr(p, R(7));
- jit_putargr(p, R(8));
- jit_putargr(p, R(9));
- jit_call(p, foobar);
-
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(-1, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-}
-
-DEFINE_TEST(test2)
-{
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_movi(p, R(0), -1);
- jit_prepare(p);
- jit_putargi(p, -1);
- jit_putargi(p, 1);
- jit_putargi(p, 2);
- jit_putargi(p, 4);
- jit_putargi(p, 8);
- jit_putargi(p, 16);
- jit_putargi(p, 32);
- jit_putargi(p, 64);
- jit_putargi(p, 128);
- jit_putargi(p, 256);
- jit_call(p, foobar);
-
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(-1, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-}
-
-DEFINE_TEST(test3)
-{
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_movi(p, R(0), -1);
- jit_movi(p, R(1), 1);
- jit_movi(p, R(2), 2);
- jit_movi(p, R(3), 4);
- jit_movi(p, R(4), 8);
- jit_movi(p, R(5), 16);
- jit_movi(p, R(6), 32);
- jit_movi(p, R(7), 64);
- jit_movi(p, R(8), 128);
- jit_movi(p, R(9), 256);
-
- jit_force_spill(p, R(5));
- jit_force_spill(p, R(6));
- jit_force_spill(p, R(7));
- jit_force_spill(p, R(8));
- jit_force_spill(p, R(9));
-
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_putargr(p, R(1));
- jit_putargr(p, R(2));
- jit_putargr(p, R(3));
- jit_putargr(p, R(4));
- jit_putargr(p, R(5));
- jit_putargr(p, R(6));
- jit_putargr(p, R(7));
- jit_putargr(p, R(8));
- jit_putargr(p, R(9));
- jit_call(p, foobar);
-
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(-1, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
- SETUP_TEST(test3);
-}
diff --git a/ext/myjit/test/t009-allocaireg.c b/ext/myjit/test/t009-allocaireg.c
deleted file mode 100755
index 920194e..0000000
--- a/ext/myjit/test/t009-allocaireg.c
+++ /dev/null
@@ -1,98 +0,0 @@
-#define JIT_REGISTER_TEST
-#include "tests.h"
-#include "simple-buffer.c"
-
-#define BLOCK_SIZE (16)
-
-int correct_result;
-
-static int foobar(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10)
-{
- correct_result = 1;
- if (a1 != -1) correct_result = 0;
- if (a2 != 1) correct_result = 0;
- if (a3 != 2) correct_result = 0;
- if (a4 != 4) correct_result = 0;
- if (a5 != 8) correct_result = 0;
- if (a6 != 16) correct_result = 0;
- if (a7 != 32) correct_result = 0;
- if (a8 != 64) correct_result = 0;
- if (a9 != 128) correct_result = 0;
- if (a10 != 256) correct_result = 0;
- return 666;
-}
-
-DEFINE_TEST(test1)
-{
- static char *msg2 = "%u ";
-
- plfv foo;
-
- jit_prolog(p, &foo);
- int i = jit_allocai(p, BLOCK_SIZE);
-
- // loads into the allocated memory multiples of 3
- jit_movi(p, R(0), 0); // index
- jit_addi(p, R(1), R_FP, i); // pointer to the allocated memory
- jit_label * lab = jit_get_label(p);
- jit_muli(p, R(2), R(0), 3);
- jit_stxr(p, R(1), R(0), R(2), 1);
- jit_addi(p, R(0), R(0), 1);
- jit_blti(p, lab, R(0), BLOCK_SIZE);
-
- // does something with registers
- jit_movi(p, R(0), -1);
- jit_movi(p, R(1), 1);
- jit_movi(p, R(2), 2);
- jit_movi(p, R(3), 4);
- jit_movi(p, R(4), 8);
- jit_movi(p, R(5), 16);
- jit_movi(p, R(6), 32);
- jit_movi(p, R(7), 64);
- jit_movi(p, R(8), 128);
- jit_movi(p, R(9), 256);
-
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_putargr(p, R(1));
- jit_putargr(p, R(2));
- jit_putargr(p, R(3));
- jit_putargr(p, R(4));
- jit_putargr(p, R(5));
- jit_putargr(p, R(6));
- jit_putargr(p, R(7));
- jit_putargr(p, R(8));
- jit_putargr(p, R(9));
- jit_call(p, foobar);
-
- // prints out allocated memory
-
- jit_movi(p, R(0), 0); // index
- jit_addi(p, R(1), R_FP, i); // pointer to the allocated memory
- jit_label * lab2 = jit_get_label(p);
-
- jit_ldxr(p, R(2), R(1), R(0), 1);
-
- jit_prepare(p);
- jit_putargi(p, BUFFER_PUT);
- jit_putargi(p, msg2);
- jit_putargr(p, R(2));
- jit_call(p, simple_buffer);
-
- jit_addi(p, R(0), R(0), 1);
- jit_blti(p, lab2, R(0), BLOCK_SIZE);
-
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(16, foo());
- ASSERT_EQ(1, correct_result);
- ASSERT_EQ_STR("0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 ", simple_buffer(BUFFER_GET, NULL));
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
-}
diff --git a/ext/myjit/test/t010-debug.c b/ext/myjit/test/t010-debug.c
deleted file mode 100755
index 3546eb8..0000000
--- a/ext/myjit/test/t010-debug.c
+++ /dev/null
@@ -1,169 +0,0 @@
-#define _POSIX_C_SOURCE 200809L
-#define JIT_REGISTER_TEST
-#include "tests.h"
-
-#define BUF_SIZE (65535)
-
-DEFINE_TEST(test1)
-{
-#ifndef __APPLE__
- char buf[BUF_SIZE];
- FILE *old_stdout = stdout;
- stdout = fmemopen(buf, BUF_SIZE, "w");
-
- plfl factorial;
- jit_prolog(p, &factorial);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
- jit_getarg(p, R(0), 0);
- jit_movi(p, R(1), 1);
-
- jit_msg(p, "Check 1.\n");
- jit_label * loop = jit_get_label(p);
- jit_op * o = jit_blei(p, JIT_FORWARD, R(0), 0);
- jit_msgr(p, "Check R(1): %i\n", R(1));
- jit_mulr(p, R(1), R(1), R(0));
- jit_subi(p, R(0), R(0), 1);
- jit_jmpi(p, loop);
-
- jit_patch(p, o);
-
- jit_msg(p, "Check X.\n");
- jit_retr(p, R(1));
-
- JIT_GENERATE_CODE(p);
-
- jit_value r = factorial(6);
-
- fclose(stdout);
- stdout = old_stdout;
-
- ASSERT_EQ(720, r);
- ASSERT_EQ_STR("Check 1.\nCheck R(1): 1\nCheck R(1): 6\nCheck R(1): 30\nCheck R(1): 120\nCheck R(1): 360\nCheck R(1): 720\nCheck X.\n", buf);
-
- return 0;
-#else
- IGNORE_TEST
-#endif
-}
-
-struct jit_debug_info {
- const char *filename;
- const char *function;
- int lineno;
- int warnings;
-};
-
-#define ASSERT_WARNING(op, warning) ASSERT_EQ((warning), (op)->debug_info->warnings);
-
-DEFINE_TEST(test2)
-{
-#ifndef __APPLE__
- char buf[BUF_SIZE];
- FILE *old_stdout = stdout;
- stdout = fmemopen(buf, BUF_SIZE, "w");
-
- plfl x;
- jit_op *op01 = jit_prolog(p, &x);
- jit_op *op01a = jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(long));
- jit_op *op01b = jit_declare_arg(p, JIT_PTR, 10);
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_op *op02 = jit_movr(p, R(0), R(1));
- jit_op *op03 = jit_fmovr(p, FR(0), FR(1));
-
- jit_op *op04 = jit_movr(p, FR(1), R(0));
- jit_label *label1 = jit_get_label(p);
- jit_op *op05 = jit_blti(p, JIT_FORWARD, R(0), 10);
- jit_op *op06 = jit_jmpi(p, JIT_FORWARD);
- jit_op *op07 = jit_retr(p, R(0));
-
- jit_op *op08 = jit_patch(p, op05);
- jit_op *op09 = jit_ldi(p, R(2), NULL, 3);
- jit_op *op10 = jit_fldi(p, FR(2), NULL, 2);
-
-
- jit_label *label2 = jit_get_label(p);
- jit_data_dword(p, 0xcaca0);
-
- jit_get_label(p);
- jit_op *op11 = jit_movi(p, R(0), 1);
- jit_op *op12 = jit_ref_code(p, R(0), label2);
- jit_op *op13 = jit_ref_data(p, R(0), label1);
-
- jit_op *op14 = jit_fsti(p, NULL, R(0), 2);
- jit_op *op15 = jit_fstxi(p, 0, R(0), R(0), 2);
-
- jit_op *op16 = jit_getarg(p, R(0), 2);
- jit_op *op17 = jit_getarg(p, FR(1), 1);
-
- jit_op *op18 = jit_fldi(p, R(0), NULL, 4);
- jit_op *op19 = jit_fldxi(p, R(0), R(1), NULL, 4);
-
- jit_check_code(p, JIT_WARN_ALL);
-
- fclose(stdout);
- stdout = old_stdout;
-
- ASSERT_WARNING(op01, JIT_WARN_UNINITIALIZED_REG);
- ASSERT_WARNING(op01a, 0);
- ASSERT_WARNING(op01b, JIT_WARN_INVALID_DATA_SIZE);
- ASSERT_WARNING(op02, 0);
- ASSERT_WARNING(op03, JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op04, JIT_WARN_REGISTER_TYPE_MISMATCH | JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op05, 0);
- ASSERT_WARNING(op06, JIT_WARN_MISSING_PATCH);
- ASSERT_WARNING(op07, JIT_WARN_DEAD_CODE);
- ASSERT_WARNING(op08, 0);
- ASSERT_WARNING(op09, JIT_WARN_INVALID_DATA_SIZE | JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op10, JIT_WARN_INVALID_DATA_SIZE | JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op11, JIT_WARN_UNALIGNED_CODE | JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op12, JIT_WARN_INVALID_CODE_REFERENCE | JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op13, JIT_WARN_INVALID_DATA_REFERENCE);
- ASSERT_WARNING(op14, JIT_WARN_INVALID_DATA_SIZE | JIT_WARN_REGISTER_TYPE_MISMATCH);
- ASSERT_WARNING(op15, JIT_WARN_INVALID_DATA_SIZE | JIT_WARN_REGISTER_TYPE_MISMATCH);
- ASSERT_WARNING(op16, JIT_WARN_REGISTER_TYPE_MISMATCH | JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op17, JIT_WARN_REGISTER_TYPE_MISMATCH | JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op18, JIT_WARN_REGISTER_TYPE_MISMATCH | JIT_WARN_OP_WITHOUT_EFFECT);
- ASSERT_WARNING(op19, JIT_WARN_REGISTER_TYPE_MISMATCH | JIT_WARN_OP_WITHOUT_EFFECT);
-
- return 0;
-#else
- IGNORE_TEST
-#endif
-}
-
-DEFINE_TEST(test3)
-{
-#ifndef __APPLE__
- char buf[BUF_SIZE];
- FILE *old_stdout = stdout;
- stdout = fmemopen(buf, BUF_SIZE, "w");
-
- jit_enable_optimization(p, JIT_OPT_OMIT_UNUSED_ASSIGNEMENTS);
- plfv x;
- jit_prolog(p, &x);
- jit_op *op03 = jit_movi(p, R(0), 10);
- jit_movi(p, R(0), 20);
- jit_addi(p, R(0), R(0), 30);
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(50, x());
- ASSERT_EQ(JIT_NOP, op03->code);
-
- fclose(stdout);
- stdout = old_stdout;
-
- return 0;
-#else
- IGNORE_TEST
-#endif
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
- SETUP_TEST(test3);
-}
diff --git a/ext/myjit/test/t101-fp-basics.c b/ext/myjit/test/t101-fp-basics.c
deleted file mode 100755
index 30e7c6e..0000000
--- a/ext/myjit/test/t101-fp-basics.c
+++ /dev/null
@@ -1,240 +0,0 @@
-#include "tests.h"
-
-DEFINE_TEST(test1)
-{
- pdfv f1;
- jit_prolog(p, &f1);
- jit_freti(p, 123, sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(123.0, f1());
- return 0;
-}
-
-DEFINE_TEST(test2)
-{
- pdfv f1;
- jit_prolog(p, &f1);
- jit_fmovi(p, FR(0), 100);
- jit_faddi(p, FR(0), FR(0), 200);
- jit_faddi(p, FR(1), FR(0), 200);
- jit_fretr(p, FR(1), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(500.0, f1());
- return 0;
-}
-
-DEFINE_TEST(test3)
-{
- pdfv f1;
- jit_prolog(p, &f1);
- jit_fmovi(p, FR(0), 100);
- jit_faddr(p, FR(0), FR(0), FR(0));
- jit_fsubi(p, FR(1), FR(0), 50);
- jit_fsubr(p, FR(2), FR(1), FR(0));
- jit_fretr(p, FR(2), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(-50.0, f1());
- return 0;
-}
-
-DEFINE_TEST(test4)
-{
- pdfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 100);
- jit_movi(p, R(1), 50);
-
- jit_extr(p, FR(0), R(0));
- jit_extr(p, FR(1), R(1));
-
- jit_faddr(p, FR(0), FR(0), FR(0));
- jit_fsubr(p, FR(1), FR(0), FR(1));
- jit_fsubr(p, FR(2), FR(1), FR(0));
- jit_fretr(p, FR(2), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(-50.0, f1());
- return 0;
-}
-
-DEFINE_TEST(test5)
-{
- pdfv f1;
- jit_prolog(p, &f1);
- jit_fmovi(p, FR(0), 100.0);
- jit_fmovr(p, FR(1), FR(0));
- jit_faddi(p, FR(0), FR(0), 20);
-
- jit_faddr(p, FR(2), FR(0), FR(1));
- jit_fretr(p, FR(2), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(220.0, f1());
- return 0;
-}
-
-DEFINE_TEST(test10)
-{
- double x = 123.4;
- pdfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), &x);
- jit_fldr(p, FR(0), R(0), sizeof(double));
- jit_fretr(p, FR(0), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(123.4, f1());
- return 0;
-}
-
-DEFINE_TEST(test11)
-{
- float x = 123.4;
- pdfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), &x);
- jit_fldr(p, FR(0), R(0), sizeof(float));
- jit_fretr(p, FR(0), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(123.4, f1());
- return 0;
-}
-
-DEFINE_TEST(test12)
-{
- double x = 123.4;
- pdfv f1;
- jit_prolog(p, &f1);
- jit_fldi(p, FR(0), &x, sizeof(double));
- jit_fretr(p, FR(0), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(123.4, f1());
- return 0;
-}
-
-DEFINE_TEST(test13)
-{
- float x = 123.4;
- pdfv f1;
- jit_prolog(p, &f1);
- jit_fldi(p, FR(0), &x, sizeof(float));
- jit_fretr(p, FR(0), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(123.4, f1());
- return 0;
-}
-
-DEFINE_TEST(test14)
-{
- double x[] = { 1.1, 2.2, 3.3 };
- pdfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), &x);
- jit_movi(p, R(1), sizeof(double));
- jit_fldxr(p, FR(0), R(0), R(1), sizeof(double));
- jit_fretr(p, FR(0), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(2.2, f1());
- return 0;
-}
-
-DEFINE_TEST(test20)
-{
- double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
- pdfv f1;
- jit_prolog(p, &f1);
-
- jit_fmovi(p, FR(0), 1.1);
- jit_fsti(p, &x, FR(0), sizeof(double));
-
-
- jit_movi(p, R(0), &x);
- jit_addi(p, R(1), R(0), sizeof(double));
- jit_fmovi(p, FR(0), 2.2);
- jit_fstr(p, R(1), FR(0), sizeof(double));
-
-
- jit_fmovi(p, FR(0), 3.3);
- jit_fstxi(p, sizeof(double) * 2, R(0), FR(0), sizeof(double));
-
-
- jit_fmovi(p, FR(0), 4.4);
- jit_movi(p, R(1), sizeof(double) * 3);
- jit_fstxr(p, R(1), R(0), FR(0), sizeof(double));
-
- jit_freti(p, 10.10, sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(10.10, f1());
- ASSERT_EQ_DOUBLE(1.1, x[0]);
- ASSERT_EQ_DOUBLE(2.2, x[1]);
- ASSERT_EQ_DOUBLE(3.3, x[2]);
- ASSERT_EQ_DOUBLE(4.4, x[3]);
- ASSERT_EQ_DOUBLE(5.0, x[4]);
- return 0;
-}
-
-DEFINE_TEST(test21)
-{
- float x[] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
- pffv f1;
- jit_prolog(p, &f1);
-
- jit_fmovi(p, FR(0), 1.1);
- jit_fsti(p, &x, FR(0), sizeof(float));
-
-
- jit_movi(p, R(0), &x);
- jit_addi(p, R(1), R(0), sizeof(float));
- jit_fmovi(p, FR(0), 2.2);
- jit_fstr(p, R(1), FR(0), sizeof(float));
-
-
- jit_fmovi(p, FR(0), 3.3);
- jit_fstxi(p, sizeof(float) * 2, R(0), FR(0), sizeof(float));
-
-
- jit_fmovi(p, FR(0), 4.4);
- jit_movi(p, R(1), sizeof(float) * 3);
- jit_fstxr(p, R(1), R(0), FR(0), sizeof(float));
-
- jit_freti(p, 10.10, sizeof(float));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(10.10, f1());
- ASSERT_EQ_DOUBLE(1.1, x[0]);
- ASSERT_EQ_DOUBLE(2.2, x[1]);
- ASSERT_EQ_DOUBLE(3.3, x[2]);
- ASSERT_EQ_DOUBLE(4.4, x[3]);
- ASSERT_EQ_DOUBLE(5.0, x[4]);
- return 0;
-}
-
-
-
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
- SETUP_TEST(test3);
- SETUP_TEST(test4);
- SETUP_TEST(test5);
-
- SETUP_TEST(test10);
- SETUP_TEST(test11);
- SETUP_TEST(test12);
- SETUP_TEST(test13);
- SETUP_TEST(test14);
-
- SETUP_TEST(test20);
- SETUP_TEST(test21);
-}
diff --git a/ext/myjit/test/t102-fp-arithmetic.c b/ext/myjit/test/t102-fp-arithmetic.c
deleted file mode 100755
index 0b9ea70..0000000
--- a/ext/myjit/test/t102-fp-arithmetic.c
+++ /dev/null
@@ -1,194 +0,0 @@
-#include "tests.h"
-
-// imm -- same reg
-#define TEST_IMM_SAME_REG(_name, _op, _arg1, _arg2, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- pdfv f1; \
- jit_prolog(p, &f1); \
- jit_fmovi(p, FR(0), _arg1); \
- _op(p, FR(0), FR(0), _arg2); \
- jit_fretr(p, FR(0), sizeof(double)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ_DOUBLE(_expected_value, f1()); \
- return 0;\
-}
-
-#define TEST_IMM_OTHER_REG(_name, _op, _arg1, _arg2, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- pdfv f1; \
- jit_prolog(p, &f1); \
- jit_fmovi(p, FR(0), _arg1); \
- _op(p, FR(1), FR(0), _arg2); \
- jit_fretr(p, FR(1), sizeof(double)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ_DOUBLE(_expected_value, f1()); \
- return 0;\
-}
-
-#define TEST_REG_SAME_REG(_name, _op, _arg1, _arg2, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- pdfv f1; \
- jit_prolog(p, &f1); \
- jit_fmovi(p, FR(0), _arg1); \
- jit_fmovi(p, FR(1), _arg2); \
- _op(p, FR(1), FR(0), FR(1)); \
- jit_fretr(p, FR(1), sizeof(double)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ_DOUBLE(_expected_value, f1()); \
- return 0;\
-}
-
-#define TEST_REG_OTHER_REG(_name, _op, _arg1, _arg2, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- pdfv f1; \
- jit_prolog(p, &f1); \
- jit_fmovi(p, FR(0), _arg1); \
- jit_fmovi(p, FR(1), _arg2); \
- _op(p, FR(2), FR(0), FR(1)); \
- jit_fretr(p, FR(2), sizeof(double)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ_DOUBLE(_expected_value, f1()); \
- return 0;\
-}
-
-#define TEST_UNARY_REG_OTHER_REG(_name, _op, _arg1, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- pdfv f1; \
- jit_prolog(p, &f1); \
- jit_fmovi(p, FR(0), _arg1); \
- _op(p, FR(2), FR(0)); \
- jit_fretr(p, FR(2), sizeof(double)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ_DOUBLE(_expected_value, f1()); \
- return 0;\
-}
-
-#define TEST_UNARY_REG_SAME_REG(_name, _op, _arg1, _expected_value) \
-DEFINE_TEST(_name) \
-{ \
- pdfv f1; \
- jit_prolog(p, &f1); \
- jit_fmovi(p, FR(0), _arg1); \
- _op(p, FR(0), FR(0)); \
- jit_fretr(p, FR(0), sizeof(double)); \
- JIT_GENERATE_CODE(p); \
-\
- ASSERT_EQ_DOUBLE(_expected_value, f1()); \
- return 0;\
-}
-
-
-TEST_IMM_SAME_REG(test10, jit_faddi, 42, 28, 70.0)
-TEST_IMM_OTHER_REG(test11, jit_faddi, 42, 28, 70.0)
-TEST_REG_SAME_REG(test12, jit_faddr, 42, 28, 70.0)
-TEST_REG_OTHER_REG(test13, jit_faddr, 42, 28, 70.0)
-
-TEST_IMM_SAME_REG(test20, jit_fsubi, 42, 28, 14.0)
-TEST_IMM_OTHER_REG(test21, jit_fsubi, 42, 28, 14.0)
-TEST_REG_SAME_REG(test22, jit_fsubr, 42, 28, 14.0)
-TEST_REG_OTHER_REG(test23, jit_fsubr, 42, 28, 14.0)
-
-TEST_IMM_SAME_REG(test30, jit_frsbi, 42, 28, -14.0)
-TEST_IMM_OTHER_REG(test31, jit_frsbi, 42, 28, -14.0)
-TEST_REG_SAME_REG(test32, jit_frsbr, 42, 28, -14.0)
-TEST_REG_OTHER_REG(test33, jit_frsbr, 42, 28, -14.0)
-
-TEST_IMM_SAME_REG(test40, jit_fmuli, 42, 28, 1176.0)
-TEST_IMM_OTHER_REG(test41, jit_fmuli, 42, 28, 1176.0)
-TEST_REG_SAME_REG(test42, jit_fmulr, 42, 28, 1176.0)
-TEST_REG_OTHER_REG(test43, jit_fmulr, 42, 28, 1176.0)
-
-TEST_IMM_SAME_REG(test44, jit_fmuli, 42, 4, 168.0)
-TEST_IMM_OTHER_REG(test45, jit_fmuli, 42, 4, 168.0)
-TEST_REG_SAME_REG(test46, jit_fmulr, 42, 4, 168.0)
-TEST_REG_OTHER_REG(test47, jit_fmulr, 42, 4, 168.0)
-
-TEST_IMM_SAME_REG(test48, jit_fmuli, 42, 5, 210.0)
-TEST_IMM_OTHER_REG(test49, jit_fmuli, 42, 5, 210.0)
-TEST_REG_SAME_REG(test50, jit_fmulr, 42, 5, 210.0)
-TEST_REG_OTHER_REG(test51, jit_fmulr, 42, 5, 210.0)
-
-TEST_IMM_SAME_REG(test52, jit_fmuli, 42, 2,84.0)
-TEST_IMM_OTHER_REG(test53, jit_fmuli, 42, 2, 84.0)
-TEST_REG_SAME_REG(test54, jit_fmulr, 42, 2, 84.0)
-TEST_REG_OTHER_REG(test55, jit_fmulr, 42, 2, 84.0)
-
-TEST_IMM_SAME_REG(test56, jit_fmuli, 42, 9, 378.0)
-TEST_IMM_OTHER_REG(test57, jit_fmuli, 42, 9, 378.0)
-TEST_REG_SAME_REG(test58, jit_fmulr, 42, 9, 378.0)
-TEST_REG_OTHER_REG(test59, jit_fmulr, 42, 9, 378.0)
-
-TEST_IMM_SAME_REG(test60, jit_fdivi, 42, 4, 42.0 / 4.0)
-TEST_IMM_OTHER_REG(test61, jit_fdivi, 42, 4, 42.0 / 4.0)
-TEST_REG_SAME_REG(test62, jit_fdivr, 42, 4, 42.0 / 4.0)
-TEST_REG_OTHER_REG(test63, jit_fdivr, 42, 4, 42.0 / 4.0)
-
-TEST_IMM_SAME_REG(test64, jit_fdivi, 42, 9, 42.0 / 9.0)
-TEST_IMM_OTHER_REG(test65, jit_fdivi, 42, 9, 42.0 / 9.0)
-TEST_REG_SAME_REG(test66, jit_fdivr, 42, 9, 42.0 / 9.0)
-TEST_REG_OTHER_REG(test67, jit_fdivr, 42, 9, 42.0 / 9.0)
-
-TEST_UNARY_REG_SAME_REG(test160, jit_fnegr, 42, -42.0)
-TEST_UNARY_REG_OTHER_REG(test161, jit_fnegr, 42, -42.0)
-
-
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test10);
- SETUP_TEST(test11);
- SETUP_TEST(test12);
- SETUP_TEST(test13);
- SETUP_TEST(test20);
- SETUP_TEST(test21);
- SETUP_TEST(test22);
- SETUP_TEST(test23);
- SETUP_TEST(test30);
- SETUP_TEST(test31);
- SETUP_TEST(test32);
- SETUP_TEST(test33);
- SETUP_TEST(test40);
- SETUP_TEST(test41);
- SETUP_TEST(test42);
- SETUP_TEST(test43);
- SETUP_TEST(test44);
-
- SETUP_TEST(test45);
- SETUP_TEST(test46);
- SETUP_TEST(test47);
- SETUP_TEST(test48);
- SETUP_TEST(test49);
- SETUP_TEST(test50);
- SETUP_TEST(test51);
- SETUP_TEST(test52);
- SETUP_TEST(test53);
- SETUP_TEST(test54);
- SETUP_TEST(test55);
- SETUP_TEST(test56);
- SETUP_TEST(test57);
- SETUP_TEST(test58);
- SETUP_TEST(test59);
-
- SETUP_TEST(test60);
- SETUP_TEST(test61);
- SETUP_TEST(test62);
- SETUP_TEST(test63);
- SETUP_TEST(test64);
- SETUP_TEST(test65);
- SETUP_TEST(test66);
- SETUP_TEST(test67);
-
- SETUP_TEST(test160);
- SETUP_TEST(test161);
-}
diff --git a/ext/myjit/test/t103-fp-rounding.c b/ext/myjit/test/t103-fp-rounding.c
deleted file mode 100755
index 4b3bce0..0000000
--- a/ext/myjit/test/t103-fp-rounding.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <math.h>
-#include "tests.h"
-
-int count = 8;
-double test_data[] = { 2.0, 2.1, 2.5, 2.7, -2.0, -2.1, -2.5, -2.7 };
-
-#define CREATE_TEST(_test_name, _jit_func, _fn) \
-DEFINE_TEST(_test_name) \
-{ \
- plfd f1; \
- jit_disable_optimization(p, JIT_OPT_ALL); \
- jit_prolog(p, &f1); \
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));\
- jit_getarg(p, FR(0), 0); \
- _jit_func(p, R(0), FR(0)); \
- jit_retr(p, R(0)); \
- JIT_GENERATE_CODE(p); \
-\
- for (int i = 0; i < count; i++) \
- ASSERT_EQ_DOUBLE(_fn(test_data[i]), f1(test_data[i])); \
-\
- return 0;\
-}
-
-CREATE_TEST(trunc_test, jit_truncr, trunc)
-CREATE_TEST(round_test, jit_roundr, round)
-CREATE_TEST(ceil_test, jit_ceilr, ceil)
-CREATE_TEST(floor_test, jit_floorr, floor)
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(trunc_test);
- SETUP_TEST(round_test);
- SETUP_TEST(ceil_test);
- SETUP_TEST(floor_test);
-}
diff --git a/ext/myjit/test/t104-fp-branches.c b/ext/myjit/test/t104-fp-branches.c
deleted file mode 100755
index 8ff65a6..0000000
--- a/ext/myjit/test/t104-fp-branches.c
+++ /dev/null
@@ -1,128 +0,0 @@
-#include "tests.h"
-
-#define CREATE_TEST_SUITE_REG(testname, _data_type, _jit_op, _operator) \
- CREATE_TEST_CASE_REG(testname ## 0, _data_type, _jit_op, _operator, 0, 0, 0) \
- CREATE_TEST_CASE_REG(testname ## 1, _data_type, _jit_op, _operator, 0, 0, 1) \
- CREATE_TEST_CASE_REG(testname ## 2, _data_type, _jit_op, _operator, 0, 1, 0) \
- CREATE_TEST_CASE_REG(testname ## 3, _data_type, _jit_op, _operator, 0, 1, 1) \
- CREATE_TEST_CASE_REG(testname ## 4, _data_type, _jit_op, _operator, 1, 0, 0) \
- CREATE_TEST_CASE_REG(testname ## 5, _data_type, _jit_op, _operator, 1, 0, 1) \
- CREATE_TEST_CASE_REG(testname ## 6, _data_type, _jit_op, _operator, 1, 1, 0) \
- CREATE_TEST_CASE_REG(testname ## 7, _data_type, _jit_op, _operator, 1, 1, 1) \
-
-#define CREATE_TEST_SUITE_IMM(testname, _data_type, _jit_op, _operator) \
- CREATE_TEST_CASE_IMM(testname ## 0, _data_type, _jit_op, _operator, 0, 0, 0) \
- CREATE_TEST_CASE_IMM(testname ## 1, _data_type, _jit_op, _operator, 0, 0, 1) \
- CREATE_TEST_CASE_IMM(testname ## 2, _data_type, _jit_op, _operator, 0, 1, 0) \
- CREATE_TEST_CASE_IMM(testname ## 3, _data_type, _jit_op, _operator, 0, 1, 1) \
- CREATE_TEST_CASE_IMM(testname ## 4, _data_type, _jit_op, _operator, 1, 0, 0) \
- CREATE_TEST_CASE_IMM(testname ## 5, _data_type, _jit_op, _operator, 1, 0, 1) \
- CREATE_TEST_CASE_IMM(testname ## 6, _data_type, _jit_op, _operator, 1, 1, 0) \
- CREATE_TEST_CASE_IMM(testname ## 7, _data_type, _jit_op, _operator, 1, 1, 1) \
-
-#define SETUP_TESTS(testname) \
- SETUP_TEST(testname ## 0); \
- SETUP_TEST(testname ## 1); \
- SETUP_TEST(testname ## 2); \
- SETUP_TEST(testname ## 3); \
- SETUP_TEST(testname ## 4); \
- SETUP_TEST(testname ## 5); \
- SETUP_TEST(testname ## 6); \
- SETUP_TEST(testname ## 7);
-
-
-#define CREATE_TEST_CASE_REG(testname, _data_type, _jit_op, _operator, _equal, _negative, _greater) \
-DEFINE_TEST(testname)\
-{\
- pdfv f1;\
- jit_prolog(p, &f1);\
-\
- _data_type firstval = 42;\
- _data_type secval = 28;\
- if (_equal) secval = firstval;\
- if (_greater) secval = 60;\
- if (_negative) secval *= -1;\
-\
- jit_fmovi(p, FR(1), firstval);\
- jit_fmovi(p, FR(2), secval);\
-\
- jit_op * br; \
- br = _jit_op(p, 0, FR(1), FR(2));\
- jit_fmovi(p, FR(3), -10); \
- jit_op * e = jit_jmpi(p, 0); \
- \
- jit_patch(p, br); \
- jit_fmovi(p, FR(3), 10); \
- jit_patch(p, e); \
- jit_fretr(p, FR(3), sizeof(double)); \
-\
- JIT_GENERATE_CODE(p);\
-\
- if (firstval _operator secval) ASSERT_EQ_DOUBLE(10.0, f1()); \
- if (!(firstval _operator secval)) ASSERT_EQ_DOUBLE(-10.0, f1()); \
- return 0; \
-}
-
-#define CREATE_TEST_CASE_IMM(testname, _data_type, _jit_op, _operator, _equal, _negative, _greater) \
-DEFINE_TEST(testname)\
-{\
- pdfv f1;\
- jit_prolog(p, &f1);\
-\
- _data_type firstval = 42;\
- _data_type secval = 28;\
- if (_equal) secval = firstval;\
- if (_greater) secval = 60;\
- if (_negative) secval *= -1;\
- \
- jit_fmovi(p, FR(1), firstval);\
-\
- jit_op * br; \
- br = _jit_op(p, 0, FR(1), secval);\
- jit_fmovi(p, FR(3), -10); \
- jit_op * e = jit_jmpi(p, 0); \
- \
- jit_patch(p, br); \
- jit_fmovi(p, FR(3), 10); \
- jit_patch(p, e); \
- jit_fretr(p, FR(3), sizeof(double)); \
-\
- JIT_GENERATE_CODE(p);\
-\
- if (firstval _operator secval) ASSERT_EQ_DOUBLE(10.0, f1()); \
- if (!(firstval _operator secval)) ASSERT_EQ_DOUBLE(-10.0, f1()); \
- return 0; \
-}
-
-CREATE_TEST_SUITE_REG(test01reg, double, jit_fbltr, <)
-CREATE_TEST_SUITE_REG(test02reg, double, jit_fbler, <=)
-CREATE_TEST_SUITE_REG(test03reg, double, jit_fbger, >=)
-CREATE_TEST_SUITE_REG(test04reg, double, jit_fbgtr, >)
-CREATE_TEST_SUITE_REG(test05reg, double, jit_fbeqr, ==)
-CREATE_TEST_SUITE_REG(test06reg, double, jit_fbner, !=)
-
-CREATE_TEST_SUITE_IMM(test21imm, double, jit_fblti, <)
-CREATE_TEST_SUITE_IMM(test22imm, double, jit_fblei, <=)
-CREATE_TEST_SUITE_IMM(test23imm, double, jit_fbgei, >=)
-CREATE_TEST_SUITE_IMM(test24imm, double, jit_fbgti, >)
-CREATE_TEST_SUITE_IMM(test25imm, double, jit_fbeqi, ==)
-CREATE_TEST_SUITE_IMM(test26imm, double, jit_fbnei, !=)
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TESTS(test01reg);
- SETUP_TESTS(test02reg);
- SETUP_TESTS(test03reg);
- SETUP_TESTS(test04reg);
- SETUP_TESTS(test05reg);
- SETUP_TESTS(test06reg);
-
- SETUP_TESTS(test21imm);
- SETUP_TESTS(test22imm);
- SETUP_TESTS(test23imm);
- SETUP_TESTS(test24imm);
- SETUP_TESTS(test25imm);
- SETUP_TESTS(test26imm);
-}
-
diff --git a/ext/myjit/test/t105-fp-functions.c b/ext/myjit/test/t105-fp-functions.c
deleted file mode 100755
index 1e0a4dc..0000000
--- a/ext/myjit/test/t105-fp-functions.c
+++ /dev/null
@@ -1,354 +0,0 @@
-#include <stddef.h>
-#include "tests.h"
-#include "simple-buffer.c"
-
-typedef double (*pdfdfd)(double, float, double);
-typedef float (*pffdui)(double, unsigned int);
-typedef double (*pdfuc)(unsigned char);
-typedef double (*pdfpcus)(char *, unsigned short);
-
-// function which computes an average of three numbers
-DEFINE_TEST(test1)
-{
- pdfdfd f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_getarg(p, FR(0), 0);
- jit_getarg(p, FR(1), 1);
- jit_faddr(p, FR(0), FR(0), FR(1));
- jit_getarg(p, FR(1), 2);
- jit_faddr(p, FR(0), FR(0), FR(1));
- jit_fdivi(p, FR(0), FR(0), 3);
- jit_fretr(p, FR(0), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(10.0, f1(20, 20, -10));
- return 0;
-}
-
-// function which computes n^m
-DEFINE_TEST(test2)
-{
- pffdui f1;
-
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(int));
- jit_getarg(p, FR(0), 0);
- jit_getarg(p, R(1), 1);
-
- jit_fmovi(p, FR(2), 1);
-
- jit_label * loop = jit_get_label(p);
- jit_op * end = jit_beqi(p, JIT_FORWARD, R(1), 0);
- jit_fmulr(p, FR(2), FR(2), FR(0));
- jit_subi(p, R(1), R(1), 1);
- jit_jmpi(p, loop);
-
- jit_patch(p, end);
- jit_fretr(p, FR(2), sizeof(float));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(81.0, f1(3, 4));
- ASSERT_EQ_DOUBLE(-27.0, f1(-3, 3));
- return 0;
-}
-
-// function which computes factorial
-DEFINE_TEST(test3)
-{
- pdfuc f1;
-
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(char));
- jit_getarg(p, R(0), 0);
-
- jit_fmovi(p, FR(1), 1);
-
- jit_label * loop = jit_get_label(p);
-
- jit_op * end = jit_beqi(p, JIT_FORWARD, R(0), 0);
-
- jit_extr(p, FR(0), R(0));
- jit_fmulr(p, FR(1), FR(1), FR(0));
- jit_subi(p, R(0), R(0), 1);
-
- jit_jmpi(p, loop);
- jit_patch(p, end);
-
- jit_fretr(p, FR(1), sizeof(double));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ_DOUBLE(120.0, f1(5));
- return 0;
-}
-
-// function which computes fibonacci's number
-DEFINE_TEST(test4)
-{
- pdfd f1;
-
- jit_label * fib = jit_get_label(p);
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
-
- jit_getarg(p, FR(0), 0);
-
- jit_op * br = jit_fblti(p, JIT_FORWARD, FR(0), 3);
-
- jit_fsubi(p, FR(0), FR(0), 1);
-
- jit_prepare(p);
- jit_fputargr(p, FR(0), sizeof(double));
- jit_call(p, fib);
-
- jit_fretval(p, FR(1), sizeof(double));
-
- jit_getarg(p, FR(0), 0);
- jit_fsubi(p, FR(0), FR(0), 2);
- jit_prepare(p);
- jit_fputargr(p, FR(0), sizeof(double));
- jit_call(p, fib);
-
- jit_fretval(p, FR(2), sizeof(double));
-
- jit_faddr(p, FR(0), FR(1), FR(2));
-
- jit_fretr(p, FR(0), sizeof(double));
-
- jit_patch(p, br);
-
- jit_freti(p, 1.0, sizeof(double));
-
- JIT_GENERATE_CODE(p);
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ_DOUBLE(832040.0, f1(30));
- return 0;
-}
-
-// function which converts string to number
-DEFINE_TEST(test5)
-{
- pdfpcus f1; // string, radix -> long
-
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(long));
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(short));
-
- // R(0): string
- // R(1): radix
- // R(2): position in string
- // R(3): current char
- // R(4): result
- jit_getarg(p, R(0), 0);
- jit_getarg(p, R(1), 1);
- jit_movi(p, R(2), 0);
- jit_fmovi(p, FR(4), 0);
- jit_extr(p, FR(1), R(1));
-
- jit_label * loop = jit_get_label(p);
-
- jit_ldxr_u(p, R(3), R(0), R(2), 1);
- jit_op * end = jit_beqi(p, JIT_FORWARD, R(3), 0);
- jit_op * lowercase = jit_bgti_u(p, JIT_FORWARD, R(3), 'Z');
- jit_op * uppercase = jit_bgti_u(p, JIT_FORWARD, R(3), '9');
- jit_subi(p, R(3), R(3), '0');
- jit_op * comput = jit_jmpi(p, JIT_FORWARD);
-
- // is upper case char
- jit_patch(p, uppercase);
- jit_subi(p, R(3), R(3), 'A' - 10);
- jit_op * comput0 = jit_jmpi(p, JIT_FORWARD);
-
- jit_patch(p, lowercase);
- jit_subi(p, R(3), R(3), 'a' - 10);
- jit_op * comput1 = jit_jmpi(p, JIT_FORWARD);
-
- // computations
- jit_patch(p, comput);
- jit_patch(p, comput0);
- jit_patch(p, comput1);
- jit_fmulr(p, FR(4), FR(4), FR(1));
- jit_extr(p, FR(3), R(3));
- jit_faddr(p, FR(4), FR(4), FR(3));
- jit_addi(p, R(2), R(2), 1);
- jit_jmpi(p, loop);
-
- jit_patch(p, end);
- jit_fretr(p, FR(4), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(31.0, f1("1f", 16));
- return 0;
-}
-
-// prints ``hello, world!''
-DEFINE_TEST(test6)
-{
- static char *str = "Hello, World! Lucky number for today is %.3f!!!\n";
- static char buf[120];
- plfv f1;
-
- jit_prolog(p, &f1);
- jit_movi(p, R(0), str);
-
- jit_fmovi(p, FR(1), 12345.678);
-
- jit_movi(p, R(2), sprintf);
-
- jit_prepare(p);
- jit_putargi(p, buf);
- jit_putargr(p, R(0));
- jit_fputargr(p, FR(1), sizeof(double));
- jit_callr(p, R(2));
-
- //jit_retval(p, R(3));
-
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ((jit_value)sprintf, f1());
- ASSERT_EQ_STR("Hello, World! Lucky number for today is 12345.678!!!\n", buf);
- return 0;
-}
-
-// prints numbers 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
-DEFINE_TEST(test7)
-{
- static int ARR_SIZE = 10;
- static char * formatstr = "%.1f ";
-
- simple_buffer(BUFFER_CLEAR, NULL);
-
- plfv f1;
-
- jit_prolog(p, &f1);
- int arr = jit_allocai(p, ARR_SIZE * sizeof(double)); // allocates an array
-
- jit_fmovi(p, FR(0), 1); // sets up the first element
- jit_fstxi(p, arr, R_FP, FR(0), sizeof(double));
-
- jit_addi(p, R(0), R_FP, arr); // pointer to the array
- jit_addi(p, R(1), R(0), sizeof(double)); // position in the array (2nd element)
- jit_movi(p, R(2), ARR_SIZE - 1); // counter
-
- jit_label * loop = jit_get_label(p);
-
- jit_fldxi(p, FR(3), R(1), -sizeof(double), sizeof(double));
- jit_faddr(p, FR(3), FR(3), FR(3));
- jit_fstr(p, R(1), FR(3), sizeof(double));
-
- jit_addi(p, R(1), R(1), sizeof(double));
- jit_subi(p, R(2), R(2), 1);
- jit_bgti(p, loop, R(2), 0);
-
- jit_movi(p, R(2), ARR_SIZE - 1);
-
- jit_label * loop2 = jit_get_label(p);
-
- jit_fldr(p, FR(1), R(0), sizeof(double));
- jit_prepare(p);
- jit_putargi(p, BUFFER_PUT);
- jit_putargi(p, formatstr);
- jit_fputargr(p, FR(1), sizeof(double));
- jit_call(p, simple_buffer);
-
- jit_addi(p, R(0), R(0), sizeof(double));
- jit_subi(p, R(2), R(2), 1);
- jit_bgei(p, loop2, R(2), 0);
-
- jit_reti(p, 0);
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(0, f1());
- ASSERT_EQ_STR("1.0 2.0 4.0 8.0 16.0 32.0 64.0 128.0 256.0 512.0 ", simple_buffer(BUFFER_GET, NULL));
- return 0;
-}
-
-struct mystruct {
- float * items;
- long count;
- float sum;
- double avg;
-};
-
-// sums integers in a an array and computes their sum and average (uses structs)
-DEFINE_TEST(test8)
-{
- static char * formatstr = "avg: %.1f\nsum: %.1f\n";
- simple_buffer(BUFFER_CLEAR, NULL);
-
- static struct mystruct s = { NULL, 0, 0, 0};
- s.items = (float []){1, 2, 3, 4, 5};
- s.count = 5;
- s.sum = 111;
- s.avg = 123;
-
- plfv f1;
-
- jit_prolog(p, &f1);
-
- jit_ldi(p, R(0), (unsigned char *)&s + offsetof(struct mystruct, count), sizeof(long)); // count
-
- //jit_movi(p, R(1), &s); // struct
-
- jit_ldi(p, R(2), (unsigned char *)&s + offsetof(struct mystruct, items), sizeof(void *)); // array
- jit_movi(p, R(3), 0); // index
-
- jit_fmovi(p, FR(5), 0); // sum
- jit_label * loop = jit_get_label(p);
-
- jit_fldxr(p, FR(4), R(2), R(3), sizeof(float));
- jit_faddr(p, FR(5), FR(5), FR(4));
-
- jit_addi(p, R(3), R(3), sizeof(float));
- jit_subi(p, R(0), R(0), 1);
-
- jit_bgti(p, loop, R(0), 0);
- jit_fsti(p, (unsigned char *)&s + offsetof(struct mystruct, sum), FR(5), sizeof(float));
- jit_ldi(p, R(0), (unsigned char *)&s + offsetof(struct mystruct, count), sizeof(long)); // count
-
- jit_extr(p, FR(0), R(0));
- jit_fdivr(p, FR(5), FR(5), FR(0));
-
- //jit_movi(p, R(0), &s);
- jit_movi(p, R(1), offsetof(struct mystruct, avg));
- jit_fstxi(p, &s, R(1), FR(5), sizeof(double));
-
- jit_fldi(p, FR(0), (unsigned char *)&s + offsetof(struct mystruct, avg), sizeof(double));
- jit_fldi(p, FR(1), (unsigned char *)&s + offsetof(struct mystruct, sum), sizeof(float));
-
- jit_prepare(p);
- jit_putargi(p, BUFFER_PUT);
- jit_putargi(p, formatstr);
- jit_fputargr(p, FR(0), sizeof(double));
- jit_fputargr(p, FR(1), sizeof(double));
-
- jit_call(p, simple_buffer);
-
- jit_reti(p, 0);
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(0, f1());
- ASSERT_EQ_STR("avg: 3.0\nsum: 15.0\n", simple_buffer(BUFFER_GET, NULL));
- ASSERT_EQ_DOUBLE(15.0, s.sum);
- ASSERT_EQ_DOUBLE(3.0, s.avg);
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
- SETUP_TEST(test3);
- SETUP_TEST(test4);
- SETUP_TEST(test5);
- SETUP_TEST(test6);
- SETUP_TEST(test7);
- SETUP_TEST(test8);
-}
diff --git a/ext/myjit/test/t107-fp-args.c b/ext/myjit/test/t107-fp-args.c
deleted file mode 100755
index de983e4..0000000
--- a/ext/myjit/test/t107-fp-args.c
+++ /dev/null
@@ -1,128 +0,0 @@
-#include "tests.h"
-
-typedef double (* pdf10f)(float, float, float, float, float, float, float, float, float, float);
-typedef double (* pdf10d)(double, double, double, double, double, double, double, double, double, double);
-
-DEFINE_TEST(test1)
-{
- pdf10f foo;
- jit_prolog(p, &foo);
-
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(float));
-
- jit_getarg(p, FR(0), 0);
- jit_getarg(p, FR(1), 1);
- jit_getarg(p, FR(2), 2);
- jit_getarg(p, FR(3), 3);
- jit_getarg(p, FR(4), 4);
- jit_getarg(p, FR(5), 5);
- jit_getarg(p, FR(6), 6);
- jit_getarg(p, FR(7), 7);
- jit_getarg(p, FR(8), 8);
- jit_getarg(p, FR(9), 9);
-
-
- jit_fmovi(p, FR(10), 0);
- jit_faddr(p, FR(10), FR(10), FR(9));
- jit_faddr(p, FR(11), FR(10), FR(8));
- jit_faddr(p, FR(12), FR(11), FR(7));
- jit_faddr(p, FR(13), FR(12), FR(6));
- jit_faddr(p, FR(14), FR(13), FR(5));
- jit_faddr(p, FR(15), FR(14), FR(4));
- jit_faddr(p, FR(16), FR(15), FR(3));
- jit_faddr(p, FR(17), FR(16), FR(2));
- jit_faddr(p, FR(18), FR(17), FR(1));
-
- jit_faddr(p, FR(8), FR(8), FR(9));
- jit_faddr(p, FR(7), FR(7), FR(8));
- jit_faddr(p, FR(6), FR(6), FR(7));
- jit_faddr(p, FR(5), FR(5), FR(6));
- jit_faddr(p, FR(4), FR(4), FR(5));
- jit_faddr(p, FR(3), FR(3), FR(4));
- jit_faddr(p, FR(2), FR(2), FR(3));
- jit_faddr(p, FR(1), FR(1), FR(2));
- jit_faddr(p, FR(0), FR(0), FR(1));
-
- jit_faddr(p, FR(0), FR(0), FR(18));
-
- jit_fretr(p, FR(0), sizeof(double));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ_DOUBLE(109.0, foo(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
- return 0;
-}
-
-DEFINE_TEST(test2)
-{
- pdf10d foo;
-
- jit_prolog(p, &foo);
-
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
- jit_declare_arg(p, JIT_FLOAT_NUM, sizeof(double));
-
- jit_getarg(p, FR(0), 0);
- jit_getarg(p, FR(1), 1);
- jit_getarg(p, FR(2), 2);
- jit_getarg(p, FR(3), 3);
- jit_getarg(p, FR(4), 4);
- jit_getarg(p, FR(5), 5);
- jit_getarg(p, FR(6), 6);
- jit_getarg(p, FR(7), 7);
- jit_getarg(p, FR(8), 8);
- jit_getarg(p, FR(9), 9);
-
- jit_fmovi(p, FR(10), 0);
- jit_faddr(p, FR(10), FR(10), FR(9));
- jit_faddr(p, FR(11), FR(10), FR(8));
- jit_faddr(p, FR(12), FR(11), FR(7));
- jit_faddr(p, FR(13), FR(12), FR(6));
- jit_faddr(p, FR(14), FR(13), FR(5));
- jit_faddr(p, FR(15), FR(14), FR(4));
- jit_faddr(p, FR(16), FR(15), FR(3));
- jit_faddr(p, FR(17), FR(16), FR(2));
- jit_faddr(p, FR(18), FR(17), FR(1));
-
- jit_faddr(p, FR(8), FR(8), FR(9));
- jit_faddr(p, FR(7), FR(7), FR(8));
- jit_faddr(p, FR(6), FR(6), FR(7));
- jit_faddr(p, FR(5), FR(5), FR(6));
- jit_faddr(p, FR(4), FR(4), FR(5));
- jit_faddr(p, FR(3), FR(3), FR(4));
- jit_faddr(p, FR(2), FR(2), FR(3));
- jit_faddr(p, FR(1), FR(1), FR(2));
- jit_faddr(p, FR(0), FR(0), FR(1));
-
- jit_faddr(p, FR(0), FR(0), FR(18));
-
- jit_fretr(p, FR(0), sizeof(double));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(109.0, foo(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
-}
diff --git a/ext/myjit/test/t108-fp-pushargs.c b/ext/myjit/test/t108-fp-pushargs.c
deleted file mode 100755
index fb18023..0000000
--- a/ext/myjit/test/t108-fp-pushargs.c
+++ /dev/null
@@ -1,272 +0,0 @@
-#include "tests.h"
-
-int correct_result;
-
-static int foobar(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
-{
- correct_result = 1;
- if (!equals(a1, -1, 0.0001)) correct_result = 0;
- if (!equals(a2, 1, 0.0001)) correct_result = 0;
- if (!equals(a3, 2, 0.0001)) correct_result = 0;
- if (!equals(a4, 4, 0.0001)) correct_result = 0;
- if (!equals(a5, 8, 0.0001)) correct_result = 0;
- if (!equals(a6, 16, 0.0001)) correct_result = 0;
- if (!equals(a7, 32, 0.0001)) correct_result = 0;
- if (!equals(a8, 64, 0.0001)) correct_result = 0;
- if (!equals(a9, 128, 0.0001)) correct_result = 0;
- if (!equals(a10, 222.222, 0.0001)) correct_result = 0;
- return 666;
-}
-
-static int barbaz(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9, float a10, float a11)
-{
- correct_result = 1;
- if (!equals(a1, -1, 0.0001)) correct_result = 0;
- if (!equals(a2, 1, 0.0001)) correct_result = 0;
- if (!equals(a3, 2, 0.0001)) correct_result = 0;
- if (!equals(a4, 4, 0.0001)) correct_result = 0;
- if (!equals(a5, 8, 0.0001)) correct_result = 0;
- if (!equals(a6, 16, 0.0001)) correct_result = 0;
- if (!equals(a7, 32, 0.0001)) correct_result = 0;
- if (!equals(a8, 64, 0.0001)) correct_result = 0;
- if (!equals(a9, 128, 0.0001)) correct_result = 0;
- if (!equals(a10, 222.222, 0.0001)) correct_result = 0;
- if (!equals(a11, 256, 0.0001)) correct_result = 0;
- return 666;
-}
-
-DEFINE_TEST(test1)
-{
- correct_result = 2;
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_fmovi(p, FR(0), -1);
- jit_fmovi(p, FR(1), 1);
- jit_fmovi(p, FR(2), 2);
- jit_fmovi(p, FR(3), 4);
- jit_fmovi(p, FR(4), 8);
- jit_fmovi(p, FR(5), 16);
- jit_fmovi(p, FR(6), 32);
- jit_fmovi(p, FR(7), 64);
- jit_fmovi(p, FR(8), 128);
- //jit_fmovi(p, FR(9), 256);
- //jit_movi(p, R(10), 123);
-
- jit_prepare(p);
- jit_fputargr(p, FR(0), sizeof(double));
- jit_fputargr(p, FR(1), sizeof(double));
- jit_fputargr(p, FR(2), sizeof(double));
- jit_fputargr(p, FR(3), sizeof(double));
- jit_fputargr(p, FR(4), sizeof(double));
- jit_fputargr(p, FR(5), sizeof(double));
- jit_fputargr(p, FR(6), sizeof(double));
- jit_fputargr(p, FR(7), sizeof(double));
- jit_fputargr(p, FR(8), sizeof(double));
- jit_fputargi(p, 222.222, sizeof(double));
- //jit_fputargr(p, FR(9), sizeof(double));
- jit_call(p, foobar);
-
- jit_reti(p, 0);
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(0, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-
-}
-
-DEFINE_TEST(test2)
-{
- correct_result = 2;
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_fmovi(p, FR(0), -1);
- jit_fmovi(p, FR(1), 1);
- jit_fmovi(p, FR(2), 2);
- jit_fmovi(p, FR(3), 4);
- jit_fmovi(p, FR(4), 8);
- jit_fmovi(p, FR(5), 16);
- jit_fmovi(p, FR(6), 32);
- jit_fmovi(p, FR(7), 64);
- jit_fmovi(p, FR(8), 128);
- jit_fmovi(p, FR(9), 256);
- //jit_movi(p, R(10), 123);
-
- jit_prepare(p);
- jit_fputargr(p, FR(0), sizeof(float));
- jit_fputargr(p, FR(1), sizeof(float));
- jit_fputargr(p, FR(2), sizeof(float));
- jit_fputargr(p, FR(3), sizeof(float));
- jit_fputargr(p, FR(4), sizeof(float));
- jit_fputargr(p, FR(5), sizeof(float));
- jit_fputargr(p, FR(6), sizeof(float));
- jit_fputargr(p, FR(7), sizeof(float));
- jit_fputargr(p, FR(8), sizeof(float));
- jit_fputargi(p, 222.222, sizeof(float));
- jit_fputargr(p, FR(9), sizeof(float));
- jit_call(p, barbaz);
-
- jit_reti(p, 0);
-
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(0, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-}
-
-DEFINE_TEST(test3)
-{
- correct_result = 2;
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_prepare(p);
- jit_fputargi(p, -1.0, sizeof(double));
- jit_fputargi(p, 1.0, sizeof(double));
- jit_fputargi(p, 2.0, sizeof(double));
- jit_fputargi(p, 4.0, sizeof(double));
- jit_fputargi(p, 8.0, sizeof(double));
- jit_fputargi(p, 16.0, sizeof(double));
- jit_fputargi(p, 32.0, sizeof(double));
- jit_fputargi(p, 64.0, sizeof(double));
- jit_fputargi(p, 128.0, sizeof(double));
- jit_fputargi(p, 222.222, sizeof(double));
- jit_call(p, foobar);
-
- jit_reti(p, 0);
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(0, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-}
-
-DEFINE_TEST(test4)
-{
- correct_result = 2;
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_prepare(p);
- jit_fputargi(p, -1.0, sizeof(float));
- jit_fputargi(p, 1.0, sizeof(float));
- jit_fputargi(p, 2.0, sizeof(float));
- jit_fputargi(p, 4.0, sizeof(float));
- jit_fputargi(p, 8.0, sizeof(float));
- jit_fputargi(p, 16.0, sizeof(float));
- jit_fputargi(p, 32.0, sizeof(float));
- jit_fputargi(p, 64.0, sizeof(float));
- jit_fputargi(p, 128.0, sizeof(float));
- jit_fputargi(p, 222.222, sizeof(float));
- jit_fputargi(p, 256.0, sizeof(float));
- jit_call(p, barbaz);
-
- jit_reti(p, 0);
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(0, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-}
-
-
-DEFINE_TEST(test5)
-{
- correct_result = 2;
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_fmovi(p, FR(9), 222.222);
- jit_fmovi(p, FR(0), -1);
- jit_fmovi(p, FR(1), 1);
- jit_fmovi(p, FR(2), 2);
- jit_fmovi(p, FR(3), 4);
- jit_fmovi(p, FR(4), 8);
- jit_fmovi(p, FR(5), 16);
- jit_fmovi(p, FR(6), 32);
- jit_fmovi(p, FR(7), 64);
- jit_fmovi(p, FR(8), 128);
-
- jit_prepare(p);
- jit_fputargr(p, FR(0), sizeof(double));
- jit_fputargr(p, FR(1), sizeof(double));
- jit_fputargr(p, FR(2), sizeof(double));
- jit_fputargr(p, FR(3), sizeof(double));
- jit_fputargr(p, FR(4), sizeof(double));
- jit_fputargr(p, FR(5), sizeof(double));
- jit_fputargr(p, FR(6), sizeof(double));
- jit_fputargr(p, FR(7), sizeof(double));
- jit_fputargr(p, FR(8), sizeof(double));
- jit_fputargr(p, FR(9), sizeof(double));
- jit_call(p, foobar);
-
- jit_reti(p, 0);
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(0, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-}
-
-DEFINE_TEST(test6)
-{
- correct_result = 2;
- plfv foo;
-
- jit_prolog(p, &foo);
-
- jit_fmovi(p, FR(9), 256);
- jit_fmovi(p, FR(0), -1);
- jit_fmovi(p, FR(1), 1);
- jit_fmovi(p, FR(2), 2);
- jit_fmovi(p, FR(3), 4);
- jit_fmovi(p, FR(4), 8);
- jit_fmovi(p, FR(5), 16);
- jit_fmovi(p, FR(6), 32);
- jit_fmovi(p, FR(7), 64);
- jit_fmovi(p, FR(8), 128);
- //jit_movi(p, R(10), 123);
-
- jit_prepare(p);
- jit_fputargr(p, FR(0), sizeof(float));
- jit_fputargr(p, FR(1), sizeof(float));
- jit_fputargr(p, FR(2), sizeof(float));
- jit_fputargr(p, FR(3), sizeof(float));
- jit_fputargr(p, FR(4), sizeof(float));
- jit_fputargr(p, FR(5), sizeof(float));
- jit_fputargr(p, FR(6), sizeof(float));
- jit_fputargr(p, FR(7), sizeof(float));
- jit_fputargr(p, FR(8), sizeof(float));
- jit_fputargi(p, 222.222, sizeof(float));
- jit_fputargr(p, FR(9), sizeof(float));
- jit_call(p, barbaz);
-
- jit_reti(p, 0);
-
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(0, foo());
- ASSERT_EQ(1, correct_result);
- return 0;
-}
-
-
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
- SETUP_TEST(test2);
- SETUP_TEST(test3);
- SETUP_TEST(test4);
- SETUP_TEST(test5);
- SETUP_TEST(test6);
-}
diff --git a/ext/myjit/test/t109-fp-allocaireg.c b/ext/myjit/test/t109-fp-allocaireg.c
deleted file mode 100755
index 9122db8..0000000
--- a/ext/myjit/test/t109-fp-allocaireg.c
+++ /dev/null
@@ -1,100 +0,0 @@
-#define JIT_REGISTER_TEST
-#include "tests.h"
-#include "simple-buffer.c"
-
-#define BLOCK_SIZE (16)
-
-int correct_result;
-
-static int foobar(double a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
-{
- correct_result = 1;
- if (!equals(a1, -1, 0.0001)) correct_result = 0;
- if (!equals(a2, 1, 0.0001)) correct_result = 0;
- if (!equals(a3, 2, 0.0001)) correct_result = 0;
- if (!equals(a4, 4, 0.0001)) correct_result = 0;
- if (!equals(a5, 8, 0.0001)) correct_result = 0;
- if (!equals(a6, 16, 0.0001)) correct_result = 0;
- if (!equals(a7, 32, 0.0001)) correct_result = 0;
- if (!equals(a8, 64, 0.0001)) correct_result = 0;
- if (!equals(a9, 128, 0.0001)) correct_result = 0;
- if (!equals(a10, 256, 0.0001)) correct_result = 0;
- return 666;
-}
-
-DEFINE_TEST(test1)
-{
- correct_result = 2;
- static char * msg2 = "%u ";
-
- plfv foo;
-
- jit_prolog(p, &foo);
- int i = jit_allocai(p, BLOCK_SIZE);
-
- // loads into the allocated memory multiples of 3
- jit_movi(p, R(0), 0); // index
- jit_addi(p, R(1), R_FP, i); // pointer to the allocated memory
- jit_label * lab = jit_get_label(p);
- jit_muli(p, R(2), R(0), 3);
- jit_stxr(p, R(1), R(0), R(2), 1);
- jit_addi(p, R(0), R(0), 1);
- jit_blti(p, lab, R(0), BLOCK_SIZE);
-
- // does something with registers
- jit_fmovi(p, FR(0), -1);
- jit_fmovi(p, FR(1), 1);
- jit_fmovi(p, FR(2), 2);
- jit_fmovi(p, FR(3), 4);
- jit_fmovi(p, FR(4), 8);
- jit_fmovi(p, FR(5), 16);
- jit_fmovi(p, FR(6), 32);
- jit_fmovi(p, FR(7), 64);
- jit_fmovi(p, FR(8), 128);
- jit_fmovi(p, FR(9), 256);
-
- jit_prepare(p);
- jit_fputargr(p, FR(0), sizeof(double));
- jit_fputargr(p, FR(1), sizeof(double));
- jit_fputargr(p, FR(2), sizeof(double));
- jit_fputargr(p, FR(3), sizeof(double));
- jit_fputargr(p, FR(4), sizeof(double));
- jit_fputargr(p, FR(5), sizeof(double));
- jit_fputargr(p, FR(6), sizeof(double));
- jit_fputargr(p, FR(7), sizeof(double));
- jit_fputargr(p, FR(8), sizeof(double));
- jit_fputargr(p, FR(9), sizeof(double));
- jit_call(p, foobar);
-
- // print outs allocated memory
-
- jit_movi(p, R(0), 0); // index
- jit_addi(p, R(1), R_FP, i); // pointer to the allocated memory
- jit_label * lab2 = jit_get_label(p);
-
- jit_ldxr(p, R(2), R(1), R(0), 1);
-
- jit_prepare(p);
- jit_putargi(p, BUFFER_PUT);
- jit_putargi(p, msg2);
- jit_putargr(p, R(2));
- jit_call(p, simple_buffer);
-
- jit_addi(p, R(0), R(0), 1);
- jit_blti(p, lab2, R(0), BLOCK_SIZE);
-
- jit_retr(p, R(0));
-
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(16, foo());
- ASSERT_EQ(1, correct_result);
- ASSERT_EQ_STR("0 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 ", simple_buffer(BUFFER_GET, NULL));
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
-}
diff --git a/ext/myjit/test/t200-callr.c b/ext/myjit/test/t200-callr.c
deleted file mode 100755
index 617fa6f..0000000
--- a/ext/myjit/test/t200-callr.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "tests.h"
-
-static int foo(int a, int b)
-{
- return a * a + b * b;
-}
-
-DEFINE_TEST(test1)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 10);
- jit_addi(p, R(1), R(0), 1);
- jit_addr(p, R(2), R(0), R(1));
- jit_addr(p, R(3), R(2), R(1));
- jit_addr(p, R(4), R(3), R(0));
- jit_addr(p, R(5), R(0), R(1));
- //jit_addr(p, R(6), R(2), R(3));
- //jit_addr(p, R(7), R(4), R(5));
- //jit_addr(p, R(8), R(0), R(1));
- //jit_addr(p, R(9), R(2), R(3));
- jit_addr(p, R(10), R(4), R(5));
- jit_movi(p, R(11), foo);
-
- jit_prepare(p);
- jit_putargi(p, 2);
- jit_putargi(p, 3);
- jit_callr(p, R(11));
- jit_retval(p, R(0));
- jit_addr(p, R(0), R(0), R(10));
- jit_retr(p, R(0));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(76, f1());
- return 0;
-}
-
-
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
-}
diff --git a/ext/myjit/test/t201-functions.c b/ext/myjit/test/t201-functions.c
deleted file mode 100755
index eb6944f..0000000
--- a/ext/myjit/test/t201-functions.c
+++ /dev/null
@@ -1,165 +0,0 @@
-#include "tests.h"
-
-typedef jit_value (*plfsss)(short, short, short);
-typedef jit_value (*plfiui)(int, unsigned int);
-typedef jit_value (*plfuc)(unsigned char);
-typedef jit_value (*plfus)(unsigned short);
-typedef jit_value (*plfpcus)(char *, unsigned short);
-
-// function which computes an average of three numbers each occupying 2 bytes
-DEFINE_TEST(test1)
-{
- plfsss f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(short));
- jit_getarg(p, R(0), 0);
- jit_getarg(p, R(1), 1);
- jit_addr(p, R(0), R(0), R(1));
- jit_getarg(p, R(1), 2);
- jit_addr(p, R(0), R(0), R(1));
- jit_divi(p, R(0), R(0), 3);
- jit_retr(p, R(0));
-
- // TEST 2
- // function which computes n^m
-
- plfiui f2;
- jit_prolog(p, &f2);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(int));
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(int));
- jit_getarg(p, R(0), 0);
- jit_getarg(p, R(1), 1);
-
- jit_movi(p, R(2), 1);
-
- jit_label * loop = jit_get_label(p);
- jit_op * end = jit_beqi(p, JIT_FORWARD, R(1), 0);
- jit_mulr(p, R(2), R(2), R(0));
- jit_subi(p, R(1), R(1), 1);
- jit_jmpi(p, loop);
-
- jit_patch(p, end);
- jit_retr(p, R(2));
-
- // TEST 3
- // function which computes factorial
- plfuc f3;
-
- jit_prolog(p, &f3);
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(char));
- jit_getarg(p, R(0), 0);
-
- jit_movi(p, R(1), 1);
-
- jit_label * loop2 = jit_get_label(p);
-
- jit_op * end2 = jit_beqi(p, JIT_FORWARD, R(0), 0);
-
- jit_mulr(p, R(1), R(1), R(0));
- jit_subi(p, R(0), R(0), 1);
-
- jit_jmpi(p, loop2);
- jit_patch(p, end2);
- jit_retr(p, R(1));
-
- // TEST 4
- // function which computes fibonacci's number
- plfus f4;
-
- jit_label * fib = jit_get_label(p);
- jit_prolog(p, &f4);
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(short));
-
- jit_getarg(p, R(0), 0);
-
- jit_op * br = jit_blti_u(p, JIT_FORWARD, R(0), 3);
-
- jit_subi(p, R(0), R(0), 1);
-
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_call(p, fib);
-
- jit_retval(p, R(1));
-
- jit_getarg(p, R(0), 0);
- jit_subi(p, R(0), R(0), 2);
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_call(p, fib);
-
- jit_retval(p, R(2));
-
- jit_addr(p, R(0), R(1), R(2));
-
- jit_retr(p, R(0));
-
- jit_patch(p, br);
- jit_reti(p, 1);
-
- // TEST 5
-
- plfpcus f5; // string, radix -> long
-
- jit_prolog(p, &f5);
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(long));
- jit_declare_arg(p, JIT_UNSIGNED_NUM, sizeof(short));
-
- // R(0): string
- // R(1): radix
- // R(2): position in string
- // R(3): current char
- // R(4): result
- jit_getarg(p, R(0), 0);
- jit_getarg(p, R(1), 1);
- jit_movi(p, R(2), 0);
- jit_movi(p, R(4), 0);
-
- jit_label * loop3 = jit_get_label(p);
-
- jit_ldxr_u(p, R(3), R(0), R(2), 1);
- jit_op * end3 = jit_beqi(p, JIT_FORWARD, R(3), 0);
- jit_op * lowercase = jit_bgti_u(p, JIT_FORWARD, R(3), 'Z');
- jit_op * uppercase = jit_bgti_u(p, JIT_FORWARD, R(3), '9');
- jit_subi(p, R(3), R(3), '0');
- jit_op * comput = jit_jmpi(p, JIT_FORWARD);
-
- // is upper case char
- jit_patch(p, uppercase);
- jit_subi(p, R(3), R(3), 'A' - 10);
- jit_op * comput0 = jit_jmpi(p, JIT_FORWARD);
-
- jit_patch(p, lowercase);
- jit_subi(p, R(3), R(3), 'a' - 10);
- jit_op * comput1 = jit_jmpi(p, JIT_FORWARD);
-
- // computations
- jit_patch(p, comput);
- jit_patch(p, comput0);
- jit_patch(p, comput1);
- jit_mulr(p, R(4), R(4), R(1));
- jit_addr(p, R(4), R(4), R(3));
- jit_addi(p, R(2), R(2), 1);
- jit_jmpi(p, loop3);
-
- jit_patch(p, end3);
- jit_retr(p, R(4));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(10, f1(20, 20, -10));
- ASSERT_EQ(81, f2(3, 4));
- ASSERT_EQ(-27, f2(-3, 3));
- ASSERT_EQ(120, f3(5));
- ASSERT_EQ(832040, f4(30));
- ASSERT_EQ(31, f5("1f", 16));
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test1);
-}
diff --git a/ext/myjit/test/t202-highmem.c b/ext/myjit/test/t202-highmem.c
deleted file mode 100755
index e1fffa9..0000000
--- a/ext/myjit/test/t202-highmem.c
+++ /dev/null
@@ -1,54 +0,0 @@
-#undef _XOPEN_SOURCE
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <sys/mman.h>
-
-#include "tests.h"
-
-#ifndef MAP_ANONYMOUS
- #define MAP_ANONYMOUS MAP_ANON
-#endif
-
-static unsigned char *xxx_alloc_addr = (void *)0x100000000000UL;
-
-static inline jit_value jit_value_align(jit_value value, jit_value alignment)
-{
- return (value + (alignment - 1)) & (- alignment);
-}
-
-void *xxx_alloc(size_t size)
-{
- size = jit_value_align(size, sysconf(_SC_PAGE_SIZE));
- if (size == 0) size = sysconf(_SC_PAGE_SIZE);
- void *result = mmap(xxx_alloc_addr, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE , -1, 0);
- xxx_alloc_addr += size;
- return result;
-}
-
-void xxx_free(void *obj)
-{
-}
-
-DEFINE_TEST(test1)
-{
- pdfv f1;
- jit_prolog(p, &f1);
- jit_fmovi(p, FR(0), 12.3);
- jit_faddi(p, FR(0), FR(0), 11.1);
- jit_fretr(p, FR(0), sizeof(double));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_DOUBLE(23.4, f1());
-
- return 0;
-}
-
-
-
-void test_setup()
-{
- test_filename = __FILE__;
-#ifdef JIT_ARCH_AMD64
- SETUP_TEST(test1);
-#endif
-}
diff --git a/ext/myjit/test/t301-optim-adds.c b/ext/myjit/test/t301-optim-adds.c
deleted file mode 100755
index 02a8e98..0000000
--- a/ext/myjit/test/t301-optim-adds.c
+++ /dev/null
@@ -1,165 +0,0 @@
-#include "tests.h"
-
-DEFINE_TEST(test10)
-{
- plfv f1;
- jit_prolog(p, &f1);
- //jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_muli(p, R(2), R(1), 2);
- jit_addi(p, R(2), R(2), 123);
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15 * 2 + 123, f1());
- return 0;
-}
-
-DEFINE_TEST(test20)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_muli(p, R(2), R(1), 2);
- jit_addr(p, R(2), R(2), R(0));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15 * 2 + 7, f1());
- return 0;
-}
-
-DEFINE_TEST(test21)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_muli(p, R(2), R(1), 2);
- jit_addr(p, R(2), R(0), R(2));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15 * 2 + 7, f1());
- return 0;
-}
-
-DEFINE_TEST(test22)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_muli(p, R(1), R(0), 4);
- jit_ori(p, R(1), R(1), 2);
- jit_retr(p, R(1));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(7 * 4 + 2, f1());
- return 0;
-}
-
-DEFINE_TEST(test23)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_lshi(p, R(1), R(0), 2);
- jit_ori(p, R(1), R(1), 2);
- jit_retr(p, R(1));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(7 * 4 + 2, f1());
- return 0;
-}
-
-DEFINE_TEST(test30)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_addi(p, R(2), R(1), 2);
- jit_addr(p, R(2), R(0), R(2));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15 + 2 + 7, f1());
- return 0;
-}
-
-DEFINE_TEST(test31)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_addi(p, R(2), R(1), 2);
- jit_addr(p, R(2), R(2), R(0));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15 + 2 + 7, f1());
- return 0;
-}
-
-DEFINE_TEST(test33)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_addi(p, R(3), R(1), 2);
- jit_addr(p, R(2), R(3), R(0));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15 + 2 + 7, f1());
- return 0;
-}
-
-
-DEFINE_TEST(test34)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_addi(p, R(3), R(1), 2);
- jit_addr(p, R(2), R(0), R(3));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15 + 2 + 7, f1());
- return 0;
-}
-
-DEFINE_TEST(test35)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_addr(p, R(3), R(0), R(1));
- jit_addi(p, R(2), R(3), 20);
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(15 + 7 + 20, f1());
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test10);
- SETUP_TEST(test20);
- SETUP_TEST(test21);
- SETUP_TEST(test22);
- SETUP_TEST(test23);
- SETUP_TEST(test30);
- SETUP_TEST(test31);
- SETUP_TEST(test33);
- SETUP_TEST(test34);
- SETUP_TEST(test35);
-}
diff --git a/ext/myjit/test/t302-optim-stores.c b/ext/myjit/test/t302-optim-stores.c
deleted file mode 100755
index b44ec20..0000000
--- a/ext/myjit/test/t302-optim-stores.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "tests.h"
-
-DEFINE_TEST(test10)
-{
- static unsigned char data;
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(1), &data);
- jit_movi(p, R(2), 10);
- jit_str(p, R(1), R(2), 1);
-
- jit_reti(p, 0);
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(0, f1());
- ASSERT_EQ(10, data);
- return 0;
-}
-
-DEFINE_TEST(test11)
-{
- static unsigned int data;
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(2), 10);
- jit_sti(p, (unsigned char *)&data, R(2), 4);
-
- jit_reti(p, 0);
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(0, f1());
- ASSERT_EQ(10, data);
- return 0;
-}
-
-DEFINE_TEST(test12)
-{
- static unsigned char data[10];
- plfv f1;
- jit_prolog(p, &f1);
- jit_movi(p, R(1), data);
- jit_movi(p, R(2), 3);
- jit_movi(p, R(3), 10);
- jit_stxr(p, R(1), R(2), R(3), 1);
-
- jit_reti(p, 0);
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(0, f1());
- ASSERT_EQ(10, data[3]);
- return 0;
-}
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test10);
- SETUP_TEST(test11);
- SETUP_TEST(test12);
-}
diff --git a/ext/myjit/test/t401-data-in-code.c b/ext/myjit/test/t401-data-in-code.c
deleted file mode 100755
index 19ad386..0000000
--- a/ext/myjit/test/t401-data-in-code.c
+++ /dev/null
@@ -1,306 +0,0 @@
-#include "tests.h"
-
-DEFINE_TEST(test10)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_op *skip_data = jit_jmpi(p, JIT_FORWARD);
-
- jit_data_byte(p, 0xaa);
- jit_data_byte(p, 0xbb);
-
- jit_data_str(p, "Hello!");
-
- jit_data_emptyarea(p, 10);
- jit_data_qword(p, 0xaabbccdd00112233);
- jit_code_align(p, 16);
-
- jit_patch(p, skip_data);
- jit_movi(p, R(0), 7);
- jit_movi(p, R(1), 15);
- jit_addr(p, R(2), R(0), R(1));
- jit_retr(p, R(2));
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(7 + 15, f1());
- return 0;
-}
-
-int check_func(char *str) {
- if (!strcmp(str, "ABCDEF!")) return 42;
- return -1;
-}
-
-DEFINE_TEST(test11)
-{
- plfv f1;
- jit_prolog(p, &f1);
- jit_op *skip_data = jit_jmpi(p, JIT_FORWARD);
-
- // data
- jit_data_byte(p, 0xaa);
- jit_data_byte(p, 0xbb);
-
- jit_label *label_string = jit_get_label(p);
- jit_data_str(p, "ABCDEF!");
-
- jit_code_align(p, 32);
-
-
- // code
- jit_patch(p, skip_data);
-
- jit_ref_data(p, R(0), label_string);
-
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_call(p, check_func);
- jit_retval(p, R(0));
-
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(42, f1());
- return 0;
-}
-
-DEFINE_TEST(test12)
-{
- plfv f1;
- jit_prolog(p, &f1);
-
- jit_op * label_string = jit_ref_data(p, R(0), JIT_FORWARD);
- jit_prepare(p);
- jit_putargr(p, R(0));
- jit_call(p, check_func);
- jit_retval(p, R(0));
- jit_retr(p, R(0));
-
- // data
- jit_code_align(p,32);
- jit_data_byte(p, 0xaa);
- jit_data_byte(p, 0xbb);
-
- jit_patch(p, label_string);
- jit_data_str(p, "ABCDEF!");
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(42, f1());
- return 0;
-}
-
-DEFINE_TEST(test13)
-{
- plfv f1;
- jit_prolog(p, &f1);
-
- jit_movi(p, R(0), 0xaa);
-
- jit_op *target_addr = jit_ref_code(p, R(1), JIT_FORWARD);
-
- jit_jmpr(p, R(1));
-
- jit_patch(p, target_addr);
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
- ASSERT_EQ(0xaa, f1());
- return 0;
-}
-
-DEFINE_TEST(test14)
-{
- plfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(int));
-
- jit_movi(p, R(0), 10);
-
- jit_op *target1_addr = jit_ref_code(p, R(1), JIT_FORWARD);
- jit_op *target2_addr = jit_ref_code(p, R(2), JIT_FORWARD);
-
- jit_movr(p, R(3), R(1));
- jit_movi(p, R(4), 20);
- jit_getarg(p, R(5), 0);
-
- jit_op *skip = jit_bgti(p, JIT_FORWARD, R(5), 0);
-
- jit_movr(p, R(3), R(2));
- jit_movi(p, R(4), 40);
-
- jit_patch(p, skip);
-
-
-
- jit_jmpr(p, R(3));
-
- jit_code_align(p, 16);
- jit_patch(p, target1_addr);
- jit_addr(p, R(0), R(0), R(4));
- jit_addr(p, R(0), R(0), R(5));
-
- jit_retr(p, R(0));
-
-
- jit_code_align(p, 16);
- jit_patch(p, target2_addr);
- jit_subr(p, R(0), R(0), R(4));
- jit_subr(p, R(0), R(0), R(5));
-
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(10 + 1 + 20, f1(1));
- ASSERT_EQ(10 + 1 - 40, f1(-1));
- return 0;
-}
-
-
-DEFINE_TEST(test15)
-{
- plfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(int));
-
- jit_op *skip = jit_jmpi(p, JIT_FORWARD);
- jit_code_align(p, 16);
-
- // data
- jit_comment(p, "\ndata\n");
- jit_label *data_addr = jit_get_label(p);
- jit_op *target1_addr = jit_data_ref_code(p, JIT_FORWARD);
- jit_op *target2_addr = jit_data_ref_code(p, JIT_FORWARD);
- jit_code_align(p, 16);
-
-
- // code
- jit_comment(p, "code");
- jit_patch(p, skip);
- jit_movi(p, R(0), 10);
- jit_getarg(p, R(1), 0);
- jit_ref_data(p, R(2), data_addr);
-
- jit_muli(p, R(3), R(1), PTR_SIZE);
- jit_ldxr(p, R(2), R(2), R(3), PTR_SIZE);
-
- jit_jmpr(p, R(2));
-
- jit_patch(p, target1_addr);
- jit_addr(p, R(0), R(0), R(1));
- jit_retr(p, R(0));
-
- jit_patch(p, target2_addr);
- jit_subr(p, R(0), R(0), R(1));
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(10, f1(0));
- ASSERT_EQ(9, f1(1));
- return 0;
-}
-
-DEFINE_TEST(test16)
-{
- ppfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(int));
-
- jit_op *skip = jit_jmpi(p, JIT_FORWARD);
- jit_code_align(p, 16);
-
- // data
- jit_comment(p, "data: days of week");
- jit_label *lb_mon = jit_get_label(p);
- jit_data_str(p, "Monday");
- jit_label *lb_tue = jit_get_label(p);
- jit_data_str(p, "Tuesday");
- jit_label *lb_wed = jit_get_label(p);
- jit_data_str(p, "Wednesday");
- jit_label *lb_thr = jit_get_label(p);
- jit_data_str(p, "Thursday");
- jit_label *lb_fri = jit_get_label(p);
- jit_data_str(p, "Friday");
- jit_code_align(p, 16);
-
-
- jit_comment(p, "data: branch table");
- jit_label *data_addr = jit_get_label(p);
- jit_data_ref_data(p, lb_mon);
- jit_data_ref_data(p, lb_tue);
- jit_data_ref_data(p, lb_wed);
- jit_data_ref_data(p, lb_thr);
- jit_data_ref_data(p, lb_fri);
- jit_code_align(p, 16);
-
-
- // code
- jit_patch(p, skip);
- jit_getarg(p, R(1), 0);
- jit_ref_data(p, R(2), data_addr);
-
- jit_muli(p, R(3), R(1), PTR_SIZE);
- jit_ldxr(p, R(0), R(2), R(3), PTR_SIZE);
-
- jit_retr(p, R(0));
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ_STR("Wednesday", f1(2));
- return 0;
-}
-
-DEFINE_TEST(test17)
-{
- plfl f1;
- jit_prolog(p, &f1);
- jit_declare_arg(p, JIT_SIGNED_NUM, sizeof(int));
-
- jit_op *branch_table = jit_ref_data(p, R(0), JIT_FORWARD);
- jit_getarg(p, R(1), 0);
- jit_muli(p, R(1), R(1), PTR_SIZE);
- jit_ldxr(p, R(2), R(1), R(0), PTR_SIZE);
- jit_jmpr(p, R(2));
-
- // branches
- jit_label *branch1 = jit_get_label(p);
- jit_reti(p, 10);
-
- jit_label *branch2 = jit_get_label(p);
- jit_reti(p, 20);
-
- jit_label *branch3 = jit_get_label(p);
- jit_reti(p, 30);
-
- // branch table
- jit_code_align(p, 16);
- jit_patch(p, branch_table);
- jit_data_ref_code(p, branch1);
- jit_data_ref_code(p, branch2);
- jit_data_ref_code(p, branch3);
-
- JIT_GENERATE_CODE(p);
-
- ASSERT_EQ(10, f1(0));
- ASSERT_EQ(20, f1(1));
- ASSERT_EQ(30, f1(2));
- return 0;
-}
-
-
-
-void test_setup()
-{
- test_filename = __FILE__;
- SETUP_TEST(test10);
- SETUP_TEST(test11);
- SETUP_TEST(test12);
- SETUP_TEST(test13);
- SETUP_TEST(test14);
- SETUP_TEST(test15);
- SETUP_TEST(test16);
- SETUP_TEST(test17);
-}
diff --git a/ext/myjit/test/tests.h b/ext/myjit/test/tests.h
deleted file mode 100755
index 5361aab..0000000
--- a/ext/myjit/test/tests.h
+++ /dev/null
@@ -1,165 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include "../myjit/jitlib.h"
-
-typedef jit_value (*plfv)(void);
-typedef jit_value (*plfl)(jit_value);
-typedef jit_value (*plfll)(jit_value, jit_value);
-typedef double (*pdfv)(void);
-typedef float (*pffv)(void);
-typedef double (*pdfd)(double);
-typedef jit_value (*plfd)(double);
-typedef void * (*ppfl)(jit_value);
-
-#define DUMP_OPS 0x01
-#define DUMP_CODE 0x02
-#define DUMP_COMBINED 0x04
-#define DUMP_COMPILABLE 0x08
-#define DUMP_ASSOC 0x10
-#define DUMP_LIVENESS 0x20
-#define DUMP_LOADS 0x40
-#define OPT_LIST 0x100
-#define OPT_ALL 0x200
-
-
-#define TOLERANCE 0.00001
-#define MAX_NUMBER_OF_TEST (1024)
-
-typedef int(*test_case_fn)(struct jit *, char *, int);
-test_case_fn test_cases[MAX_NUMBER_OF_TEST];
-char * test_names[MAX_NUMBER_OF_TEST];
-int test_cnt = 0;
-char *test_filename;
-
-#define DEFINE_TEST(_name) \
- int _name(struct jit *p, char *test_name, int test_flags)
-
-#define SETUP_TEST(name) \
- test_cases[test_cnt] = name;\
- test_names[test_cnt] = "" #name "";\
- test_cnt++;
-
-#define JIT_GENERATE_CODE(p) { \
- jit_check_code(p, JIT_WARN_ALL); \
- if (test_flags & DUMP_COMPILABLE) jit_dump_ops(p, JIT_DEBUG_COMPILABLE); \
- jit_generate_code(p); \
- if (test_flags & (DUMP_OPS | DUMP_ASSOC | DUMP_LIVENESS)) \
- jit_dump_ops(p, JIT_DEBUG_OPS | \
- (test_flags & DUMP_ASSOC ? JIT_DEBUG_ASSOC : 0) | \
- (test_flags & DUMP_LIVENESS ? JIT_DEBUG_LIVENESS : 0) | \
- (test_flags & DUMP_LOADS ? JIT_DEBUG_LOADS: 0) ); \
- if (test_flags & DUMP_CODE) jit_dump_ops(p, JIT_DEBUG_CODE); \
- if (test_flags & DUMP_COMBINED) jit_dump_ops(p, JIT_DEBUG_COMBINED); \
-}
-
-
-#define ASSERT_EQ(_expected, _actual) { \
- if ((_expected) != (_actual)) {\
- fprintf(stderr, "%s: %s at line %i (expected: %li, actual: %li)\n", test_filename, test_name, __LINE__, (jit_value)(_expected), (jit_value)(_actual)); \
- return 1; \
- } \
-}
-
-#define ASSERT_EQ_DOUBLE(_expected, _actual) { \
- if (!equals((_expected), (_actual), TOLERANCE)) {\
- fprintf(stderr, "%s: %s at line %i (expected: %f, actual: %f)\n", test_filename, test_name, __LINE__, (double)(_expected), (double)(_actual)); \
- return 1; \
- } \
-}
-
-#define ASSERT_EQ_STR(_expected, _actual) { \
- if (strcmp((_expected), (_actual))) {\
- fprintf(stderr, "%s: %s at line %i (expected: %s, actual: %s)\n", test_filename, test_name, __LINE__, (char *)(_expected), (char *)(_actual)); \
- return 1; \
- } \
-}
-
-#define IGNORE_TEST { \
- fprintf(stderr, " \033[1;33m??\033[0m %s: %s ignored\n", test_filename, test_name); \
- return -1;\
-}
-
-static inline int equals(double x, double y, double tolerance)
-{
- return fabs(x - y) < tolerance;
-}
-
-void test_setup();
-
-int run_test(int id, int options)
-{
- struct jit *p = jit_init();
- int result = test_cases[id](p, test_names[id], options);
- jit_free(p);
- return result;
-}
-
-void report_results_and_quit(int successful, int ignored, int total)
-{
- total -= ignored;
- int ok = (total == successful);
- if (ok) printf(" \033[1;32mOK\033[0m ");
- else printf(" \033[1;31m!!\033[0m ");
- printf("%-25s %i/%i\n", test_filename, successful, total);
- exit(ok ? 0 : 1);
-}
-
-int main(int argc, char **argv)
-{
- int options = 0;
- int successful = 0;
- int ignored = 0;
- if (argc == 1) options |= OPT_ALL;
-
- for (int i = 1; i < argc; i++) {
- if (!strcmp("--ops", argv[i])) options |= DUMP_OPS;
- if (!strcmp("--code", argv[i])) options |= DUMP_CODE;
- if (!strcmp("--compilable", argv[i])) options |= DUMP_COMPILABLE;
- if (!strcmp("--combined", argv[i])) options |= DUMP_COMBINED;
- if (!strcmp("--assoc", argv[i])) options |= DUMP_ASSOC;
- if (!strcmp("--loads", argv[i])) options |= DUMP_LOADS;
- if (!strcmp("--liveness", argv[i])) options |= DUMP_LIVENESS;
- if (!strcmp("-l", argv[i])) options |= OPT_LIST;
- if (!strcmp("--all", argv[i])) options |= OPT_ALL;
- }
-
- test_setup();
-
- if (options & OPT_LIST) {
- for (int i = 0; i < test_cnt; i++)
- printf("%s\n", test_names[i]);
- return 0;
- }
-
- if (options & OPT_ALL) {
- for (int i = 0; i < test_cnt; i++) {
- int status = run_test(i, options);
- if (status == 0) successful++;
- if (status < 0) ignored++;
- }
- report_results_and_quit(successful, ignored, test_cnt);
- }
-
- int performed = 0;
- for (int i = 1; i < argc; i++) {
- char *name = argv[i];
- if (name[0] == '-') continue;
-
- int found = 0;
- for (int j = 0; j < test_cnt; j++) {
- if (!strcmp(test_names[j], name)) {
- performed++;
- int status = run_test(j, options);
- if (status == 0) successful++;
- if (status < 0) ignored++;
- found = 1;
- break;
- }
- }
- if (!found) fprintf(stderr, "%s: %s: test not found!\n", test_filename, name);
- }
- report_results_and_quit(successful, ignored, performed);
-
-}
diff --git a/filelist.tcsh b/filelist.tcsh
index 1aab19e..63bf95c 100755
--- a/filelist.tcsh
+++ b/filelist.tcsh
@@ -3,7 +3,6 @@ set CFiles = ( \
"./main.c" \
"./ext/vec/src/vec.c" \
"./ext/map/src/map.c" \
- "./ext/myjit/myjit/jitlib-core.c" \
"./TOSPrint.c" \
"./ext/C_Unescaper/escaper.c" \
"./ext/argtable3/argtable3.c" \
@@ -14,8 +13,10 @@ set CFiles = ( \
"./ext/linenoise/linenoise.c" \
)
set AsmFiles = ( \
+ "./TOSJMP.yasm" \
"./exceptLin.yasm" \
"./debuggerAsm.yasm" \
+ "./FFI_SYSV.yasm" \
)
set HolyCFiles = ( \
@@ -44,21 +45,15 @@ set HolyCFiles = ( \
"./HolyEd/KEYS2.HC" \
"./HolyEd/FONT.HC" \
"./FULL_RUNTIME.HC" \
+ "./PARSER2.HC" \
+ "./CODEGEN.HC" \
)
-set MyjitFiles = (\
- `find ext/myjit/myjit/` \
-)
set HeaderFiles = ( \
`find ext/ -name "*.h"` \
"./3d.h" \
"./poopalloc.h" \
- # IMPORTANT,these files are used like headers so they are put in HeaderFiles \
- "./ext/myjit/myjit/llrb.c" \
- "./ext/myjit/myjit/jitlib-debug.c" \
- "./ext/myjit/myjit/code-check.c" \
- "./ext/myjit/myjit/x86-common-stuff.c" \
"./alloc.h" \
"./rl.h" \
)
@@ -66,5 +61,5 @@ set HeaderFiles = ( \
set MiscFiles = ( \
"./make.tcsh" \
"./filelist.tcsh" \
- "./REPL.VBIN" \
+ "./HCRT/HCRT_TOS.BIN" \
)
diff --git a/filelistWIN.tcsh b/filelistWIN.tcsh
index c00a10f..6509c1d 100755
--- a/filelistWIN.tcsh
+++ b/filelistWIN.tcsh
@@ -3,7 +3,6 @@ set CFiles= ( \
"main.c" \
"ext/vec/src/vec.c" \
"ext/map/src/map.c" \
- "ext/myjit/myjit/jitlib-core.c" \
"TOSPrint.c" \
"ext/C_Unescaper/escaper.c" \
"ext/argtable3/argtable3.c" \
@@ -14,7 +13,9 @@ set CFiles= ( \
)
set AsmFiles = ( \
"exceptWin.yasm" \
- "debuggerAsmWin.yasm" \
+ "debuggerAsm.yasm" \
+ "FFI_WIN64.yasm" \
+ "TOSJMP.yasm" \
)
set HolyCFiles = ( \
@@ -45,19 +46,9 @@ set HolyCFiles = ( \
"HolyEd/FONT.HC" \
)
-set MyjitFiles = (\
- `find ext/myjit/myjit/` \
-)
-
set HeaderFiles = ( \
- `find ext/ -name '*.h' ` \
"3d.h" \
"poopalloc.h" \
- # IMPORTANT,these files are used like headers so they are put in HeaderFiles \
- "ext/myjit/myjit/llrb.c" \
- "ext/myjit/myjit/jitlib-debug.c" \
- "ext/myjit/myjit/code-check.c" \
- "ext/myjit/myjit/x86-common-stuff.c" \
"alloc.h" \
"rl.h" \
)
@@ -65,5 +56,5 @@ set HeaderFiles = ( \
set MiscFiles = ( \
"make.tcsh" \
"filelist.tcsh" \
- "HCRT/HCRT.BIN" \
+ "HCRT/HCRT_TOS.BIN" \
)
diff --git a/main.c b/main.c
index 78de874..382a0c7 100755
--- a/main.c
+++ b/main.c
@@ -5,7 +5,7 @@
#ifndef TARGET_WIN32
#include <sys/syscall.h>
#include <unistd.h>
-#define HCRT_INSTALLTED_DIR "/HolyC/HCRT.BIN"
+#define HCRT_INSTALLTED_DIR "/HolyC/HCRT_TOS.BIN"
#include <libgen.h>
#include "ext/C_Unescaper/escaper.h"
#else
@@ -14,7 +14,7 @@
#include <fileapi.h>
#include <userenv.h>
#include <winnt.h>
-#define HCRT_INSTALLTED_DIR "\\HCRT\\HCRT.BIN"
+#define HCRT_INSTALLTED_DIR "\\HCRT\\HCRT_TOS.BIN"
#endif
static struct arg_lit *helpArg;
static struct arg_lit *dbgArg;
@@ -112,12 +112,12 @@ int main(int argc,char **argv) {
exit(0);
}
PoopInit(__builtin_frame_address(0));
- RegisterFuncPtrs();
+ TOS_RegisterFuncPtrs();
if(1) {
int flags=noRuntime->count?AOT_NO_IMPORT_SYMS:0;
#ifndef TARGET_WIN32
- if(0==access("HCRT/HCRT.BIN",F_OK)) {
- FILE *rt=fopen("HCRT/HCRT.BIN","rb");
+ if(0==access("HCRT/HCRT_TOS.BIN",F_OK)) {
+ FILE *rt=fopen("HCRT/HCRT_TOS.BIN","rb");
LoadAOTBin(rt,flags,&header);
fclose(rt);
} else if(0==access("/usr/local/include" HCRT_INSTALLTED_DIR,F_OK)) {
diff --git a/make.tcsh b/make.tcsh
deleted file mode 100755
index 389ca1f..0000000
--- a/make.tcsh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/tcsh
-source filelist.tcsh
-set CFlags = "-Os -g3 `sdl2-config --cflags --libs` -lm -fno-omit-frame-pointer"
-
-if ! -e HCRT/HCRT.BIN then
- cp REPL.VBIN HCRT/HCRT.BIN
-endif
-
-if ! -e 3d_loader then
- foreach f ( $CFiles )
- gcc $CFlags -c $f -o $f.o || rm $f.o
- end
-else
- foreach f ( $CFiles )
- if $f:t == "jitlib-core.c" then
- if -e $f.obj then
- foreach f2 ( $MyjitFiles )
- set find = `find . -wholename "./$f2" -newer $f.o `
- if($#find) goto compile
- end
- endif
- endif
- set find = `find -wholename $f -newer 3d_loader `
- compile:
- if($#find) gcc $CFlags -c $f -o $f.o || rm $f.o
- end
-endif
-
-if ! -e 3d_loader then
- foreach f ( $AsmFiles )
- yasm -f elf64 $f -o $f.o || rm $f.o
- end
-else
- foreach f ( $AsmFiles )
- set find = `find . -wholename "./$f" -newer 3d_loader `
- if($#find) yasm -f elf64 $f -o $f.o || rm $f.o
- end
-endif
-
-set Objs = ()
-foreach f ( $CFiles )
- set Objs = ( $Objs "$f.o" )
-end
-foreach f ( $AsmFiles )
- set Objs = ( $Objs "$f.o" )
-end
-gcc $Objs `sdl2-config --libs` -lm -o 3d_loader
diff --git a/makeBSD.tcsh b/makeBSD.tcsh
index 3f3ec8e..eb8d01b 100644
--- a/makeBSD.tcsh
+++ b/makeBSD.tcsh
@@ -1,2 +1,41 @@
-alias find gfind
-source make.tcsh
+#!/bin/tcsh
+set gFindLoc = `which gfind`
+set binary = 3d_loader2
+set cc = gcc
+if ! $#gFindLoc then
+ echo "Install findutils for your BSD,im or if your up to it,port this file to use the BSD find."
+ exit
+endif
+source filelist.tcsh
+set CFlags = "-Os -g3 `sdl2-config --cflags --libs` -lm -fno-omit-frame-pointer"
+
+if ! -e $binary then
+ foreach f ( $CFiles )
+ $cc $CFlags -c $f -o $f.o || rm $f.o
+ end
+else
+ foreach f ( $CFiles )
+ set find = `$gFindLoc -wholename ./$f -newer $binary `
+ if($#find) $cc $CFlags -c $f -o $f.o || rm $f.o
+ end
+endif
+
+if ! -e $binary then
+ foreach f ( $AsmFiles )
+ yasm -f elf64 $f -o $f.o || rm $f.o
+ end
+else
+ foreach f ( $AsmFiles )
+ set find = `$gFindLoc -wholename ./$f -newer $binary `
+ if($#find) yasm -f elf64 $f -o $f.o || rm $f.o
+ end
+endif
+
+set Objs = ()
+foreach f ( $CFiles )
+ set Objs = ( $Objs "$f.o" )
+end
+foreach f ( $AsmFiles )
+ set Objs = ( $Objs "$f.o" )
+end
+$cc $Objs `sdl2-config --libs` -lm -o $binary
diff --git a/makeWIN.tcsh b/makeWIN.tcsh
index b396096..b109f02 100755
--- a/makeWIN.tcsh
+++ b/makeWIN.tcsh
@@ -4,10 +4,6 @@ set CC = "x86_64-w64-mingw32-gcc"
set CFlags = "-DTARGET_WIN32 -I./SDL2-mingw64/include -I./SDL2-mingw64/include/SDL2 -Os -g3 -lm -fno-omit-frame-pointer"
-if ! -e HCRT/HCRT.BIN then
- cp REPL.WBIN HCRT/HCRT.BIN
-endif
-
if ! -e 3d_loader.exe then
foreach f ( $CFiles )
$CC $CFlags -c $f -o $f.obj || rm $f.obj
diff --git a/poopalloc.c b/poopalloc.c
index 92bb394..836aca5 100755
--- a/poopalloc.c
+++ b/poopalloc.c
@@ -198,10 +198,10 @@ static CPoopSlab2 *GetSlabByPtr(void *ptr) {
return slab;
}
}
- if(scale*4096<=(1<<17))
- goto loop;
if(LargestAlloc>=scale*4096)
goto loop;
+ if(scale*4096<=(1<<17))
+ goto loop;
return NULL;
}
static void AddSlabToHash(CPoopSlab2 *slab) {
@@ -529,11 +529,12 @@ void *PoopMAlloc(int64_t size) {
assert(MSize(ret)==size);
return ret;
}
-int InBounds(void *ptr,int64_t size) {
+void *BoundsCheck(void *ptr,int64_t size) {
void *fptr;
+ CSymbol *bt;
asm ("movq %%rsp, %0" : "=r" (fptr) );
if(StackStart>=ptr&&ptr>=fptr)
- return 1;
+ return ptr;
LockHeap();
int64_t idx,cnt,size2;
CPoopSlab2 *cur_slab=GetSlabByPtr(ptr);
@@ -585,20 +586,28 @@ int InBounds(void *ptr,int64_t size) {
break;
}
if(!((base+cnt>=ptr+size)&&(base<=ptr))) {
+ bt=map_get(&Loader.symbols,"Backtrace");
+ UnlockHeap();
+ FFI_CALL_TOS_2(bt->value_ptr,-1,0);
if(ptr-(base+cnt)>=0)
fprintf(stderr,"Access is %ld bytes beyond %ld byte area.\n",ptr-(base+cnt),cnt);
else
fprintf(stderr,"Access is %ld bytes before %ld byte area.\n",base-(ptr),cnt);
+ return ptr;
} else {
- UnlockHeap();
- return 1;
+ UnlockHeap();
+ return ptr;
}
} else {
oob:
+ UnlockHeap();
+ bt=map_get(&Loader.symbols,"Backtrace");
+ FFI_CALL_TOS_2(bt->value_ptr,-1,0);
fprintf(stderr,"Access is out of bounds.\n");
+ return ptr;
}
- UnlockHeap();
- return 0;
+
+ return ptr;
}
static int64_t __ScanPtr(void **ptr,int64_t len) {
int64_t idx,cnt=0;
diff --git a/poopalloc.h b/poopalloc.h
index 0147c2d..f6bd699 100755
--- a/poopalloc.h
+++ b/poopalloc.h
@@ -6,5 +6,5 @@ void *PoopReAlloc(void *ptr,int64_t size);
int64_t MSize(void *ptr);
void PoopCollect();
void PoopInit(void *frame_start);
-int InBounds(void *ptr,int64_t size);
+void *BoundsCheck(void *ptr,int64_t size);
int PoopSetGCEnable(int en);
diff --git a/rl.c b/rl.c
index c79fb79..262ba5d 100755
--- a/rl.c
+++ b/rl.c
@@ -93,7 +93,7 @@ static void completion(const char *buf,linenoiseCompletions *lc) {
#endif
CSymbol *hccomps;
if(hccomps=map_get(&Loader.symbols,"__HCCompetions")) {
- char **res=((char**(*)(char*))(hccomps->value_ptr))(buf);
+ char **res=FFI_CALL_TOS_1(hccomps->value_ptr,buf);
if(!res) return;
int64_t cnt=MSize(res)/sizeof(char*),idx;
for(idx=0;idx!=cnt;idx++) {
@@ -127,7 +127,7 @@ static char **AttemptComps(const char *buf,int s,int e) {
CSymbol *hccomps;
count=0;
if(hccomps=map_get(&Loader.symbols,"__HCCompetions")) {
- char **res=((char**(*)(char*))(hccomps->value_ptr))(buf);
+ char **res=FFI_CALL_TOS_1(hccomps->value_ptr,buf);
cmps=res;
if(!res) {
count=0;
diff --git a/runtime.c b/runtime.c
index c9b9b64..ff2dd6d 100755
--- a/runtime.c
+++ b/runtime.c
@@ -9,7 +9,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
-#include <signal.h>
extern int64_t HCSetJmp(void *ptr);
extern void HCLongJmp(void *ptr);
#ifndef MACOS
@@ -38,539 +37,6 @@ extern void HCLongJmp(void *ptr);
#include <sys/mman.h>
#endif
typedef struct CType CType;
-static void *jit_INIT() {
- return jit_init();
-}
-#ifdef TARGET_WIN32
-#include <winnt.h>
-#include <dbghelp.h>
-#endif
-static void *jit_BREAKPOINT(void *jit,void *bp,void *routine,void *ctrl) {
- return jit_breakpoint(jit,bp,routine,ctrl);
-}
-static void jit_GENERATE_CODE(void *jit) {
- jit_generate_code(jit,NULL);
-}
-static int64_t jit_BINSIZE(void *jit) {
- return jit_bin_size(jit);
-}
-static void jit_DUMP_OPS(void *jit,int l) {
- jit_dump_ops(jit,l);
-}
-static int64_t jit_R(int64_t r) {
- return R(r);
-}
-static int64_t jit_FR(int64_t r) {
- return FR(r);
-}
-static int64_t jit_R_FP() {
- return R_FP;
-}
-static void *jit_ANDR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_andr(jit,a,b,c);
-}
-static void *jit_ANDI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_andi(jit,a,b,c);
-}
-static void *jit_GET_LABEL(void *j) {
- return jit_get_label(j);
-}
-static void *jit_PROLOG(void *jit,void *fp) {
- return jit_prolog(jit,fp);
-}
-static void *jit_MOVR(void *jit,int64_t a,int64_t b) {
- return jit_movr(jit,a,b);
-}
-static void *jit_MOVI(void *jit,int64_t a,int64_t b) {
- return jit_movi(jit,a,b);
-}
-static void *jit_JMPR(void *jit,int64_t a) {
- return jit_jmpr(jit,a);
-}
-static void *jit_JMPI(void *jit,int64_t a) {
- return jit_jmpi(jit,a);
-}
-static void *jit_PATCH(void *jit,void *a) {
- return jit_patch(jit,a);
-}
-static void *jit_PREPARE(void *jit) {
- return jit_prepare(jit);
-}
-static void *jit_PUTARGI(void *jit,int64_t a) {
- return jit_putargi(jit,a);
-}
-static void *jit_PUTARGR(void *jit,int64_t a) {
- return jit_putargr(jit,a);
-}
-static void *jit_CALL(void *jit,int64_t a) {
- return jit_call(jit,a);
-}
-static void *jit_CALLR(void *jit,int64_t a) {
- return jit_callr(jit,a);
-}
-static void *jit_DECLARE_ARG(void *jit,int64_t a,int64_t b) {
- return jit_declare_arg(jit,a,b);
-}
-static void *jit_RETR(void *jit,int64_t a) {
- return jit_retr(jit,a);
-}
-static void *jit_RETI(void *jit,int64_t a) {
- return jit_reti(jit,a);
-}
-static void *jit_RETVAL(void *jit,int64_t a) {
- return jit_retval(jit,a);
-}
-static void *jit_GETARG(void *jit,int64_t a,int64_t b) {
- return jit_getarg(jit,a,b);
-}
-static void *jit_ADDR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_addr(jit,a,b,c);
-}
-static void *jit_ADDI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_addi(jit,a,b,c);
-}
-static void *jit_SUBR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_subr(jit,a,b,c);
-}
-static void *jit_SUBI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_subi(jit,a,b,c);
-}
-static void *jit_NEGR(void *jit,int64_t a,int64_t b) {
- return jit_negr(jit,a,b);
-}
-static void *jit_MULR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_mulr(jit,a,b,c);
-}
-static void *jit_MULI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_muli(jit,a,b,c);
-}
-static void *jit_MULR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_mulr_u(jit,a,b,c);
-}
-static void *jit_MULI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_muli_u(jit,a,b,c);
-}
-static void *jit_DIVR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_divr(jit,a,b,c);
-}
-static void *jit_DIVI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_divi(jit,a,b,c);
-}
-static void *jit_DIVR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_divr_u(jit,a,b,c);
-}
-static void *jit_DIVI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_divi_u(jit,a,b,c);
-}
-static void *jit_MODR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_modr(jit,a,b,c);
-}
-static void *jit_MODI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_modi(jit,a,b,c);
-}
-static void *jit_MODR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_modr_u(jit,a,b,c);
-}
-static void *jit_MODI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_modi_u(jit,a,b,c);
-}
-static void *jit_ORR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_orr(jit,a,b,c);
-}
-static void *jit_ORI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ori(jit,a,b,c);
-}
-static void *jit_XORR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_xorr(jit,a,b,c);
-}
-static void *jit_XORI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_xori(jit,a,b,c);
-}
-static void *jit_LSHR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_lshr(jit,a,b,c);
-}
-static void *jit_LSHI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_lshi(jit,a,b,c);
-}
-static void *jit_RSHR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_rshr(jit,a,b,c);
-}
-static void *jit_RSHI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_rshi(jit,a,b,c);
-}
-static void *jit_RSHR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_rshr_u(jit,a,b,c);
-}
-static void *jit_RSHI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_rshi_u(jit,a,b,c);
-}
-static void *jit_NOTR(void*jit,int64_t a,int64_t b) {
- return jit_notr(jit,a,b);
-}
-static void *jit_BLTR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bltr(jit,a,b,c);
-}
-static void *jit_BLTI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_blti(jit,a,b,c);
-}
-static void *jit_BLTR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bltr_u(jit,a,b,c);
-}
-static void *jit_BLTI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_blti_u(jit,a,b,c);
-}
-
-static void *jit_BLER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bler(jit,a,b,c);
-}
-static void *jit_BLEI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_blei(jit,a,b,c);
-}
-static void *jit_BLER_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bler_u(jit,a,b,c);
-}
-static void *jit_BLEI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_blei_u(jit,a,b,c);
-}
-
-static void *jit_BGTR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bgtr(jit,a,b,c);
-}
-static void *jit_BGTI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bgti(jit,a,b,c);
-}
-static void *jit_BGTR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bgtr_u(jit,a,b,c);
-}
-static void *jit_BGTI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bgti_u(jit,a,b,c);
-}
-
-static void *jit_BGER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bger(jit,a,b,c);
-}
-static void *jit_BGEI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bgei(jit,a,b,c);
-}
-static void *jit_BGER_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bger_u(jit,a,b,c);
-}
-static void *jit_BGEI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bgei_u(jit,a,b,c);
-}
-
-static void*jit_BEQR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_beqr(jit,a,b,c);
-}
-static void*jit_BEQI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_beqi(jit,a,b,c);
-}
-
-static void*jit_BNER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bner(jit,a,b,c);
-}
-static void*jit_BNEI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_bnei(jit,a,b,c);
-}
-
-static void *jit_LTR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ltr(jit,a,b,c);
-}
-static void *jit_LTI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_lti(jit,a,b,c);
-}
-static void *jit_LTR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ltr_u(jit,a,b,c);
-}
-static void *jit_LTI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_lti_u(jit,a,b,c);
-}
-
-static void *jit_GTR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_gtr(jit,a,b,c);
-}
-static void *jit_GTI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_gti(jit,a,b,c);
-}
-static void *jit_GTR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_gtr_u(jit,a,b,c);
-}
-static void *jit_GTI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_gti_u(jit,a,b,c);
-}
-
-static void *jit_GER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ger(jit,a,b,c);
-}
-static void *jit_GEI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_gei(jit,a,b,c);
-}
-static void *jit_GER_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ger_u(jit,a,b,c);
-}
-static void *jit_GEI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_gei_u(jit,a,b,c);
-}
-
-static void *jit_LER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ler(jit,a,b,c);
-}
-static void *jit_LEI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_lei(jit,a,b,c);
-}
-static void *jit_LER_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ler_u(jit,a,b,c);
-}
-static void *jit_LEI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_lei_u(jit,a,b,c);
-}
-
-static void *jit_EQR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_eqr(jit,a,b,c);
-}
-static void *jit_EQI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_eqi(jit,a,b,c);
-}
-
-static void *jit_NER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ner(jit,a,b,c);
-}
-static void *jit_NEI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_nei(jit,a,b,c);
-}
-
-static void* jit_LDR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ldr(jit,a,b,c);
-}
-static void* jit_LDI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ldi(jit,a,b,c);
-}
-static void* jit_LDXR(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_ldxr(jit,a,b,c,d);
-}
-static void* jit_LDXI(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_ldxi(jit,a,b,c,d);
-}
-
-static void* jit_LDR_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ldr_u(jit,a,b,c);
-}
-static void* jit_LDI_U(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_ldi_u(jit,a,b,c);
-}
-static void* jit_LDXR_U(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_ldxr_u(jit,a,b,c,d);
-}
-static void* jit_LDXI_U(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_ldxi_u(jit,a,b,c,d);
-}
-
-static void* jit_STR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_str(jit,a,b,c);
-}
-static void* jit_STI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_sti(jit,a,b,c);
-}
-
-static void* jit_STXR(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_stxr(jit,a,b,c,d);
-}
-static void* jit_STXI(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_stxi(jit,a,b,c,d);
-}
-
-static void* jit_FMOVR(void *jit,int64_t a,int64_t b) {
- return jit_fmovr(jit,a,b);
-}
-static void* jit_FMOVI(void *jit,int64_t a,double b) {
- return jit_fmovi(jit,a,b);
-}
-
-static void* jit_FADDR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_faddr(jit,a,b,c);
-}
-static void* jit_FADDI(void *jit,int64_t a,int64_t b,double c) {
- return jit_faddi(jit,a,b,c);
-}
-
-static void* jit_FSUBR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fsubr(jit,a,b,c);
-}
-static void* jit_FSUBI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fsubi(jit,a,b,c);
-}
-
-static void* jit_FMULR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fmulr(jit,a,b,c);
-}
-static void* jit_FMULI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fmuli(jit,a,b,c);
-}
-
-static void* jit_FDIVR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fdivr(jit,a,b,c);
-}
-static void* jit_FDIVI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fdivi(jit,a,b,c);
-}
-
-static void* jit_FNEGR(void *jit,int64_t a,int64_t b) {
- return jit_fnegr(jit,a,b);
-}
-
-static void* jit_EXTR(void *jit,int64_t a,int64_t b) {
- return jit_extr(jit,a,b);
-}
-static void* jit_TRUNCR(void *jit,int64_t a,int64_t b) {
- return jit_truncr(jit,a,b);
-}
-static void* jit_FLOORR(void *jit,int64_t a,int64_t b) {
- return jit_floorr(jit,a,b);
-}
-static void* jit_CEILR(void *jit,int64_t a,int64_t b) {
- return jit_ceilr(jit,a,b);
-}
-static void* jit_ROUNDR(void *jit,int64_t a,int64_t b) {
- return jit_roundr(jit,a,b);
-}
-
-static void* jit_FBLTR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fbltr(jit,a,b,c);
-}
-static void* jit_FBLTI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fblti(jit,a,b,c);
-}
-static void* jit_FBGTR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fbgtr(jit,a,b,c);
-}
-static void* jit_FBGTI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fbgti(jit,a,b,c);
-}
-
-static void* jit_FBLER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fbler(jit,a,b,c);
-}
-static void* jit_FBLEI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fblei(jit,a,b,c);
-}
-static void* jit_FBGER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fbger(jit,a,b,c);
-}
-static void* jit_FBGEI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fbgei(jit,a,b,c);
-}
-
-static void* jit_FBEQR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fbeqr(jit,a,b,c);
-}
-static void* jit_FBEQI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fbeqi(jit,a,b,c);
-}
-
-static void* jit_FBNER(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fbner(jit,a,b,c);
-}
-static void* jit_FBNEI(void *jit,int64_t a,int64_t b,double c) {
- return jit_fbnei(jit,a,b,c);
-}
-
-static void* jit_FSTR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fstr(jit,a,b,c);
-}
-static void* jit_FSTI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fsti(jit,a,b,c);
-}
-static void* jit_FSTXR(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_fstxr(jit,a,b,c,d);
-}
-static void* jit_FSTXI(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_fstxi(jit,a,b,c,d);
-}
-
-static void* jit_FLDR(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fldr(jit,a,b,c);
-}
-static void* jit_FLDI(void *jit,int64_t a,int64_t b,int64_t c) {
- return jit_fldi(jit,a,b,c);
-}
-
-static void* jit_FLDXR(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_fldxr(jit,a,b,c,d);
-}
-static void* jit_FLDXI(void *jit,int64_t a,int64_t b,int64_t c,int64_t d) {
- return jit_fldxi(jit,a,b,c,d);
-}
-
-static void* jit_FPUTARGR(void *jit,int64_t a,int64_t b) {
- return jit_fputargr(jit,a,b);
-}
-static void* jit_FPUTARGI(void *jit,double a,int64_t b) {
- return jit_fputargi(jit,a,b);
-}
-
-static void* jit_FRETR(void *jit,int64_t a,int64_t b) {
- return jit_fretr(jit,a,b);
-}
-static void* jit_FRETI(void *jit,double a,int64_t b) {
- return jit_freti(jit,a,b);
-}
-static void* jit_FRETVAL(void *jit,int64_t a,int64_t b) {
- return jit_fretval(jit,a,b);
-}
-
-static void *jit_REF_CODE(void *jit,int64_t a,int64_t b) {
- return jit_ref_code(jit,a,b);
-}
-static void *jit_REF_DATA(void *jit,int64_t a,int64_t b) {
- return jit_ref_data(jit,a,b);
-}
-static void *jit_TAINT_LABEL(void *jit,int64_t a) {
- return jit_taint_label(jit,a);
-}
-static void *jit_END_ASM_BLK(void *jit) {
- return jit_end_asm_blk(jit);
-}
-static void *jit_CODE_ALIGN(void *jit,int64_t a) {
- return jit_code_align(jit,a);
-}
-static void *jit_CODE_ALIGN_FILL(void *jit,int64_t a,int64_t b) {
- return jit_align_fill(jit,a,b);
-}
-static void *jit_DATA_STR(void *jit,void *a) {
- jit_data_str(jit,a);
- return NULL;
-}
-static void *jit_DATA_BYTE(void *jit,int64_t a) {
- return jit_data_byte(jit,a);
-}
-static void *jit_DATA_WORD(void *jit,int64_t a) {
- jit_data_word(jit,a);
- return NULL;
-}
-static void *jit_DATA_DWORD(void *jit,int64_t a) {
- jit_data_dword(jit,a);
- return NULL;
-}
-static void *jit_DATA_QWORD(void *jit,int64_t a) {
- jit_data_qword(jit,a);
- return NULL;
-}
-
-static void *jit_DATA_REF_CODE(void *jit,int64_t a) {
- return jit_data_ref_code(jit,a);
-}
-static void *jit_DATA_REF_DATA(void *jit,int64_t a) {
- return jit_data_ref_data(jit,a);
-}
-static void *jit_DUMP_PTR(void *jit,void *a) {
- return jit_dump_ptr(jit,a);
-}
-static void *jit_RELOCATION(void *jit,int64_t a,void *b) {
- return jit_relocation(jit,a,b);
-}
-static int64_t jit_ALLOCAI(void *jit,int64_t a) {
- return jit_allocai(jit,a);
-}
TOS_Fs Fs;
void *GetFs() {
return &Fs;
@@ -588,11 +54,6 @@ void PopTryFrame() {
TD_FREE(curframe);
curframe=par;
}
-static void GCollect() {
- int old=PoopSetGCEnable(1);
- PoopCollect();
- PoopSetGCEnable(old);
-}
void throw(uint64_t val) {
if(!curframe)
exit(0);
@@ -654,22 +115,6 @@ static uint64_t PowU64(uint64_t x,uint64_t n) {
}
return x*y;
}
-static int64_t PowI64(int64_t x,int64_t n) {
- if(n<0) return 0;
- if(n==0) return 1;
- int64_t y=1;
- while(n>1) {
- if(!(n%2)) {
- x=x*x;
- n=n/2;
- } else {
- y=x*y;
- x=x*x;
- n=(n-1)/2;
- }
- }
- return x*y;
-}
static char *__GetStr(char*txt) {
return rl(txt);
}
@@ -682,11 +127,13 @@ static int64_t __Move(char *old,char *new) {
static int64_t Cd(char *dir) {
return 0==chdir(dir);
}
+
static char *DirCur(char *dir) {
char buffer[1024];
getcwd(buffer,1024);
return strdup(buffer);
}
+
static int64_t DirMk(char *dir) {
#ifndef TARGET_WIN32
return 0==mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
@@ -813,13 +260,6 @@ void CreateTagsAndErrorsFiles(char *tags,char *errs,char *root) {
system(buffer);
#endif
}
-static void Test(int64_t a,int64_t b,int64_t c,int64_t d,int64_t e,int64_t f,int64_t g) {
- printf("%lld,%lld,%lld,%lld,%lld,%lld,%lld\n",a,b,c,d,e,f,g);
-}
-//https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-160
-static void TestMixed(int a, double b, int c, double d, int e, double f) {
- printf("%d,%lf,%d,%lf,%d,%lf\n",a,b,c,d,e,f);
-}
static char *hc_SDL_GetWindowTitle(SDL_Window *win) {
return strdup(SDL_GetWindowTitle(win));
}
@@ -832,31 +272,6 @@ static int64_t GetSurfaceW(SDL_Surface *s) {
static int64_t GetSurfaceH(SDL_Surface *s) {
return s->h;
}
-static double Bit4BitU64ToF64(uint64_t b) {
- union {double f;int64_t i;} val;
- val.i=b;
- return val.f;
-}
-static uint64_t Bit4BitF64ToU64(double b) {
- union {double f;int64_t i;} val;
- val.f=b;
- return val.i;
-}
-static double F64And(double a,double b) {
- return (*(uint64_t*)&a)&(*(uint64_t*)&b);
-}
-static double F64Or(double a,double b) {
- return (*(uint64_t*)&a)&(*(uint64_t*)&b);
-}
-static double F64Xor(double a,double b) {
- return (*(uint64_t*)&a)&(*(uint64_t*)&b);
-}
-static double F64Shl(double a,int64_t b) {
- return (*(uint64_t*)&a)<<b;
-}
-static double F64Shr(double a,int64_t b) {
- return (*(uint64_t*)&a)>>b;
-}
static void ForeachFunc(void(*func)(const char *name,void *ptr,long sz)) {
map_iter_t iter=map_iter(&Loader.symbols);
const char *key;
@@ -864,13 +279,10 @@ static void ForeachFunc(void(*func)(const char *name,void *ptr,long sz)) {
CSymbol *var=map_get(&Loader.symbols, key);
if(!var->is_importable)
continue;
- func(key,var->value_ptr,var->size);
+ FFI_CALL_TOS_3(func,key,var->value_ptr,var->size);
}
}
-static void jit_DATA_BYTES(struct jit *j,int64_t count,void *d) {
- jit_data_bytes(j,count,d);
-}
-static void RegisterFunctionPtr(char *name,void *fptr) {
+static void STK_RegisterFunctionPtr(char *name,void *fptr) {
CSymbol sym;
sym.type=SYM_FUNC;
sym.value_ptr=fptr;
@@ -880,374 +292,775 @@ static void RegisterFunctionPtr(char *name,void *fptr) {
static double Log2(double c) {
return log(c)/log(2);
}
-#ifndef TARGET_WIN32
void UnblockSignals() {
+ #ifndef TARGET_WIN32
sigset_t set;
sigfillset(&set);
sigprocmask(SIG_UNBLOCK,&set,NULL);
+ #endif
}
-#else
-void UnblockSignals() {
+char *GetBuiltinMacrosText();
+int64_t STK_RegisterRuntimeClasses(int64_t *stk) {
+ RegisterRuntimeClasses(stk[0],stk[1],stk[2],stk[3]);
+}
+int64_t STK_FileRead(int64_t *stk) {
+ return FileRead(stk[0],stk[1]);
+}
+int64_t STK_FileWrite(int64_t *stk) {
+ return FileWrite(stk[0],stk[1],stk[2]);
+}
+int64_t STK_UnblockSignals(int64_t *stk) {
+ UnblockSignals();
+}
+int64_t STK_Signal(int64_t *stk) {
+ signal(stk[0],stk[1]);
+}
+int64_t STK_ForeachFunc(int64_t *stk) {
+ ForeachFunc(stk[0]);
}
+int64_t STK_PopTryFrame(int64_t *stk) {
+ PopTryFrame();
+}
+int64_t STK_EnterTry(int64_t *stk) {
+ return EnterTry();
+}
+int64_t STK_ExitCatch(int64_t *stk) {
+ ExitCatch();
+}
+int64_t STK_TOSPrint(int64_t *stk) {
+ TOSPrint(stk[0],stk[1],stk+2);
+}
+int64_t STK_BoundsCheck(int64_t *stk) {
+ BoundsCheck(stk[0],stk[1]);
+}
+ int64_t STK_Del(int64_t *stk) {
+#ifdef TARGET_WIN32
+ return DeleteFileA(stk[0]);
+#else
+ return remove(stk[0]);
#endif
-char *GetBuiltinMacrosText();
-void RegisterFuncPtrs() {
- RegisterFunctionPtr("RegisterRuntimeClasses",RegisterRuntimeClasses);
- RegisterFunctionPtr("UnblockSignals",UnblockSignals);
- RegisterFunctionPtr("signal",signal);
- RegisterFunctionPtr("IsDir",IsDir);
- RegisterFunctionPtr("FileRead",FileRead);
- RegisterFunctionPtr("FileWrite",FileWrite);
- RegisterFunctionPtr("jit_breakpoint",jit_BREAKPOINT);
- RegisterFunctionPtr("jit_putargi",jit_PUTARGI);
- RegisterFunctionPtr("jit_dump_ptr",jit_DUMP_PTR);
- RegisterFunctionPtr("jit_putargr",jit_PUTARGR);
- RegisterFunctionPtr("jit_get_breakpoint_by_ptr",jit_get_breakpoint_btr_ptr);
- RegisterFunctionPtr("jit_free",jit_free);
- RegisterFunctionPtr("jit_BREAKPOINT",jit_BREAKPOINT);
- RegisterFunctionPtr("jit_debugger_get_reg_ptr",jit_debugger_get_reg_ptr);
- RegisterFunctionPtr("jit_debugger_get_vreg_ptr_from_parent",jit_debugger_get_vreg_ptr_from_parent);
- RegisterFunctionPtr("jit_get_breakpoint_btr_ptr",jit_get_breakpoint_btr_ptr);
- RegisterFunctionPtr("jit_disable_optimization",jit_disable_optimization);
- RegisterFunctionPtr("jit_enable_optimization",jit_enable_optimization);
- RegisterFunctionPtr("ForeachFuncInTable",ForeachFunc);//
- RegisterFunctionPtr("jit_init",jit_INIT);
- RegisterFunctionPtr("jit_dump_ops",jit_DUMP_OPS);
- RegisterFunctionPtr("jit_generate_code",jit_GENERATE_CODE);
- RegisterFunctionPtr("jit_andr",jit_ANDR);
- RegisterFunctionPtr("jit_andi",jit_ANDI);
- RegisterFunctionPtr("R_FP",jit_R_FP);
- RegisterFunctionPtr("jit_bin_size",jit_BINSIZE);
- RegisterFunctionPtr("jit_FR",jit_FR);
- RegisterFunctionPtr("jit_R",jit_R);
- RegisterFunctionPtr("jit_allocai",jit_ALLOCAI);
- RegisterFunctionPtr("jit_get_label",jit_GET_LABEL);
- RegisterFunctionPtr("jit_prolog",jit_PROLOG);
- RegisterFunctionPtr("jit_movr",jit_MOVR);
- RegisterFunctionPtr("jit_movi",jit_MOVI);
- RegisterFunctionPtr("jit_jmpr",jit_JMPR);
- RegisterFunctionPtr("jit_jmpi",jit_JMPI);
- RegisterFunctionPtr("jit_patch",jit_PATCH);
- RegisterFunctionPtr("jit_prepare",jit_PREPARE);
- RegisterFunctionPtr("jit_call",jit_CALL);
- RegisterFunctionPtr("jit_callr",jit_CALLR);
- RegisterFunctionPtr("jit_reti",jit_RETI);
- RegisterFunctionPtr("jit_retr",jit_RETR);
- RegisterFunctionPtr("jit_retval",jit_RETVAL);
- RegisterFunctionPtr("jit_getarg",jit_GETARG);
- RegisterFunctionPtr("jit_declare_arg",jit_DECLARE_ARG);
- RegisterFunctionPtr("jit_addr",jit_ADDR);
- RegisterFunctionPtr("jit_addi",jit_ADDI);
- RegisterFunctionPtr("jit_subr",jit_SUBR);
- RegisterFunctionPtr("jit_subi",jit_SUBI);
- RegisterFunctionPtr("jit_mulr",jit_MULR);
- RegisterFunctionPtr("jit_muli",jit_MULI);
- RegisterFunctionPtr("jit_mulr_u",jit_MULR_U);
- RegisterFunctionPtr("jit_muli_u",jit_MULI_U);
- RegisterFunctionPtr("jit_divr",jit_DIVR);
- RegisterFunctionPtr("jit_divi",jit_DIVI);
- RegisterFunctionPtr("jit_divr_u",jit_DIVR_U);
- RegisterFunctionPtr("jit_divi_u",jit_DIVI_U);
- RegisterFunctionPtr("jit_modr",jit_MODR);
- RegisterFunctionPtr("jit_modi",jit_MODI);
- RegisterFunctionPtr("jit_modr_u",jit_MODR_U);
- RegisterFunctionPtr("jit_modi_u",jit_MODI_U);
- RegisterFunctionPtr("jit_orr",jit_ORR);
- RegisterFunctionPtr("jit_ori",jit_ORI);
- RegisterFunctionPtr("jit_xorr",jit_XORR);
- RegisterFunctionPtr("jit_xori",jit_XORI);
- RegisterFunctionPtr("jit_lshr",jit_LSHR);
- RegisterFunctionPtr("jit_lshi",jit_LSHI);
- RegisterFunctionPtr("jit_rshr",jit_RSHR);
- RegisterFunctionPtr("jit_rshi",jit_RSHI);
- RegisterFunctionPtr("jit_rshr_u",jit_RSHR_U);
- RegisterFunctionPtr("jit_rshi_u",jit_RSHI_U);
- RegisterFunctionPtr("jit_notr",jit_NOTR);
- RegisterFunctionPtr("jit_bltr",jit_BLTR);
- RegisterFunctionPtr("jit_blti",jit_BLTI);
- RegisterFunctionPtr("jit_bltr_u",jit_BLTR_U);
- RegisterFunctionPtr("jit_blti_u",jit_BLTI_U);
- RegisterFunctionPtr("jit_bler",jit_BLER);
- RegisterFunctionPtr("jit_blei",jit_BLEI);
- RegisterFunctionPtr("jit_bler_u",jit_BLER_U);
- RegisterFunctionPtr("jit_blei_u",jit_BLEI_U);
- RegisterFunctionPtr("jit_bger",jit_BGER);
- RegisterFunctionPtr("jit_bgei",jit_BGEI);
- RegisterFunctionPtr("jit_bger_u",jit_BGER_U);
- RegisterFunctionPtr("jit_bgei_u",jit_BGEI_U);
- RegisterFunctionPtr("jit_bgtr",jit_BGTR);
- RegisterFunctionPtr("jit_bgti",jit_BGTI);
- RegisterFunctionPtr("jit_bgtr_u",jit_BGTR_U);
- RegisterFunctionPtr("jit_bgti_u",jit_BGTI_U);
- RegisterFunctionPtr("jit_beqr",jit_BEQR);
- RegisterFunctionPtr("jit_beqi",jit_BEQI);
- RegisterFunctionPtr("jit_bner",jit_BNER);
- RegisterFunctionPtr("jit_bnei",jit_BNEI);
-
- RegisterFunctionPtr("jit_ltr",jit_LTR);
- RegisterFunctionPtr("jit_lti",jit_LTI);
- RegisterFunctionPtr("jit_ltr_u",jit_LTR_U);
- RegisterFunctionPtr("jit_lti_u",jit_LTI_U);
- RegisterFunctionPtr("jit_ler",jit_LER);
- RegisterFunctionPtr("jit_lei",jit_LEI);
- RegisterFunctionPtr("jit_ger_u",jit_GER_U);
- RegisterFunctionPtr("jit_gei_u",jit_GEI_U);
- RegisterFunctionPtr("jit_ger",jit_GER);
- RegisterFunctionPtr("jit_gei",jit_GEI);
- RegisterFunctionPtr("jit_ger_u",jit_GER_U);
- RegisterFunctionPtr("jit_gei_u",jit_GEI_U);
- RegisterFunctionPtr("jit_gtr",jit_GTR);
- RegisterFunctionPtr("jit_gti",jit_GTI);
- RegisterFunctionPtr("jit_gtr_u",jit_GTR_U);
- RegisterFunctionPtr("jit_gti_u",jit_GTI_U);
- RegisterFunctionPtr("jit_eqr",jit_EQR);
- RegisterFunctionPtr("jit_eqi",jit_EQI);
- RegisterFunctionPtr("jit_ner",jit_NER);
- RegisterFunctionPtr("jit_nei",jit_NEI);
- RegisterFunctionPtr("jit_ldr",jit_LDR);
- RegisterFunctionPtr("jit_ldi",jit_LDI);
- RegisterFunctionPtr("jit_ldxr",jit_LDXR);
- RegisterFunctionPtr("jit_ldxi",jit_LDXI);
- RegisterFunctionPtr("jit_ldr_u",jit_LDR_U);
- RegisterFunctionPtr("jit_ldi_u",jit_LDI_U);
- RegisterFunctionPtr("jit_ldxr_u",jit_LDXR_U);
- RegisterFunctionPtr("jit_ldxi_u",jit_LDXI_U);
- RegisterFunctionPtr("jit_str",jit_STR);
- RegisterFunctionPtr("jit_sti",jit_STI);
- RegisterFunctionPtr("jit_stxr",jit_STXR);
- RegisterFunctionPtr("jit_stxi",jit_STXI);
- RegisterFunctionPtr("jit_fmovi",jit_FMOVI);
- RegisterFunctionPtr("jit_fmovr",jit_FMOVR);
- RegisterFunctionPtr("jit_faddr",jit_FADDR);
- RegisterFunctionPtr("jit_faddi",jit_FADDI);
- RegisterFunctionPtr("jit_fsubi",jit_FSUBI);
- RegisterFunctionPtr("jit_fsubr",jit_FSUBR);
- RegisterFunctionPtr("jit_fmulr",jit_FMULR);
- RegisterFunctionPtr("jit_fmuli",jit_FMULI);
- RegisterFunctionPtr("jit_fdivi",jit_FDIVI);
- RegisterFunctionPtr("jit_fdivr",jit_FDIVR);
- RegisterFunctionPtr("jit_fnegr",jit_FNEGR);
- RegisterFunctionPtr("jit_negr",jit_NEGR);
- RegisterFunctionPtr("jit_extr",jit_EXTR);
- RegisterFunctionPtr("jit_truncr",jit_TRUNCR);
- RegisterFunctionPtr("jit_floorr",jit_FLOORR);
- RegisterFunctionPtr("jit_ceilr",jit_CEILR);
- RegisterFunctionPtr("jit_roundr",jit_ROUNDR);
- RegisterFunctionPtr("jit_fbltr",jit_FBLTR);
- RegisterFunctionPtr("jit_fbgtr",jit_FBGTR);
- RegisterFunctionPtr("jit_fbler",jit_FBLER);
- RegisterFunctionPtr("jit_fbger",jit_FBGER);
- RegisterFunctionPtr("jit_fbeqr",jit_FBEQR);
- RegisterFunctionPtr("jit_fbner",jit_FBNER);
- RegisterFunctionPtr("jit_fblti",jit_FBLTI);
- RegisterFunctionPtr("jit_fbgti",jit_FBGTI);
- RegisterFunctionPtr("jit_fblei",jit_FBLEI);
- RegisterFunctionPtr("jit_fbgei",jit_FBGEI);
- RegisterFunctionPtr("jit_fbeqi",jit_FBEQI);
- RegisterFunctionPtr("jit_fbnei",jit_FBNEI);
- RegisterFunctionPtr("jit_fstr",jit_FSTR);
- RegisterFunctionPtr("jit_fsti",jit_FSTI);
- RegisterFunctionPtr("jit_fstxr",jit_FSTXR);
- RegisterFunctionPtr("jit_fstxi",jit_FSTXI);
- RegisterFunctionPtr("jit_fldr",jit_FLDR);
- RegisterFunctionPtr("jit_fldi",jit_FLDI);
- RegisterFunctionPtr("jit_fldxr",jit_FLDXR);
- RegisterFunctionPtr("jit_fldxi",jit_FLDXI);
- RegisterFunctionPtr("jit_fputargi",jit_FPUTARGI);
- RegisterFunctionPtr("jit_fputargr",jit_FPUTARGR);
- RegisterFunctionPtr("jit_freti",jit_FRETI);
- RegisterFunctionPtr("jit_fretr",jit_FRETR);
- RegisterFunctionPtr("jit_fretval",jit_FRETVAL);
- RegisterFunctionPtr("jit_ref_code",jit_REF_CODE);
- RegisterFunctionPtr("jit_ref_data",jit_REF_DATA);
- RegisterFunctionPtr("jit_taint_label",jit_TAINT_LABEL);
- RegisterFunctionPtr("jit_end_asm_blk",jit_END_ASM_BLK);
- RegisterFunctionPtr("jit_code_align",jit_CODE_ALIGN);
- RegisterFunctionPtr("jit_code_align_fill",jit_CODE_ALIGN_FILL);
- RegisterFunctionPtr("jit_data_str",jit_DATA_STR);
- RegisterFunctionPtr("jit_data_byte",jit_DATA_BYTE);
- RegisterFunctionPtr("jit_data_word",jit_DATA_WORD);
- RegisterFunctionPtr("jit_data_dword",jit_DATA_DWORD);
- RegisterFunctionPtr("jit_data_qword",jit_DATA_QWORD);
- RegisterFunctionPtr("jit_data_ref_code",jit_DATA_REF_CODE);
- RegisterFunctionPtr("jit_data_ref_data",jit_DATA_REF_DATA);
- RegisterFunctionPtr("jit_relocation",jit_RELOCATION);
- RegisterFunctionPtr("jit_data_bytes",jit_DATA_BYTES);
- RegisterFunctionPtr("HCSetJmp",HCSetJmp);
- RegisterFunctionPtr("PopTryFrame",PopTryFrame);
- RegisterFunctionPtr("EnterTry",EnterTry);
- RegisterFunctionPtr("ExitCatch",ExitCatch);
- RegisterFunctionPtr("TOSPrint",TOSPrint);
- RegisterFunctionPtr("PowI64",PowI64);
- RegisterFunctionPtr("PowU64",PowU64);
- RegisterFunctionPtr("FMod",fmod);
- RegisterFunctionPtr("WhineOnOutOfBounds",InBounds);
- RegisterFunctionPtr("Bit4BitU64ToF64",Bit4BitU64ToF64);
- RegisterFunctionPtr("Bit4BitF64ToU64",Bit4BitF64ToU64);
- RegisterFunctionPtr("F64And",F64And);
- RegisterFunctionPtr("F64Xor",F64Xor);
- RegisterFunctionPtr("F64Shr",F64Shr);
- RegisterFunctionPtr("F64Shl",F64Shl);
- RegisterFunctionPtr("Pow",pow);
- RegisterFunctionPtr("PoopSetGCEnable",PoopSetGCEnable);
- RegisterFunctionPtr("GC_Collect",GCollect);
- RegisterFunctionPtr("CreateTagsAndErrorsFiles",CreateTagsAndErrorsFiles);
- RegisterFunctionPtr("MSize",MSize);
- RegisterFunctionPtr("Bsf",BFFS);
- RegisterFunctionPtr("Bsr",BCLZ);
- RegisterFunctionPtr("throw",throw);
- RegisterFunctionPtr("MAlloc",PoopMAlloc);
- RegisterFunctionPtr("Free",PoopFree);
- RegisterFunctionPtr("MemCpy",MemNCpy);
- RegisterFunctionPtr("MemNCpy",MemNCpy);
- RegisterFunctionPtr("StrLen",strlen);
- RegisterFunctionPtr("StrCmp",strcmp);
- RegisterFunctionPtr("StrNCmp",strncmp);
- RegisterFunctionPtr("StrCpy",strcpy);
- RegisterFunctionPtr("StrNCpy",strncpy);
- RegisterFunctionPtr("StrMatch",strstr);
- RegisterFunctionPtr("Fs",GetFs);
- RegisterFunctionPtr("__GetStr",__GetStr);
- RegisterFunctionPtr("ATan",atan);
- RegisterFunctionPtr("Abs",fabs);
- RegisterFunctionPtr("Cos",cos);
- RegisterFunctionPtr("Sin",sin);
- RegisterFunctionPtr("Sqrt",sqrt);
- RegisterFunctionPtr("Tan",tan);
- RegisterFunctionPtr("Ceil",ceil);
- RegisterFunctionPtr("Floor",floor);
- RegisterFunctionPtr("Ln",log);
- RegisterFunctionPtr("Log10",log10);
- RegisterFunctionPtr("Log2",Log2);
- RegisterFunctionPtr("Round",round);
- RegisterFunctionPtr("Trunc",trunc);
- RegisterFunctionPtr("Exit",exit);
- RegisterFunctionPtr("Cd",Cd);
- RegisterFunctionPtr("DirCur",DirCur);
- RegisterFunctionPtr("DirMk",DirMk);
- RegisterFunctionPtr("__Move",__Move);
- RegisterFunctionPtr("FileNameAbs",FileNameAbs);
- RegisterFunctionPtr("DirNameAbs",FileNameAbs);
- RegisterFunctionPtr("__Dir",__Dir);
- RegisterFunctionPtr("IsWindows",IsWindows);
- RegisterFunctionPtr("IsMac",IsMac);
- RegisterFunctionPtr("MemSet",memset);
- RegisterFunctionPtr("SDL_Init",SDL_Init);
- RegisterFunctionPtr("SDL_WasInit",SDL_WasInit);
- RegisterFunctionPtr("SDL_CreateWindow",SDL_CreateWindow);
- RegisterFunctionPtr("SDL_SetTextureBlendMode",SDL_SetTextureBlendMode);
- RegisterFunctionPtr("SDL_CreateWindowAndRenderer",SDL_CreateWindowAndRenderer);
- RegisterFunctionPtr("SDL_DestroyWindow",SDL_DestroyWindow);
- RegisterFunctionPtr("SDL_DestroyRenderer",SDL_DestroyRenderer);
- RegisterFunctionPtr("SDL_DisableScreenSaver",SDL_DisableScreenSaver);
- RegisterFunctionPtr("SDL_GetGrabbedWindow",SDL_GetGrabbedWindow);
- RegisterFunctionPtr("SDL_GetWindowPosition",SDL_GetWindowPosition);
- RegisterFunctionPtr("SDL_GetWindowMinimumSize",SDL_GetWindowMinimumSize);
- RegisterFunctionPtr("SDL_GetWindowMaximumSize",SDL_GetWindowMaximumSize);
- RegisterFunctionPtr("SDL_GetWindowSize",SDL_GetWindowSize);
- RegisterFunctionPtr("SDL_GetWindowTitle",hc_SDL_GetWindowTitle);
- RegisterFunctionPtr("SDL_HideWindow",SDL_HideWindow);
- RegisterFunctionPtr("SDL_MaximizeWindow",SDL_MaximizeWindow);
- RegisterFunctionPtr("SDL_MinimizeWindow",SDL_MinimizeWindow);
- RegisterFunctionPtr("SDL_SetWindowBordered",SDL_SetWindowBordered);
- RegisterFunctionPtr("SDL_SetWindowFullscreen",SDL_SetWindowFullscreen);
- RegisterFunctionPtr("SDL_SetWindowMaximumSize",SDL_SetWindowMaximumSize);
- RegisterFunctionPtr("SDL_SetWindowMinimumSize",SDL_SetWindowMinimumSize);
- RegisterFunctionPtr("SDL_SetWindowResizable",SDL_SetWindowResizable);
- RegisterFunctionPtr("SDL_SetWindowSize",SDL_SetWindowSize);
- RegisterFunctionPtr("SDL_SetWindowTitle",SDL_SetWindowTitle);
- RegisterFunctionPtr("SDL_ShowWindow",SDL_ShowWindow);
- RegisterFunctionPtr("SDL_CreateRenderer",SDL_CreateRenderer);
- RegisterFunctionPtr("SDL_CreateTexture",SDL_CreateTexture);
- RegisterFunctionPtr("SDL_DestroyRenderer",SDL_DestroyRenderer);
- RegisterFunctionPtr("SDL_GetRenderDrawColor",SDL_GetRenderDrawColor);
- RegisterFunctionPtr("SDL_GetRenderer",SDL_GetRenderer);
- RegisterFunctionPtr("SDL_GetRendererOutputSize",SDL_GetRendererOutputSize);
- RegisterFunctionPtr("SDL_GetRenderTarget",SDL_GetRenderTarget);
- RegisterFunctionPtr("SDL_GetTextureAlphaMod",SDL_GetTextureAlphaMod);
- RegisterFunctionPtr("SDL_GetTextureColorMod",SDL_GetTextureColorMod);
- RegisterFunctionPtr("SDL_RenderClear",SDL_RenderClear);
- RegisterFunctionPtr("SDL_RenderCopy",SDL_RenderCopy);
- RegisterFunctionPtr("SDL_RenderDrawLine",SDL_RenderDrawLine);
- RegisterFunctionPtr("SDL_RenderDrawLines",SDL_RenderDrawLines);
- RegisterFunctionPtr("SDL_RenderDrawPoint",SDL_RenderDrawPoint);
- RegisterFunctionPtr("SDL_RenderDrawPoints",SDL_RenderDrawPoints);
- RegisterFunctionPtr("SDL_RenderDrawRect",SDL_RenderDrawRect);
- RegisterFunctionPtr("SDL_RenderDrawRects",SDL_RenderDrawRects);
- RegisterFunctionPtr("SDL_RenderFillRects",SDL_RenderFillRects);
- RegisterFunctionPtr("SDL_RenderFillRects",SDL_RenderFillRects);
- RegisterFunctionPtr("SDL_RenderGetClipRect",SDL_RenderGetClipRect);
- RegisterFunctionPtr("SDL_RenderPresent",SDL_RenderPresent);
- RegisterFunctionPtr("SDL_RenderSetClipRect",SDL_RenderSetClipRect);
- RegisterFunctionPtr("SDL_SetRenderDrawColor",SDL_SetRenderDrawColor);
- RegisterFunctionPtr("SDL_SetRenderTarget",SDL_SetRenderTarget);
- RegisterFunctionPtr("SDL_SetTextureAlphaMod",SDL_SetTextureAlphaMod);
- RegisterFunctionPtr("SDL_SetTextureColorMod",SDL_SetTextureColorMod);
- RegisterFunctionPtr("SDL_UpdateTexture",SDL_UpdateTexture);
- RegisterFunctionPtr("SDL_QueryTexture",SDL_QueryTexture);
- RegisterFunctionPtr("SDL_GetClipboardText",hc_SDL_GetClipboardText);
- RegisterFunctionPtr("SDL_SetClipboardText",SDL_SetClipboardText);
- RegisterFunctionPtr("SDL_PollEvent",SDL_PollEvent);
- RegisterFunctionPtr("SDL_WaitEvent",SDL_WaitEvent);
- RegisterFunctionPtr("SDL_DestroyRenderer",SDL_DestroyRenderer);
- RegisterFunctionPtr("SDL_DestroyTexture",SDL_DestroyTexture);
- RegisterFunctionPtr("SDL_StartTextInput",SDL_StartTextInput);
- RegisterFunctionPtr("SDL_StopTextInput",SDL_StopTextInput);
- RegisterFunctionPtr("SDL_GetError",SDL_GetError);
- RegisterFunctionPtr("SDL_ClearError",SDL_ClearError);
- RegisterFunctionPtr("SDL_FlushEvent",SDL_FlushEvent);
- RegisterFunctionPtr("SDL_GetSurfaceWidth",GetSurfaceW);
- RegisterFunctionPtr("SDL_GetSurfaceHeight",GetSurfaceH);
- RegisterFunctionPtr("SDL_CreateRGBSurface",SDL_CreateRGBSurface);
- RegisterFunctionPtr("SDL_CreateRGBSurfaceFrom",SDL_CreateRGBSurfaceFrom);
- RegisterFunctionPtr("SDL_UpperBlit",SDL_UpperBlit);
- RegisterFunctionPtr("SDL_FillRect",SDL_FillRect);
- RegisterFunctionPtr("SDL_FillRects",SDL_FillRects);
- RegisterFunctionPtr("SDL_GetClipRect",SDL_GetClipRect);
- RegisterFunctionPtr("SDL_GetColorKey",SDL_GetColorKey);
- RegisterFunctionPtr("SDL_GetSurfaceAlphaMod",SDL_GetSurfaceAlphaMod);
- RegisterFunctionPtr("SDL_GetSurfaceColorMod",SDL_GetSurfaceColorMod);
- RegisterFunctionPtr("SDL_LockSurface",SDL_LockSurface);
- RegisterFunctionPtr("SDL_UnlockSurface",SDL_UnlockSurface);
- RegisterFunctionPtr("SDL_SetClipRect",SDL_SetClipRect);
- RegisterFunctionPtr("SDL_SetColorKey",SDL_SetColorKey);
- RegisterFunctionPtr("SDL_SetSurfaceAlphaMod",SDL_SetSurfaceAlphaMod);
- RegisterFunctionPtr("SDL_SetSurfaceColorMod",SDL_SetSurfaceColorMod);
- RegisterFunctionPtr("SDL_SetSurfaceRLE",SDL_SetSurfaceRLE);
- RegisterFunctionPtr("SDL_BlitSurface",SDL_BlitSurface);
- RegisterFunctionPtr("SDL_BlitScaled",SDL_BlitScaled);
- RegisterFunctionPtr("SDL_FreeSurface",SDL_FreeSurface);
- RegisterFunctionPtr("SDL_UpdateWindowSurface",SDL_UpdateWindowSurface);
- RegisterFunctionPtr("SDL_GetWindowSurface",SDL_GetWindowSurface);
- RegisterFunctionPtr("__GetBuiltinMacrosText",GetBuiltinMacrosText);
+
+}
+int64_t STK_pow(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=pow(stk[0],stk[1]);
+ return val.i;
+}
+int64_t STK_PoopSetGCEnable(int64_t *stk) {
+ return PoopSetGCEnable(stk[0]);
+}
+int64_t STK_CreateTagsAndErrorsFiles(int64_t *stk) {
+ CreateTagsAndErrorsFiles(stk[0],stk[1],stk[2]);
+}
+int64_t STK_MSize(int64_t *stk) {
+ return MSize(stk[0]);
+}
+int64_t STK_BFFS(int64_t *stk) {
+ return BFFS(stk[0]);
+}
+int64_t STK_BCLZ(int64_t *stk) {
+ return BCLZ(stk[0]);
+}
+int64_t STK_throw(int64_t *stk) {
+ throw(stk[0]);
+}
+int64_t STK_PoopMAlloc(int64_t *stk) {
+ return PoopMAlloc(stk[0]);
+}
+int64_t STK_PoopFree(int64_t *stk) {
+ PoopFree(stk[0]);
+}
+int64_t STK_MemNCpy(int64_t *stk) {
+ return memcpy(stk[0],stk[1],stk[2]);
+}
+int64_t STK_strlen(int64_t *stk) {
+ return strlen(stk[0]);
+}
+int64_t STK_strcmp(int64_t *stk) {
+ return strcmp(stk[0],stk[1]);
+}
+int64_t STK_strncmp(int64_t *stk) {
+ return strncmp(stk[0],stk[1],stk[2]);
+}
+int64_t STK_strcpy(int64_t *stk) {
+ return strcpy(stk[0],stk[1]);
+}
+int64_t STK_strncpy(int64_t *stk) {
+ return strncpy(stk[0],stk[1],stk[2]);
+}
+int64_t STK_strstr(int64_t *stk) {
+ return strstr(stk[0],stk[1]);
+}
+int64_t STK_GetFs(int64_t *stk) {
+ return GetFs();
+}
+int64_t STK___GetStr(int64_t *stk) {
+ return __GetStr(stk[0]);
+}
+int64_t STK_atan(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=atan(stk[0]);
+ return val.i;
+}
+int64_t STK_abs(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=abs(stk[0]);
+ return val.i;
+}
+int64_t STK_cos(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=cos(stk[0]);
+ return val.i;
+}
+int64_t STK_sin(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=sin(stk[0]);
+ return val.i;
+}
+int64_t STK_sqrt(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=sin(stk[0]);
+ return val.i;
+}
+int64_t STK_tan(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=tan(stk[0]);
+ return val.i;
+}
+int64_t STK_ceil(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=ceil(stk[0]);
+ return val.i;
+}
+int64_t STK_floor(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=floor(stk[0]);
+ return val.i;
+}
+int64_t STK_log(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=log(stk[0]);
+ return val.i;
+}
+int64_t STK_log10(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=log10(stk[0]);
+ return val.i;
+}
+int64_t STK_log2(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=log2(stk[0]);
+ return val.i;
+}
+int64_t STK_round(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=round(stk[0]);
+ return val.i;
+}
+int64_t STK_trunc(double *stk) {
+ union {int64_t i;double_t d;} val;
+ val.d=trunc(stk[0]);
+ return val.i;
+}
+int64_t STK_exit(int64_t *stk) {
+ exit(stk[0]);
+}
+int64_t STK_Cd(int64_t *stk) {
+ return Cd(stk[0]);
+}
+int64_t STK_DirCur(int64_t *stk) {
+ return DirCur(stk[0]);
+}
+int64_t STK_DirMk(int64_t *stk) {
+ return DirMk(stk[0]);
+}
+int64_t STK___Move(int64_t *stk) {
+ return __Move(stk[0],stk[1]);
+}
+int64_t STK_FileNameAbs(int64_t *stk) {
+ return FileNameAbs(stk[0]);
+}
+int64_t STK_IsMac(int64_t *stk) {
+ return IsMac();
+}
+int64_t STK_IsWindows(int64_t *stk) {
+ return IsWindows();
+}
+int64_t STK___Dir(int64_t *stk) {
+ return __Dir(stk[0]);
+}
+int64_t STK_memset(int64_t *stk) {
+ return memset(stk[0],stk[1],stk[2]);
+}
+int64_t STK_SDL_Init(int64_t *stk) {
+ return SDL_Init(stk[0]);
+}
+int64_t STK_SDL_WasInit(int64_t *stk) {
+ return SDL_WasInit(stk[0]);
+}
+int64_t STK_SDL_CreateWindow(int64_t *stk) {
+ return (int64_t)SDL_CreateWindow((char*)stk[0],stk[1],stk[2],stk[3],stk[4],stk[5]);
+}
+int64_t STK_SDL_SetTextureBlendMode(int64_t *stk) {
+ SDL_SetTextureBlendMode((SDL_Texture*)stk[0],stk[1]);
+}
+int64_t STK_SDL_CreateWindowAndRenderer(int64_t *stk) {
+ SDL_CreateWindowAndRenderer(stk[0],stk[1],stk[2],(SDL_Window**)stk[3],(SDL_Renderer**)stk[4]);
+}
+int64_t STK_SDL_DestroyWindow(int64_t *stk) {
+ SDL_DestroyWindow(stk[0]);
+}
+int64_t STK_SDL_GetGrabbedWindow(int64_t *stk) {
+ return (int64_t)SDL_GetGrabbedWindow();
+}
+int64_t STK_SDL_GetWindowPosition(int64_t *stk) {
+ SDL_GetWindowPosition((SDL_Window*)stk[0],(int*)stk[1],(int*)stk[2]);
+}
+int64_t STK_SDL_GetWindowMaximumSize(int64_t *stk) {
+ SDL_GetWindowMaximumSize((SDL_Window*)stk[0],(int*)stk[1],(int*)stk[2]);
+}
+int64_t STK_SDL_GetWindowMinimumSize(int64_t *stk) {
+ SDL_GetWindowMinimumSize((SDL_Window*)stk[0],(int*)stk[1],(int*)stk[2]);
+}
+int64_t STK_SDL_GetWindowSize(int64_t *stk) {
+ SDL_GetWindowSize(stk[0],stk[1],stk[2]);
+}
+int64_t STK_hc_SDL_GetWindowTitle(int64_t *stk) {
+ return (int64_t)hc_SDL_GetWindowTitle((SDL_Window*)stk[0]);
+}
+int64_t STK_SDL_MaximizeWindow(int64_t *stk) {
+ SDL_MaximizeWindow((SDL_Window*)stk[0]);
+}
+int64_t STK_SDL_MinimizeWindow(int64_t *stk) {
+ SDL_MinimizeWindow((SDL_Window*)stk[0]);
+}
+int64_t STK_SDL_SetWindowBordered(int64_t *stk) {
+ SDL_SetWindowBordered((SDL_Window*)stk[0],stk[1]);
+}
+int64_t STK_SDL_SetWindowFullscreen(int64_t *stk) {
+ SDL_SetWindowFullscreen((SDL_Window*)stk[0],stk[1]);
+}
+int64_t STK_SDL_SetWindowMaximumSize(int64_t *stk) {
+ SDL_SetWindowMaximumSize((SDL_Window*)stk[0],stk[1],stk[2]);
+}
+int64_t STK_SDL_SetWindowMinimumSize(int64_t *stk) {
+ SDL_SetWindowMinimumSize((SDL_Window*)stk[0],stk[1],stk[2]);
+}
+int64_t STK_SDL_SetWindowResizable(int64_t *stk) {
+ SDL_SetWindowResizable((SDL_Window*)stk[0],stk[1]);
+}
+int64_t STK_SDL_SetWindowSize(int64_t *stk) {
+ SDL_SetWindowSize((SDL_Window*)stk[0],stk[1],stk[2]);
+}
+int64_t STK_SDL_SetWindowTitle(int64_t *stk) {
+ SDL_SetWindowTitle((SDL_Window*)stk[0],stk[1]);
+}
+int64_t STK_SDL_ShowWindow(int64_t *stk) {
+ SDL_ShowWindow((SDL_Window*)stk[0]);
+}
+int64_t STK_SDL_HideWindow(int64_t *stk) {
+ SDL_HideWindow((SDL_Window*)stk[0]);
+}
+int64_t STK_SDL_CreateRenderer(int64_t *stk) {
+ return (int64_t)SDL_CreateRenderer((SDL_Renderer*)stk[0],stk[1],stk[2]);
+}
+int64_t STK_SDL_CreateTexture(int64_t *stk) {
+ return (int64_t)SDL_CreateTexture((SDL_Renderer*)stk[0],stk[1],stk[2],stk[3],stk[4]);
+}
+int64_t STK_SDL_DestroyRenderer(int64_t *stk) {
+ SDL_DestroyRenderer((SDL_Renderer*)stk[0]);
+}
+int64_t STK_SDL_GetRenderer(int64_t *stk) {
+ return (int64_t)SDL_GetRenderer((SDL_Window*)stk[0]);
+}
+int64_t STK_SDL_GetRendererOutputSize(int64_t *stk) {
+ return SDL_GetRendererOutputSize((SDL_Renderer*)stk[0],(int*)stk[1],(int*)stk[2]);
+}
+int64_t STK_SDL_GetRenderTarget(int64_t *stk) {
+ return (int64_t)SDL_GetRenderTarget((SDL_Renderer*)stk[0]);
+}
+int64_t STK_SDL_GetTextureAlphaMod(int64_t *stk) {
+ return SDL_GetTextureAlphaMod((SDL_Texture*)stk[0],(Uint8*)stk[1]);
+}
+int64_t STK_SDL_GetTextureColorMod(int64_t *stk) {
+ return SDL_GetTextureColorMod((SDL_Texture*)stk[0],(Uint8*)stk[1],(Uint8*)stk[2],(Uint8*)stk[3]);
+}
+int64_t STK_SDL_RenderClear(int64_t *stk) {
+ return SDL_RenderClear((SDL_Renderer*)stk[0]);
+}
+int64_t STK_SDL_RenderCopy(int64_t *stk) {
+ return SDL_RenderCopy((SDL_Renderer*)stk[0],(SDL_Texture*)stk[1],(SDL_Rect*)stk[2],(SDL_Rect*)stk[3]);
+}
+int64_t STK_SDL_RenderDrawLine(int64_t *stk) {
+ return SDL_RenderDrawLine((SDL_Renderer*)stk[0],stk[1],stk[2],stk[3],stk[4]);
+}
+int64_t STK_SDL_RenderDrawPoint(int64_t *stk) {
+ return SDL_RenderDrawPoint((SDL_Renderer*)stk[0],stk[1],stk[2]);
+}
+int64_t STK_SDL_RenderDrawPoints(int64_t *stk) {
+ return SDL_RenderDrawPoints((SDL_Renderer*)stk[0],(SDL_Point*)stk[1],stk[2]);
+}
+int64_t STK_SDL_RenderDrawRect(int64_t *stk) {
+ return SDL_RenderDrawRect((SDL_Renderer*)stk[0],(SDL_Rect*)stk[1]);
+}
+int64_t STK_SDL_RenderDrawRects(int64_t *stk) {
+ return SDL_RenderDrawRects((SDL_Renderer*)stk[0],(SDL_Rect*)stk[1],stk[2]);
+}
+int64_t STK_SDL_RenderFillRects(int64_t *stk) {
+ return SDL_RenderDrawRects((SDL_Renderer*)stk[0],(SDL_Rect*)stk[1],stk[2]);
+}
+int64_t STK_SDL_RenderGetClipRect(int64_t *stk) {
+ SDL_RenderGetClipRect((SDL_Renderer*)stk[0],(SDL_Rect*)stk[1]);
+}
+int64_t STK_SDL_RenderPresent(int64_t *stk) {
+ SDL_RenderPresent((SDL_Renderer*)stk[0]);
+}
+int64_t STK_SDL_RenderSetClipRect(int64_t *stk) {
+ return SDL_RenderSetClipRect((SDL_Renderer*)stk[0],(SDL_Rect*)stk[1]);
+}
+int64_t STK_SDL_SetRenderTarget(int64_t *stk) {
+ return SDL_SetRenderTarget((SDL_Renderer*)stk[0],(SDL_Texture*)stk[1]);
+}
+int64_t STK_SDL_SetTextureAlphaMod(int64_t *stk) {
+ return SDL_SetTextureAlphaMod((SDL_Texture*)stk[0],stk[1]);
+}
+int64_t STK_SDL_SetTextureColorMod(int64_t *stk) {
+ return SDL_SetTextureColorMod((SDL_Texture*)stk[0],stk[1],stk[2],stk[3]);
+}
+int64_t STK_SDL_UpdateTexture(int64_t *stk) {
+ return SDL_UpdateTexture((SDL_Texture*)stk[0],(SDL_Rect*)stk[1],(void*)stk[2],stk[3]);
+}
+int64_t STK_SDL_QueryTexture(int64_t *stk) {
+ return SDL_QueryTexture((SDL_Texture*)stk[0],(Uint32*)stk[1],(int*)stk[2],(int*)stk[3],(int*)stk[4]);
+}
+int64_t STK_SDL_GetClipboardText(int64_t *stk) {
+ return (int64_t)hc_SDL_GetClipboardText();
+}
+int64_t STK_SDL_SetClipboardText(int64_t *stk) {
+ return SDL_SetClipboardText((char*)stk[0]);
+}
+int64_t STK_SDL_PollEvent(int64_t *stk) {
+ return SDL_PollEvent((SDL_Event*)stk[0]);
+}
+int64_t STK_SDL_WaitEvent(int64_t *stk) {
+ return SDL_WaitEvent((SDL_Event*)stk[0]);
+}
+int64_t STK_SDL_DestroyTexture(int64_t *stk) {
+ SDL_DestroyTexture((SDL_Texture*)stk[0]);
+}
+int64_t STK_SDL_StartTextInput(int64_t *stk) {
+ SDL_StartTextInput();
+}
+int64_t STK_SDL_StopTextInput(int64_t *stk) {
+ SDL_StopTextInput();
+}
+int64_t STK_SDL_GetError(int64_t *stk) {
+ SDL_GetError();
+}
+int64_t STK_SDL_ClearError(int64_t *stk) {
+ SDL_ClearError();
+}
+int64_t STK_SDL_FlushEvent(int64_t *stk) {
+ SDL_FlushEvent(stk[0]);
+}
+int64_t STK_GetSurfaceW(int64_t *stk) {
+ return GetSurfaceW((SDL_Surface*)stk[0]);
+}
+int64_t STK_GetSurfaceH(int64_t *stk) {
+ return GetSurfaceH((SDL_Surface*)stk[0]);
+}
+int64_t STK_SDL_CreateRGBSurface(int64_t *stk) {
+ return (int64_t)SDL_CreateRGBSurface(stk[0],stk[1],stk[2],stk[3],stk[4],stk[5],stk[6],stk[7]);
+}
+int64_t STK_SDL_CreateRGBSurfaceFrom(int64_t *stk) {
+ return (int64_t)SDL_CreateRGBSurfaceFrom((void*)stk[0],stk[1],stk[2],stk[3],stk[4],stk[5],stk[6],stk[7],stk[8]);
+}
+int64_t STK_SDL_UpperBlit(int64_t *stk) {
+ return SDL_UpperBlit((SDL_Surface*)stk[0],(SDL_Rect*)stk[1],(SDL_Surface*)stk[2],(SDL_Rect*)stk[3]);
+}
+int64_t STK_SDL_FillRect(int64_t *stk) {
+ return SDL_FillRect((SDL_Surface*)stk[0],(SDL_Rect*)stk[1],stk[2]);
+}
+int64_t STK_SDL_FillRects(int64_t *stk) {
+ return SDL_FillRects((SDL_Surface*)stk[0],(SDL_Rect*)stk[1],stk[2],stk[3]);
+}
+int64_t STK_SDL_GetClipRect(int64_t *stk) {
+ SDL_GetClipRect((SDL_Surface*)stk[0],(SDL_Rect*)stk[1]);
+}
+int64_t STK_SDL_GetColorKey(int64_t *stk) {
+ return SDL_GetColorKey((SDL_Surface*)stk[0],(Uint32*)stk[1]);
+}
+int64_t STK_SDL_GetSurfaceAlphaMod(int64_t *stk) {
+ return SDL_GetSurfaceAlphaMod((SDL_Surface*)stk[0],(Uint8*)stk[1]);
+}
+int64_t STK_SDL_GetSurfaceColorMod(int64_t *stk) {
+ return SDL_GetSurfaceColorMod((SDL_Surface*)stk[0],(Uint8*)stk[1],(Uint8*)stk[2],(Uint8*)stk[3]);
+}
+int64_t STK_SDL_LockSurface(int64_t *stk) {
+ return SDL_LockSurface((SDL_Surface*)stk[0]);
+}
+int64_t STK_SDL_UnlockSurface(int64_t *stk) {
+ SDL_UnlockSurface((SDL_Surface*)stk[0]);
+}
+int64_t STK_SDL_SetClipRect(int64_t *stk) {
+ SDL_SetClipRect((SDL_Surface*)stk[0],(SDL_Rect*)stk[1]);
+}
+int64_t STK_SDL_SetColorKey(int64_t *stk) {
+ SDL_SetColorKey((SDL_Surface*)stk[0],stk[1],stk[2]);
+}
+int64_t STK_SDL_SetSurfaceAlphaMod(int64_t *stk) {
+ return SDL_SetSurfaceAlphaMod((SDL_Surface*)stk[0],stk[1]);
+}
+int64_t STK_SDL_SetSurfaceColorMod(int64_t *stk) {
+ return SDL_SetSurfaceColorMod((SDL_Surface*)stk[0],stk[1],stk[2],stk[3]);
+}
+int64_t STK_SDL_SetSurfaceRLE(int64_t *stk) {
+ return SDL_SetSurfaceRLE((SDL_Surface*)stk[0],stk[1]);
+}
+int64_t STK_SDL_BlitSurface(int64_t *stk) {
+ return SDL_BlitSurface((SDL_Surface*)stk[0],(SDL_Rect*)stk[1],(SDL_Surface*)stk[2],(SDL_Rect*)stk[3]);
+}
+int64_t STK_SDL_BlitScaled(int64_t *stk) {
+ return SDL_LowerBlitScaled((SDL_Surface*)stk[0],(SDL_Rect*)stk[1],(SDL_Surface*)stk[2],(SDL_Rect*)stk[3]);
+}
+int64_t STK_SDL_FreeSurface(int64_t *stk) {
+ SDL_FreeSurface((SDL_Surface*)stk[0]);
+}
+int64_t STK_SDL_UpdateWindowSurface(int64_t *stk) {
+ return (int64_t)SDL_UpdateWindowSurface((SDL_Window*)stk[0]);
+}
+int64_t STK_SDL_GetWindowSurface(int64_t *stk) {
+ return (int64_t)SDL_GetWindowSurface((SDL_Window*)stk[0]);
+}
+int64_t STK_GetBuiltinMacrosText(int64_t *stk) {
+ return (int64_t)GetBuiltinMacrosText();
+}
+int64_t STK_SDL_DisableScreenSaver(int64_t *stk) {
+ SDL_DisableScreenSaver();
+}
+int64_t STK_GCollect(int64_t *stk) {
+ PoopCollect();
+}
+int64_t STK_IsDir(int64_t *stk) {
+ return IsDir(stk[0]);
+}
+int64_t STK___GetBuiltinMacrosText(int64_t *stk) {
+ return GetBuiltinMacrosText();
+}
+//
+//This was built for TOS abi
+//
+void JIT_DebuggerHit();
+void STK_HCSetJmp();
+int64_t FFI_RegisterRuntimeClasses();
+int64_t FFI_UnblockSignals();
+int64_t FFI_Signal();
+int64_t FFI_ForeachFunc();
+int64_t TOS_HCSetJmp();
+int64_t FFI_PopTryFrame();
+int64_t FFI_EnterTry();
+int64_t FFI_ExitCatch();
+int64_t FFI_TOSPrint();
+int64_t FFI_BoundsCheck();
+int64_t FFI_pow();
+int64_t FFI_PoopSetGCEnable();
+int64_t FFI_GCollect();
+int64_t FFI_CreateTagsAndErrorsFiles();
+int64_t FFI_MSize();
+int64_t FFI_BFFS();
+int64_t FFI_BCLZ();
+int64_t FFI_throw();
+int64_t FFI_PoopMAlloc();
+int64_t FFI_PoopFree();
+int64_t FFI_MemNCpy();
+int64_t FFI_MemNCpy();
+int64_t FFI_strlen();
+int64_t FFI_strcmp();
+int64_t FFI_strncmp();
+int64_t FFI_strcpy();
+int64_t FFI_strncpy();
+int64_t FFI_strstr();
+int64_t FFI_GetFs();
+int64_t FFI___GetStr();
+int64_t FFI_atan();
+int64_t FFI_abs();
+int64_t FFI_cos();
+int64_t FFI_sin();
+int64_t FFI_sqrt();
+int64_t FFI_tan();
+int64_t FFI_ceil();
+int64_t FFI_floor();
+int64_t FFI_log();
+int64_t FFI_log10();
+int64_t FFI_log2();
+int64_t FFI_round();
+int64_t FFI_trunc();
+int64_t FFI_exit();
+int64_t FFI_Cd();
+int64_t FFI_DirCur();
+int64_t FFI_DirMk();
+int64_t FFI___Move();
+int64_t FFI_FileNameAbs();
+int64_t FFI_FileNameAbs();
+int64_t FFI___Dir();
+int64_t FFI_IsWindows();
+int64_t FFI_IsMac();
+int64_t FFI_memset();
+int64_t FFI_SDL_Init();
+int64_t FFI_SDL_WasInit();
+int64_t FFI_SDL_CreateWindow();
+int64_t FFI_SDL_SetTextureBlendMode();
+int64_t FFI_SDL_CreateWindowAndRenderer();
+int64_t FFI_SDL_DestroyWindow();
+int64_t FFI_SDL_DestroyRenderer();
+int64_t FFI_SDL_DisableScreenSaver();
+int64_t FFI_SDL_GetGrabbedWindow();
+int64_t FFI_SDL_GetWindowPosition();
+int64_t FFI_SDL_GetWindowMinimumSize();
+int64_t FFI_SDL_GetWindowMaximumSize();
+int64_t FFI_SDL_GetWindowSize();
+int64_t FFI_hc_SDL_GetWindowTitle();
+int64_t FFI_SDL_HideWindow();
+int64_t FFI_SDL_MaximizeWindow();
+int64_t FFI_SDL_MinimizeWindow();
+int64_t FFI_SDL_SetWindowBordered();
+int64_t FFI_SDL_SetWindowFullscreen();
+int64_t FFI_SDL_SetWindowMaximumSize();
+int64_t FFI_SDL_SetWindowMinimumSize();
+int64_t FFI_SDL_SetWindowResizable();
+int64_t FFI_SDL_SetWindowSize();
+int64_t FFI_SDL_SetWindowTitle();
+int64_t FFI_SDL_ShowWindow();
+int64_t FFI_SDL_CreateRenderer();
+int64_t FFI_SDL_CreateTexture();
+int64_t FFI_SDL_DestroyRenderer();
+int64_t FFI_SDL_GetRenderDrawColor();
+int64_t FFI_SDL_GetRenderer();
+int64_t FFI_SDL_GetRendererOutputSize();
+int64_t FFI_SDL_GetRenderTarget();
+int64_t FFI_SDL_GetTextureAlphaMod();
+int64_t FFI_SDL_GetTextureColorMod();
+int64_t FFI_SDL_RenderClear();
+int64_t FFI_SDL_RenderCopy();
+int64_t FFI_SDL_RenderDrawLine();
+int64_t FFI_SDL_RenderDrawLines();
+int64_t FFI_SDL_RenderDrawPoint();
+int64_t FFI_SDL_RenderDrawPoints();
+int64_t FFI_SDL_RenderDrawRect();
+int64_t FFI_SDL_RenderDrawRects();
+int64_t FFI_SDL_RenderFillRects();
+int64_t FFI_SDL_RenderGetClipRect();
+int64_t FFI_SDL_RenderPresent();
+int64_t FFI_SDL_RenderSetClipRect();
+int64_t FFI_SDL_SetRenderDrawColor();
+int64_t FFI_SDL_SetRenderTarget();
+int64_t FFI_SDL_SetTextureAlphaMod();
+int64_t FFI_SDL_SetTextureColorMod();
+int64_t FFI_SDL_UpdateTexture();
+int64_t FFI_SDL_QueryTexture();
+int64_t FFI_SDL_GetClipboardText();
+int64_t FFI_SDL_SetClipboardText();
+int64_t FFI_SDL_PollEvent();
+int64_t FFI_SDL_WaitEvent();
+int64_t FFI_SDL_DestroyRenderer();
+int64_t FFI_SDL_DestroyTexture();
+int64_t FFI_SDL_StartTextInput();
+int64_t FFI_SDL_StopTextInput();
+int64_t FFI_SDL_GetError();
+int64_t FFI_SDL_ClearError();
+int64_t FFI_SDL_FlushEvent();
+int64_t FFI_GetSurfaceW();
+int64_t FFI_GetSurfaceH();
+int64_t FFI_SDL_CreateRGBSurface();
+int64_t FFI_SDL_CreateRGBSurfaceFrom();
+int64_t FFI_SDL_UpperBlit();
+int64_t FFI_SDL_FillRect();
+int64_t FFI_SDL_FillRects();
+int64_t FFI_SDL_GetClipRect();
+int64_t FFI_SDL_GetColorKey();
+int64_t FFI_SDL_GetSurfaceAlphaMod();
+int64_t FFI_SDL_GetSurfaceColorMod();
+int64_t FFI_SDL_LockSurface();
+int64_t FFI_SDL_UnlockSurface();
+int64_t FFI_SDL_SetClipRect();
+int64_t FFI_SDL_SetColorKey();
+int64_t FFI_SDL_SetSurfaceAlphaMod();
+int64_t FFI_SDL_SetSurfaceColorMod();
+int64_t FFI_SDL_SetSurfaceRLE();
+int64_t FFI_SDL_BlitSurface();
+int64_t FFI_SDL_BlitScaled();
+int64_t FFI_SDL_FreeSurface();
+int64_t FFI_SDL_UpdateWindowSurface();
+int64_t FFI_SDL_GetWindowSurface();
+int64_t FFI_GetBuiltinMacrosText();
+int64_t FFI_IsDir();
+int64_t FFI_FileRead();
+int64_t FFI_FileWrite();
+int64_t FFI_Del();
+void TOS_RegisterFuncPtrs() {
+ STK_RegisterFunctionPtr("RegisterRuntimeClasses",FFI_RegisterRuntimeClasses);
+ STK_RegisterFunctionPtr("UnblockSignals",FFI_UnblockSignals);
+ STK_RegisterFunctionPtr("signal",FFI_Signal);
+ STK_RegisterFunctionPtr("ForeachFuncInTable",FFI_ForeachFunc);
+ STK_RegisterFunctionPtr("FileRead",FFI_FileRead);
+ STK_RegisterFunctionPtr("FileWrite",FFI_FileWrite);
+ STK_RegisterFunctionPtr("IsDir",FFI_IsDir);
+ //SPECIAL
+ STK_RegisterFunctionPtr("HCSetJmp",TOS_HCSetJmp);
+ //SPECIAL
+ STK_RegisterFunctionPtr("JIT_DebuggerHit",JIT_DebuggerHit);
+ STK_RegisterFunctionPtr("PopTryFrame",FFI_PopTryFrame);
+ STK_RegisterFunctionPtr("EnterTry",FFI_EnterTry);
+ STK_RegisterFunctionPtr("ExitCatch",FFI_ExitCatch);
+ STK_RegisterFunctionPtr("TOSPrint",FFI_TOSPrint);
+ STK_RegisterFunctionPtr("WhineOnOutOfBounds",FFI_BoundsCheck);
+ STK_RegisterFunctionPtr("Pow",FFI_pow);
+ STK_RegisterFunctionPtr("PoopSetGCEnable",FFI_PoopSetGCEnable);
+ STK_RegisterFunctionPtr("GC_Collect",FFI_GCollect);
+ STK_RegisterFunctionPtr("CreateTagsAndErrorsFiles",FFI_CreateTagsAndErrorsFiles);
+ STK_RegisterFunctionPtr("MSize",FFI_MSize);
+ STK_RegisterFunctionPtr("Bsf",FFI_BFFS);
+ STK_RegisterFunctionPtr("Bsr",FFI_BCLZ);
+ STK_RegisterFunctionPtr("throw",FFI_throw);
+ STK_RegisterFunctionPtr("MAlloc",FFI_PoopMAlloc);
+ STK_RegisterFunctionPtr("Free",FFI_PoopFree);
+ STK_RegisterFunctionPtr("MemCpy",FFI_MemNCpy);
+ STK_RegisterFunctionPtr("MemNCpy",FFI_MemNCpy);
+ STK_RegisterFunctionPtr("StrLen",FFI_strlen);
+ STK_RegisterFunctionPtr("StrCmp",FFI_strcmp);
+ STK_RegisterFunctionPtr("StrNCmp",FFI_strncmp);
+ STK_RegisterFunctionPtr("StrCpy",FFI_strcpy);
+ STK_RegisterFunctionPtr("StrNCpy",FFI_strncpy);
+ STK_RegisterFunctionPtr("StrMatch",FFI_strstr);
+ STK_RegisterFunctionPtr("Fs",FFI_GetFs);
+ STK_RegisterFunctionPtr("__GetStr",FFI___GetStr);
+ STK_RegisterFunctionPtr("ATan",FFI_atan);
+ STK_RegisterFunctionPtr("Abs",FFI_abs);
+ STK_RegisterFunctionPtr("Cos",FFI_cos);
+ STK_RegisterFunctionPtr("Sin",FFI_sin);
+ STK_RegisterFunctionPtr("Sqrt",FFI_sqrt);
+ STK_RegisterFunctionPtr("Tan",FFI_tan);
+ STK_RegisterFunctionPtr("Ceil",FFI_ceil);
+ STK_RegisterFunctionPtr("Floor",FFI_floor);
+ STK_RegisterFunctionPtr("Ln",FFI_log);
+ STK_RegisterFunctionPtr("Log10",FFI_log10);
+ STK_RegisterFunctionPtr("Log2",FFI_log2);
+ STK_RegisterFunctionPtr("Round",FFI_round);
+ STK_RegisterFunctionPtr("Trunc",FFI_trunc);
+ STK_RegisterFunctionPtr("Exit",FFI_exit);
+ STK_RegisterFunctionPtr("Cd",FFI_Cd);
+ STK_RegisterFunctionPtr("DirCur",FFI_DirCur);
+ STK_RegisterFunctionPtr("DirMk",FFI_DirMk);
+ STK_RegisterFunctionPtr("__Move",FFI___Move);
+ STK_RegisterFunctionPtr("Del",FFI_Del);
+ STK_RegisterFunctionPtr("FileNameAbs",FFI_FileNameAbs);
+ STK_RegisterFunctionPtr("DirNameAbs",FFI_FileNameAbs);
+ STK_RegisterFunctionPtr("__Dir",FFI___Dir);
+ STK_RegisterFunctionPtr("IsWindows",FFI_IsWindows);
+ STK_RegisterFunctionPtr("IsMac",FFI_IsMac);
+ STK_RegisterFunctionPtr("MemSet",FFI_memset);
+ STK_RegisterFunctionPtr("SDL_Init",FFI_SDL_Init);
+ STK_RegisterFunctionPtr("SDL_WasInit",FFI_SDL_WasInit);
+ STK_RegisterFunctionPtr("SDL_CreateWindow",FFI_SDL_CreateWindow);
+ STK_RegisterFunctionPtr("SDL_SetTextureBlendMode",FFI_SDL_SetTextureBlendMode);
+ STK_RegisterFunctionPtr("SDL_CreateWindowAndRenderer",FFI_SDL_CreateWindowAndRenderer);
+ STK_RegisterFunctionPtr("SDL_DestroyWindow",FFI_SDL_DestroyWindow);
+ STK_RegisterFunctionPtr("SDL_DestroyRenderer",FFI_SDL_DestroyRenderer);
+ STK_RegisterFunctionPtr("SDL_DisableScreenSaver",FFI_SDL_DisableScreenSaver);
+ STK_RegisterFunctionPtr("SDL_GetGrabbedWindow",FFI_SDL_GetGrabbedWindow);
+ STK_RegisterFunctionPtr("SDL_GetWindowPosition",FFI_SDL_GetWindowPosition);
+ STK_RegisterFunctionPtr("SDL_GetWindowMinimumSize",FFI_SDL_GetWindowMinimumSize);
+ STK_RegisterFunctionPtr("SDL_GetWindowMaximumSize",FFI_SDL_GetWindowMaximumSize);
+ STK_RegisterFunctionPtr("SDL_GetWindowSize",FFI_SDL_GetWindowSize);
+ STK_RegisterFunctionPtr("SDL_GetWindowTitle",FFI_hc_SDL_GetWindowTitle);
+ STK_RegisterFunctionPtr("SDL_HideWindow",FFI_SDL_HideWindow);
+ STK_RegisterFunctionPtr("SDL_MaximizeWindow",FFI_SDL_MaximizeWindow);
+ STK_RegisterFunctionPtr("SDL_MinimizeWindow",FFI_SDL_MinimizeWindow);
+ STK_RegisterFunctionPtr("SDL_SetWindowBordered",FFI_SDL_SetWindowBordered);
+ STK_RegisterFunctionPtr("SDL_SetWindowFullscreen",FFI_SDL_SetWindowFullscreen);
+ STK_RegisterFunctionPtr("SDL_SetWindowMaximumSize",FFI_SDL_SetWindowMaximumSize);
+ STK_RegisterFunctionPtr("SDL_SetWindowMinimumSize",FFI_SDL_SetWindowMinimumSize);
+ STK_RegisterFunctionPtr("SDL_SetWindowResizable",FFI_SDL_SetWindowResizable);
+ STK_RegisterFunctionPtr("SDL_SetWindowSize",FFI_SDL_SetWindowSize);
+ STK_RegisterFunctionPtr("SDL_SetWindowTitle",FFI_SDL_SetWindowTitle);
+ STK_RegisterFunctionPtr("SDL_ShowWindow",FFI_SDL_ShowWindow);
+ STK_RegisterFunctionPtr("SDL_CreateRenderer",FFI_SDL_CreateRenderer);
+ STK_RegisterFunctionPtr("SDL_CreateTexture",FFI_SDL_CreateTexture);
+ STK_RegisterFunctionPtr("SDL_DestroyRenderer",FFI_SDL_DestroyRenderer);
+ STK_RegisterFunctionPtr("SDL_GetRenderer",FFI_SDL_GetRenderer);
+ STK_RegisterFunctionPtr("SDL_GetRendererOutputSize",FFI_SDL_GetRendererOutputSize);
+ STK_RegisterFunctionPtr("SDL_GetTextureAlphaMod",FFI_SDL_GetTextureAlphaMod);
+ STK_RegisterFunctionPtr("SDL_GetTextureColorMod",FFI_SDL_GetTextureColorMod);
+ STK_RegisterFunctionPtr("SDL_RenderClear",FFI_SDL_RenderClear);
+ STK_RegisterFunctionPtr("SDL_RenderCopy",FFI_SDL_RenderCopy);
+ STK_RegisterFunctionPtr("SDL_RenderDrawLine",FFI_SDL_RenderDrawLine);
+ STK_RegisterFunctionPtr("SDL_RenderDrawPoint",FFI_SDL_RenderDrawPoint);
+ STK_RegisterFunctionPtr("SDL_RenderDrawPoints",FFI_SDL_RenderDrawPoints);
+ STK_RegisterFunctionPtr("SDL_RenderDrawRect",FFI_SDL_RenderDrawRect);
+ STK_RegisterFunctionPtr("SDL_RenderDrawRects",FFI_SDL_RenderDrawRects);
+ STK_RegisterFunctionPtr("SDL_RenderFillRects",FFI_SDL_RenderFillRects);
+ STK_RegisterFunctionPtr("SDL_RenderGetClipRect",FFI_SDL_RenderGetClipRect);
+ STK_RegisterFunctionPtr("SDL_RenderPresent",FFI_SDL_RenderPresent);
+ STK_RegisterFunctionPtr("SDL_RenderSetClipRect",FFI_SDL_RenderSetClipRect);
+ STK_RegisterFunctionPtr("SDL_SetTextureAlphaMod",FFI_SDL_SetTextureAlphaMod);
+ STK_RegisterFunctionPtr("SDL_SetTextureColorMod",FFI_SDL_SetTextureColorMod);
+ STK_RegisterFunctionPtr("SDL_UpdateTexture",FFI_SDL_UpdateTexture);
+ STK_RegisterFunctionPtr("SDL_QueryTexture",FFI_SDL_QueryTexture);
+ STK_RegisterFunctionPtr("SDL_GetClipboardText",FFI_SDL_GetClipboardText);
+ STK_RegisterFunctionPtr("SDL_SetClipboardText",FFI_SDL_SetClipboardText);
+ STK_RegisterFunctionPtr("SDL_PollEvent",FFI_SDL_PollEvent);
+ STK_RegisterFunctionPtr("SDL_WaitEvent",FFI_SDL_WaitEvent);
+ STK_RegisterFunctionPtr("SDL_DestroyRenderer",FFI_SDL_DestroyRenderer);
+ STK_RegisterFunctionPtr("SDL_DestroyTexture",FFI_SDL_DestroyTexture);
+ STK_RegisterFunctionPtr("SDL_StartTextInput",FFI_SDL_StartTextInput);
+ STK_RegisterFunctionPtr("SDL_StopTextInput",FFI_SDL_StopTextInput);
+ STK_RegisterFunctionPtr("SDL_GetError",FFI_SDL_GetError);
+ STK_RegisterFunctionPtr("SDL_ClearError",FFI_SDL_ClearError);
+ STK_RegisterFunctionPtr("SDL_FlushEvent",FFI_SDL_FlushEvent);
+ STK_RegisterFunctionPtr("SDL_GetSurfaceWidth",FFI_GetSurfaceW);
+ STK_RegisterFunctionPtr("SDL_GetSurfaceHeight",FFI_GetSurfaceH);
+ STK_RegisterFunctionPtr("SDL_CreateRGBSurface",FFI_SDL_CreateRGBSurface);
+ STK_RegisterFunctionPtr("SDL_CreateRGBSurfaceFrom",FFI_SDL_CreateRGBSurfaceFrom);
+ STK_RegisterFunctionPtr("SDL_UpperBlit",FFI_SDL_UpperBlit);
+ STK_RegisterFunctionPtr("SDL_FillRect",FFI_SDL_FillRect);
+ STK_RegisterFunctionPtr("SDL_FillRects",FFI_SDL_FillRects);
+ STK_RegisterFunctionPtr("SDL_GetClipRect",FFI_SDL_GetClipRect);
+ STK_RegisterFunctionPtr("SDL_GetColorKey",FFI_SDL_GetColorKey);
+ STK_RegisterFunctionPtr("SDL_GetSurfaceAlphaMod",FFI_SDL_GetSurfaceAlphaMod);
+ STK_RegisterFunctionPtr("SDL_GetSurfaceColorMod",FFI_SDL_GetSurfaceColorMod);
+ STK_RegisterFunctionPtr("SDL_LockSurface",FFI_SDL_LockSurface);
+ STK_RegisterFunctionPtr("SDL_UnlockSurface",FFI_SDL_UnlockSurface);
+ STK_RegisterFunctionPtr("SDL_SetClipRect",FFI_SDL_SetClipRect);
+ STK_RegisterFunctionPtr("SDL_SetColorKey",FFI_SDL_SetColorKey);
+ STK_RegisterFunctionPtr("SDL_SetSurfaceAlphaMod",FFI_SDL_SetSurfaceAlphaMod);
+ STK_RegisterFunctionPtr("SDL_SetSurfaceColorMod",FFI_SDL_SetSurfaceColorMod);
+ STK_RegisterFunctionPtr("SDL_SetSurfaceRLE",FFI_SDL_SetSurfaceRLE);
+ STK_RegisterFunctionPtr("SDL_BlitSurface",FFI_SDL_BlitSurface);
+ STK_RegisterFunctionPtr("SDL_BlitScaled",FFI_SDL_BlitScaled);
+ STK_RegisterFunctionPtr("SDL_FreeSurface",FFI_SDL_FreeSurface);
+ STK_RegisterFunctionPtr("SDL_UpdateWindowSurface",FFI_SDL_UpdateWindowSurface);
+ STK_RegisterFunctionPtr("SDL_GetWindowSurface",FFI_SDL_GetWindowSurface);
+ STK_RegisterFunctionPtr("__GetBuiltinMacrosText",FFI_GetBuiltinMacrosText);
}
static void *GetType(void *fp,char *name,long ptr_level) {
CSymbol *gt;
- if(!fp) {
- gt=map_get(&Loader.symbols,"GetType");
- if(!gt) return NULL;
- fp=gt->value_ptr;
- }
- return ((void*(*)(char *,long))fp)(name,ptr_level);
+ gt=map_get(&Loader.symbols,"GetType");
+ if(!gt) return NULL;
+ fp=gt->value_ptr;
+ return FFI_CALL_TOS_2(gt->value_ptr,name,ptr_level);
}
static void *__LoaderCreateTypeFwd(void *fp,char *name,long sz,long align) {
CSymbol *gt;
- if(!fp) {
- gt=map_get(&Loader.symbols,"LoaderCreateTypeFwd");
- if(!gt) return NULL;
- fp=gt->value_ptr;
- }
- return ((void*(*)(char *,long,long))fp)(name,sz,align);
+ gt=map_get(&Loader.symbols,"LoaderCreateTypeFwd");
+ if(!gt) return NULL;
+ return FFI_CALL_TOS_3(gt->value_ptr,name,sz,align);
}
#define LoaderCreateTypeFwd(fp,t) __LoaderCreateTypeFwd(fp,#t,sizeof(t),8);
static void __LoaderAddMember(void *fp,void *dst,void *t,char *name,long off) {
CSymbol *gt;
- if(!fp) {
- gt=map_get(&Loader.symbols,"LoaderAddMember");
- if(!gt) return NULL;
- fp=gt->value_ptr;
- }
- return ((void(*)(void*,void*,char *,long))fp)(dst,t,name,off);
+ gt=map_get(&Loader.symbols,"LoaderAddMember");
+ if(!gt) return NULL;
+ return FFI_CALL_TOS_4(gt->value_ptr,dst,t,name,off);
}
static CType *PrimType(void *fp,int64_t sz) {
switch(sz) {
@@ -1264,12 +1077,10 @@ static CType *PrimType(void *fp,int64_t sz) {
}
static CType *LoaderCreateArrayType(void *fp,char *name,int64_t dim) {
CSymbol *gt;
- if(!fp) {
- gt=map_get(&Loader.symbols,"LoaderCreateArrayType");
- if(!gt) return NULL;
- fp=gt->value_ptr;
- }
- return ((void*(*)(char *,long))fp)(name,dim);
+ gt=map_get(&Loader.symbols,"LoaderCreateArrayType");
+ if(!gt) return NULL;
+ fp=gt->value_ptr;
+ return FFI_CALL_TOS_2(fp,name,dim);
}
#define LoaderAddMember(fp,d,t,ct,mem) __LoaderAddMember(fp,d,t,#mem,offsetof(ct,mem));
#define LoaderAddPrimMember(fp,gt,d,ct,mem) __LoaderAddMember(fp,d,PrimType(gt,sizeof(((ct*)NULL)->mem)),#mem,offsetof(ct,mem));
@@ -1281,25 +1092,17 @@ static void CreateMacroInt(vec_char_t *to,char *name,int64_t value) {
vec_char_t CreateMacros() {
vec_char_t macros;
vec_init(&macros);
- CreateMacroInt(&macros,"JIT_SIGNED_NUM", JIT_SIGNED_NUM);
- CreateMacroInt(&macros,"JIT_UNSIGNED_NUM", JIT_UNSIGNED_NUM);
- CreateMacroInt(&macros,"JIT_FLOAT_NUM", JIT_FLOAT_NUM);
- CreateMacroInt(&macros,"JIT_PTR", JIT_PTR);
- CreateMacroInt(&macros,"JIT_OPT_ALL",JIT_OPT_ALL);
- CreateMacroInt(&macros,"JIT_OPT_JOIN_ADDMUL",JIT_OPT_JOIN_ADDMUL);
- CreateMacroInt(&macros,"JIT_OPT_OMIT_UNUSED_ASSIGNEMENTS",JIT_OPT_OMIT_UNUSED_ASSIGNEMENTS);
- CreateMacroInt(&macros,"JIT_OPT_OMIT_FRAME_PTR",JIT_OPT_OMIT_FRAME_PTR);
//SIGNALS
- #ifndef TARGET_WIN32
CreateMacroInt(&macros,"SIGILL",SIGILL);
CreateMacroInt(&macros,"SIGABRT",SIGABRT);
- CreateMacroInt(&macros,"SIGBUS",SIGBUS);
CreateMacroInt(&macros,"SIGFPE",SIGFPE);
+ #ifndef TARGET_WIN32
CreateMacroInt(&macros,"SIGKILL",SIGKILL);
- CreateMacroInt(&macros,"SIGSEGV",SIGSEGV);
- CreateMacroInt(&macros,"SIGTERM",SIGTERM);
+ CreateMacroInt(&macros,"SIGBUS",SIGBUS);
CreateMacroInt(&macros,"SIGSTOP",SIGSTOP);
#endif
+ CreateMacroInt(&macros,"SIGSEGV",SIGSEGV);
+ CreateMacroInt(&macros,"SIGTERM",SIGTERM);
CreateMacroInt(&macros,"SDL_INIT_TIMER",SDL_INIT_TIMER);
CreateMacroInt(&macros,"SDL_INIT_AUDIO",SDL_INIT_AUDIO);
CreateMacroInt(&macros,"SDL_INIT_VIDEO",SDL_INIT_VIDEO);
@@ -1459,7 +1262,7 @@ void RegisterMacrosAndREPL(char *includes,int flags,char *body_code) {
assert(repl);
for(;;) {
if(!HCSetJmp(EnterTry())) {
- ((void(*)(char*,long,char *))repl->value_ptr)(macros.data,flags,body_code);
+ FFI_CALL_TOS_3(repl->value_ptr,macros.data,flags,body_code);
break;
} else {
fprintf(stderr,"Caught exception,re-entering.\n");
@@ -1477,5 +1280,5 @@ void RegisterMacrosAndCompile(char *includes,char *to_file,char *embed_header) {
vec_pusharr(&macros,includes,strlen(includes));
vec_push(&macros,0);
CSymbol *comp=map_get(&Loader.symbols,"CompileBinModule");
- ((void(*)(char*,char*,char *))comp->value_ptr)(macros.data,to_file,embed_header);
+ FFI_CALL_TOS_3(comp->value_ptr,macros.data,to_file,embed_header);
}