Commit Graph

275 Commits

Author SHA1 Message Date
Alexis Engelke
003c7ca750 encode-test: Make cases generally usable
This is a preparation for a new API which exposes different instructions
as different functions.
2022-02-20 17:18:15 +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
5e546f5458 instrs: Fix INTO flags 2022-01-06 10:29:02 +01:00
Alexis Engelke
f9a773c619 format: Fix unused parameter warning 2022-01-06 09:56:01 +01:00
Alexis Engelke
38a7a5f075 format: Fix cast alignment warning for __m128i 2022-01-06 09:55:29 +01:00
Ole André Vadla Ravnås
e98e96c28c decode: Remove inline hint on table_walk()
To avoid GCC warnings when building with `-Os`:

    warning: inlining failed in call to 'table_walk': call is
        unlikely and code size would grow [-Winline]

I don't know if this causes a performance regression when optimizing for
speed instead of size, but perhaps there's a different way we can help
the compiler make this decision in such cases.
2022-01-06 09:54:47 +01:00
Ole André Vadla Ravnås
8e56088c6f encode: Fix OPC_*_MSK on 32-bit systems
Where we'd end up losing the upper bits.

GCC catches this and emits a warning such as:

    warning: result of '7 << 31' requires 35 bits to represent, but
        'long int' only has 32 bits [-Wshift-overflow=]
2022-01-06 09:46:50 +01:00
Ole André Vadla Ravnås
5c35f0e40e decode: Fix LOAD_LE_8() on 32-bit systems
Where size_t is only 32 bits wide, and we end up losing the upper bits.

GCC catches this and emits a warning such as:

    warning: left shift count >= width of type [-Wshift-count-overflow]
2022-01-06 09:45:21 +01:00
Ole André Vadla Ravnås
4b42ddb567 meson: Override provided dependency
For convenience when used as a subproject.
2022-01-05 10:06:37 +01:00
Alexis Engelke
204580f480 tests: Move to root directory 2021-09-22 13:16:58 +02:00
Alexis Engelke
16c5c64932 tests: Add more corner cases 2021-09-22 12:15:59 +02:00
Alexis Engelke
1bd5f7c572 decode: Set address size when decoding prefixes 2021-09-20 13:52:06 +02:00
Alexis Engelke
a150822fe1 meson: Add -fstrict-aliasing if supported 2021-09-19 17:06:59 +02:00
Alexis Engelke
49984c940c parseinstrs: Encode struct in InstrDesc 2021-09-14 18:15:38 +02:00
Alexis Engelke
c8ff70d436 tests/decode: Test more instructions and operands 2021-09-13 17:44:34 +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
bf0425f057 decode: Expose immediate in RVMR encodings
The AMD64 instructions VPERMIL2PS and VPERMIL2PD (currently not
supported) encode a fifth immediate operand in the lower bits of the
re-purposed immediate. Expose this value in any case so that no
information gets lost during decoding.
2021-09-13 17:38:24 +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
e164803037 instrs: Support FRED instructions 2021-06-13 16:01:03 +02:00
Alexis Engelke
7df4c9542f format: Reduce size of register name table 2021-06-13 15:59:44 +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
d67eb93148 general: Improve documentation 2021-04-02 11:31:28 +02:00
Alexis Engelke
c99e860a5e tests: Add few more encode/decode cases 2021-04-02 11:28:13 +02:00
Alexis Engelke
4185d7b2d6 encode: Support FD/TD encodings 2021-04-02 11:26:12 +02:00
Alexis Engelke
fa52782e76 encode: Enforce 15-byte limit 2021-04-02 11:00:24 +02:00
Alexis Engelke
d9183228d0 encode: Actually encode LOCK prefix 2021-04-02 10:59:06 +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
51ffe2598e ci: Fix GitHub CI 2021-03-28 15:17:35 +02:00
Alexis Engelke
cf8d1be15f encode: Fix erroneous encoding of SREG push/pop 2021-03-23 13:25:30 +01:00
Alexis Engelke
5faa90a292 encode: Support RVMR encoding 2021-03-23 12:55:43 +01:00
Alexis Engelke
0521ff7d42 decode: Fix VBLENDVP[SD] opcodes 2021-03-23 12:52:37 +01:00
Alexis Engelke
b5994b2f2d ci: Add build description for builds.sr.ht 2021-02-06 12:44:24 +01:00
Alexis Engelke
4f2366afd1 instrs: Add VIA PadLock and AMD RDPRU 2021-01-23 16:47:30 +01:00
Alexis Engelke
f7567c89bd instrs: Fix VMOVSS/VMOVSD with memory operand 2021-01-23 16:44:16 +01:00
Alexis Engelke
e8f440c713 instrs: Minor fix with mandatory prefixes 2021-01-23 16:43:52 +01:00
Alexis Engelke
d7b9c97681 instrs: Remove MPX instructions
These instructions have plenty of corner cases and some instructions
have a different usage of the memory operand. Given that MPX is already
deprecated by Intel, it seems that the better option is to decode these
(rarely occuring) instructions as NOPs.
2021-01-23 16:18:12 +01:00
Alexis Engelke
0efd44cc28 instrs: Add some missing opcodes and FPU aliases 2021-01-23 16:17:42 +01:00
Alexis Engelke
103fc536b0 instrs: Fix operands of VRCPPS/VSQRTP[SD]/VRSQRTPS 2021-01-23 14:39:48 +01:00
Alexis Engelke
f17d84cee6 format: Emit XACQUIRE/XRELEASE
As CMPXCHGD has a mandatory prefix table, it is absolutely necessary
that the presence of any tables does not modify any decoding state.
2021-01-23 14:35:08 +01:00
Alexis Engelke
ab63a3c921 instrs: Fix mandatory prefixes of CMPXCHG8B/16B 2021-01-23 14:30:45 +01:00
Alexis Engelke
7919b8115a format: Emit REP/REPNZ only for string instruction 2021-01-23 14:29:29 +01:00
Alexis Engelke
fe68dbb743 decode: Fix LOCK handling for MOV CR/DR 2021-01-23 14:28:27 +01:00