target-microblaze: Add support for BSXFI
cover target-microblaze: Add support for BSXFI
From: "Edgar E. Iglesias" <[email protected]>
Add support for bitfield extract and deposit instructions.
Cheers,
Edgar
Edgar E. Iglesias (7):
target-microblaze: dec_barrel: Use bool instead of unsigned int
target-microblaze: dec_barrel: Use extract32
target-microblaze: dec_barrel: Add braces around if-statements
target-microblaze: dec_barrel: Plug TCG temp leak
target-microblaze: dec_barrel: Add BSEFI
target-microblaze: dec_barrel: Add BSIFI
target-microblaze: Add CPU version 10.0
target/microblaze/cpu.c | 1 + target/microblaze/translate.c | 54 ++++++++++++++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 14 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/7 target-microblaze: dec_barrel: Use bool instead of unsigned int
From: "Edgar E. Iglesias" <[email protected]>
Use bool instead of unsigned int to represent flags. No functional change.
--- target/microblaze/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/microblaze/translate.c +1 -1
@@ -660,7 +660,7 @@ static void dec_div(DisasContext *dc)static void dec_barrel (DisasContext *dc) {TCGv t0; -unsigned int s, t; +bool s, t;if ((dc->tb_flags &MSR_EE_FLAG ) && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v1 1/7] target-microblaze: dec_barrel: Use bool instead of unsigned int
Quoted 9 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias"<[email protected]>
Use bool instead of unsigned int to represent flags. No functional change.
Signed-off-by Edgar E. Iglesias<[email protected]>--- target/microblaze/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
PATCH 2/7 target-microblaze: dec_barrel: Use extract32
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Use extract32 instead of opencoding the shifting and masking. No functional change.
--- target/microblaze/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/microblaze/translate.c +2 -2
@@ -670,8 +670,8 @@ static void dec_barrel(DisasContext *dc)return ; } - s = dc->imm & (1 <<10 ); - t = dc->imm & (1 <<9 ); + s =extract32 (dc->imm,10 ,1 ); + t =extract32 (dc->imm,9 ,1 );LOG_DIS ("bs%s%s r%d r%d r%d\n" , s ?"l" :"r" , t ?"a" :"l" , dc->rd, dc->ra, dc->rb);
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v1 2/7] target-microblaze: dec_barrel: Use extract32
Quoted 9 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias"<[email protected]>
Use extract32 instead of opencoding the shifting and masking. No functional change.
Signed-off-by Edgar E. Iglesias<[email protected]>--- target/microblaze/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
r~
PATCH 3/7 target-microblaze: dec_barrel: Add braces around if-statements
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add braces around if-statements.
No functional change.
--- target/microblaze/translate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
target/microblaze/translate.c +5 -4
@@ -681,13 +681,14 @@ static void dec_barrel(DisasContext *dc)tcg_gen_mov_tl (t0, *(dec_alu_op_b (dc)));tcg_gen_andi_tl (t0, t0,31 ); -if (s) +if (s) {tcg_gen_shl_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); -else { -if (t) + }else { +if (t) {tcg_gen_sar_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); -else + }else {tcg_gen_shr_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); + } } }
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v1 3/7] target-microblaze: dec_barrel: Add braces around if-statements
Quoted 9 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias"<[email protected]>
Add braces around if-statements.
No functional change.Signed-off-by Edgar E. Iglesias<[email protected]>--- target/microblaze/translate.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
r~
PATCH 4/7 target-microblaze: dec_barrel: Plug TCG temp leak
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Plug TCG temp leak.
--- target/microblaze/translate.c | 1 + 1 file changed, 1 insertion(+)
target/microblaze/translate.c +1 -0
@@ -690,6 +690,7 @@ static void dec_barrel(DisasContext *dc)tcg_gen_shr_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); } } +tcg_temp_free (t0); }static void dec_bit (DisasContext *dc)
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v1 4/7] target-microblaze: dec_barrel: Plug TCG temp leak
Quoted 8 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias"<[email protected]>
Plug TCG temp leak.
Signed-off-by Edgar E. Iglesias<[email protected]>--- target/microblaze/translate.c | 1 + 1 file changed, 1 insertion(+)
r~
PATCH 5/7 target-microblaze: dec_barrel: Add BSEFI
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add support for BSEFI.
--- target/microblaze/translate.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-)
target/microblaze/translate.c +24 -12
@@ -660,7 +660,8 @@ static void dec_div(DisasContext *dc)static void dec_barrel (DisasContext *dc) {TCGv t0; -bool s, t; +unsigned int imm_w, imm_s; +bool s, t, e = false;if ((dc->tb_flags &MSR_EE_FLAG ) && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
@@ -670,27 +671,38 @@ static void dec_barrel(DisasContext *dc)return ; } +if (dc->type_b) { +/* Insert and extract are only available in immediate mode. */ + e =extract32 (dc->imm,14 ,1 ); + } s =extract32 (dc->imm,10 ,1 ); t =extract32 (dc->imm,9 ,1 ); + imm_w =extract32 (dc->imm,6 ,5 ); + imm_s =extract32 (dc->imm,0 ,5 ); -LOG_DIS ("bs%s%s r%d r%d r%d\n" , +LOG_DIS ("bs%s%s%s r%d r%d r%d\n" , + e ?"e" :"" , s ?"l" :"r" , t ?"a" :"l" , dc->rd, dc->ra, dc->rb); - t0 =tcg_temp_new (); +if (e) { +tcg_gen_extract_i32 (cpu_R[dc->rd], cpu_R[dc->ra], imm_s, imm_w); + }else { + t0 =tcg_temp_new (); -tcg_gen_mov_tl (t0, *(dec_alu_op_b (dc))); -tcg_gen_andi_tl (t0, t0,31 ); +tcg_gen_mov_tl (t0, *(dec_alu_op_b (dc))); +tcg_gen_andi_tl (t0, t0,31 ); -if (s) { -tcg_gen_shl_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); - }else { -if (t) { -tcg_gen_sar_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); +if (s) { +tcg_gen_shl_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); }else { -tcg_gen_shr_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); +if (t) { +tcg_gen_sar_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); + }else { +tcg_gen_shr_tl (cpu_R[dc->rd], cpu_R[dc->ra], t0); + } } +tcg_temp_free (t0); } -tcg_temp_free (t0); }static void dec_bit (DisasContext *dc)
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v1 5/7] target-microblaze: dec_barrel: Add BSEFI
target/microblaze/translate.c static void dec_barrel(DisasContext *dc) · line 688
Quoted 2 lines · Edgar E. Iglesias
target/microblaze/translate.c +2
-0+if (e) { +tcg_gen_extract_i32 (cpu_R[dc->rd], cpu_R[dc->ra], imm_s, imm_w);
You'll want to validate imm_s and imm_w lest you trigger the asserts in tcg_gen_extract_i32.
r~
PATCH 6/7 target-microblaze: dec_barrel: Add BSIFI
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add support for BSIFI.
--- target/microblaze/translate.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
target/microblaze/translate.c +13 -1
@@ -661,7 +661,7 @@ static void dec_barrel(DisasContext *dc) {TCGv t0;unsigned int imm_w, imm_s; -bool s, t, e = false; +bool s, t, e = false, i = false;if ((dc->tb_flags &MSR_EE_FLAG ) && (dc->cpu->env.pvr.regs[2] & PVR2_ILL_OPCODE_EXC_MASK)
@@ -673,6 +673,7 @@ static void dec_barrel(DisasContext *dc)if (dc->type_b) {/* Insert and extract are only available in immediate mode. */ + i =extract32 (dc->imm,15 ,1 ); e =extract32 (dc->imm,14 ,1 ); } s =extract32 (dc->imm,10 ,1 );
@@ -686,6 +687,17 @@ static void dec_barrel(DisasContext *dc)if (e) {tcg_gen_extract_i32 (cpu_R[dc->rd], cpu_R[dc->ra], imm_s, imm_w); + }else if (i) { +int width = imm_w - imm_s +1 ; + +if (width ==0 || imm_w <= imm_s) { +/* These inputs have an undefined behavior. */ +qemu_log_mask (LOG_GUEST_ERROR ,"bsifi: Bad input w=%d s=%d\n" , + imm_w, imm_s); + }else { +tcg_gen_deposit_i32 (cpu_R[dc->rd], cpu_R[dc->rd], cpu_R[dc->ra], + imm_s, width); + } }else { t0 =tcg_temp_new ();
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v1 6/7] target-microblaze: dec_barrel: Add BSIFI
target/microblaze/translate.c static void dec_barrel(DisasContext *dc) · line 693
Quoted 3 lines · Edgar E. Iglesias
target/microblaze/translate.c +3
-0+int width = imm_w - imm_s +1 ; + +if (width ==0 || imm_w <= imm_s) {
The width == 0 check is redundant; the imm_w <= imm_s check is wrong. It should be <.
If imm_w >= imm_s, as per the proper check, then width must be >= 1.
r~
Re: [Qemu-devel] [PATCH v1 6/7] target-microblaze: dec_barrel: Add BSIFI
Quoted 9 lines · Richard Henderson
target/microblaze/translate.c static void dec_barrel(DisasContext *dc) · line 693
Quoted 3 lines · Edgar E. Iglesias
target/microblaze/translate.c +3
-0+int width = imm_w - imm_s +1 ; + +if (width ==0 || imm_w <= imm_s) {The width == 0 check is redundant; the
imm_w<=imm_scheck is wrong. It should be <.If
imm_w>=imm_s, as per the proper check, then width must be >= 1.
Right, will fix for v2.
Thanks!
Edgar
PATCH 7/7 target-microblaze: Add CPU version 10.0
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add CPU version 10.0.
--- target/microblaze/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/microblaze/cpu.c +1 -0
@@ -67,6 +67,7 @@ static const struct { {"9.4", 0x21}, {"9.5", 0x22}, {"9.6", 0x23}, + {"10.0", 0x24}, {NULL, 0}, };
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH v1 7/7] target-microblaze: Add CPU version 10.0
Quoted 8 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias"<[email protected]>
Add CPU version 10.0.
Signed-off-by Edgar E. Iglesias<[email protected]>--- target/microblaze/cpu.c | 1 + 1 file changed, 1 insertion(+)
r~