From: Jan Bobek <jan.bobek@gmail.com>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [RISU RFC PATCH v2 04/14] risugen_x86: add module
Date: Wed, 10 Jul 2019 14:21:31 -0400 [thread overview]
Message-ID: <5260d896-37e3-e6f0-1ed4-b5d09bf9fbcd@gmail.com> (raw)
In-Reply-To: <67fbe51c-ab7c-11e9-ecbc-aa72ff430911@linaro.org>
[-- Attachment #1.1: Type: text/plain, Size: 3220 bytes --]
On 7/3/19 12:11 PM, Richard Henderson wrote:
> On 7/1/19 6:35 AM, Jan Bobek wrote:
>> +sub write_mov_rr($$)
>> +{
>> + my ($r1, $r2) = @_;
>> +
>> + my %insn = (opcode => X86OP_MOV,
>> + modrm => {mod => MOD_DIRECT,
>> + reg => ($r1 & 0x7),
>> + rm => ($r2 & 0x7)});
>> +
>> + $insn{rex}{w} = 1 if $is_x86_64;
>> + $insn{rex}{r} = 1 if $r1 >= 8;
>> + $insn{rex}{b} = 1 if $r2 >= 8;
>
> This is where maybe it's better to leave rex.[rb] to risugen_x86_asm, and just
> leave $modrm{reg} and $modrm{rm} as 4-bit quantities.
That's what I have in v3, stay tuned!
>> +sub write_mov_reg_imm($$)
>> +{
>> + my ($reg, $imm) = @_;
>> + my %insn;
>> +
>> + if (0 <= $imm && $imm <= 0xffffffff) {
>
> Should include !$is_x86_64 here,
>
>> + %insn = (opcode => {value => 0xB8 | ($reg & 0x7), len => 1},
>> + imm => {value => $imm, len => 4});
>> + } elsif (-0x80000000 <= $imm && $imm <= 0x7fffffff) {
>> + %insn = (opcode => {value => 0xC7, len => 1},
>> + modrm => {mod => MOD_DIRECT,
>> + reg => 0, rm => ($reg & 0x7)},
>> + imm => {value => $imm, len => 4});
>> +
>> + $insn{rex}{w} = 1 if $is_x86_64;
>
> making this unconditional.
Doesn't B8 (without REX.W) work for x86_64, too? It zeroes the upper
part of the destination, so it's effectively zero-extending, and it's
one byte shorter than C7 (no ModR/M byte needed).
That being said, I moved most of this function to risugen_x86_asm and
included a bunch of comments regarding different cases, so it should
be easier to understand.
>> +sub write_random_ymmdata()
>> +{
>> + my $ymm_cnt = $is_x86_64 ? 16 : 8;
>> + my $ymm_len = 32;
>> + my $datalen = $ymm_cnt * $ymm_len;
>> +
>> + # Generate random data blob
>> + write_random_datablock($datalen);
>> +
>> + # Load the random data into YMM regs.
>> + for (my $ymm_reg = 0; $ymm_reg < $ymm_cnt; $ymm_reg++) {
>> + write_insn(vex => {l => VEX_L_256, p => VEX_P_DATA16,
>> + r => !($ymm_reg >= 8)},
>
> Again, vex.r should be handled in vex_encode.
As I said, there will be more high-level instruction-assembling
functions exported by risugen_x86_asm in v3, which take care of this.
>> + opcode => X86OP_VMOVAPS,
>> + modrm => {mod => MOD_INDIRECT_DISP32,
>> + reg => ($ymm_reg & 0x7),
>> + rm => REG_EAX},
>> + disp => {value => $ymm_reg * $ymm_len,
>> + len => 4});
>> + }
>
> So... this now generates code that cannot run without AVX2.
>
> Which is probably fine for testing right now, since we do
> want to be able to notice effects of SSE/AVX insns on the
> high bits of the registers.
>
> But we'll probably need to have the same --xsave=foo
> command-line option that we have for risu itself.
>
> That would let you initialize only 16-bytes here, or
> for avx512 initialize 64-bytes, plus the k-registers.
Ah yes, indeed.
-Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-07-10 18:23 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 4:35 [Qemu-devel] [RISU RFC PATCH v2 00/14] Support for generating x86 MMX/SSE/AVX test images Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 01/14] risugen_common: add insnv, randint_constr, rand_fill Jan Bobek
2019-07-03 15:22 ` Richard Henderson
2019-07-10 17:48 ` Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 02/14] risugen_x86_asm: add module Jan Bobek
2019-07-03 15:37 ` Richard Henderson
2019-07-10 18:02 ` Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 03/14] risugen_x86_emit: " Jan Bobek
2019-07-03 15:47 ` Richard Henderson
2019-07-10 18:08 ` Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 04/14] risugen_x86: " Jan Bobek
2019-07-03 16:11 ` Richard Henderson
2019-07-10 18:21 ` Jan Bobek [this message]
2019-07-11 9:26 ` Richard Henderson
2019-07-11 13:10 ` Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 05/14] risugen: allow all byte-aligned instructions Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 06/14] x86.risu: add MMX instructions Jan Bobek
2019-07-03 21:35 ` Richard Henderson
2019-07-10 18:29 ` Jan Bobek
2019-07-11 9:32 ` Richard Henderson
2019-07-11 13:29 ` Jan Bobek
2019-07-11 13:57 ` Richard Henderson
2019-07-11 21:29 ` Jan Bobek
2019-07-03 21:49 ` Richard Henderson
2019-07-10 18:32 ` Jan Bobek
2019-07-11 9:34 ` Richard Henderson
2019-07-11 9:44 ` Alex Bennée
2019-07-03 22:01 ` Peter Maydell
2019-07-10 18:35 ` Jan Bobek
2019-07-11 6:45 ` Alex Bennée
2019-07-11 13:33 ` Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 07/14] x86.risu: add SSE instructions Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 08/14] x86.risu: add SSE2 instructions Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 09/14] x86.risu: add SSE3 instructions Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 10/14] x86.risu: add SSSE3 instructions Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 11/14] x86.risu: add SSE4.1 and SSE4.2 instructions Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 13/14] x86.risu: add AVX instructions Jan Bobek
2019-07-01 4:35 ` [Qemu-devel] [RISU RFC PATCH v2 14/14] x86.risu: add AVX2 instructions Jan Bobek
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=5260d896-37e3-e6f0-1ed4-b5d09bf9fbcd@gmail.com \
--to=jan.bobek@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).