All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang S <gang.chen@sunrus.com.cn>
To: Chris Metcalf <cmetcalf@ezchip.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Richard Henderson <rth@redhat.com>,
	"walt@tilera.com" <walt@tilera.com>,
	Riku Voipio <riku.voipio@iki.fi>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] target-tilegx: Execute _start and reach to __libc_start_main successfully
Date: Wed, 25 Feb 2015 01:25:01 +0800	[thread overview]
Message-ID: <54ECB3ED.7030100@sunrus.com.cn> (raw)
In-Reply-To: <54ECAB00.6000501@ezchip.com>

On 2/25/15 00:46, Chris Metcalf wrote:
> On 2/24/2015 11:31 AM, Chen Gang S wrote:
>>   - When dst is zero, in most cases, we can just skip the insn, but in
>>     some cases, it may cause exception in user mode (e.g st zero r0).
> 
> Be careful of skipping instructions in general, since for example a "ld zero, r1" may be targeting an MMIO address that we are reading to trigger some device operation, but don't need the result from.

OK, thanks, I shall notice about it, next.

> 
>> - For add/addi operation, it will change to mov/movi operation.
>>
>>   - For mov operation, it will change to movi operation.
>>
>>   - For shl3add, if srcb is zero register, it will change to shli
>>     operation.
> 
> I assume you are referring to missed performance optimization opportunities if you don't treat "zero" specially?  You certainly could treat "add r1, r2, zero" as just an "add" instruction anyway, just with a zero addend.  You don't have to convert it to a move instruction.  Likewise with the others.
> 

OK, thanks. Next, I shall not change the instruction, and will only use
tcg temporary variable instead of zero register, when I send patch v2.

>> OK, thanks.  originally I wanted to reuse them, but after think of, I
>> prefer the 64-bit immediate number instead of.
>>
>>   - The decoding function may be very long, but it is still a simple
>>     function, I guess, it is still simple enough for readers.
>>
>>   - 64-bit immediate number has better performance under 64-bit machine
>>     (e.g x86-64).
> 
> What I mean is you should just directly use all those accessor functions.  Then your code would look like
> 
> switch (get_Opcode_X1(bundle)) {   // this is a 59-bit shift and mask by 0x7
> case SHL16INSLI_OPCODE_X1:   // this is the constant 7
>   [...]
> }
> 
> Typically dealing with smaller integers is higher-performance on any platform, I suspect, even on x86 when you can have large inline constants in the code.  The compiler might be smart enough to do this for you, to be fair.  In any case any performance difference of this switch is almost certainly lost in the noise.
> 

Hmm... maybe what you said is correct, but I am not quite sure.

> More to the point, named constants are almost always better for code maintainability than raw integers in code.
> 

For me, if the raw integer is only used once, we needn't define a macro
for it (instead of, we can give a comment for it).

> Also, my point is that you should just include a verbatim copy of the kernel header into qemu, and then use those names.  This is helpful to people who are already familiar with the <arch/opcode.h> naming, and reduces the amount of code needed to review qemu in any case.
> 

OK, thanks. What you said above sounds reasonable to me, for compatible
reason, I shall use "arch/opcode_tilegx.h" totally -- it will be helpful
for the readers who are already familiar with "arch/opcode_tilegx.h".

Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

  reply	other threads:[~2015-02-24 17:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24  7:53 [Qemu-devel] [PATCH] target-tilegx: Execute _start and reach to __libc_start_main successfully Chen Gang S
2015-02-24  8:07 ` Chen Gang S
2015-02-24 14:21 ` Chris Metcalf
2015-02-24 14:38   ` Peter Maydell
2015-02-24 15:39     ` Chen Gang S
2015-02-24 16:42       ` Richard Henderson
2015-02-24 17:08         ` Chen Gang S
2015-02-24 16:31   ` Chen Gang S
2015-02-24 16:46     ` Chris Metcalf
2015-02-24 17:25       ` Chen Gang S [this message]
2015-02-24 18:18         ` Chris Metcalf
2015-02-25  1:01           ` Chen Gang S
2015-02-24 17:55 ` Richard Henderson
2015-02-25  3:40   ` Chen Gang S
2015-02-25 17:19     ` Richard Henderson
2015-02-26  1:44       ` Chen Gang S
2015-02-26 16:31         ` Richard Henderson
2015-02-26 23:30           ` Chen Gang S
2015-02-27  3:01         ` Chris Metcalf
2015-02-27  3:41           ` Chen Gang S

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=54ECB3ED.7030100@sunrus.com.cn \
    --to=gang.chen@sunrus.com.cn \
    --cc=cmetcalf@ezchip.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@redhat.com \
    --cc=walt@tilera.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.