Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 3/16/15 23:37, Richard Henderson wrote: > On 03/15/2015 04:57 PM, Chen Gang wrote: >> OK, thanks. And next, I shall try to send the whole tilegx patches again >> (it is about 6-8 patches), within 2015-03-18. > > When you do so, make sure it's against the *current* master tree. > > Your patch set doesn't compile at all at the moment, after > > > commit 2994fd96d986578a342f2342501b4ad30f6d0a85 > Author: Eduardo Habkost > Date: Thu Feb 26 17:37:49 2015 -0300 > > cpu: Make cpu_init() return QOM CPUState object > > > changed the return type of cpu_init. > OK, thanks, I shall merge current code to the latest master version. > In addition, one of your patches is going to need to copy over the linux > opcodes_tilegx.h header file. Perhaps you forgot to "git add" the file when > you created this "v3 Execute" patch? Oh, sorry, I forgot it in patch v3. And I shall send the tilegx patches within today (2015-03-18). Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 3/16/15 23:31, Richard Henderson wrote: > On 03/13/2015 11:03 PM, Chen Gang wrote: >> +static void decode_rrr_1_opcode_y0(struct DisasContext *dc, >> + tilegx_bundle_bits bundle) >> +{ >> +switch (get_RRROpcodeExtension_Y0(bundle)) { >> +case UNARY_RRR_1_OPCODE_Y0: >> +switch (get_UnaryOpcodeExtension_Y0(bundle)) { >> +case FNOP_UNARY_OPCODE_Y0: >> +if (!get_SrcA_Y0(bundle) && !get_Dest_Y0(bundle)) { >> +gen_fnop(); >> +return; >> +} >> +break; >> +default: >> +break; >> +} >> +break; >> +default: >> +break; >> +} >> + >> +qemu_log_mask(LOG_UNIMP, "UNIMP rrr_1_opcode_y0, %16.16llx\n", bundle); >> +dc->exception = TILEGX_EXCP_OPCODE_UNIMPLEMENT; >> +} > > I think it would be helpful if, in the first patch, you put all of the opcode > symbols into the proper place in the switch statements. That way it's easy to > tell at a glance what has yet to be implemented. For instance, for this > function you'd put > > $ grep _UNARY opcode_tilegx.h | grep _Y0 > CNTLZ_UNARY_OPCODE_Y0 = 1, > CNTTZ_UNARY_OPCODE_Y0 = 2, > FNOP_UNARY_OPCODE_Y0 = 3, > FSINGLE_PACK1_UNARY_OPCODE_Y0 = 4, > NOP_UNARY_OPCODE_Y0 = 5, > PCNT_UNARY_OPCODE_Y0 = 6, > REVBITS_UNARY_OPCODE_Y0 = 7, > REVBYTES_UNARY_OPCODE_Y0 = 8, > TBLIDXB0_UNARY_OPCODE_Y0 = 9, > TBLIDXB1_UNARY_OPCODE_Y0 = 10, > TBLIDXB2_UNARY_OPCODE_Y0 = 11, > TBLIDXB3_UNARY_OPCODE_Y0 = 12, > > in the get_UnaryOpcodeExtension_Y0 switch statement and > > $ grep _RRR_1 opcode_tilegx.h | grep _Y0 > SHL1ADD_RRR_1_OPCODE_Y0 = 0, > SHL2ADD_RRR_1_OPCODE_Y0 = 1, > SHL3ADD_RRR_1_OPCODE_Y0 = 2, > UNARY_RRR_1_OPCODE_Y0 = 3, > > in the get_RRROpcodeExtension_Y0 switch statement. > > Likewise with all of the other "decode" functions that contain a switch. > OK, thanks. It is a good idea to me. >> +qemu_log("fnop\n"); >> +qemu_log("addi r%d, r%d, %d\n", rdst, rsrc, imm8); > > Again, use qemu_log_mask(CPU_LOG_TB_IN_ASM). > OK, thanks. I shall use qemu_log_mask in all areas within tilegx. Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 03/15/2015 04:57 PM, Chen Gang wrote: > OK, thanks. And next, I shall try to send the whole tilegx patches again > (it is about 6-8 patches), within 2015-03-18. When you do so, make sure it's against the *current* master tree. Your patch set doesn't compile at all at the moment, after commit 2994fd96d986578a342f2342501b4ad30f6d0a85 Author: Eduardo Habkost Date: Thu Feb 26 17:37:49 2015 -0300 cpu: Make cpu_init() return QOM CPUState object changed the return type of cpu_init. In addition, one of your patches is going to need to copy over the linux opcodes_tilegx.h header file. Perhaps you forgot to "git add" the file when you created this "v3 Execute" patch? r~
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 03/13/2015 11:03 PM, Chen Gang wrote: > +static void decode_rrr_1_opcode_y0(struct DisasContext *dc, > + tilegx_bundle_bits bundle) > +{ > +switch (get_RRROpcodeExtension_Y0(bundle)) { > +case UNARY_RRR_1_OPCODE_Y0: > +switch (get_UnaryOpcodeExtension_Y0(bundle)) { > +case FNOP_UNARY_OPCODE_Y0: > +if (!get_SrcA_Y0(bundle) && !get_Dest_Y0(bundle)) { > +gen_fnop(); > +return; > +} > +break; > +default: > +break; > +} > +break; > +default: > +break; > +} > + > +qemu_log_mask(LOG_UNIMP, "UNIMP rrr_1_opcode_y0, %16.16llx\n", bundle); > +dc->exception = TILEGX_EXCP_OPCODE_UNIMPLEMENT; > +} I think it would be helpful if, in the first patch, you put all of the opcode symbols into the proper place in the switch statements. That way it's easy to tell at a glance what has yet to be implemented. For instance, for this function you'd put $ grep _UNARY opcode_tilegx.h | grep _Y0 CNTLZ_UNARY_OPCODE_Y0 = 1, CNTTZ_UNARY_OPCODE_Y0 = 2, FNOP_UNARY_OPCODE_Y0 = 3, FSINGLE_PACK1_UNARY_OPCODE_Y0 = 4, NOP_UNARY_OPCODE_Y0 = 5, PCNT_UNARY_OPCODE_Y0 = 6, REVBITS_UNARY_OPCODE_Y0 = 7, REVBYTES_UNARY_OPCODE_Y0 = 8, TBLIDXB0_UNARY_OPCODE_Y0 = 9, TBLIDXB1_UNARY_OPCODE_Y0 = 10, TBLIDXB2_UNARY_OPCODE_Y0 = 11, TBLIDXB3_UNARY_OPCODE_Y0 = 12, in the get_UnaryOpcodeExtension_Y0 switch statement and $ grep _RRR_1 opcode_tilegx.h | grep _Y0 SHL1ADD_RRR_1_OPCODE_Y0 = 0, SHL2ADD_RRR_1_OPCODE_Y0 = 1, SHL3ADD_RRR_1_OPCODE_Y0 = 2, UNARY_RRR_1_OPCODE_Y0 = 3, in the get_RRROpcodeExtension_Y0 switch statement. Likewise with all of the other "decode" functions that contain a switch. > +qemu_log("fnop\n"); > +qemu_log("addi r%d, r%d, %d\n", rdst, rsrc, imm8); Again, use qemu_log_mask(CPU_LOG_TB_IN_ASM). r~
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 3/16/15 07:44, Peter Maydell wrote: > On 15 March 2015 at 23:08, Chen Gang wrote: >> On 3/16/15 00:50, Andreas Färber wrote: >>> Am 15.03.2015 um 15:19 schrieb Chen Gang: If no additional reply of this thread within 3 days, I shall send a new patch which will include system call implementation. >>> >>> Please use a proper subject then, saying what it does (rather what works >>> afterwards). In particular don't forget "target-tilegx:". :) >>> >> >> Oh, sorry for my carelessness, and if no additional reply, I shall send >> patch v4 for it with the latest code (include syscall implementation) >> within 3 days (2015-03-18) > > Make sure you split the patch up sensibly into a > series of patches if you're planning to add more > code to it... > OK, thanks. I shall try to split it into 2-3 patches. Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 3/16/15 07:45, Peter Maydell wrote: > On 14 March 2015 at 06:03, Chen Gang wrote: >> QEMU TILE-Gx can decode bundle, disassemble code, and generate tcg code >> for 1st TB block (__start). Then directly jump to __libc_start_main (2nd >> TB block). >> >> In __libc_start_main, it can continue executing to the first function >> call _dl_aux_init(). > >> /* TILE-Gx register alias */ >> -#define TILEGX_R_RE 0 /* 0 register, for function/syscall return value >> */ >> -#define TILEGX_R_NR 10 /* 10 register, for syscall number */ >> -#define TILEGX_R_BP 52 /* 52 register, optional frame pointer */ >> -#define TILEGX_R_TP 53 /* TP register, thread local storage data */ >> -#define TILEGX_R_SP 54 /* SP register, stack pointer */ >> -#define TILEGX_R_LR 55 /* LR register, may save pc, but it is not pc */ >> +#define TILEGX_R_RE0 /* 0 register, for function/syscall return >> value */ >> +#define TILEGX_R_NR10 /* 10 register, for syscall number */ >> +#define TILEGX_R_BP52 /* 52 register, optional frame pointer */ >> +#define TILEGX_R_TP53 /* TP register, thread local storage data */ >> +#define TILEGX_R_SP54 /* SP register, stack pointer */ >> +#define TILEGX_R_LR55 /* LR register, may save pc, but it is not pc */ >> +#define TILEGX_R_ZERO 63 /* Zero register, always zero */ >> +#define TILEGX_R_COUNT 56 /* Only 56 registers are really useful */ >> +#define TILEGX_R_NOREG 255 /* Invalid register value */ > > This appears to be changing code that was introduced in > a previous patch (which one? this patch doesn't appear to be > part of a series). Don't do that -- just get it right in > the first place. > OK, thanks. And next, I shall try to send the whole tilegx patches again (it is about 6-8 patches), within 2015-03-18. Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 14 March 2015 at 06:03, Chen Gang wrote: > QEMU TILE-Gx can decode bundle, disassemble code, and generate tcg code > for 1st TB block (__start). Then directly jump to __libc_start_main (2nd > TB block). > > In __libc_start_main, it can continue executing to the first function > call _dl_aux_init(). > /* TILE-Gx register alias */ > -#define TILEGX_R_RE 0 /* 0 register, for function/syscall return value */ > -#define TILEGX_R_NR 10 /* 10 register, for syscall number */ > -#define TILEGX_R_BP 52 /* 52 register, optional frame pointer */ > -#define TILEGX_R_TP 53 /* TP register, thread local storage data */ > -#define TILEGX_R_SP 54 /* SP register, stack pointer */ > -#define TILEGX_R_LR 55 /* LR register, may save pc, but it is not pc */ > +#define TILEGX_R_RE0 /* 0 register, for function/syscall return value > */ > +#define TILEGX_R_NR10 /* 10 register, for syscall number */ > +#define TILEGX_R_BP52 /* 52 register, optional frame pointer */ > +#define TILEGX_R_TP53 /* TP register, thread local storage data */ > +#define TILEGX_R_SP54 /* SP register, stack pointer */ > +#define TILEGX_R_LR55 /* LR register, may save pc, but it is not pc */ > +#define TILEGX_R_ZERO 63 /* Zero register, always zero */ > +#define TILEGX_R_COUNT 56 /* Only 56 registers are really useful */ > +#define TILEGX_R_NOREG 255 /* Invalid register value */ This appears to be changing code that was introduced in a previous patch (which one? this patch doesn't appear to be part of a series). Don't do that -- just get it right in the first place. -- PMM
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 15 March 2015 at 23:08, Chen Gang wrote: > On 3/16/15 00:50, Andreas Färber wrote: >> Am 15.03.2015 um 15:19 schrieb Chen Gang: >>> If no additional reply of this thread within 3 days, I shall send a new >>> patch which will include system call implementation. >> >> Please use a proper subject then, saying what it does (rather what works >> afterwards). In particular don't forget "target-tilegx:". :) >> > > Oh, sorry for my carelessness, and if no additional reply, I shall send > patch v4 for it with the latest code (include syscall implementation) > within 3 days (2015-03-18) Make sure you split the patch up sensibly into a series of patches if you're planning to add more code to it... -- PMM
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
On 3/16/15 00:50, Andreas Färber wrote: > Am 15.03.2015 um 15:19 schrieb Chen Gang: >> If no additional reply of this thread within 3 days, I shall send a new >> patch which will include system call implementation. > > Please use a proper subject then, saying what it does (rather what works > afterwards). In particular don't forget "target-tilegx:". :) > Oh, sorry for my carelessness, and if no additional reply, I shall send patch v4 for it with the latest code (include syscall implementation) within 3 days (2015-03-18). And again, really thank all of you very much for your reviewing. Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
Am 15.03.2015 um 15:19 schrieb Chen Gang: > If no additional reply of this thread within 3 days, I shall send a new > patch which will include system call implementation. Please use a proper subject then, saying what it does (rather what works afterwards). In particular don't forget "target-tilegx:". :) Thanks, Andreas -- SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)
Re: [Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
At present, I finished the first system call successfully (it is uname called by glibc). If no additional reply of this thread within 3 days, I shall send a new patch which will include system call implementation. Thanks. On 3/14/15 14:03, Chen Gang wrote: > QEMU TILE-Gx can decode bundle, disassemble code, and generate tcg code > for 1st TB block (__start). Then directly jump to __libc_start_main (2nd > TB block). > > In __libc_start_main, it can continue executing to the first function > call _dl_aux_init(). > > Signed-off-by: Chen Gang > --- > target-tilegx/cpu-qom.h | 2 + > target-tilegx/cpu.c | 4 - > target-tilegx/cpu.h | 22 +- > target-tilegx/translate.c | 790 > +- > 4 files changed, 798 insertions(+), 20 deletions(-) > > diff --git a/target-tilegx/cpu-qom.h b/target-tilegx/cpu-qom.h > index 4ee11e1..5615c3b 100644 > --- a/target-tilegx/cpu-qom.h > +++ b/target-tilegx/cpu-qom.h > @@ -68,4 +68,6 @@ static inline TileGXCPU *tilegx_env_get_cpu(CPUTLGState > *env) > > #define ENV_GET_CPU(e) CPU(tilegx_env_get_cpu(e)) > > +#define ENV_OFFSET offsetof(TileGXCPU, env) > + > #endif > diff --git a/target-tilegx/cpu.c b/target-tilegx/cpu.c > index cf46b8b..8255fdc 100644 > --- a/target-tilegx/cpu.c > +++ b/target-tilegx/cpu.c > @@ -69,10 +69,6 @@ static void tilegx_cpu_realizefn(DeviceState *dev, Error > **errp) > tcc->parent_realize(dev, errp); > } > > -static void tilegx_tcg_init(void) > -{ > -} > - > static void tilegx_cpu_initfn(Object *obj) > { > CPUState *cs = CPU(obj); > diff --git a/target-tilegx/cpu.h b/target-tilegx/cpu.h > index 87dc56b..93e16c3 100644 > --- a/target-tilegx/cpu.h > +++ b/target-tilegx/cpu.h > @@ -30,16 +30,21 @@ > #include "fpu/softfloat.h" > > /* TILE-Gx register alias */ > -#define TILEGX_R_RE 0 /* 0 register, for function/syscall return value */ > -#define TILEGX_R_NR 10 /* 10 register, for syscall number */ > -#define TILEGX_R_BP 52 /* 52 register, optional frame pointer */ > -#define TILEGX_R_TP 53 /* TP register, thread local storage data */ > -#define TILEGX_R_SP 54 /* SP register, stack pointer */ > -#define TILEGX_R_LR 55 /* LR register, may save pc, but it is not pc */ > +#define TILEGX_R_RE0 /* 0 register, for function/syscall return value > */ > +#define TILEGX_R_NR10 /* 10 register, for syscall number */ > +#define TILEGX_R_BP52 /* 52 register, optional frame pointer */ > +#define TILEGX_R_TP53 /* TP register, thread local storage data */ > +#define TILEGX_R_SP54 /* SP register, stack pointer */ > +#define TILEGX_R_LR55 /* LR register, may save pc, but it is not pc */ > +#define TILEGX_R_ZERO 63 /* Zero register, always zero */ > +#define TILEGX_R_COUNT 56 /* Only 56 registers are really useful */ > +#define TILEGX_R_NOREG 255 /* Invalid register value */ > + > > typedef struct CPUTLGState { > -uint64_t regs[56]; > -uint64_t pc; > +uint64_t regs[TILEGX_R_COUNT]; /* Common used registers by outside */ > +uint64_t pc; /* Current pc */ > + > CPU_COMMON > } CPUTLGState; > > @@ -54,6 +59,7 @@ typedef struct CPUTLGState { > > #include "exec/cpu-all.h" > > +void tilegx_tcg_init(void); > int cpu_tilegx_exec(CPUTLGState *s); > int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc); > > diff --git a/target-tilegx/translate.c b/target-tilegx/translate.c > index 9aa82a9..a862006 100644 > --- a/target-tilegx/translate.c > +++ b/target-tilegx/translate.c > @@ -23,19 +23,793 @@ > #include "disas/disas.h" > #include "tcg-op.h" > #include "exec/cpu_ldst.h" > +#include "opcode_tilegx.h" > + > +#define TILEGX_OPCODE_MAX_X0164 /* include 164 */ > +#define TILEGX_OPCODE_MAX_X1107 /* include 107 */ > +#define TILEGX_OPCODE_MAX_Y0 15 /* include 15 */ > +#define TILEGX_OPCODE_MAX_Y1 15 /* include 15 */ > +#define TILEGX_OPCODE_MAX_Y2 3 /* include 3 */ > + > +#define TILEGX_EXCP_OPCODE_UNKNOWN 0x1 > +#define TILEGX_EXCP_OPCODE_UNIMPLEMENT 0x2 > +#define TILEGX_EXCP_REG_UNSUPPORTED 0x81 > + > +static TCGv_ptr cpu_env; > +static TCGv cpu_pc; > +static TCGv cpu_regs[TILEGX_R_COUNT]; > + > +static const char * const reg_names[] = { > + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", > + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", > +"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", > +"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", > +"r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", > +"r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", > +"r48", "r49", "r50", "r51", "bp", "tp", "sp", "lr" > +}; > + > +/* It is for temporary registers */ > +typedef struct DisasContextTemp { > +unsigned char idx; /* index */ > +TCGv val; /* value */ > +} DisasContextTemp; > + > +/* This is the state at tr
[Qemu-devel] [PATCH v3] Execute _start and reach to the first function call successfully
QEMU TILE-Gx can decode bundle, disassemble code, and generate tcg code for 1st TB block (__start). Then directly jump to __libc_start_main (2nd TB block). In __libc_start_main, it can continue executing to the first function call _dl_aux_init(). Signed-off-by: Chen Gang --- target-tilegx/cpu-qom.h | 2 + target-tilegx/cpu.c | 4 - target-tilegx/cpu.h | 22 +- target-tilegx/translate.c | 790 +- 4 files changed, 798 insertions(+), 20 deletions(-) diff --git a/target-tilegx/cpu-qom.h b/target-tilegx/cpu-qom.h index 4ee11e1..5615c3b 100644 --- a/target-tilegx/cpu-qom.h +++ b/target-tilegx/cpu-qom.h @@ -68,4 +68,6 @@ static inline TileGXCPU *tilegx_env_get_cpu(CPUTLGState *env) #define ENV_GET_CPU(e) CPU(tilegx_env_get_cpu(e)) +#define ENV_OFFSET offsetof(TileGXCPU, env) + #endif diff --git a/target-tilegx/cpu.c b/target-tilegx/cpu.c index cf46b8b..8255fdc 100644 --- a/target-tilegx/cpu.c +++ b/target-tilegx/cpu.c @@ -69,10 +69,6 @@ static void tilegx_cpu_realizefn(DeviceState *dev, Error **errp) tcc->parent_realize(dev, errp); } -static void tilegx_tcg_init(void) -{ -} - static void tilegx_cpu_initfn(Object *obj) { CPUState *cs = CPU(obj); diff --git a/target-tilegx/cpu.h b/target-tilegx/cpu.h index 87dc56b..93e16c3 100644 --- a/target-tilegx/cpu.h +++ b/target-tilegx/cpu.h @@ -30,16 +30,21 @@ #include "fpu/softfloat.h" /* TILE-Gx register alias */ -#define TILEGX_R_RE 0 /* 0 register, for function/syscall return value */ -#define TILEGX_R_NR 10 /* 10 register, for syscall number */ -#define TILEGX_R_BP 52 /* 52 register, optional frame pointer */ -#define TILEGX_R_TP 53 /* TP register, thread local storage data */ -#define TILEGX_R_SP 54 /* SP register, stack pointer */ -#define TILEGX_R_LR 55 /* LR register, may save pc, but it is not pc */ +#define TILEGX_R_RE0 /* 0 register, for function/syscall return value */ +#define TILEGX_R_NR10 /* 10 register, for syscall number */ +#define TILEGX_R_BP52 /* 52 register, optional frame pointer */ +#define TILEGX_R_TP53 /* TP register, thread local storage data */ +#define TILEGX_R_SP54 /* SP register, stack pointer */ +#define TILEGX_R_LR55 /* LR register, may save pc, but it is not pc */ +#define TILEGX_R_ZERO 63 /* Zero register, always zero */ +#define TILEGX_R_COUNT 56 /* Only 56 registers are really useful */ +#define TILEGX_R_NOREG 255 /* Invalid register value */ + typedef struct CPUTLGState { -uint64_t regs[56]; -uint64_t pc; +uint64_t regs[TILEGX_R_COUNT]; /* Common used registers by outside */ +uint64_t pc; /* Current pc */ + CPU_COMMON } CPUTLGState; @@ -54,6 +59,7 @@ typedef struct CPUTLGState { #include "exec/cpu-all.h" +void tilegx_tcg_init(void); int cpu_tilegx_exec(CPUTLGState *s); int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc); diff --git a/target-tilegx/translate.c b/target-tilegx/translate.c index 9aa82a9..a862006 100644 --- a/target-tilegx/translate.c +++ b/target-tilegx/translate.c @@ -23,19 +23,793 @@ #include "disas/disas.h" #include "tcg-op.h" #include "exec/cpu_ldst.h" +#include "opcode_tilegx.h" + +#define TILEGX_OPCODE_MAX_X0164 /* include 164 */ +#define TILEGX_OPCODE_MAX_X1107 /* include 107 */ +#define TILEGX_OPCODE_MAX_Y0 15 /* include 15 */ +#define TILEGX_OPCODE_MAX_Y1 15 /* include 15 */ +#define TILEGX_OPCODE_MAX_Y2 3 /* include 3 */ + +#define TILEGX_EXCP_OPCODE_UNKNOWN 0x1 +#define TILEGX_EXCP_OPCODE_UNIMPLEMENT 0x2 +#define TILEGX_EXCP_REG_UNSUPPORTED 0x81 + +static TCGv_ptr cpu_env; +static TCGv cpu_pc; +static TCGv cpu_regs[TILEGX_R_COUNT]; + +static const char * const reg_names[] = { + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", +"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", +"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", +"r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", +"r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", +"r48", "r49", "r50", "r51", "bp", "tp", "sp", "lr" +}; + +/* It is for temporary registers */ +typedef struct DisasContextTemp { +unsigned char idx; /* index */ +TCGv val; /* value */ +} DisasContextTemp; + +/* This is the state at translation time. */ +typedef struct DisasContext { +uint64_t pc; /* Current pc */ +uint64_t exception;/* Current exception, 0 means empty */ + +TCGv zero; /* For zero register */ + +DisasContextTemp *tmp_regcur; /* Current temporary registers */ +DisasContextTemp tmp_regs[TILEGX_MAX_INSTRUCTIONS_PER_BUNDLE]; + /* All temporary registers */ + +struct { +TCGCond cond; /* Branch condition *