Commit Graph

5 Commits

Author SHA1 Message Date
Benjamin Oldenburg
c15dff2e5a feat(arm64): add more opcode constants for load/store and shift instructions 2026-04-04 20:02:33 +07:00
Benjamin Oldenburg
926f4a3cb8 feat(arm64): add more opcode constants for code generator
Add additional ARM64 instruction opcode constants needed by arm64-gen.c:
- ARM64_FMOV_*: Floating-point move variants
- ARM64_STR_Q_PRE/LDR_Q_POST: Quadword load/store with pre/post increment
- ARM64_LDPSW: Load pair of words with sign-extend
- ARM64_LDR_S_SIMD: SIMD load (distinct from scalar LDR_S)
- ARM64_MOV_V_D: Move vector to double
- ARM64_FCMP: Floating-point compare
- ARM64_SDIV: Signed divide
- ARM64_MUL: Multiply

These constants will be used in the next commit to refactor arm64-gen.c.
2026-04-04 20:02:33 +07:00
Benjamin Oldenburg
99d2daeb47 refactor(arm64): use symbolic opcode constants consistently
Replace hardcoded magic numbers with symbolic constants for ARM64
instruction opcodes, matching the style used in x86_64 backend.

Changes:
- arm64-tok.h: Add 93 new opcode constants and helper macros
  - Instruction opcodes: ARM64_ADD_IMM, ARM64_LDR_X, ARM64_B, etc.
  - Helper macros: ARM64_RD(), ARM64_RN(), ARM64_IMM12(), etc.
  - Field encodings: ARM64_SF(), ARM64_S(), ARM64_SH(), etc.

- arm64-asm.c: Refactor all instruction generation functions
  - gen_movz/gen_movn/gen_movk: Use ARM64_MOVZ/MOVN/MOVK
  - gen_add_imm/gen_sub_imm: Use ARM64_ADD_IMM/SUB_IMM
  - gen_dp_reg: Use symbolic opcodes
  - gen_ldst_imm/gen_ldst_pair: Use ARM64_LDR_*/STR_*
  - gen_b/gen_bl/gen_br/gen_blr/gen_ret: Use ARM64_B/BL/BR/BLR/RET
  - gen_cbz/gen_cbnz: Use ARM64_CBZ/CBNZ
  - gen_shift: Use ARM64_LSL_REG/LSR_REG/ASR_REG/ROR_REG
  - gen_barrier: Use ARM64_ISB/DSB/DMB
  - gen_mrs/gen_msr: Use symbolic constants
  - Inline asm save/restore: Use ARM64_STP_X/LDP_X

- arm64-gen.c: Begin systematic refactoring (first batch)
  - arm64_sub_sp: Use ARM64_SUB_IMM with helper macros

Benefits:
- Readability: Self-documenting code (ARM64_LDR_X vs 0xF9400000)
- Maintainability: Easier to spot encoding errors
- Consistency: Matches x86_64 backend style
- Safety: Helper macros prevent bit-shift mistakes

All tests pass with no functional changes.
2026-04-04 20:02:33 +07:00
Benjamin Oldenburg
0decb1b86f arm64: support mnemonic win32 stack helpers 2026-04-04 20:02:32 +07:00
Benjamin Oldenburg
4f4b3dda6b Add and stabilize Windows ARM64 support 2026-04-04 20:02:31 +07:00