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
39#include <stdint.h>
163// Common bitfields
164#define A64_SF_64BIT (1U << 31) // 'sf' (size field) bit for 64-bit operations
165#define A64_SF_32BIT (0U << 31) // 'sf' bit for 32-bit operations
166#define A64_V_VECTOR (1U << 26) // Vector bit for SIMD/FP instructions
167// Data Processing -- Immediate (e.g., ADD, SUB)
168#define A64_OPC_ADD (0b00U << 29)
169#define A64_OPC_ADDS (0b01U << 29)
170#define A64_OPC_SUB (0b10U << 29)
171#define A64_OPC_SUBS (0b11U << 29)
172#define A64_OP_ADD_SUB_IMM (0b0010001U << 24)
173// Data Processing -- Register (e.g., ADD, ORR)
174#define A64_OP_ADD_SUB_REG (0b01011U << 24)
175#define A64_OP_LOGICAL_REG (0b01010U << 24)
176#define A64_OPCODE_ORR (0b01U << 29)
177// Move Wide (MOVZ, MOVK)
178#define A64_OPC_MOVZ (0b10U << 29)
179#define A64_OPC_MOVK (0b11U << 29)
180#define A64_OP_MOVE_WIDE_IMM (0b100101U << 23)
181// Load/Store -- Immediate Unsigned Offset
182#define A64_OP_LOAD_STORE_IMM_UNSIGNED (0b111001U << 24)
183#define A64_LDR_OP (1U << 22)
184#define A64_OP_LOAD_STORE_PAIR_BASE (0b101000U << 24) // Base for all LDP/STP variants
185#define A64_OPC_STP (0b00U << 30) // opc field for Store Pair
186#define A64_OPC_LDP (0b01U << 30) // opc field for Load Pair
187#define A64_L_BIT_LOAD (1U << 22) // The 'L' bit distinguishes Load (1) from Store (0)
188// Addressing modes for LDP/STP
189#define A64_ADDR_POST_INDEX (0b01U << 23) // [Xn], #imm
190#define A64_ADDR_PRE_INDEX (0b11U << 23) // [Xn, #imm]!
191#define A64_ADDR_SIGNED_OFFSET (0b10U << 23) // [Xn, #imm]
192// Branching
193#define A64_OP_BRANCH_REG (0b1101011U << 25)
194#define A64_OPC_BR (0b0000U << 21)
195#define A64_OPC_BLR (0b0001U << 21)
196#define A64_OPC_RET (0b0010U << 21)
197#define A64_OP_COMPARE_BRANCH_IMM (0b011010U << 25)
198#define A64_OPC_CBNZ (1U << 24)
199// System
200#define A64_OP_SYSTEM (0b11010100U << 25)
201#define A64_OP_BRK (0b00000000001U << 16)
202#define A64_OP_SVC (0b00000000001U << 21)
// end aarch64_opcodes
arm64_gpr
Definition abi_arm64_common.h:51
@ X1_REG
Argument 2 / Volatile.
Definition abi_arm64_common.h:53
@ X13_REG
Volatile scratch register.
Definition abi_arm64_common.h:65
@ X24_REG
Callee-saved.
Definition abi_arm64_common.h:76
@ X14_REG
Volatile scratch register.
Definition abi_arm64_common.h:66
@ X12_REG
Volatile scratch register.
Definition abi_arm64_common.h:64
@ X28_REG
Callee-saved.
Definition abi_arm64_common.h:80
@ X25_REG
Callee-saved.
Definition abi_arm64_common.h:77
@ X7_REG
Argument 8 / Volatile.
Definition abi_arm64_common.h:59
@ X4_REG
Argument 5 / Volatile.
Definition abi_arm64_common.h:56
@ X22_REG
Callee-saved.
Definition abi_arm64_common.h:74
@ X21_REG
Callee-saved.
Definition abi_arm64_common.h:73
@ X16_REG
Intra-Procedure-call scratch register (IP0) / Volatile. May be modified by the linker.
Definition abi_arm64_common.h:68
@ SP_REG
Stack Pointer (SP). In some instructions, encoding 31 refers to the Zero Register (XZR/WZR).
Definition abi_arm64_common.h:83
@ X15_REG
Volatile scratch register.
Definition abi_arm64_common.h:67
@ X29_FP_REG
Frame Pointer (FP) / Callee-saved.
Definition abi_arm64_common.h:81
@ X11_REG
Volatile scratch register.
Definition abi_arm64_common.h:63
@ X8_REG
Indirect Result Location Register (holds address for large struct returns) / Volatile.
Definition abi_arm64_common.h:60
@ X23_REG
Callee-saved.
Definition abi_arm64_common.h:75
@ X0_REG
Argument 1 / Return value / Volatile (caller-saved).
Definition abi_arm64_common.h:52
@ X6_REG
Argument 7 / Volatile.
Definition abi_arm64_common.h:58
@ X17_REG
Intra-Procedure-call scratch register (IP1) / Volatile. May be modified by the linker.
Definition abi_arm64_common.h:69
@ X3_REG
Argument 4 / Volatile.
Definition abi_arm64_common.h:55
@ X19_REG
Callee-saved. Must be preserved by a called function.
Definition abi_arm64_common.h:71
@ X30_LR_REG
Link Register (LR), holds the return address / Volatile across calls.
Definition abi_arm64_common.h:82
@ X18_REG
Platform Register (reserved, usage is platform-specific) / May be callee-saved. Best to avoid.
Definition abi_arm64_common.h:70
@ X5_REG
Argument 6 / Volatile.
Definition abi_arm64_common.h:57
@ X27_REG
Callee-saved.
Definition abi_arm64_common.h:79
@ X9_REG
Volatile (caller-saved) scratch register.
Definition abi_arm64_common.h:61
@ X2_REG
Argument 3 / Volatile.
Definition abi_arm64_common.h:54
@ X26_REG
Callee-saved.
Definition abi_arm64_common.h:78
@ X20_REG
Callee-saved.
Definition abi_arm64_common.h:72
@ X10_REG
Volatile scratch register.
Definition abi_arm64_common.h:62
arm64_vpr
Definition abi_arm64_common.h:94
@ V13_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:108
@ V23_REG
Volatile scratch register.
Definition abi_arm64_common.h:118
@ V10_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:105
@ V5_REG
Argument 6 / Volatile.
Definition abi_arm64_common.h:100
@ V12_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:107
@ V27_REG
Volatile scratch register.
Definition abi_arm64_common.h:122
@ V1_REG
Argument 2 / Volatile.
Definition abi_arm64_common.h:96
@ V0_REG
Argument 1 / Return value / Volatile (caller-saved).
Definition abi_arm64_common.h:95
@ V9_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:104
@ V7_REG
Argument 8 / Volatile.
Definition abi_arm64_common.h:102
@ V17_REG
Volatile scratch register.
Definition abi_arm64_common.h:112
@ V21_REG
Volatile scratch register.
Definition abi_arm64_common.h:116
@ V29_REG
Volatile scratch register.
Definition abi_arm64_common.h:124
@ V8_REG
Callee-saved (Note: only the lower 64 bits, D8-D15, must be preserved).
Definition abi_arm64_common.h:103
@ V18_REG
Volatile scratch register.
Definition abi_arm64_common.h:113
@ V19_REG
Volatile scratch register.
Definition abi_arm64_common.h:114
@ V30_REG
Volatile scratch register.
Definition abi_arm64_common.h:125
@ V28_REG
Volatile scratch register.
Definition abi_arm64_common.h:123
@ V26_REG
Volatile scratch register.
Definition abi_arm64_common.h:121
@ V25_REG
Volatile scratch register.
Definition abi_arm64_common.h:120
@ V31_REG
Volatile scratch register.
Definition abi_arm64_common.h:126
@ V6_REG
Argument 7 / Volatile.
Definition abi_arm64_common.h:101
@ V16_REG
Volatile (caller-saved) scratch register.
Definition abi_arm64_common.h:111
@ V15_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:110
@ V3_REG
Argument 4 / Volatile.
Definition abi_arm64_common.h:98
@ V2_REG
Argument 3 / Volatile.
Definition abi_arm64_common.h:97
@ V4_REG
Argument 5 / Volatile.
Definition abi_arm64_common.h:99
@ V24_REG
Volatile scratch register.
Definition abi_arm64_common.h:119
@ V11_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:106
@ V22_REG
Volatile scratch register.
Definition abi_arm64_common.h:117
@ V14_REG
Callee-saved (only lower 64 bits).
Definition abi_arm64_common.h:109
@ V20_REG
Volatile scratch register.
Definition abi_arm64_common.h:115
arm64_cond
Definition abi_arm64_common.h:133
@ A64_COND_CC
Carry Clear (Lower, unsigned)
Definition abi_arm64_common.h:138
@ A64_COND_HI
Higher (Unsigned)
Definition abi_arm64_common.h:144
@ A64_COND_HS
Definition abi_arm64_common.h:137
@ A64_COND_VC
No Overflow.
Definition abi_arm64_common.h:143
@ A64_COND_LT
Less Than (Signed)
Definition abi_arm64_common.h:147
@ A64_COND_LO
Definition abi_arm64_common.h:139
@ A64_COND_GE
Greater or Equal (Signed)
Definition abi_arm64_common.h:146
@ A64_COND_LS
Lower or Same (Unsigned)
Definition abi_arm64_common.h:145
@ A64_COND_MI
Minus (Negative)
Definition abi_arm64_common.h:140
@ A64_COND_VS
Overflow.
Definition abi_arm64_common.h:142
@ A64_COND_LE
Less Than or Equal (Signed)
Definition abi_arm64_common.h:149
@ A64_COND_CS
Carry Set (Higher or Same, unsigned)
Definition abi_arm64_common.h:136
@ A64_COND_NE
Not Equal.
Definition abi_arm64_common.h:135
@ A64_COND_AL
Always.
Definition abi_arm64_common.h:150
@ A64_COND_PL
Plus (Positive or Zero)
Definition abi_arm64_common.h:141
@ A64_COND_EQ
Equal.
Definition abi_arm64_common.h:134
@ A64_COND_GT
Greater Than (Signed)
Definition abi_arm64_common.h:148