infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
abi_arm64_common.h
Go to the documentation of this file.
1#pragma once
40#include <stdint.h>
41
87
131
144// Common bitfields
145#define A64_SF_64BIT (1U << 31) // 'sf' (size field) bit for 64-bit operations
146#define A64_SF_32BIT (0U << 31) // 'sf' bit for 32-bit operations
147#define A64_V_VECTOR (1U << 26) // Vector bit for SIMD/FP instructions
148
149// Data Processing -- Immediate (e.g., ADD, SUB)
150#define A64_OPC_ADD (0b00U << 29)
151#define A64_OPC_ADDS (0b01U << 29)
152#define A64_OPC_SUB (0b10U << 29)
153#define A64_OPC_SUBS (0b11U << 29)
154#define A64_OP_ADD_SUB_IMM (0b0010001U << 24)
155
156// Data Processing -- Register (e.g., ADD, ORR)
157#define A64_OP_ADD_SUB_REG (0b01011U << 24)
158#define A64_OP_LOGICAL_REG (0b01010U << 24)
159#define A64_OPCODE_ORR (0b01U << 29)
160
161// Move Wide (MOVZ, MOVK)
162#define A64_OPC_MOVZ (0b10U << 29)
163#define A64_OPC_MOVK (0b11U << 29)
164#define A64_OP_MOVE_WIDE_IMM (0b100101U << 23)
165
166// Load/Store -- Immediate Unsigned Offset
167#define A64_OP_LOAD_STORE_IMM_UNSIGNED (0b111001U << 24)
168#define A64_LDR_OP (1U << 22)
169#define A64_OP_LOAD_STORE_PAIR_BASE (0b101000U << 24) // Base for all LDP/STP variants
170#define A64_OPC_STP (0b00U << 30) // opc field for Store Pair
171#define A64_OPC_LDP (0b01U << 30) // opc field for Load Pair
172#define A64_L_BIT_LOAD (1U << 22) // The 'L' bit distinguishes Load (1) from Store (0)
173
174// Addressing modes for LDP/STP
175#define A64_ADDR_POST_INDEX (0b01U << 23) // [Xn], #imm
176#define A64_ADDR_PRE_INDEX (0b11U << 23) // [Xn, #imm]!
177#define A64_ADDR_SIGNED_OFFSET (0b10U << 23) // [Xn, #imm]
178
179// Branching
180#define A64_OP_BRANCH_REG (0b1101011U << 25)
181#define A64_OPC_BR (0b0000U << 21)
182#define A64_OPC_BLR (0b0001U << 21)
183#define A64_OPC_RET (0b0010U << 21)
184#define A64_OP_COMPARE_BRANCH_IMM (0b011010U << 25)
185#define A64_OPC_CBNZ (1U << 24)
186
187// System
188#define A64_OP_SYSTEM (0b11010100U << 25)
189#define A64_OP_BRK (0b00000000001U << 16)
190#define A64_OP_SVC (0b00000000001U << 21)
191
// end aarch64_opcodes
arm64_gpr
Definition abi_arm64_common.h:53
@ X1_REG
Argument 2 / Volatile.
Definition abi_arm64_common.h:55
@ X13_REG
Volatile scratch register.
Definition abi_arm64_common.h:67
@ X24_REG
Callee-saved.
Definition abi_arm64_common.h:78
@ X14_REG
Volatile scratch register.
Definition abi_arm64_common.h:68
@ X12_REG
Volatile scratch register.
Definition abi_arm64_common.h:66
@ X28_REG
Callee-saved.
Definition abi_arm64_common.h:82
@ X25_REG
Callee-saved.
Definition abi_arm64_common.h:79
@ X7_REG
Argument 8 / Volatile.
Definition abi_arm64_common.h:61
@ X4_REG
Argument 5 / Volatile.
Definition abi_arm64_common.h:58
@ X22_REG
Callee-saved.
Definition abi_arm64_common.h:76
@ X21_REG
Callee-saved.
Definition abi_arm64_common.h:75
@ X16_REG
Intra-Procedure-call scratch register (IP0) / Volatile. May be modified by the linker.
Definition abi_arm64_common.h:70
@ SP_REG
Stack Pointer (SP). In some instructions, encoding 31 refers to the Zero Register (XZR/WZR).
Definition abi_arm64_common.h:85
@ X15_REG
Volatile scratch register.
Definition abi_arm64_common.h:69
@ X29_FP_REG
Frame Pointer (FP) / Callee-saved.
Definition abi_arm64_common.h:83
@ X11_REG
Volatile scratch register.
Definition abi_arm64_common.h:65
@ X8_REG
Indirect Result Location Register (holds address for large struct returns) / Volatile.
Definition abi_arm64_common.h:62
@ X23_REG
Callee-saved.
Definition abi_arm64_common.h:77
@ X0_REG
Argument 1 / Return value / Volatile (caller-saved).
Definition abi_arm64_common.h:54
@ X6_REG
Argument 7 / Volatile.
Definition abi_arm64_common.h:60
@ X17_REG
Intra-Procedure-call scratch register (IP1) / Volatile. May be modified by the linker.
Definition abi_arm64_common.h:71
@ X3_REG
Argument 4 / Volatile.
Definition abi_arm64_common.h:57
@ X19_REG
Callee-saved. Must be preserved by a called function.
Definition abi_arm64_common.h:73
@ X30_LR_REG
Link Register (LR), holds the return address / Volatile across calls.
Definition abi_arm64_common.h:84
@ X18_REG
Platform Register (reserved, usage is platform-specific) / May be callee-saved. Best to avoid.
Definition abi_arm64_common.h:72
@ X5_REG
Argument 6 / Volatile.
Definition abi_arm64_common.h:59
@ X27_REG
Callee-saved.
Definition abi_arm64_common.h:81
@ X9_REG
Volatile (caller-saved) scratch register.
Definition abi_arm64_common.h:63
@ X2_REG
Argument 3 / Volatile.
Definition abi_arm64_common.h:56
@ X26_REG
Callee-saved.
Definition abi_arm64_common.h:80
@ X20_REG
Callee-saved.
Definition abi_arm64_common.h:74
@ X10_REG
Volatile scratch register.
Definition abi_arm64_common.h:64
arm64_vpr
Definition abi_arm64_common.h:97
@ V13_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:111
@ V23_REG
Volatile scratch register.
Definition abi_arm64_common.h:121
@ V10_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:108
@ V5_REG
Argument 6 / Volatile.
Definition abi_arm64_common.h:103
@ V12_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:110
@ V27_REG
Volatile scratch register.
Definition abi_arm64_common.h:125
@ V1_REG
Argument 2 / Volatile.
Definition abi_arm64_common.h:99
@ V0_REG
Argument 1 / Return value / Volatile (caller-saved).
Definition abi_arm64_common.h:98
@ V9_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:107
@ V7_REG
Argument 8 / Volatile.
Definition abi_arm64_common.h:105
@ V17_REG
Volatile scratch register.
Definition abi_arm64_common.h:115
@ V21_REG
Volatile scratch register.
Definition abi_arm64_common.h:119
@ V29_REG
Volatile scratch register.
Definition abi_arm64_common.h:127
@ V8_REG
Callee-saved (Note: only the lower 64 bits, D8-D15, must be preserved).
Definition abi_arm64_common.h:106
@ V18_REG
Volatile scratch register.
Definition abi_arm64_common.h:116
@ V19_REG
Volatile scratch register.
Definition abi_arm64_common.h:117
@ V30_REG
Volatile scratch register.
Definition abi_arm64_common.h:128
@ V28_REG
Volatile scratch register.
Definition abi_arm64_common.h:126
@ V26_REG
Volatile scratch register.
Definition abi_arm64_common.h:124
@ V25_REG
Volatile scratch register.
Definition abi_arm64_common.h:123
@ V31_REG
Volatile scratch register.
Definition abi_arm64_common.h:129
@ V6_REG
Argument 7 / Volatile.
Definition abi_arm64_common.h:104
@ V16_REG
Volatile (caller-saved) scratch register.
Definition abi_arm64_common.h:114
@ V15_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:113
@ V3_REG
Argument 4 / Volatile.
Definition abi_arm64_common.h:101
@ V2_REG
Argument 3 / Volatile.
Definition abi_arm64_common.h:100
@ V4_REG
Argument 5 / Volatile.
Definition abi_arm64_common.h:102
@ V24_REG
Volatile scratch register.
Definition abi_arm64_common.h:122
@ V11_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:109
@ V22_REG
Volatile scratch register.
Definition abi_arm64_common.h:120
@ V14_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:112
@ V20_REG
Volatile scratch register.
Definition abi_arm64_common.h:118