125 Commits

Author SHA1 Message Date
Alexis Engelke
6abc971576 decode: Move instr-width to legacy path
Very few instructions set use instrwidth, so move this check as well to
the legacy path. The only affected common instructions are RET and
LEAVE.
2023-04-24 08:55:56 +02:00
Alexis Engelke
538708cd21 decode: Change encoding of T16 index
This encoding change saves a shift for the "is register" part.
2023-04-23 08:57:08 +02:00
Alexis Engelke
513cc709a4 decode: Handle GPH, NOP and 3DNow in legacy block 2023-04-23 08:57:08 +02:00
Alexis Engelke
dac2ff1987 decode: Encode trie node kind in 2 bits 2023-04-23 08:57:08 +02:00
Alexis Engelke
e1084be859 decode: Encode prefixes in trie
This allows to handle unescaped opcodes with a single table lookup.
2023-04-23 08:57:08 +02:00
Alexis Engelke
a34cd9d2aa parseinstrs: Verify more x86 constraints 2023-04-23 08:57:08 +02:00
Alexis Engelke
e247ead397 parseinstrs: Minor refactoring of trie entries 2023-04-23 08:57:08 +02:00
Alexis Engelke
b48495805e decode: Minor tweaks for performance 2023-01-15 13:47:11 +01:00
Alexis Engelke
955f139025 instrs: Add AVX512-FP16 instructions 2023-01-15 13:47:11 +01:00
Alexis Engelke
8550e2cac9 parseinstrs: Add support for BCST16
2-byte broadcasts cannot be inferred from the encoding and need to be
indicated in the descriptor.
2023-01-15 13:47:11 +01:00
Alexis Engelke
a3c8848005 instrs: Remove unused WIG specifier
If REX.W/VEX.W/EVEX.W is not used as opcode extension or as operand
size, it is ignored automatically. No need to encode this.
2023-01-15 13:47:11 +01:00
Alexis Engelke
e04aff73dc decode: Add AVX-512 support 2023-01-15 13:47:11 +01:00
Alexis Engelke
ec5a430b5c decode: Decode EVEX prefix 2023-01-15 13:40:51 +01:00
Alexis Engelke
36c37186dd encode-test: Test all REX/VEX.RXB combinations 2023-01-15 13:38:28 +01:00
Alexis Engelke
7b2a586449 parseinstrs: Fix erroneous 16-bit operand size 2023-01-15 11:24:35 +01:00
Alexis Engelke
2f7e8dd0de encode: Remove descriptor table
All relevant information is now encoded directly in the numeric value of
the mnemonic, significantly shrinking the size of the encoder.
2023-01-15 11:09:40 +01:00
Alexis Engelke
9f0ddeb44a encode: Fix [LMS]FENCE encoding 2023-01-13 14:25:55 +01:00
Alexis Engelke
36019517cf parseinstrs: Print stats only if not subproject
Statistics are only interesting for development.
2022-12-28 12:28:22 +01:00
Alexis Engelke
6bf96d6963 parseinstrs: Improve performance of superstring
This algorithm yields slightly worse results, but is substantially
faster for larger string counts.
2022-12-28 12:28:22 +01:00
Alexis Engelke
377e362a0e decode: Handle imm_byte size differently
For byte-sized immediates, there are only two options for the operand
size: byte and the instruction's operand size. This knowledge allows to
remove the byte constraint from the set of fixed operand sizes.
2022-12-27 19:46:04 +01:00
Alexis Engelke
99a9802f50 decode: Store op size per operand type
This change doesn't really affect performance and is preparatory
work for AVX-512, where the memory operand size is required to compute
the compressed displacement.
2022-12-03 14:52:06 +01:00
Alexis Engelke
c54a749713 parseinstrs: Simplify encode opsize derivation 2022-11-30 09:32:02 +01:00
Alexis Engelke
4abad24610 decode: Support half vector size
This is realized by two changes: first, GP and vector operand size are
completely separated using one extra bit. If the operand size of an
instruction is derived from VEX.L (or EVEX.L'L), then the "opsize" bits
indicate how to derive a smaller vector size (half/quarter/eighth).
2022-11-30 09:32:02 +01:00
Alexis Engelke
f565f09f9d instrs: Clearly separate vector and GP opsize
Now, an instruction cannot refer to the GP operand size and the vector
operand size at the same time. This isn't necessary, all necessary
distinguishing could also be achieved manually using W0/W1/66 selectors.
2022-11-27 18:07:44 +01:00
Alexis Engelke
fe6fe0ffc1 instrs: Add CMPCCXADD 2022-11-27 13:39:37 +01:00
Alexis Engelke
1c04ded9b7 decode: Merge zeroreg and vexreg
There is no instruction that uses an implicit register and an
VEX-encoded register at the same time. Thus, we can merge vexreg and
zeroreg in the instruction descriptor; the zeroreg value will be added
to the vex-operand (which is zero unless set by a VEX prefix).

This also frees 4 descriptor bits for use with AVX-512 (which will
probably need 1-2 additional unused bits, probably from the type).
2022-11-20 15:25:37 +01:00
Alexis Engelke
1f0ef1ba0c parseinstr: Remove duplicate encode mnem generator 2022-02-26 10:11:12 +01:00
Alexis Engelke
6b8c2968c1 encode2: Add new encoder API, one func per instr.
This is an *experimental* (read: unstable) API which exposes encoding
functionality as one function per instruction. This makes the encoding
process itself significantly faster, at the cost of a much larger binary
size (~1 MiB of code, no data) and much higher compilation time.
2022-02-20 17:21:04 +01:00
Alexis Engelke
2fd83903cf meson,parseinstrs: Make decode and encode optional 2022-02-20 17:15:21 +01:00
Alexis Engelke
87fe6314b8 instrs: Disambiguate instr type by mnemonic 2022-02-20 15:38:12 +01:00
Alexis Engelke
e78a89b610 instrs: Annotate 67h and segment override usage
Some instructions honor an address-size override or a segment override,
even in the absence of a directly encoded memory operand.

These annotations are not yet used, but may be used in future to
optimize the size of encoded instructions.
2022-01-06 10:31:09 +01:00
Alexis Engelke
49984c940c parseinstrs: Encode struct in InstrDesc 2021-09-14 18:15:38 +02:00
Alexis Engelke
4193ef96bf parseinstrs: Generate more statistics 2021-09-13 17:44:00 +02:00
Alexis Engelke
e5cdc57743 parseinstrs: Minor simplification 2021-09-13 17:43:12 +02:00
Alexis Engelke
7229f13742 parseinstrs: Don't generate 16-bit version for I66 2021-09-13 17:28:49 +02:00
Alexis Engelke
effc0c7e49 parseinstrs: Fold trie layers with only one child 2021-09-13 17:27:47 +02:00
Alexis Engelke
71c0daf581 instrs: Change operand format
This changes the instruction description format:

- Use Intel/AMD terminology for describing operands (where applicable)
- Group instructions by ISA extension
- Indicate read/written status flags
2021-09-13 17:26:43 +02:00
Alexis Engelke
e41d6c26f8 parseinstrs: Make superstring function generic 2021-09-11 13:19:17 +02:00
Alexis Engelke
1fcacdeda7 parseinstrs: Optimize mnemonic compression
As the formatter no longer demands a null-terminated string, mnemonics
can arbitarily overlap and therefore save space.

This is the shortest superstring problem, which is NP-hard. This is
currently approximated with a greedy heuristic.
2021-09-11 13:05:34 +02:00
Alexis Engelke
99a1fbeee1 format: Major refactoring for performance 2021-05-30 14:25:38 +02:00
Alexis Engelke
50f052488d decode: More precise register types 2021-04-02 17:20:23 +02:00
Alexis Engelke
4185d7b2d6 encode: Support FD/TD encodings 2021-04-02 11:26:12 +02:00
Alexis Engelke
2d9587bc16 encode: Fix encoding of memory operand
When a modrm_idx is used without a ModRM being present, the encoder
attempted to encode memory operands using O/OA/AO encodings.
2021-04-02 10:54:04 +02:00
Alexis Engelke
5faa90a292 encode: Support RVMR encoding 2021-03-23 12:55:43 +01:00
Alexis Engelke
4f2366afd1 instrs: Add VIA PadLock and AMD RDPRU 2021-01-23 16:47:30 +01:00
Alexis Engelke
363698db3b parseinstrs: Move decode table gen to new function 2021-01-23 13:59:59 +01:00
Alexis Engelke
85fdaa3a9b instrs: Remove incorrect NFx specifiers
The new trie implementation is more flexible and allows omitting
prefixes even with a ModRM specifier in the opcode. Use this flexibility
to simplify instruction descriptions.
2021-01-23 13:25:23 +01:00
Alexis Engelke
dc399390a4 parseinstrs: Refactor mapping of opcode to Trie 2021-01-23 13:25:23 +01:00
Alexis Engelke
13a2456458 parseinstrs: Simplify trie implementation 2021-01-23 13:25:23 +01:00
Alexis Engelke
43910a6227 parseinstrs: Avoid redundant encoding of InstrDesc 2021-01-23 13:25:23 +01:00