[Qemu-devel] [RISU RFC PATCH v1 5/7] risugen: allow all byte-aligned instructions

Jan Bobek posted 7 patches 6 years, 4 months ago
[Qemu-devel] [RISU RFC PATCH v1 5/7] risugen: allow all byte-aligned instructions
Posted by Jan Bobek 6 years, 4 months ago
Accept all instructions whose bit length is divisible by 8. Note that
the maximum instruction length (as specified in the config file) is 32
bits, hence this change permits instructions which are 8 bits or 24
bits long (16-bit instructions have already been considered valid).

Note that while valid x86 instructions may be up to 15 bytes long, the
length constraint described above only applies to the main opcode
field, which is usually only 1 or 2 bytes long. Therefore, the primary
purpose of this change is to allow 1-byte x86 opcodes.

Signed-off-by: Jan Bobek <jan.bobek@gmail.com>
---
 risugen | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/risugen b/risugen
index 09a702a..17bf98f 100755
--- a/risugen
+++ b/risugen
@@ -229,12 +229,11 @@ sub parse_config_file($)
                 push @fields, [ $var, $bitpos, $bitmask ];
             }
         }
-        if ($bitpos == 16) {
-            # assume this is a half-width thumb instruction
+        if ($bitpos % 8 == 0) {
             # Note that we don't fiddle with the bitmasks or positions,
             # which means the generated insn will be in the high halfword!
-            $insnwidth = 16;
-        } elsif ($bitpos != 0) {
+            $insnwidth -= $bitpos;
+        } else {
             print STDERR "$file:$.: ($insn $enc) not enough bits specified\n";
             exit(1);
         }
-- 
2.20.1


Re: [Qemu-devel] [RISU RFC PATCH v1 5/7] risugen: allow all byte-aligned instructions
Posted by Richard Henderson 6 years, 4 months ago
On 6/19/19 7:04 AM, Jan Bobek wrote:
> Accept all instructions whose bit length is divisible by 8. Note that
> the maximum instruction length (as specified in the config file) is 32
> bits, hence this change permits instructions which are 8 bits or 24
> bits long (16-bit instructions have already been considered valid).
> 
> Note that while valid x86 instructions may be up to 15 bytes long, the
> length constraint described above only applies to the main opcode
> field, which is usually only 1 or 2 bytes long. Therefore, the primary
> purpose of this change is to allow 1-byte x86 opcodes.
> 
> Signed-off-by: Jan Bobek <jan.bobek@gmail.com>
> ---
>  risugen | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~