public inbox for linux-snps-arc@lists.infradead.org
 help / color / mirror / Atom feed
From: Cupertino Miranda <Cupertino.Miranda@synopsys.com>
To: Richard Henderson <richard.henderson@linaro.org>,
	"cupertinomiranda@gmail.com" <cupertinomiranda@gmail.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Shahab Vahedi <shahab.vahedi@gmail.com>,
	Claudiu Zissulescu <Claudiu.Zissulescu@synopsys.com>,
	"linux-snps-arc@lists.infradead.org"
	<linux-snps-arc@lists.infradead.org>,
	Claudiu Zissulescu <claziss@gmail.com>,
	Shahab Vahedi <Shahab.Vahedi@synopsys.com>
Subject: Re: [PATCH 06/15] arc: TCG instruction definitions
Date: Fri, 15 Jan 2021 17:11:42 +0000	[thread overview]
Message-ID: <13d2fe20-35dc-a47b-c7bb-8ce049119e3b@synopsys.com> (raw)
In-Reply-To: <74cfc5bd-d02c-768b-37e4-18ff8c88656b@linaro.org>

>> +
>> +    assert(ctx->insn.limm_p == 0 && !in_delay_slot);
>> +
>> +    if (ctx->insn.limm_p == 0 && !in_delay_slot) {
>> +        in_delay_slot = true;
>> +        uint32_t cpc = ctx->cpc;
>> +        uint32_t pcl = ctx->pcl;
>> +        insn_t insn = ctx->insn;
>> +
>> +        ctx->cpc = ctx->npc;
>> +        ctx->pcl = ctx->cpc & 0xfffffffc;
>> +
>> +        ++ctx->ds;
>> +
>> +        TCGLabel *do_not_set_bta_and_de = gen_new_label();
>> +        tcg_gen_brcondi_i32(TCG_COND_NE, take_branch, 1, do_not_set_bta_and_de);
>> +        /*
>> +         * In case an exception should be raised during the execution
>> +         * of delay slot, bta value is used to set erbta.
>> +         */
>> +        tcg_gen_mov_tl(cpu_bta, bta);
>> +        /* We are in a delay slot */
>> +        tcg_gen_mov_tl(cpu_DEf, take_branch);
>> +        gen_set_label(do_not_set_bta_and_de);
>> +
>> +        tcg_gen_movi_tl(cpu_is_delay_slot_instruction, 1);
>> +
>> +        /* Set the pc to the next pc */
>> +        tcg_gen_movi_tl(cpu_pc, ctx->npc);
>> +        /* Necessary for the likely call to restore_state_to_opc() */
>> +        tcg_gen_insn_start(ctx->npc);
> 
> Wow, this looks wrong.
> 
> It doesn't work with icount or single-stepping.  You need to be able to begin a
> TB at any instruction, including a delay slot.
> 
> You should have a look at some of the other targets that handle this, e.g.
> openrisc or sparc.  Since you've got NPC already, for looping, sparc is
> probably the better match.
> 
> There should be no reason why you'd need to emit insn_start outside of
> arc_tr_insn_start.
> 

We are also able to start TB at any instruction, that is not what is 
being validated here. It is just verifying if a delayslot instruction 
does not have the delayslot flag set, and that the delayslot instruction 
does not have a limm.

The way we encode delayslot instructions is a little peculiar. When some 
instruction defines a delayslot, it calls this function and the 
instruction is decoded inline.
As far as I remember the change of instruction context, with 
tcg_gen_insns_start, allowed us to properly make gdb jump from branch 
instruction to delay slot instruction and then back.

The asser was used to guarantee that those conditions where never broken 
internally. The condition becomes irrelevant.


>> + ***************************************
>> + * Statically inferred return function *
>> + ***************************************
>> + */
>> +
>> +TCGv arc_gen_next_reg(const DisasCtxt *ctx, TCGv reg)
>> +{
>> +    int i;
>> +    for (i = 0; i < 64; i += 2) {
>> +        if (reg == cpu_r[i]) {
>> +            return cpu_r[i + 1];
>> +        }
>> +    }
>> +    /* Check if REG is an odd register. */
>> +    for (i = 1; i < 64; i += 2) {
>> +        /* If so, that is unsanctioned. */
>> +        if (reg == cpu_r[i]) {
>> +            arc_gen_excp(ctx, EXCP_INST_ERROR, 0, 0);
>> +            return NULL;
>> +        }
>> +    }
> 
> Wow, really?  Can't you grab this directly from the operand decoding?  Where
> surely we have already ensured that the relevant regnos are not odd.

Indeed, we can grab it from operand decoding. Please allow us to do this 
change once we rework binutils code.
_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

  parent reply	other threads:[~2021-01-15 17:11 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11 16:17 [PATCH 00/15] *** ARC port for review *** cupertinomiranda
2020-11-11 16:17 ` [PATCH 01/15] arc: Add initial core cpu files cupertinomiranda
2020-12-01 19:06   ` Richard Henderson
2020-11-11 16:17 ` [PATCH 02/15] arc: Decoder code cupertinomiranda
2020-11-11 16:17 ` [PATCH 03/15] arc: Opcode definitions table cupertinomiranda
2020-12-01 20:22   ` Richard Henderson
2021-01-15 17:11     ` Cupertino Miranda
2021-01-15 19:52       ` Richard Henderson
2020-11-11 16:17 ` [PATCH 04/15] arc: TCG and decoder glue code and helpers cupertinomiranda
2020-12-01 21:35   ` Richard Henderson
2021-01-15 17:11     ` Cupertino Miranda
2021-01-15 20:31       ` Richard Henderson
2021-01-15 21:48         ` Cupertino Miranda
2021-01-15 21:53           ` Richard Henderson
2021-01-15 22:06             ` Cupertino Miranda
2021-01-15 21:28     ` Shahab Vahedi
2021-01-15 21:51       ` Richard Henderson
2020-11-11 16:17 ` [PATCH 05/15] arc: TCG instruction generator and hand-definitions cupertinomiranda
2020-12-01 22:16   ` Richard Henderson
2021-01-15 17:11     ` Cupertino Miranda
2021-01-15 20:17       ` Richard Henderson
2021-01-15 21:38         ` Cupertino Miranda
2020-11-11 16:17 ` [PATCH 06/15] arc: TCG instruction definitions cupertinomiranda
2020-12-01 23:09   ` Richard Henderson
2020-12-02 12:55     ` Cupertino Miranda
2020-12-03 16:07       ` Richard Henderson
2020-12-03 16:54         ` Cupertino Miranda
2020-12-03 19:34           ` Richard Henderson
2020-12-03 19:51             ` Cupertino Miranda
2021-01-15 17:11     ` Cupertino Miranda [this message]
2020-11-11 16:17 ` [PATCH 07/15] arc: Add BCR and AUX registers implementation cupertinomiranda
2020-11-11 16:17 ` [PATCH 08/15] arc: Add IRQ and timer subsystem support cupertinomiranda
2020-11-11 16:17 ` [PATCH 09/15] arc: Add memory management unit (MMU) support cupertinomiranda
2020-11-11 16:17 ` [PATCH 10/15] arc: Add memory protection unit (MPU) support cupertinomiranda
2020-11-11 16:17 ` [PATCH 11/15] arc: Add gdbstub and XML for debugging support cupertinomiranda
2020-11-11 16:17 ` [PATCH 12/15] arc: Add Synopsys ARC emulation boards cupertinomiranda
2020-11-11 16:17 ` [PATCH 13/15] arc: Add support for ARCv2 cupertinomiranda
2020-11-11 16:17 ` [PATCH 14/15] tests/tcg: ARC: Add TCG instruction definition tests cupertinomiranda
2020-11-11 16:17 ` [PATCH 15/15] tests/acceptance: ARC: Add linux boot testing cupertinomiranda
2020-11-11 16:43 ` [PATCH 00/15] *** ARC port for review *** no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13d2fe20-35dc-a47b-c7bb-8ce049119e3b@synopsys.com \
    --to=cupertino.miranda@synopsys.com \
    --cc=Claudiu.Zissulescu@synopsys.com \
    --cc=Shahab.Vahedi@synopsys.com \
    --cc=claziss@gmail.com \
    --cc=cupertinomiranda@gmail.com \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=shahab.vahedi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox