Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NX9qf-0007H2-Ef for qemu-devel@nongnu.org; Tue, 19 Jan 2010 03:54:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NX9qa-0007Cu-Ll for qemu-devel@nongnu.org; Tue, 19 Jan 2010 03:54:05 -0500 Received: from [199.232.76.173] (port=33040 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NX9qa-0007Cm-I7 for qemu-devel@nongnu.org; Tue, 19 Jan 2010 03:54:00 -0500 Received: from web15901.mail.cnb.yahoo.com ([202.165.103.82]:47187) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1NX9qY-0007T5-EP for qemu-devel@nongnu.org; Tue, 19 Jan 2010 03:54:00 -0500 Message-ID: <828660.81307.qm@web15901.mail.cnb.yahoo.com> Date: Tue, 19 Jan 2010 16:47:12 +0800 (CST) From: identifier scorpio MIME-Version: 1.0 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] Porting TCG to alpha platform List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hello.=0A=0AI ported TCG to alpha platform, the patch is currently based on= stable-0.10 branch, and now it can run linux-0.2.img testing image on my a= lpha XP1000 workstation. but it still can't run MS-windows, and I hope some= one, especially those guys that are working on target-alpha, may help me to= find the bugs.=0A=0AFrom 0ee33ea1e43298e6045e16dfcf07cb7a530dfd56 Mon Sep = 17 00:00:00 2001=0AFrom: Dong Weiyu =0ADate: Tue,= 19 Jan 2010 16:22:54 +0800=0ASubject: [PATCH] porting TCG to alpha platfor= m.=0A=0A---=0A cpu-all.h | 2 +-=0A tcg/alpha/tcg-target.c |= 1335 ++++++++++++++++++++++++++++++++++++++++++++++++=0A tcg/alpha/tcg-tar= get.h | 70 +++=0A 3 files changed, 1406 insertions(+), 1 deletions(-)=0A = create mode 100644 tcg/alpha/tcg-target.c=0A create mode 100644 tcg/alpha/t= cg-target.h=0A=0Adiff --git a/cpu-all.h b/cpu-all.h=0Aindex e0c3efd..bdf6fb= 2 100644=0A--- a/cpu-all.h=0A+++ b/cpu-all.h=0A@@ -22,7 +22,7 @@=0A =0A #in= clude "qemu-common.h"=0A =0A-#if defined(__arm__) || defined(__sparc__) || = defined(__mips__) || defined(__hppa__)=0A+#if defined(__arm__) || defined(_= _sparc__) || defined(__mips__) || defined(__hppa__) || defined(__alpha__)= =0A #define WORDS_ALIGNED=0A #endif=0A =0Adiff --git a/tcg/alpha/tcg-target= .c b/tcg/alpha/tcg-target.c=0Anew file mode 100644=0Aindex 0000000..6bbd69f= =0A--- /dev/null=0A+++ b/tcg/alpha/tcg-target.c=0A@@ -0,0 +1,1335 @@=0A+/*= =0A=0A+ * Tiny Code Generator for QEMU on ALPHA platform=0A+*/=0A=0A+=0A=0A= +#ifndef NDEBUG=0A=0A+static const char * const tcg_target_reg_names[TCG_TA= RGET_NB_REGS] =3D {=0A=0A+ "$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7= ",=0A=0A+ "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15",=0A=0A+ = "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23",=0A=0A+ "$24", = "$25", "$26", "$27", "$28", "$29", "$30", "$31",=0A=0A+};=0A=0A+#endif=0A= =0A+=0A=0A+/* =0A=0A+ * $26 ~ $31 are special, reserved, =0A=0A+ * and $25 = is deliberately reserved for jcc operation=0A=0A+ * and $0 is usually used = for return function result, better allocate it later=0A=0A+ * and $15 is us= ed for cpu_env pointer, allocate it at last=0A=0A+*/=0A=0A+static const int= tcg_target_reg_alloc_order[] =3D {=0A=0A+ TCG_REG_1, TCG_REG_2, TCG_REG= _3, TCG_REG_4, TCG_REG_5, TCG_REG_6,=0A=0A+ TCG_REG_7, TCG_REG_8, TCG_RE= G_22, =0A+ TCG_REG_9, TCG_REG_10, TCG_REG_11, TCG_REG_12, TCG_REG_13, TC= G_REG_14,=0A=0A+ TCG_REG_16, TCG_REG_17, TCG_REG_18, TCG_REG_19, TCG_REG= _20, TCG_REG_21=0A+};=0A=0A+=0A=0A+/*=0A=0A+ * according to alpha calling c= onvention, these 6 registers are used for =0A=0A+ * function parameter pass= ing. if function has more than 6 parameters, remained=0A=0A+ * ones are sto= red on stack.=0A=0A+*/=0A=0A+static const int tcg_target_call_iarg_regs[6] = =3D { =0A=0A+ TCG_REG_16, TCG_REG_17, TCG_REG_18, TCG_REG_19, TCG_REG_20= , TCG_REG_21=0A=0A+};=0A=0A+=0A=0A+/*=0A=0A+ * according to alpha calling c= onvention, $0 is used for returning function result.=0A=0A+*/=0A=0A+static = const int tcg_target_call_oarg_regs[1] =3D { TCG_REG_0 };=0A=0A+=0A=0A+/*= =0A=0A+ * save the address of TB's epilogue.=0A=0A+*/=0A=0A+static uint8_t = *tb_ret_addr;=0A=0A+=0A=0A+/* =0A=0A+ * op-code and func-code for jump insn= =0A=0A+*/=0A=0A+#define OP_CALL 0x01A=0A=0A+#define OP_RET = 0x01A=0A=0A+#define OP_JMP 0x01A=0A=0A+=0A=0A+#define FUNC_JMP = 0x00=0A=0A+#define FUNC_CALL 0x01=0A=0A+#define FUNC_RET 0x02= =0A=0A+=0A=0A+#define OP_BR 0x30=0A=0A+#define OP_BEQ=09 0x3= 9=0A=0A+#define OP_BNE=09 0x3D=0A=0A+#define OP_BLBC 0x38=0A= =0A+#define OP_BLBS 0x3C=0A=0A+=0A=0A+#define OP_ADDSUBCMP 0x10=0A= =0A+=0A=0A+#define FUNC_ADDL 0x00=0A=0A+#define FUNC_SUBL 0x09=0A= =0A+#define FUNC_ADDQ 0x20=0A=0A+#define FUNC_SUBQ 0x29=0A=0A+#de= fine FUNC_CMPEQ 0x2D=0A=0A+#define FUNC_CMPLT 0x4D=0A=0A+#define FU= NC_CMPLE 0x6D=0A=0A+#define FUNC_CMPULT 0x1D=0A=0A+#define FUNC_CMPU= LE 0x3D=0A=0A+=0A=0A+#define OP_MUL 0x13=0A=0A+=0A=0A+#define FU= NC_MULL 0x00=0A=0A+#define FUNC_MULQ 0x20=0A=0A+=0A=0A+#define OP= _LOGIC 0x11=0A=0A+=0A=0A+#define FUNC_AND 0x00=0A=0A+#define FU= NC_BIS 0x20=0A=0A+#define FUNC_XOR 0x40=0A=0A+=0A=0A+#define OP= _SHIFT 0x12=0A=0A+=0A=0A+#define FUNC_SLL 0x39=0A=0A+#define FU= NC_SRL 0x34=0A=0A+#define FUNC_SRA 0x3C=0A=0A+=0A=0A+#define OP= _SEXT 0x1C=0A=0A+=0A=0A+#define FUNC_SEXTB 0x00=0A=0A+#define FU= NC_SEXTW 0x01=0A=0A+=0A=0A+#define OP_LDA 0x08=0A=0A+#define OP= _LDAH 0x09=0A=0A+#define OP_LDBU 0x0A=0A=0A+#define OP_LDWU = 0x0C=0A=0A+#define OP_LDL 0x28=0A=0A+#define OP_LDQ 0= x29=0A=0A+#define OP_STB 0x0E=0A=0A+#define OP_STW 0x0D=0A= =0A+#define OP_STL 0x2C=0A=0A+#define OP_STQ 0x2D=0A+=0A=0A= +/*=0A=0A+ * return the # of regs used for parameter passing on procedure c= alling.=0A=0A+ * note that alpha use $16~$21 to transfer the first 6 parame= nters of a procedure.=0A=0A+*/=0A=0A+static inline int tcg_target_get_call_= iarg_regs_count(int flags)=0A=0A+{=0A=0A+ return 6;=0A=0A+}=0A=0A+=0A=0A= +/*=0A=0A+ * given constraint, return available register set. this function= is called once=0A=0A+ * for each op at qemu's initialization stage.=0A=0A+= */=0A=0A+static int target_parse_constraint(TCGArgConstraint *ct, const cha= r **pct_str)=0A=0A+{=0A=0A+ const char *ct_str =3D *pct_str;=0A=0A+=0A= =0A+ switch(ct_str[0]) =0A=0A+ {=0A=0A+ case 'r':=0A=0A+ /*= constaint 'r' means any register is okay */=0A=0A+ ct->ct |=3D TCG_= CT_REG;=0A=0A+ tcg_regset_set32(ct->u.regs, 0, 0xffffffffu);=0A=0A+ = break;=0A=0A+=0A=0A+ case 'L':=0A=0A+ /* =0A=0A+ * = constranit 'L' is used for qemu_ld/st, which has 2 meanings:=0A=0A+ = * 1st, we the argument need to be allocated a register.=0A=0A+ * 2nd= , we should reserve some registers that belong to caller-clobbered =0A=0A+ = * list for qemu_ld/st local usage, so these registers must not be = =0A=0A+ * allocated to the argument that the 'L' constraint is descr= ibing.=0A=0A+ *=0A=0A+ * note that op qemu_ld/st has the TCG_= OPF_CALL_CLOBBER flag, and =0A=0A+ * tcg will free all callee-clobbe= red registers before generate target=0A=0A+ * insn for qemu_ld/st, s= o we can use these register directly without=0A=0A+ * warrying about= destroying their content.=0A=0A+ */=0A=0A+ ct->ct |=3D TCG_C= T_REG;=0A=0A+ tcg_regset_set32(ct->u.regs, 0, 0xffffffffu);=0A+ = tcg_regset_reset_reg(ct->u.regs, TCG_REG_0);=0A+ tcg_regset_reset= _reg(ct->u.regs, TCG_REG_16);=0A+ tcg_regset_reset_reg(ct->u.regs, T= CG_REG_17);=0A+ tcg_regset_reset_reg(ct->u.regs, TCG_REG_18);=0A+ = break;=0A+=0A=0A+ default:=0A=0A+ return -1;=0A=0A+ }=0A= =0A+=0A=0A+ ct_str++;=0A=0A+ *pct_str =3D ct_str;=0A=0A+ return 0;= =0A=0A+}=0A=0A+=0A=0A+/*=0A=0A+ * whether op's input argument may use const= ant =0A=0A+*/=0A=0A+static inline int tcg_target_const_match( \=0A=0A+=09tc= g_target_long val, const TCGArgConstraint *arg_ct)=0A=0A+{=0A=0A+ int ct= =3D arg_ct->ct;=0A+ return (ct & TCG_CT_CONST) ? 1 : 0;=0A+}=0A=0A+=0A= =0A+static inline void tcg_out_inst2(TCGContext *s, int Opcode, int Ra, int= Disp)=0A=0A+{=0A=0A+ uint32_t v =3D 0;=0A=0A+ v =3D ( ( Opcode & 0x3= f ) << 26 )=0A=0A+ | ( ( Ra & 0x1f ) << 21 )=0A=0A+ | ( Disp= & 0x1fffff) ;=0A=0A+ tcg_out32(s, v);=09=0A=0A+}=0A=0A+=0A=0A+static in= line void tcg_out_inst3_disp(TCGContext *s, int Opcode, int Ra, int Rb, int= Disp)=0A=0A+{=0A=0A+ uint32_t v =3D 0;=0A=0A+ v =3D ( ( Opcode & 0x3= f ) << 26 )=0A=0A+ | ( ( Ra & 0x1f ) << 21 )=0A=0A+ | ( ( Rb= & 0x1f ) << 16 )=0A=0A+ | ( Disp & 0xffff) ;=0A=0A+ tcg_out32(s,= v);=09=0A=0A+}=0A=0A+=0A=0A+static inline void tcg_out_inst3_func(TCGConte= xt *s, int Opcode, int Ra, int Rb, int Func, int Disp)=0A=0A+{=0A=0A+ ui= nt32_t v =3D 0;=0A+ v =3D ( ( Opcode & 0x3f ) << 26 )=0A=0A+ | ( = ( Ra & 0x1f ) << 21 )=0A=0A+ | ( ( Rb & 0x1f ) << 16 )=0A=0A+ |= ( ( Func & 0x3 ) << 14 )=0A=0A+ | ( Disp & 0x3fff) ;=0A=0A+ tcg_o= ut32(s, v);=09=0A=0A+}=0A=0A+=0A=0A+static inline void tcg_out_inst4(TCGCon= text *s, int Opcode, int Ra, int Rb, int Func, int Rc)=0A=0A+{=0A=0A+ ui= nt32_t v =3D 0;=0A+ v =3D ( (Opcode & 0x3f) << 26 )=0A=0A+ | ( (= Ra & 0x1f ) << 21 )=0A=0A+ | ( ( Rb & 0x1f ) << 16 )=0A=0A+ = | ( ( Func & 0x7f ) << 5 )=0A=0A+ | ( Rc & 0x1f ) ;=0A=0A+ tcg_ou= t32(s, v);=09=0A=0A+}=0A=0A+=0A=0A+static inline void tcg_out_inst4i(TCGCon= text *s, int Opcode, int Ra, int Lit, int Func, int Rc)=0A=0A+{=0A=0A+ u= int32_t v =3D 0;=0A+ v =3D ( (Opcode & 0x3f) << 26 )=0A=0A+ | ( = ( Ra & 0x1f ) << 21 )=0A=0A+ | ( ( Lit & 0xff ) << 13 )=0A=0A+ = | ( ( Func & 0x7f ) << 5 )=0A=0A+ | ( 1 << 12 )=0A=0A+ | ( = Rc & 0x1f ) ;=0A=0A+ tcg_out32(s, v);=09=0A=0A+}=0A=0A+=0A=0A+/*=0A=0A+ = * mov from a reg to another=0A=0A+*/=0A=0A+static inline void tcg_out_mov(T= CGContext *s, int Rc, int Rb)=0A=0A+{ =0A=0A+ if ( Rb !=3D Rc ) {=0A=0A= + tcg_out_inst4(s, OP_LOGIC, TCG_REG_31, Rb, FUNC_BIS, Rc);=0A+ }= =0A=0A+}=0A=0A+=0A=0A+/*=0A+ * mov a 64-bit immediate 'arg' to regsiter 'Ra= ', this function will=0A+ * generate fixed length (8 insns, 32 bytes) of ta= rget insn sequence.=0A+*/=0A+static void tcg_out_movi_fixl( \=0A+ TCGCon= text *s, TCGType type, int Ra, tcg_target_long arg)=0A+{=0A+ tcg_target_= long l0, l1, l2, l3;=0A+ tcg_target_long l1_tmp, l2_tmp, l3_tmp;=0A+=0A+= l0 =3D arg & 0xffffu;=0A+ l1_tmp =3D l1 =3D ( arg >> 16) & 0xffffu;= =0A+ l2_tmp =3D l2 =3D ( arg >> 32) & 0xffffu;=0A+ l3_tmp =3D l3 =3D = ( arg >> 48) & 0xffffu;=0A+=0A+ if ( l0 & 0x8000u)=0A+ l1_tmp =3D= (l1 + 1) & 0xffffu;=0A+ if ( (l1_tmp & 0x8000u) || ((l1_tmp =3D=3D 0) &= & (l1_tmp !=3D l1)))=0A+ l2_tmp =3D (l2 + 1) & 0xffffu;=0A+ if ( = (l2_tmp & 0x8000u) || ((l2_tmp =3D=3D 0) && (l2_tmp !=3D l2)))=0A+ l= 3_tmp =3D (l3 + 1) & 0xffffu;=0A+=0A+ tcg_out_inst3_disp( s, OP_LDAH, Ra= , TCG_REG_31, l3_tmp);=0A+ tcg_out_inst3_disp( s, OP_LDA, Ra, Ra, l2_tmp= );=0A+ tcg_out_inst4i( s, OP_SHIFT, Ra, 32, FUNC_SLL, Ra);=0A+ tcg_ou= t_inst3_disp( s, OP_LDAH, Ra, Ra, l1_tmp);=0A+ tcg_out_inst3_disp( s, OP= _LDA, Ra, Ra, l0);=0A+}=0A+=0A+/*=0A=0A+ * mov 64-bit immediate 'arg' to re= gsiter 'Ra'. this function will=0A=0A+ * generate variable length of target= insn sequence.=0A=0A+*/=0A=0A+static inline void tcg_out_movi( \=0A=0A+ = TCGContext *s, TCGType type, int Ra, tcg_target_long arg)=0A=0A+{=0A+ i= f (type =3D=3D TCG_TYPE_I32) {=0A+ if ( arg !=3D (int32_t)arg)=0A+ = tcg_abort();=0A+ }=0A+=0A+ if (arg =3D=3D 0) {=0A=0A+ = tcg_out_inst4(s, OP_LOGIC, Ra, Ra, FUNC_XOR, Ra);=0A+ }=0A=0A+ else= if( arg =3D=3D (int16_t)arg ) {=0A=0A+ tcg_out_inst3_disp(s, OP_LDA= , Ra, TCG_REG_31, arg );=0A+ }=0A=0A+ else if( arg =3D=3D (int32_t)ar= g ) {=0A+ tcg_out_inst3_disp(s, OP_LDAH, Ra, TCG_REG_31, (arg>>16));= =0A+ if( arg & ((tcg_target_ulong)0x8000) ) {=0A+ tcg_out= _inst3_disp(s, OP_LDAH, Ra, Ra, 1);=0A+ }=0A+ tcg_out_inst3_d= isp(s, OP_LDA, Ra, Ra, arg);=0A+ } else {=0A=0A+ tcg_out_movi_fix= l(s, type, Ra, arg);=0A=0A+ }=0A+}=0A+=0A+static inline int _is_tmp_reg(= int r)=0A+{=0A+ if ( r =3D=3D TMP_REG1 || r =3D=3D TMP_REG2 || r =3D=3D= TMP_REG3)=0A+ return 1;=0A+ else=0A+ return 0;=0A+}=0A+= =0A+/*=0A=0A+ * load value in disp(Rb) to Ra.=0A=0A+*/=0A=0A+static inline = void tcg_out_ld( \=0A=0A+ TCGContext *s, TCGType type, int Ra, int Rb, t= cg_target_long disp)=0A=0A+{=0A=0A+ int Opcode;=0A=0A+ =0A+ if ( _= is_tmp_reg(Ra) || _is_tmp_reg(Rb))=0A+ tcg_abort();=0A+=0A+ Opcod= e =3D ((type =3D=3D TCG_TYPE_I32) ? OP_LDL : OP_LDQ);=0A+=0A+ if( disp != =3D (int16_t)disp ) {=0A=0A+ tcg_out_movi(s, TCG_TYPE_I64, TMP_REG1,= disp);=09=0A=0A+ tcg_out_inst4(s, OP_ADDSUBCMP, Rb, TMP_REG1, FUNC_= ADDQ, TMP_REG1);=0A+ tcg_out_inst3_disp(s, Opcode, Ra, TMP_REG1, 0);= =0A+ }=0A=0A+ else=0A=0A+ tcg_out_inst3_disp(s, Opcode, Ra, Rb= , disp);=0A+}=0A=0A+=0A+/*=0A=0A+ * store value in Ra to disp(Rb).=0A=0A+*/= =0A=0A+static inline void tcg_out_st( \=0A=0A+ TCGContext *s, TCGType ty= pe, int Ra, int Rb, tcg_target_long disp)=0A=0A+{=0A=0A+ int Opcode;=0A= =0A+=0A+ if ( _is_tmp_reg(Ra) || _is_tmp_reg(Rb))=0A+ tcg_abort()= ;=0A+ =0A+ Opcode =3D ((type =3D=3D TCG_TYPE_I32) ? OP_STL : OP_STQ);= =0A+=0A=0A+ if( disp !=3D (int16_t)disp ) {=0A=0A+ tcg_out_movi(s= , TCG_TYPE_I64, TMP_REG1, disp);=0A=0A+ tcg_out_inst4(s, OP_ADDSUBCM= P, Rb, TMP_REG1, FUNC_ADDQ, TMP_REG1);=0A+ tcg_out_inst3_disp(s, Opc= ode, Ra, TMP_REG1, 0);=0A+ }=0A=0A+ else=0A=0A+ tcg_out_inst3_= disp(s, Opcode, Ra, Rb, disp);=0A+}=0A=0A+=0A=0A+/*=0A=0A+ * generate arith= matic instruction with immediate. Ra is used as both=0A=0A+ * input and out= put, and val is used as another input.=0A=0A+*/=0A=0A+static inline void tg= en_arithi( \=0A=0A+ TCGContext *s, int Opcode, int Func, int Ra, tcg_tar= get_long val)=0A=0A+{=0A+ if ( _is_tmp_reg(Ra))=0A+ tcg_abort();= =0A+=0A+ if (val =3D=3D (uint8_t)val) {=0A=0A+ tcg_out_inst4i(s, = Opcode, Ra, val, Func, Ra);=0A+ } else {=0A=0A+ tcg_out_movi(s, T= CG_TYPE_I64, TMP_REG1, val);=0A=0A+ tcg_out_inst4(s, Opcode, Ra, TMP= _REG1, Func, Ra);=0A+ }=0A=0A+}=0A=0A+=0A=0A+/*=0A=0A+ * generate addq i= nstruction with immediate.=0A=0A+*/=0A=0A+static void tcg_out_addi(TCGConte= xt *s, int reg, tcg_target_long val)=0A=0A+{=0A=0A+ if (val !=3D 0)=0A= =0A+ tgen_arithi(s, OP_ADDSUBCMP, FUNC_ADDQ, reg, val);=0A=0A+}=0A= =0A+=0A=0A+/*=0A=0A+ * generate insn to push reg onto stack.=0A=0A+*/=0A=0A= +static inline void tcg_out_push(TCGContext *s, int reg)=0A=0A+{=0A=0A+ = tcg_out_inst4i(s, OP_ADDSUBCMP, TCG_REG_30, 8, FUNC_SUBQ, TCG_REG_30);=0A= =0A+ tcg_out_inst3_disp(s, OP_STQ, reg, TCG_REG_30, 0);=0A=0A+}=0A=0A+= =0A=0A+/*=0A=0A+ * generate insn to pop value from stack to reg.=0A=0A+*/= =0A=0A+static inline void tcg_out_pop(TCGContext *s, int reg)=0A=0A+{=0A=0A= + tcg_out_inst3_disp(s, OP_LDQ, reg, TCG_REG_30, 0);=0A=0A+ tcg_out_i= nst4i(s, OP_ADDSUBCMP, TCG_REG_30, 8, FUNC_ADDQ, TCG_REG_30);=0A=0A+}=0A=0A= +=0A+static const uint8_t tcg_cond_to_jcc[10] =3D {=0A=0A+ [TCG_COND_EQ]= =3D FUNC_CMPEQ,=0A=0A+ [TCG_COND_NE] =3D FUNC_CMPEQ,=0A=0A+ [TCG_CON= D_LT] =3D FUNC_CMPLT,=0A=0A+ [TCG_COND_GE] =3D FUNC_CMPLT,=0A=0A+ [TC= G_COND_LE] =3D FUNC_CMPLE,=0A=0A+ [TCG_COND_GT] =3D FUNC_CMPLE,=0A=0A+ = [TCG_COND_LTU] =3D FUNC_CMPULT,=0A=0A+ [TCG_COND_GEU] =3D FUNC_CMPULT,= =0A=0A+ [TCG_COND_LEU] =3D FUNC_CMPULE,=0A=0A+ [TCG_COND_GTU] =3D FUN= C_CMPULE=0A=0A+};=0A=0A+=0A=0A+/*=0A=0A+ * called by tcg_out_reloc() when t= he label address is determined, =0A=0A+ * i.e., label->has_value is true. w= hat should be done is to patch =0A=0A+ * the jmp insn that reference this l= abel.=0A=0A+ *=0A=0A+ * code_ptr - position need to patch=0A=0A+ * type - r= elocation type=0A=0A+ * value - label address=0A=0A+ * addend - not used=0A= =0A+*/=0A=0A+static void patch_reloc(uint8_t *code_ptr, \=0A=0A+ int typ= e, tcg_target_long value, tcg_target_long addend)=0A=0A+{=0A=0A+ TCGCont= ext s;=0A+ tcg_target_long val;=0A+=0A+ if ( type !=3D R_ALPHA_REFQUA= D)=0A+ tcg_abort();=0A+ if ( value & 3)=0A+ tcg_abort();= =0A+=0A+ s.code_ptr =3D code_ptr;=0A+ val =3D (value - (tcg_target_lo= ng)s.code_ptr - 4) >> 2; =0A+ if ( !(val >=3D -0x100000 && val < 0x10000= 0)) {=0A+ tcg_abort();=0A+ }=0A+=0A+ tcg_out_inst2(&s, OP_BR, = TCG_REG_31, val);=0A+}=0A=0A+=0A+/*=0A=0A+ * generate insns for BR =0A=0A+*= /=0A=0A+static void tcg_out_br(TCGContext *s, int label_index)=0A+{=0A=0A+ = TCGLabel *l =3D &s->labels[label_index];=0A+=0A+ if (l->has_value) {= =0A+ tcg_target_long val;=0A+ if ( l->u.value & 0x3)=0A+ = tcg_abort();=0A+ val =3D ((tcg_target_long)(l->u.value) - (tc= g_target_long)s->code_ptr - 4) >> 2;=0A+ if ( val >=3D -0x100000 && = val < 0x100000) {=0A+ // if distance can be put into 21-bit fiel= d=0A+ tcg_out_inst2(s, OP_BR, TMP_REG1, val);=0A+=09} else {=0A+= tcg_abort();=0A+=09}=0A+ } else {=0A+ /* record reloc= ation infor */=0A+ tcg_out_reloc(s, s->code_ptr, R_ALPHA_REFQUAD, la= bel_index, 0);=0A+ s->code_ptr +=3D 4;=0A+ }=0A+}=0A+=0A+/*=0A=0A= + * generate insn for INDEX_op_brcond=0A=0A+*/=0A=0A+static void tcg_out_br= cond( TCGContext *s, int cond, \=0A=0A+ TCGArg arg1, TCGArg arg2, int co= nst_arg2, int label_index)=0A=0A+{=0A+ int func, opc;=0A+ TCGLabel *l= =3D &s->labels[label_index];=0A+=0A+ if ( cond < TCG_COND_EQ || cond > = TCG_COND_GTU || const_arg2)=0A+ tcg_abort();=0A+=0A=0A+ func =3D = tcg_cond_to_jcc[cond];=0A+ tcg_out_inst4(s, OP_ADDSUBCMP, arg1, arg2, fu= nc, TMP_REG1);=0A+=0A+ // if cond is an odd number, TMP_REG1 =3D 0 means= true=0A+ opc =3D (cond & 1) ? OP_BLBC : OP_BLBS; =0A+=0A+ if (l->ha= s_value) {=0A+ tcg_target_long val;=0A+ if ( l->u.value & 3)= =0A+ tcg_abort();=0A+ val =3D ((tcg_target_long)l->u.valu= e - (tcg_target_long)s->code_ptr - 4) >> 2;=0A+ if ( val >=3D -0x100= 000 && val < 0x100000) {=0A+ // if distance can be put into 21-b= it field=0A+ tcg_out_inst2(s, opc, TMP_REG1, val);=0A+=09} else = {=0A+ tcg_abort();=0A+=09}=0A+ } else {=0A+ tcg_out_in= st2(s, opc^4, TMP_REG1, 1);=0A+=09/* record relocation infor */=0A+ = tcg_out_reloc(s, s->code_ptr, R_ALPHA_REFQUAD, label_index, 0);=0A+ = s->code_ptr +=3D 4;=0A+ }=0A+}=0A=0A+=0A=0A+=0A=0A+#if defined(CONFIG_SO= FTMMU)=0A=0A+=0A=0A+#include "../../softmmu_defs.h"=0A=0A+=0A=0A+static voi= d *qemu_ld_helpers[4] =3D {=0A=0A+ __ldb_mmu,=0A=0A+ __ldw_mmu,=0A=0A= + __ldl_mmu,=0A=0A+ __ldq_mmu,=0A=0A+};=0A=0A+=0A=0A+static void *qem= u_st_helpers[4] =3D {=0A=0A+ __stb_mmu,=0A=0A+ __stw_mmu,=0A=0A+ _= _stl_mmu,=0A=0A+ __stq_mmu,=0A=0A+};=0A=0A+=0A=0A+#endif=0A=0A+=0A=0A+/*= =0A=0A+ * XXX: qemu_ld and qemu_st could be modified to clobber only EDX a= nd=0A=0A+ * EAX. It will be useful once fixed registers globals are less co= mmon. =0A=0A+ *=0A=0A+ * output host insn for op 'qemu_ldxx t0, t1, flags',= which means fetching value from t1 to t0.=0A=0A+ * flags gives the current= CPU mode, kernel or user.=0A=0A+ *=0A=0A+ * opc argument determines the da= ta width and extension type (zero or signed), and has the =0A=0A+ * followi= ng layout:=0A=0A+ * 2 1 0=0A=0A+ * -----------= -------------------------=0A=0A+ * | | E | W |=0A= =0A+ * ------------------------------------=0A=0A+ *=0A=0A+ * E =3D 0 means= zero extention, 1 means signed extension=0A=0A+ * W =3D 0 means byte, 1 me= ans word, 2 means dword.=0A=0A+ *=0A=0A+ * Note that VM addr space may be 3= 2-bit or 64-bit, below, we take 32-bit addr space as example=0A=0A+ * when = doing the comment.=0A=0A+*/=0A=0A+static void tcg_out_qemu_ld(TCGContext *s= , const TCGArg *args, int opc)=0A=0A+{=0A=0A+ int addr_reg, data_reg, r0= , r1, mem_index, s_bits;=0A=0A+ tcg_target_long val;=0A+=0A=0A+#if defin= ed(CONFIG_SOFTMMU)=0A=0A+ uint8_t *label1_ptr, *label2_ptr;=0A=0A+#endif= =0A=0A+=0A=0A+ data_reg =3D *args++;=0A=0A+ addr_reg =3D *args++;=0A= =0A+ mem_index =3D *args;=0A=0A+ s_bits =3D opc & 3;=0A=0A+=0A=0A+ = r0 =3D TCG_REG_16;=0A=0A+ r1 =3D TCG_REG_17;=0A=0A+=0A=0A+#if defined(C= ONFIG_SOFTMMU)=0A=0A+=0A=0A+ tcg_out_mov(s, r1, addr_reg); =0A=0A+ tc= g_out_mov(s, r0, addr_reg); =0A=0A+ =0A=0A+#if TARGET_LONG_BITS =3D=3D 32= =0A=0A+ /* if VM is of 32-bit arch, clear higher 32-bit of addr */=0A=0A= + tcg_out_inst4i(s, OP_SHIFT, r0, 32, FUNC_SLL, r0);=0A+ tcg_out_inst= 4i(s, OP_SHIFT, r0, 32, FUNC_SRL, r0);=0A=0A+ tcg_out_inst4i(s, OP_SHIFT= , r1, 32, FUNC_SLL, r1);=0A=0A+ tcg_out_inst4i(s, OP_SHIFT, r1, 32, FUNC= _SRL, r1);=0A+#endif=0A=0A+=0A=0A+ tgen_arithi(s, OP_LOGIC, FUNC_AND, r0= , TARGET_PAGE_MASK|((1<code_ptr;=0A=0A+ s->code_ptr +=3D 4;=0A=0A+=0A=0A+ //=0A= =0A+ // here, unequal, TLB-miss.=0A=0A+ //=0A=0A+ tcg_out_movi(s, = TCG_TYPE_I32, TCG_REG_17, mem_index);=09=09// pass argument 2=0A=0A+ tcg= _out_movi(s, TCG_TYPE_I64, \=0A=0A+ TMP_REG1, (tcg_target_long)qemu_= ld_helpers[s_bits]);=09=09// get helper func entry=0A+ tcg_out_push(s, a= ddr_reg);=0A+ tcg_out_push(s, TCG_REG_26);=0A+ tcg_out_push(s, TCG_RE= G_15);=0A+ tcg_out_mov(s, TCG_REG_27, TMP_REG1);=0A+ tcg_out_inst3_fu= nc(s, OP_CALL, TCG_REG_26, TMP_REG1, FUNC_CALL, 0); // call helper func=0A= =0A+ tcg_out_pop(s, TCG_REG_15);=0A+ tcg_out_pop(s, TCG_REG_26);=0A+ = tcg_out_pop(s, addr_reg);=0A+=09=0A=0A+ //=0A=0A+ // after helper = function call, the result of ld is saved in $0=0A=0A+ //=0A=0A+ switc= h(opc) {=0A=0A+ case 0 | 4:=0A=0A+ tcg_out_inst4(s, OP_SEXT, TCG_= REG_31, TCG_REG_0, FUNC_SEXTB, data_reg);=0A+ break;=0A=0A+ case = 1 | 4:=0A=0A+ tcg_out_inst4(s, OP_SEXT, TCG_REG_31, TCG_REG_0, FUNC_= SEXTW, data_reg);=0A+ break;=0A=0A+ case 2 | 4:=0A=0A+ tcg= _out_inst4i(s, OP_SHIFT, TCG_REG_0, 32, FUNC_SLL, data_reg);=0A+ tcg= _out_inst4i(s, OP_SHIFT, data_reg, 32, FUNC_SRA, data_reg);=0A+ brea= k;=0A=0A+ case 0:=0A=0A+ tcg_out_inst4i(s, OP_SHIFT, TCG_REG_0, 5= 6, FUNC_SLL, data_reg);=0A+ tcg_out_inst4i(s, OP_SHIFT, data_reg, 56= , FUNC_SRL, data_reg);=0A+ break;=0A=0A+ case 1:=0A=0A+ tc= g_out_inst4i(s, OP_SHIFT, TCG_REG_0, 48, FUNC_SLL, data_reg);=0A+ tc= g_out_inst4i(s, OP_SHIFT, data_reg, 48, FUNC_SRL, data_reg);=0A+ bre= ak;=0A=0A+ case 2:=0A=0A+ tcg_out_inst4i(s, OP_SHIFT, TCG_REG_0, = 32, FUNC_SLL, data_reg);=0A+=09tcg_out_inst4i(s, OP_SHIFT, data_reg, 32, FU= NC_SRL, data_reg);=0A+ break;=0A=0A+ case 3:=0A=0A+ tcg_ou= t_mov(s, data_reg, TCG_REG_0);=0A=0A+ break;=0A+ default:=0A+ = tcg_abort();=0A+ break;=0A+ }=0A=0A+=0A=0A+ //=0A=0A+ /= / we have done, jmp to label2. label2 is not resolved yet, =0A=0A+ // we= record a relocation.=0A=0A+ //=0A=0A+ label2_ptr =3D s->code_ptr;=0A= =0A+ s->code_ptr +=3D 4;=0A=0A+ =0A=0A+ // patch jmp to label1=0A+= val =3D (s->code_ptr - label1_ptr - 4) >> 2;=0A+ if ( !(val >=3D -0x= 100000 && val < 0x100000)) {=0A+ tcg_abort();=0A+ }=0A+ *(uint= 32_t *)label1_ptr =3D (uint32_t) \=0A=0A+ ( ( OP_BNE << 26 ) | ( TMP= _REG1 << 21 ) \=0A=0A+ | ( val & 0x1fffff) );=0A+=0A=0A+ //=0A=0A= + // if we get here, a TLB entry is hit, r0 contains the guest addr and = =0A=0A+ // r1 contains the ptr that point to tlb_entry.addr_read. what w= e should=0A=0A+ // do is to load the tlb_entry.addend (64-bit on alpha) = and add it to =0A=0A+ // r0 to get the host VA=0A=0A+ //=0A=0A+ tc= g_out_movi(s, TCG_TYPE_I64, TMP_REG1, \=0A=0A+=09offsetof(CPUTLBEntry, adde= nd) - offsetof(CPUTLBEntry, addr_read));=0A+ tcg_out_inst4(s, OP_ADDSUBC= MP, r1, TMP_REG1, FUNC_ADDQ, r1);=0A+ tcg_out_inst3_disp(s, OP_LDQ, TMP_= REG1, r1, 0);=0A+ tcg_out_inst4(s, OP_ADDSUBCMP, r0, TMP_REG1, FUNC_ADDQ= , r0);=0A+=09=0A=0A+#else=0A=0A+ r0 =3D addr_reg;=0A=0A+#endif // endif = defined(CONFIG_SOFTMMU)=0A=0A+=0A=0A+#ifdef TARGET_WORDS_BIGENDIAN=0A=0A+ = tcg_abort();=0A+#endif=0A=0A+=0A=0A+ //=0A=0A+ // when we get here,= r0 contains the host VA that can be used to access guest PA=0A=0A+ //= =0A=0A+ switch(opc) {=0A+ case 0:=0A+ tcg_out_inst3_disp(s, OP= _LDBU, data_reg, r0, 0);=0A+ break;=0A+ case 0 | 4:=0A+ tc= g_out_inst3_disp(s, OP_LDBU, data_reg, r0, 0);=0A+ tcg_out_inst4(s, = OP_SEXT, TCG_REG_31, data_reg, FUNC_SEXTB, data_reg);=0A+ break;=0A+= case 1:=0A+ tcg_out_inst3_disp(s, OP_LDWU, data_reg, r0, 0);=0A+= break;=0A+ case 1 | 4:=0A+ tcg_out_inst3_disp(s, OP_LDWU,= data_reg, r0, 0);=0A+ tcg_out_inst4(s, OP_SEXT, TCG_REG_31, data_re= g, FUNC_SEXTW, data_reg);=0A+ break;=0A+ case 2:=0A=0A+ tc= g_out_inst3_disp(s, OP_LDL, data_reg, r0, 0);=0A+ tcg_out_inst4i(s, = OP_SHIFT, data_reg, 32, FUNC_SLL, data_reg);=0A+ tcg_out_inst4i(s, O= P_SHIFT, data_reg, 32, FUNC_SRL, data_reg);=0A+ break;=0A=0A+ cas= e 2 | 4:=0A=0A+ tcg_out_inst3_disp(s, OP_LDL, data_reg, r0, 0);=0A+ = break;=0A+ case 3:=0A+ tcg_out_inst3_disp(s, OP_LDQ, data_= reg, r0, 0);=0A+ break;=0A+ default:=0A+ tcg_abort();=0A+ = }=0A+=0A+#if defined(CONFIG_SOFTMMU)=0A=0A+ /* label2: */=0A+ val = =3D (s->code_ptr - label2_ptr - 4) >> 2;=0A+ if ( !(val >=3D -0x100000 &= & val < 0x100000)) {=0A+ tcg_abort();=0A+ }=0A+ *(uint32_t *)l= abel2_ptr =3D (uint32_t)( ( OP_BR << 26 ) \=0A+ | ( TCG_REG_31 << 2= 1 ) | ( val & 0x1fffff) );=0A+#endif=0A=0A+}=0A=0A+=0A+static void tcg_out_= qemu_st(TCGContext *s, const TCGArg *args, int opc)=0A=0A+{=0A=0A+ int a= ddr_reg, data_reg, r0, r1, mem_index, s_bits;=0A=0A+ tcg_target_long val= ;=0A+=0A+#if defined(CONFIG_SOFTMMU)=0A=0A+ uint8_t *label1_ptr, *label2= _ptr;=0A=0A+#endif=0A=0A+=0A=0A+ data_reg =3D *args++;=0A=0A+ addr_re= g =3D *args++;=0A=0A+ mem_index =3D *args;=0A=0A+ s_bits =3D opc&3;= =0A=0A+=0A=0A+ r0 =3D TCG_REG_16;=0A=0A+ r1 =3D TCG_REG_17;=0A=0A+=0A= =0A+#if defined(CONFIG_SOFTMMU)=0A=0A+=0A=0A+ tcg_out_mov(s, r1, addr_re= g); =0A=0A+ tcg_out_mov(s, r0, addr_reg); =0A=0A+ =0A=0A+#if TARGET_LONG= _BITS =3D=3D 32=0A=0A+ /* if VM is of 32-bit arch, clear higher 32-bit o= f addr */=0A=0A+ tcg_out_inst4i(s, OP_SHIFT, r0, 32, FUNC_SLL, r0);=0A+ = tcg_out_inst4i(s, OP_SHIFT, r0, 32, FUNC_SRL, r0);=0A+ tcg_out_inst4i= (s, OP_SHIFT, r1, 32, FUNC_SLL, r1);=0A+ tcg_out_inst4i(s, OP_SHIFT, r1,= 32, FUNC_SRL, r1);=0A+#endif=0A=0A+=0A=0A+ tgen_arithi(s, OP_LOGIC, FUN= C_AND, r0, TARGET_PAGE_MASK | ((1 << s_bits) - 1));=0A+=0A=0A+ tgen_arit= hi(s, OP_SHIFT, FUNC_SRL, r1, TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS);=0A+ = tgen_arithi(s, OP_LOGIC, FUNC_AND, r1, (CPU_TLB_SIZE-1) << CPU_TLB_ENTRY_= BITS);=0A+=0A=0A+ tcg_out_addi(s, r1, offsetof(CPUState, tlb_table[mem_i= ndex][0].addr_write));=0A+ tcg_out_inst4(s, OP_ADDSUBCMP, r1, TCG_REG_15= , FUNC_ADDQ, r1);=0A+=0A=0A+#if TARGET_LONG_BITS =3D=3D 32=0A=0A+ tcg_ou= t_inst3_disp(s, OP_LDL, TMP_REG1, r1, 0);=0A+ tcg_out_inst4i(s, OP_SHIFT= , TMP_REG1, 32, FUNC_SLL, TMP_REG1);=0A+ tcg_out_inst4i(s, OP_SHIFT, TMP= _REG1, 32, FUNC_SRL, TMP_REG1);=0A+#else=0A=0A+ tcg_out_inst3_disp(s, OP= _LDQ, TMP_REG1, r1, 0);=0A+#endif=0A=0A+=0A=0A+ //=0A=0A+ // now, r0 = contains the page# and TMP_REG1 contains the addr to tlb_entry.addr_read=0A= =0A+ // we below will compare them=0A=0A+ // =0A=0A+ tcg_out_in= st4(s, OP_ADDSUBCMP, TMP_REG1, r0, FUNC_CMPEQ, TMP_REG1);=0A+=0A+ tcg_ou= t_mov(s, r0, addr_reg);=0A+#if TARGET_LONG_BITS =3D=3D 32=0A=0A+ tcg_out= _inst4i(s, OP_SHIFT, r0, 32, FUNC_SLL, r0);=0A+ tcg_out_inst4i(s, OP_SHI= FT, r0, 32, FUNC_SRL, r0);=0A+#endif=0A+=0A+ //=0A=0A+ // if equal, w= e jump to label1. since label1 is not resolved yet, =0A=0A+ // we just r= ecord a relocation.=0A=0A+ //=0A=0A+ label1_ptr =3D s->code_ptr;=0A= =0A+ s->code_ptr +=3D 4;=0A=0A+=0A=0A+ // here, unequal, TLB-miss, ..= .=0A=0A+ tcg_out_mov(s, TCG_REG_17, data_reg);=0A+ tcg_out_movi(s, TC= G_TYPE_I32, TCG_REG_18, mem_index);=0A+ tcg_out_movi(s, TCG_TYPE_I64, TM= P_REG1, (tcg_target_long)qemu_st_helpers[s_bits]);=0A+ =0A+ tcg_o= ut_push(s, data_reg);=0A+ tcg_out_push(s, addr_reg);=0A+ tcg_out_push= (s, TCG_REG_26);=0A=0A+ tcg_out_push(s, TCG_REG_15);=0A+ tcg_out_mov(= s, TCG_REG_27,TMP_REG1);=0A+ tcg_out_inst3_func(s, OP_CALL, TCG_REG_26, = TMP_REG1, FUNC_CALL, 0);=0A+ tcg_out_pop(s, TCG_REG_15);=0A+ tcg_out_= pop(s, TCG_REG_26);=0A+ tcg_out_pop(s, addr_reg);=0A+ tcg_out_pop(s, = data_reg);=0A+=0A+ //=0A+ // we have done, jmp to label2. label2 is n= ot resolved yet,=0A+ // we record a relocation.=0A+ //=0A+ label2_= ptr =3D s->code_ptr;=0A+ s->code_ptr +=3D 4;=0A+ =0A=0A+ // patch = jmp to label1=0A=0A+ val =3D (s->code_ptr - label1_ptr - 4) >> 2;=0A+ = if ( !(val >=3D -0x100000 && val < 0x100000)) {=0A+ tcg_abort();=0A= + }=0A+ *(uint32_t *)label1_ptr =3D (uint32_t) \=0A+ ( ( OP_BN= E << 26) | ( TMP_REG1 << 21 )=0A+ | ( val & 0x1fffff) );=0A+=0A=0A+= //=0A=0A+ // if we get here, a TLB entry is hit, r0 contains the gue= st addr and =0A=0A+ // r1 contains the ptr that point to tlb_entry.addr_= read. what we should=0A=0A+ // do is to load the tlb_entry.addend (64-bi= t on alpha) and add it to =0A=0A+ // r0 to get the host VA=0A=0A+ //= =0A=0A+ tcg_out_movi(s, TCG_TYPE_I64, TMP_REG1, \=0A=0A+ offsetof= (CPUTLBEntry, addend) - offsetof(CPUTLBEntry, addr_write));=0A+ tcg_out_= inst4(s, OP_ADDSUBCMP, r1, TMP_REG1, FUNC_ADDQ, r1);=0A+ tcg_out_inst3_d= isp(s, OP_LDQ, TMP_REG1, r1, 0);=0A+ tcg_out_inst4(s, OP_ADDSUBCMP, r0,= TMP_REG1, FUNC_ADDQ, r0);=0A+=0A=0A+#else=0A=0A+ r0 =3D addr_reg;=0A=0A= +#endif=0A=0A+=0A=0A+#ifdef TARGET_WORDS_BIGENDIAN=0A=0A+ tcg_abort();= =0A+#endif=0A=0A+=0A=0A+ //=0A=0A+ // when we get here, r0 contains t= he host VA that can be used to access guest PA=0A=0A+ //=0A=0A+ switc= h(opc) {=0A=0A+ case 0:=0A=0A+ tcg_out_inst3_disp(s, OP_STB, data= _reg, r0, 0);=0A+ break;=0A=0A+ case 1:=0A=0A+ tcg_out_ins= t3_disp(s, OP_STW, data_reg, r0, 0);=0A+ break;=0A+ case 2:=0A+ = tcg_out_inst3_disp(s, OP_STL, data_reg, r0, 0);=0A+ break;=0A+= case 3:=0A+ tcg_out_inst3_disp(s, OP_STQ, data_reg, r0, 0);=0A+ = break;=0A+ default:=0A+ tcg_abort();=0A+ }=0A+=0A=0A+#i= f defined(CONFIG_SOFTMMU)=0A=0A+ /* patch jmp to label2: */=0A=0A+ va= l =3D (s->code_ptr - label2_ptr - 4) >> 2;=0A+ if ( !(val >=3D -0x100000= && val < 0x100000)) {=0A+ tcg_abort();=0A+ }=0A+ *(uint32_t *= )label2_ptr =3D (uint32_t)( ( OP_BR << 26 ) \=0A=0A+ | ( TCG_REG_31 = << 21 ) | ( val & 0x1fffff));=0A=0A+#endif=0A+}=0A=0A+=0A+static inline vo= id tgen_ldxx( TCGContext *s, int Ra, int Rb, tcg_target_long disp, int flag= s)=0A=0A+{=0A=0A+ int opc_array[4] =3D { OP_LDBU, OP_LDWU, OP_LDL, OP_LD= Q};=0A=0A+ int opc =3D opc_array[flags & 3];=0A=0A+=0A+ if ( _is_tmp_= reg(Ra) || _is_tmp_reg(Rb))=0A+ tcg_abort();=0A+=0A+ if( disp != =3D (int16_t)disp ) {=0A+ /* disp cannot be stored in insn directly = */=0A=0A+ tcg_out_movi(s, TCG_TYPE_I64, TMP_REG1, disp);=09=0A=0A+ = tcg_out_inst4(s, OP_ADDSUBCMP, Rb, TMP_REG1, FUNC_ADDQ, TMP_REG1);=0A= + tcg_out_inst3_disp(s, opc, Ra, TMP_REG1, 0);=0A+ } else {=0A=0A= + tcg_out_inst3_disp(s, opc, Ra, Rb, disp);=0A+ }=0A+=0A=0A+ s= witch ( flags & 7)=09{=0A=0A+ case 0:=0A=0A+ case 1:=0A=0A+ case 2= |4:=0A=0A+ case 3:=0A=0A+ break;=0A=0A+ case 0|4:=0A=0A+ = tcg_out_inst4(s, OP_SEXT, TCG_REG_31, Ra, FUNC_SEXTB, Ra);=0A+ bre= ak;=0A+ case 1|4:=0A=0A+ tcg_out_inst4(s, OP_SEXT, TCG_REG_31, Ra= , FUNC_SEXTW, Ra);=0A+ break;=0A+ case 2:=0A+ tcg_out_inst= 4i(s, OP_SHIFT, Ra, 32, FUNC_SLL, Ra);=0A+ tcg_out_inst4i(s, OP_SHIF= T, Ra, 32, FUNC_SRL, Ra);=0A+ break;=0A+ default:=0A+ tcg_= abort();=0A+ }=0A+}=0A+=0A=0A+static inline void tgen_stxx( TCGContext *= s, int Ra, int Rb, tcg_target_long disp, int flags)=0A=0A+{=0A=0A+ int o= pc_array[4] =3D { OP_STB, OP_STW, OP_STL, OP_STQ};=0A=0A+ int opc =3D op= c_array[flags & 3];=0A=0A+=0A=0A+ if( disp !=3D (int16_t)disp ) {=0A=0A+= /* disp cannot be stored in insn directly */=0A=0A+ tcg_out_= movi(s, TCG_TYPE_I64, TMP_REG1, disp);=0A=0A+ tcg_out_inst4(s, OP_AD= DSUBCMP, Rb, TMP_REG1, FUNC_ADDQ, TMP_REG1);=0A+ tcg_out_inst3_disp(= s, opc, Ra, TMP_REG1, 0);=0A+ } else {=0A+ tcg_out_inst3_disp(s, = opc, Ra, Rb, disp);=0A+ }=0A=0A+}=0A=0A+=0A=0A+static inline void tcg_ou= t_op(TCGContext *s, \=0A=0A+=09int opc, const TCGArg *args, const int *cons= t_args)=0A=0A+{=0A=0A+ int oc, c;=0A=0A+ switch(opc)=0A+ {=0A+ = case INDEX_op_exit_tb:=0A+ /*=0A+ * exit_tb t0, where t0 is = always constant and should be returned to engine=0A+ * since we'll = back to engine soon, $0 and $1 will never be used=0A+ */=0A+ = tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_0, args[0]);=0A+ tcg_out_movi(= s, TCG_TYPE_I64, TMP_REG1, (tcg_target_long)tb_ret_addr);=0A+ =09tcg_out= _inst3_func(s, OP_JMP, TCG_REG_31, TMP_REG1, FUNC_JMP, 0);=0A+ break= ;=0A=0A+=0A=0A+ case INDEX_op_goto_tb:=0A=0A+ /* goto_tb idx, whe= re idx is constant 0 or 1, indicating the branch # */=0A=0A+ if (s->= tb_jmp_offset) {=0A=0A+ /* we don't support direct jmp */=0A=0A+= tcg_abort();=0A=0A+ } else {=0A=0A+ tcg_out_m= ovi( s, TCG_TYPE_I64, TMP_REG1, (tcg_target_long)(s->tb_next + args[0]));= =0A+ tcg_out_inst3_disp(s, OP_LDQ, TMP_REG1, TMP_REG1, 0);=0A+ = tcg_out_inst3_func(s, OP_JMP, TCG_REG_31, TMP_REG1, FUNC_JMP, 0);= =0A+ }=0A=0A+ s->tb_next_offset[args[0]] =3D s->code_ptr - s-= >code_buf;=0A=0A+ break;=0A=0A+=0A=0A+ case INDEX_op_call:=0A=0A+= if (const_args[0]) {=0A=0A+ tcg_abort();=0A=0A+=09} else= {=0A=0A+ tcg_out_push( s, TCG_REG_26);=0A+ tcg_out_p= ush( s, TCG_REG_15);=0A+ tcg_out_mov( s, TCG_REG_27, args[0]);= =0A+ tcg_out_inst3_func(s, OP_CALL, TCG_REG_26, args[0], FUNC_CA= LL, 0);=0A=0A+ tcg_out_pop( s, TCG_REG_15);=0A+ tcg_o= ut_pop( s, TCG_REG_26);=0A=0A+ }=0A+ break;=0A=0A+=0A=0A+ = case INDEX_op_jmp: =0A=0A+ if (const_args[0]) {=0A=0A+ tc= g_abort();=0A=0A+ } else {=0A=0A+ tcg_out_inst3_func(s, O= P_JMP, TCG_REG_31, args[0], FUNC_JMP, 0);=0A=0A+ }=0A=0A+ bre= ak;=0A=0A+=0A=0A+ case INDEX_op_br:=0A+ tcg_out_br(s, args[0]);= =0A+ break;=0A=0A+=0A=0A+ case INDEX_op_ld8u_i32: =0A=0A+ case= INDEX_op_ld8u_i64:=0A=0A+ tgen_ldxx( s, args[0], args[1], args[2], = 0);=0A=0A+ break;=0A=0A=0A+ case INDEX_op_ld8s_i32: =0A=0A+ ca= se INDEX_op_ld8s_i64: =0A=0A+ tgen_ldxx( s, args[0], args[1], args[2= ], 0|4);=0A=0A+ break;=0A=0A+ case INDEX_op_ld16u_i32:=0A=0A+ = case INDEX_op_ld16u_i64:=0A=0A+ tgen_ldxx( s, args[0], args[1], args= [2], 1);=0A=0A+ break;=0A=0A+ case INDEX_op_ld16s_i32:=0A=0A+ = case INDEX_op_ld16s_i64: =0A=0A+ tgen_ldxx( s, args[0], args[1], arg= s[2], 1|4);=0A=0A+ break;=0A=09=0A=0A+ case INDEX_op_ld32u_i64: = =0A=0A+ tgen_ldxx( s, args[0], args[1], args[2], 2);=0A=0A+ b= reak;=0A=0A+ case INDEX_op_ld_i32: =0A=0A+ case INDEX_op_ld32s_i64:= =0A=0A+ tgen_ldxx( s, args[0], args[1], args[2], 2|4);=0A=0A+ = break;=0A=0A+ case INDEX_op_ld_i64: =0A=0A+ tgen_ldxx( s, args[0= ], args[1], args[2], 3);=0A=0A+ break;=0A=0A+=09=09=0A=0A+ case I= NDEX_op_st8_i32:=0A=0A+ case INDEX_op_st8_i64: =0A=0A+ tgen_stxx(= s, args[0], args[1], args[2], 0);=0A=0A+ break;=0A=0A=0A+ case I= NDEX_op_st16_i32:=0A=0A+ case INDEX_op_st16_i64: =0A=0A+ tgen_stx= x( s, args[0], args[1], args[2], 1);=0A=0A+ break;=0A=0A+ case IN= DEX_op_st_i32:=0A=0A+ case INDEX_op_st32_i64: =0A=0A+ tgen_stxx( = s, args[0], args[1], args[2], 2);=0A=0A+ break;=0A=0A=0A+ case IN= DEX_op_st_i64: =0A=0A+ tgen_stxx( s, args[0], args[1], args[2], 3);= =0A=0A+ break;=0A=0A+=0A=0A+ case INDEX_op_add_i32: =0A=0A+ ca= se INDEX_op_add_i64: =0A=0A+ oc =3D OP_ADDSUBCMP;=0A=0A+ c = =3D FUNC_ADDQ;=0A=0A+ goto gen_arith;=0A+ case INDEX_op_sub_i32: = =0A=0A+ case INDEX_op_sub_i64:=0A+ oc =3D OP_ADDSUBCMP;=0A=0A+ = c =3D FUNC_SUBQ;=0A+ goto gen_arith;=0A+ case INDEX_op_mul_i= 32: =0A=0A+ oc =3D OP_MUL;=0A+ c =3D FUNC_MULL;=0A+=09goto ge= n_arith;=0A+ case INDEX_op_mul_i64: =0A=0A+ oc =3D OP_MUL;=0A+ = c =3D FUNC_MULQ;=0A+ goto gen_arith;=0A=0A+ case INDEX_op_an= d_i32:=0A=0A+ case INDEX_op_and_i64:=0A=0A+ oc =3D OP_LOGIC;=0A= =0A+ c =3D FUNC_AND;=0A=0A+ goto gen_arith;=0A=0A+ case IN= DEX_op_or_i32:=0A=0A+ case INDEX_op_or_i64: =0A=0A+ oc =3D OP_LOG= IC;=0A=0A+ c =3D FUNC_BIS;=0A=0A+ goto gen_arith;=0A=0A+ c= ase INDEX_op_xor_i32:=0A=0A+ case INDEX_op_xor_i64:=0A=0A+ oc =3D= OP_LOGIC;=0A=0A+ c =3D FUNC_XOR;=0A=0A+=09goto gen_arith;=0A=0A+ = case INDEX_op_shl_i32:=0A+ case INDEX_op_shl_i64:=0A=0A+ oc =3D = OP_SHIFT;=0A=0A+ c =3D FUNC_SLL;=0A=0A+=09goto gen_arith;=0A=0A+ = case INDEX_op_shr_i32:=0A+ tcg_out_inst4i(s, OP_SHIFT, args[1], 32, = FUNC_SLL, args[1]);=0A+ tcg_out_inst4i(s, OP_SHIFT, args[1], 32, FUN= C_SRL, args[1]);=0A+ case INDEX_op_shr_i64: =0A=0A+ oc =3D OP_SHI= FT;=0A=0A+ c =3D FUNC_SRL;=0A=0A+ goto gen_arith;=0A=0A+ c= ase INDEX_op_sar_i32:=0A+ tcg_out_inst4i(s, OP_SHIFT, args[1], 32, F= UNC_SLL, args[1]);=0A+ tcg_out_inst4i(s, OP_SHIFT, args[1], 32, FUNC= _SRA, args[1]);=0A+ case INDEX_op_sar_i64:=0A=0A+ oc =3D OP_SHIFT= ;=0A=0A+ c =3D FUNC_SRA;=0A=0A+ gen_arith:=0A=0A+ if (cons= t_args[2]) {=0A+ tcg_abort();=0A=0A+ } else {=0A=0A+ = tcg_out_inst4(s, oc, args[1], args[2], c, args[0]);=0A+ }=0A+= break;=0A=0A+=0A=0A+ case INDEX_op_brcond_i32:=0A+ tcg_ou= t_mov(s, TMP_REG2, args[0]);=0A+ tcg_out_mov(s, TMP_REG3, args[1]);= =0A+ if ( args[2] >=3D TCG_COND_LTU && args[2] <=3D TCG_COND_GTU) {= =0A+ tcg_out_inst4i(s, OP_SHIFT, TMP_REG2, 32, FUNC_SLL, TMP_REG= 2);=0A+ tcg_out_inst4i(s, OP_SHIFT, TMP_REG2, 32, FUNC_SRL, TMP_= REG2);=0A+ tcg_out_inst4i(s, OP_SHIFT, TMP_REG3, 32, FUNC_SLL, T= MP_REG3);=0A+ tcg_out_inst4i(s, OP_SHIFT, TMP_REG3, 32, FUNC_SRL= , TMP_REG3);=0A+ } else { =0A+ tcg_out_inst4i(s, OP_SHIFT= , TMP_REG2, 32, FUNC_SLL, TMP_REG2);=0A+ tcg_out_inst4i(s, OP_SH= IFT, TMP_REG2, 32, FUNC_SRA, TMP_REG2);=0A+ tcg_out_inst4i(s, OP= _SHIFT, TMP_REG3, 32, FUNC_SLL, TMP_REG3);=0A+ tcg_out_inst4i(s,= OP_SHIFT, TMP_REG3, 32, FUNC_SRA, TMP_REG3);=0A+=09}=0A+ tcg_out_br= cond(s, args[2], TMP_REG2, TMP_REG3, const_args[1], args[3]);=0A+ br= eak;=0A+ case INDEX_op_brcond_i64:=0A=0A+ tcg_out_brcond(s, args[= 2], args[0], args[1], const_args[1], args[3]);=0A=0A+ break;=0A=0A+= =0A=0A+ case INDEX_op_ext8s_i32:=0A+ case INDEX_op_ext8s_i64:=0A+ = tcg_out_inst4(s, OP_SEXT, TCG_REG_31, args[1], FUNC_SEXTB, args[0]);=0A= + printf("ext8s met\n");=0A+ break;=0A+ case INDEX_op_ext1= 6s_i32:=0A+ case INDEX_op_ext16s_i64:=0A+ tcg_out_inst4(s, OP_SEX= T, TCG_REG_31, args[1], FUNC_SEXTW, args[0]);=0A+ printf("ext16s met= \n");=0A+ break;=0A+ =0A+ case INDEX_op_qemu_ld8u:=0A=0A+ = tcg_out_qemu_ld(s, args, 0);=0A=0A+ break;=0A=0A+ case INDEX_o= p_qemu_ld8s:=0A=0A+ tcg_out_qemu_ld(s, args, 0 | 4);=0A=0A+ b= reak;=0A=0A+ case INDEX_op_qemu_ld16u:=0A=0A+ tcg_out_qemu_ld(s, = args, 1);=0A=0A+ break;=0A=0A+ case INDEX_op_qemu_ld16s:=0A=0A+ = tcg_out_qemu_ld(s, args, 1 | 4);=0A=0A+ break;=0A=0A+ case = INDEX_op_qemu_ld32u:=0A=0A+ tcg_out_qemu_ld(s, args, 2);=0A=0A+ = break;=0A=0A+ case INDEX_op_qemu_ld32s:=0A=0A+ tcg_out_qemu_ld= (s, args, 2 | 4);=0A=0A+ break;=0A=0A+ case INDEX_op_qemu_ld64:= =0A=0A+ tcg_out_qemu_ld(s, args, 3);=0A=0A+ break;=0A=0A+=0A= =0A+ case INDEX_op_qemu_st8:=0A=0A+ tcg_out_qemu_st(s, args, 0);= =0A=0A+ break;=0A=0A+ case INDEX_op_qemu_st16:=0A=0A+ tcg_= out_qemu_st(s, args, 1);=0A=0A+ break;=0A=0A+ case INDEX_op_qemu_= st32:=0A=0A+ tcg_out_qemu_st(s, args, 2);=0A=0A+ break;=0A=0A= + case INDEX_op_qemu_st64:=0A+ tcg_out_qemu_st(s, args, 3);=0A=0A= + break;=0A=0A+=0A=0A+ case INDEX_op_movi_i32: =0A=0A+ case IN= DEX_op_movi_i64: =0A=0A+ case INDEX_op_mov_i32: =0A=0A+ case INDEX_op= _mov_i64:=0A=0A+ case INDEX_op_div2_i32:=0A=0A+ case INDEX_op_divu2_i= 32:=0A=0A+ default:=0A=0A+ tcg_abort();=0A=0A+ }=0A=0A+}=0A=0A= +=0A=0A+static const TCGTargetOpDef alpha_op_defs[] =3D {=0A=0A+ { INDEX= _op_exit_tb, { } },=0A=0A+ { INDEX_op_goto_tb, { } },=0A=0A+ { INDEX_= op_call, { "r" } },=0A+ { INDEX_op_jmp, { "r" } },=0A+ { INDEX_op_br,= { } },=0A=0A+=0A=0A+ { INDEX_op_mov_i32, { "r", "r" } },=0A+ { INDEX= _op_movi_i32, { "r" } },=0A=0A+ { INDEX_op_ld8u_i32, { "r", "r" } },=0A+= { INDEX_op_ld8s_i32, { "r", "r" } },=0A=0A+ { INDEX_op_ld16u_i32, { = "r", "r" } },=0A=0A+ { INDEX_op_ld16s_i32, { "r", "r" } },=0A=0A+ { I= NDEX_op_ld_i32, { "r", "r" } },=0A=0A+ { INDEX_op_st8_i32, { "r", "r" } = },=0A+ { INDEX_op_st16_i32, { "r", "r" } },=0A=0A+ { INDEX_op_st_i32,= { "r", "r" } },=0A=0A+=0A=0A+ { INDEX_op_add_i32, { "r", "0", "r" } },= =0A=0A+ { INDEX_op_mul_i32, { "r", "0", "r" } },=0A=0A+ //{ INDEX_op_= div2_i32, { "a", "d", "0", "1", "r" } },=0A=0A+ //{ INDEX_op_divu2_i32, = { "a", "d", "0", "1", "r" } },=0A=0A+ { INDEX_op_sub_i32, { "r", "0", "r= " } },=0A=0A+ { INDEX_op_and_i32, { "r", "0", "r" } },=0A=0A+ { INDEX= _op_or_i32, { "r", "0", "r" } },=0A=0A+ { INDEX_op_xor_i32, { "r", "0", = "r" } },=0A=0A+=0A=0A+ { INDEX_op_shl_i32, { "r", "0", "r" } },=0A=0A+ = { INDEX_op_shr_i32, { "r", "0", "r" } },=0A=0A+ { INDEX_op_sar_i32, { = "r", "0", "r" } },=0A=0A+=0A=0A+ { INDEX_op_brcond_i32, { "r", "r" } },= =09=09=0A=0A+=0A=0A+ { INDEX_op_mov_i64, { "r", "r" } },=09=0A=0A+ { = INDEX_op_movi_i64, { "r" } },=0A=0A+ { INDEX_op_ld8u_i64, { "r", "r" } }= ,=0A=0A+ { INDEX_op_ld8s_i64, { "r", "r" } },=0A=0A+ { INDEX_op_ld16u= _i64, { "r", "r" } },=0A=0A+ { INDEX_op_ld16s_i64, { "r", "r" } },=0A=0A= + { INDEX_op_ld32u_i64, { "r", "r" } },=0A=0A+ { INDEX_op_ld32s_i64, = { "r", "r" } },=0A=0A+ { INDEX_op_ld_i64, { "r", "r" } },=0A=0A+ { IN= DEX_op_st8_i64, { "r", "r" } },=09=0A=0A+ { INDEX_op_st16_i64, { "r", "r= " } },=0A=0A+ { INDEX_op_st32_i64, { "r", "r" } },=0A=0A+ { INDEX_op_= st_i64, { "r", "r" } },=0A=0A+=0A=0A+ { INDEX_op_add_i64, { "r", "0", "r= " } },=0A=0A+ { INDEX_op_mul_i64, { "r", "0", "r" } },=0A=0A+ //{ IND= EX_op_div2_i64, { "a", "d", "0", "1", "r" } },=0A=0A+ //{ INDEX_op_divu2= _i64, { "a", "d", "0", "1", "r" } },=0A=0A+ { INDEX_op_sub_i64, { "r", "= 0", "r" } },=0A=0A+ { INDEX_op_and_i64, { "r", "0", "r" } },=0A=0A+ {= INDEX_op_or_i64, { "r", "0", "r" } },=0A=0A+ { INDEX_op_xor_i64, { "r",= "0", "r" } },=0A=0A+=0A=0A+ { INDEX_op_shl_i64, { "r", "0", "r" } },=0A= =0A+ { INDEX_op_shr_i64, { "r", "0", "r" } },=0A=0A+ { INDEX_op_sar_i= 64, { "r", "0", "r" } },=0A=0A+=0A=0A+ { INDEX_op_brcond_i64, { "r", "r"= } },=0A=0A+=0A+ { INDEX_op_ext8s_i32, { "r", "r"} },=0A+ { INDEX_op_= ext16s_i32, { "r", "r"} },=0A+ { INDEX_op_ext8s_i64, { "r", "r"} },=0A+ = { INDEX_op_ext16s_i64, { "r", "r"} },=0A+=0A+ { INDEX_op_qemu_ld8u, {= "r", "L" } },=0A=0A+ { INDEX_op_qemu_ld8s, { "r", "L" } },=0A=0A+ { = INDEX_op_qemu_ld16u, { "r", "L" } },=0A=0A+ { INDEX_op_qemu_ld16s, { "r"= , "L" } },=0A=0A+ { INDEX_op_qemu_ld32u, { "r", "L" } },=0A=0A+ { IND= EX_op_qemu_ld32s, { "r", "L" } },=0A=0A+ { INDEX_op_qemu_ld64, { "r", "L= " } },=0A=0A+=0A=0A+ { INDEX_op_qemu_st8, { "L", "L" } },=0A=0A+ { IN= DEX_op_qemu_st16, { "L", "L" } },=0A=0A+ { INDEX_op_qemu_st32, { "L", "L= " } },=0A=0A+ //{ INDEX_op_qemu_st64, { "L", "L", "L"} },=0A=0A+ { IN= DEX_op_qemu_st64, { "L", "L"} },=0A=0A+ { -1 },=0A=0A+};=0A=0A+=0A=0A+= =0A=0A+static int tcg_target_callee_save_regs[] =3D {=0A=0A+ TCG_REG_15,= =09=09// used for the global env, so no need to save=0A=0A+ TCG_REG_9,= =0A=0A+ TCG_REG_10,=0A=0A+ TCG_REG_11,=0A=0A+ TCG_REG_12,=0A=0A+ = TCG_REG_13,=0A=0A+ TCG_REG_14=0A=0A+};=0A=0A+=0A=0A+/*=0A=0A+ * Genera= te global QEMU prologue and epilogue code =0A=0A+*/=0A=0A+void tcg_target_q= emu_prologue(TCGContext *s)=0A=0A+{=0A=0A+ int i, frame_size, push_size,= stack_addend;=0A=0A+ =0A=0A+ /* TB prologue */=0A=0A+ /*printf("TB= prologue @ %lx\n", s->code_ptr);*/=0A+=09=0A=0A+ /* save TCG_REG_26 */= =0A=0A+ tcg_out_push(s, TCG_REG_26);=0A+ tcg_out_push(s, TCG_REG_27);= =0A+ tcg_out_push(s, TCG_REG_28);=0A+ tcg_out_push(s, TCG_REG_29);=0A= +=0A=0A+ /* save all callee saved registers */=0A=0A+ for(i =3D 0; i = < ARRAY_SIZE(tcg_target_callee_save_regs); i++) {=0A=0A+ tcg_out_pus= h(s, tcg_target_callee_save_regs[i]);=0A=0A+ }=0A=0A+=09=0A=0A+ /* re= serve some stack space */=0A=0A+ push_size =3D 8 + (4 + ARRAY_SIZE(tcg_t= arget_callee_save_regs)) * 8;=0A=0A+ frame_size =3D push_size + 4*TCG_ST= ATIC_CALL_ARGS_SIZE;=0A=0A+ frame_size =3D (frame_size + TCG_TARGET_STAC= K_ALIGN - 1) & ~(TCG_TARGET_STACK_ALIGN - 1);=0A=0A+ stack_addend =3D fr= ame_size - push_size;=0A=0A+ tcg_out_addi(s, TCG_REG_30, -stack_addend);= =0A=0A+=0A=0A+ tcg_out_inst3_func(s, OP_JMP, TCG_REG_31, TCG_REG_16, FUN= C_JMP, 0);=09=09/* jmp $16 */=0A=0A+=0A=0A+ /* TB epilogue */=0A=0A+ = tb_ret_addr =3D s->code_ptr;=0A=0A+ tcg_out_addi(s, TCG_REG_30, stack_ad= dend);=0A=0A+ for(i =3D ARRAY_SIZE(tcg_target_callee_save_regs) - 1; i >= =3D 0; i--) {=0A=0A+ tcg_out_pop(s, tcg_target_callee_save_regs[i]);= =0A=0A+ }=0A=0A+=0A=0A+ tcg_out_pop(s, TCG_REG_29);=0A+ tcg_out_po= p(s, TCG_REG_28);=0A+ tcg_out_pop(s, TCG_REG_27);=0A+ tcg_out_pop(s, = TCG_REG_26);=0A=0A+ tcg_out_inst3_func(s, OP_RET, TCG_REG_31, TCG_REG_26= , FUNC_RET, 0);=09=09/* ret */=0A=0A+}=0A=0A+=0A=0A+=0A=0A+void tcg_target_= init(TCGContext *s)=0A=0A+{=0A=0A+ /* fail safe */=0A=0A+ if ((1 << C= PU_TLB_ENTRY_BITS) !=3D sizeof(CPUTLBEntry))=0A=0A+ tcg_abort();=0A= =0A+=0A=0A+ tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I32], 0,= 0xffffffff);=0A+ tcg_regset_set32(tcg_target_available_regs[TCG_TYPE_I6= 4], 0, 0xffffffff);=0A=0A+ tcg_regset_set32(tcg_target_call_clobber_regs= , 0,=0A=0A+=09=09(1 << TCG_REG_1 ) | (1 << TCG_REG_2 ) | (1 << TCG_REG_3 = ) | (1 << TCG_REG_4 ) |=0A=0A+=09=09(1 << TCG_REG_5 ) | (1 << TCG_REG_6 ) = | (1 << TCG_REG_7 ) | (1 << TCG_REG_8 ) | =0A=0A+=09=09(1 << TCG_REG_22) |= (1 << TCG_REG_23) | (1 << TCG_REG_24) | (1 << TCG_REG_25) | =0A=0A+ = (1 << TCG_REG_16) | (1 << TCG_REG_17) | (1 << TCG_REG_18) | (1 << TC= G_REG_19) | =0A=0A+ (1 << TCG_REG_20) | (1 << TCG_REG_21) | (1= << TCG_REG_0 ));=0A+=0A+ //tcg_regset_set32( tcg_target_call_clobber_re= gs, 0, 0xffffffff);=0A+ =0A=0A+ tcg_regset_clear(s->reserved_regs);= =0A+ // $26~$31 not allocated by tcg.c=0A+ tcg_regset_set_reg(s->rese= rved_regs, TCG_REG_26);=0A=0A+ tcg_regset_set_reg(s->reserved_regs, TCG_= REG_27);=0A=0A+ tcg_regset_set_reg(s->reserved_regs, TCG_REG_28);=0A=0A+= tcg_regset_set_reg(s->reserved_regs, TCG_REG_29);=0A=0A+ tcg_regset_= set_reg(s->reserved_regs, TCG_REG_30);=0A=0A+ tcg_regset_set_reg(s->rese= rved_regs, TCG_REG_31);=0A+ // resved registers for tmp usage=0A+ tcg= _regset_set_reg(s->reserved_regs, TMP_REG1);=0A=0A+ tcg_regset_set_reg(s= ->reserved_regs, TMP_REG2);=0A+ tcg_regset_set_reg(s->reserved_regs, TMP= _REG3);=0A+=0A=0A+ tcg_add_target_add_op_defs(alpha_op_defs);=0A+}=0A=0A= +=0A=0Adiff --git a/tcg/alpha/tcg-target.h b/tcg/alpha/tcg-target.h=0Anew f= ile mode 100644=0Aindex 0000000..3c15a15=0A--- /dev/null=0A+++ b/tcg/alpha/= tcg-target.h=0A@@ -0,0 +1,70 @@=0A+/*=0A+ * Tiny Code Generator for QEMU=0A= + *=0A+ * Copyright (c) 2008 Fabrice Bellard=0A+ *=0A+ * Permission is here= by granted, free of charge, to any person obtaining a copy=0A+ * of this so= ftware and associated documentation files (the "Software"), to deal=0A+ * i= n the Software without restriction, including without limitation the rights= =0A+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or= sell=0A+ * copies of the Software, and to permit persons to whom the Softw= are is=0A+ * furnished to do so, subject to the following conditions:=0A+ *= =0A+ * The above copyright notice and this permission notice shall be inclu= ded in=0A+ * all copies or substantial portions of the Software.=0A+ *=0A+ = * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS O= R=0A+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABI= LITY,=0A+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVE= NT SHALL=0A+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DA= MAGES OR OTHER=0A+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR O= THERWISE, ARISING FROM,=0A+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR = THE USE OR OTHER DEALINGS IN=0A+ * THE SOFTWARE.=0A+ */=0A+#define TCG_TARG= ET_ALPHA 1=0A+=0A+#define TCG_TARGET_REG_BITS 64=0A+=0A+#define TCG_TARGET_= NB_REGS 32=0A+=0A+enum {=0A+ TCG_REG_0 =3D 0, TCG_REG_1, TCG_REG_2, TCG_= REG_3,=0A+ TCG_REG_4, TCG_REG_5, TCG_REG_6, TCG_REG_7,=0A+ TCG_REG_8,= TCG_REG_9, TCG_REG_10, TCG_REG_11,=0A+ TCG_REG_12, TCG_REG_13, TCG_REG_= 14, TCG_REG_15,=0A+ TCG_REG_16, TCG_REG_17, TCG_REG_18, TCG_REG_19,=0A+ = TCG_REG_20, TCG_REG_21, TCG_REG_22, TCG_REG_23,=0A+ TCG_REG_24, TCG_R= EG_25, TCG_REG_26, TCG_REG_27,=0A+ TCG_REG_28, TCG_REG_29, TCG_REG_30, T= CG_REG_31=0A+};=0A+=0A+/* used for function call generation */=0A+#define T= CG_REG_CALL_STACK TCG_REG_30=0A+#define TCG_TARGET_STACK_ALIGN 16=0A+#defin= e TCG_TARGET_CALL_STACK_OFFSET 0=0A+=0A+/* we have signed extension instruc= tions */=0A+#define TCG_TARGET_HAS_ext8s_i32=0A+#define TCG_TARGET_HAS_ext1= 6s_i32=0A+#define TCG_TARGET_HAS_ext8s_i64=0A+#define TCG_TARGET_HAS_ext16s= _i64=0A+//#define TCG_TARGET_HAS_ext32s_i64=0A+=0A+/* Note: must be synced = with dyngen-exec.h */=0A+#define TCG_AREG0 TCG_REG_15=0A+#define TCG_AREG1 = TCG_REG_9=0A+#define TCG_AREG2 TCG_REG_10=0A+#define TCG_AREG3 TCG_REG_11= =0A+#define TCG_AREG4 TCG_REG_12=0A+#define TCG_AREG5 TCG_REG_13=0A+#define= TCG_AREG6 TCG_REG_14=0A+=0A+#define TMP_REG1 TCG_REG_23=0A+#define TMP_REG= 2 TCG_REG_24=0A+#define TMP_REG3 TCG_REG_25=0A+=0A+static inline void flush= _icache_range(unsigned long start, unsigned long stop)=0A+{=0A+ __asm__ = __volatile__ ("call_pal 0x86");=0A+}=0A+=0A-- =0A1.6.3.3=0A=0A=0A=0A _= __________________________________________________________ =0A =BA=C3=CD= =E6=BA=D8=BF=A8=B5=C8=C4=E3=B7=A2=A3=AC=D3=CA=CF=E4=BA=D8=BF=A8=C8=AB=D0=C2= =C9=CF=CF=DF=A3=A1 =0Ahttp://card.mail.cn.yahoo.com/