interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / src / aarch64_decoder.h

61 lines · 1597 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0
2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef AARCH64_DECODER_H
18#define AARCH64_DECODER_H
19
20#include "aarch64_target.h"
21#include <stddef.h>
22
23typedef enum {
24 DECODED_INVALID = 0,
25 DECODED_ADD,
26 DECODED_SUB,
27 DECODED_MUL,
28 DECODED_AND,
29 DECODED_ORR,
30 DECODED_EOR,
31 DECODED_MOVZ,
32 DECODED_RET,
33 DECODED_B,
34 DECODED_B_COND,
35 DECODED_CBZ,
36 DECODED_CBNZ,
37 DECODED_MOVK,
38 DECODED_ADR,
39 DECODED_LDR,
40 DECODED_STR,
41 DECODED_LDRB,
42 DECODED_STRB,
43 DECODED_SUBS
44} DecodedOp;
45
46typedef struct {
47 DecodedOp op;
48 bool sf;
49 uint8_t rd;
50 uint8_t rn;
51 uint8_t rm;
52 uint16_t imm16;
53 uint8_t hw; /* MOVZ/MOVK: 16-bit chunk index (shift = hw * 16) */
54 int32_t branch_imm;
55 Aarch64Cond cond;
56} DecodedInsn;
57
58int aarch64_decode_instruction(uint32_t insn, DecodedInsn *out_dec);
59int aarch64_validate_code_buffer(const uint8_t *code, size_t len, char *err_msg, size_t err_msg_len);
60
61#endif /* AARCH64_DECODER_H */