diff mbox

[3/8] target-ppc: Add bctar Instruction

Message ID 1390845264-2532-4-git-send-email-tommusta@gmail.com
State New
Headers show

Commit Message

Tom Musta Jan. 27, 2014, 5:54 p.m. UTC
This patch adds the Branch Conditional to Address Register (bctar)
instruction.

Signed-off-by: Tom Musta <tommusta@gmail.com>
---
 target-ppc/translate.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

Comments

Alexander Graf Jan. 27, 2014, 6:46 p.m. UTC | #1
On 27.01.2014, at 18:54, Tom Musta <tommusta@gmail.com> wrote:

> This patch adds the Branch Conditional to Address Register (bctar)
> instruction.
> 
> Signed-off-by: Tom Musta <tommusta@gmail.com>
> ---
> target-ppc/translate.c |   11 ++++++++++-
> 1 files changed, 10 insertions(+), 1 deletions(-)
> 
> diff --git a/target-ppc/translate.c b/target-ppc/translate.c
> index f245946..90cbb72 100644
> --- a/target-ppc/translate.c
> +++ b/target-ppc/translate.c
> @@ -3748,6 +3748,7 @@ static void gen_b(DisasContext *ctx)
> #define BCOND_IM  0
> #define BCOND_LR  1
> #define BCOND_CTR 2
> +#define BCOND_TAR 3
> 
> static inline void gen_bcond(DisasContext *ctx, int type)
> {
> @@ -3756,10 +3757,12 @@ static inline void gen_bcond(DisasContext *ctx, int type)
>     TCGv target;
> 
>     ctx->exception = POWERPC_EXCP_BRANCH;
> -    if (type == BCOND_LR || type == BCOND_CTR) {
> +    if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
>         target = tcg_temp_local_new();
>         if (type == BCOND_CTR)
>             tcg_gen_mov_tl(target, cpu_ctr);
> +        else if (type == BCOND_TAR)
> +            gen_load_spr(target, SPR_TAR);

How frequently is this used in generated code? Would it make sense to make it a global TCG variable?


Alex

>         else
>             tcg_gen_mov_tl(target, cpu_lr);
>     } else {
> @@ -3841,6 +3844,11 @@ static void gen_bclr(DisasContext *ctx)
>     gen_bcond(ctx, BCOND_LR);
> }
> 
> +static void gen_bctar(DisasContext *ctx)
> +{
> +    gen_bcond(ctx, BCOND_TAR);
> +}
> +
> /***                      Condition register logical                       ***/
> #define GEN_CRLOGIC(name, tcg_op, opc)                                        \
> static void glue(gen_, name)(DisasContext *ctx)                                       \
> @@ -9540,6 +9548,7 @@ GEN_HANDLER(b, 0x12, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
> GEN_HANDLER(bc, 0x10, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
> GEN_HANDLER(bcctr, 0x13, 0x10, 0x10, 0x00000000, PPC_FLOW),
> GEN_HANDLER(bclr, 0x13, 0x10, 0x00, 0x00000000, PPC_FLOW),
> +GEN_HANDLER_E(bctar, 0x13, 0x10, 0x11, 0, PPC_NONE, PPC2_BCTAR_ISA207),
> GEN_HANDLER(mcrf, 0x13, 0x00, 0xFF, 0x00000001, PPC_INTEGER),
> GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW),
> #if defined(TARGET_PPC64)
> -- 
> 1.7.1
> 
>
Tom Musta Jan. 27, 2014, 7:34 p.m. UTC | #2
On 1/27/2014 12:46 PM, Alexander Graf wrote:
>> static inline void gen_bcond(DisasContext *ctx, int type)
>> > {
>> > @@ -3756,10 +3757,12 @@ static inline void gen_bcond(DisasContext *ctx, int type)
>> >     TCGv target;
>> > 
>> >     ctx->exception = POWERPC_EXCP_BRANCH;
>> > -    if (type == BCOND_LR || type == BCOND_CTR) {
>> > +    if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
>> >         target = tcg_temp_local_new();
>> >         if (type == BCOND_CTR)
>> >             tcg_gen_mov_tl(target, cpu_ctr);
>> > +        else if (type == BCOND_TAR)
>> > +            gen_load_spr(target, SPR_TAR);
> How frequently is this used in generated code? Would it make sense to make it a global TCG variable?
> 

I have not yet seen a case of this being generated by the newer compilers.  But it is certainly not difficult
or much more code to make it be a global.
Alexander Graf Jan. 27, 2014, 9:44 p.m. UTC | #3
On 27.01.2014, at 20:34, Tom Musta <tommusta@gmail.com> wrote:

> On 1/27/2014 12:46 PM, Alexander Graf wrote:
>>> static inline void gen_bcond(DisasContext *ctx, int type)
>>>> {
>>>> @@ -3756,10 +3757,12 @@ static inline void gen_bcond(DisasContext *ctx, int type)
>>>>    TCGv target;
>>>> 
>>>>    ctx->exception = POWERPC_EXCP_BRANCH;
>>>> -    if (type == BCOND_LR || type == BCOND_CTR) {
>>>> +    if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
>>>>        target = tcg_temp_local_new();
>>>>        if (type == BCOND_CTR)
>>>>            tcg_gen_mov_tl(target, cpu_ctr);
>>>> +        else if (type == BCOND_TAR)
>>>> +            gen_load_spr(target, SPR_TAR);
>> How frequently is this used in generated code? Would it make sense to make it a global TCG variable?
>> 
> 
> I have not yet seen a case of this being generated by the newer compilers.  But it is certainly not difficult
> or much more code to make it be a global.

Well, we shouldn't waste a global on a register that doesn't get used frequently, so I'd say we leave it like this for now and change it to a global if / when we see it used often.


Alex
diff mbox

Patch

diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index f245946..90cbb72 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -3748,6 +3748,7 @@  static void gen_b(DisasContext *ctx)
 #define BCOND_IM  0
 #define BCOND_LR  1
 #define BCOND_CTR 2
+#define BCOND_TAR 3
 
 static inline void gen_bcond(DisasContext *ctx, int type)
 {
@@ -3756,10 +3757,12 @@  static inline void gen_bcond(DisasContext *ctx, int type)
     TCGv target;
 
     ctx->exception = POWERPC_EXCP_BRANCH;
-    if (type == BCOND_LR || type == BCOND_CTR) {
+    if (type == BCOND_LR || type == BCOND_CTR || type == BCOND_TAR) {
         target = tcg_temp_local_new();
         if (type == BCOND_CTR)
             tcg_gen_mov_tl(target, cpu_ctr);
+        else if (type == BCOND_TAR)
+            gen_load_spr(target, SPR_TAR);
         else
             tcg_gen_mov_tl(target, cpu_lr);
     } else {
@@ -3841,6 +3844,11 @@  static void gen_bclr(DisasContext *ctx)
     gen_bcond(ctx, BCOND_LR);
 }
 
+static void gen_bctar(DisasContext *ctx)
+{
+    gen_bcond(ctx, BCOND_TAR);
+}
+
 /***                      Condition register logical                       ***/
 #define GEN_CRLOGIC(name, tcg_op, opc)                                        \
 static void glue(gen_, name)(DisasContext *ctx)                                       \
@@ -9540,6 +9548,7 @@  GEN_HANDLER(b, 0x12, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
 GEN_HANDLER(bc, 0x10, 0xFF, 0xFF, 0x00000000, PPC_FLOW),
 GEN_HANDLER(bcctr, 0x13, 0x10, 0x10, 0x00000000, PPC_FLOW),
 GEN_HANDLER(bclr, 0x13, 0x10, 0x00, 0x00000000, PPC_FLOW),
+GEN_HANDLER_E(bctar, 0x13, 0x10, 0x11, 0, PPC_NONE, PPC2_BCTAR_ISA207),
 GEN_HANDLER(mcrf, 0x13, 0x00, 0xFF, 0x00000001, PPC_INTEGER),
 GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW),
 #if defined(TARGET_PPC64)