diff options
| author | Julian Blake Kongslie | 2022-09-22 11:29:07 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-09-22 11:29:07 -0700 |
| commit | eb3fd68203fee7c63245c702914c2acd3332d65a (patch) | |
| tree | 7796707c0372e7fbe4a8bac70aad95f619e8ba29 /inst.h | |
| download | procmodel-eb3fd68203fee7c63245c702914c2acd3332d65a.tar.xz | |
Initial commit.
Diffstat (limited to 'inst.h')
| -rw-r--r-- | inst.h | 56 |
1 files changed, 56 insertions, 0 deletions
| @@ -0,0 +1,56 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstdint> | ||
| 4 | |||
| 5 | #include "infra/pipetrace.h" | ||
| 6 | |||
| 7 | struct inst { | ||
| 8 | infra::transaction transaction; | ||
| 9 | unsigned int generation; | ||
| 10 | unsigned int size = 0; | ||
| 11 | std::uint64_t linear_next_pc; | ||
| 12 | std::optional<std::uint64_t> predicted_next_pc; | ||
| 13 | std::uint64_t field[4] = {}; | ||
| 14 | std::optional<std::uint64_t> result; | ||
| 15 | }; | ||
| 16 | |||
| 17 | constexpr unsigned int OPCODE = 0; | ||
| 18 | constexpr unsigned int FLAGS_DST = 1; | ||
| 19 | constexpr unsigned int SRC1 = 2; | ||
| 20 | constexpr unsigned int SRC2 = 3; | ||
| 21 | |||
| 22 | constexpr std::uint64_t FLAG_IMM1 = 1 << 4; | ||
| 23 | constexpr std::uint64_t FLAG_IMM2 = 1 << 5; | ||
| 24 | |||
| 25 | enum { | ||
| 26 | OP_JUMP_ABS_IF_ZERO, | ||
| 27 | OP_JUMP_ABS_IF_NONZERO, | ||
| 28 | OP_EMIT, | ||
| 29 | OP_ADD, | ||
| 30 | OP_LOAD, | ||
| 31 | OP_STORE, | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct decodebyte { | ||
| 35 | std::uint8_t bits:4; | ||
| 36 | std::uint8_t field:2; | ||
| 37 | std::uint8_t invert:1; | ||
| 38 | std::uint8_t hold:1; | ||
| 39 | } __attribute__((packed)); | ||
| 40 | |||
| 41 | // 0x - shift opcode and issue | ||
| 42 | // 1x - shift flagsdst and issue | ||
| 43 | // 2x - shift src1 and issue | ||
| 44 | // 3x - shift src2 and issue | ||
| 45 | // 4x - invert+shift opcode and issue | ||
| 46 | // 5x - invert+shift flagsdst and issue | ||
| 47 | // 6x - invert+shift src1 and issue | ||
| 48 | // 7x - invert+shift src2 and issue | ||
| 49 | // 8x - shift opcode | ||
| 50 | // 9x - shift flagsdst | ||
| 51 | // Ax - shift src1 | ||
| 52 | // Bx - shift src2 | ||
| 53 | // Cx - invert+shift opcode | ||
| 54 | // Dx - invert+shift flagsdst | ||
| 55 | // Ex - invert+shift src1 | ||
| 56 | // Fx - invert+shift src2 | ||
