Affix

 view release on metacpan or  search on metacpan

infix/src/arch/x64/abi_x64_emitters.c  view on Meta::CPAN

#include <assert.h>
#include <string.h>
// Helper defines for REX prefix bits, making the code more readable.
#define REX_W (1 << 3)  // 64-bit operand size
#define REX_R (1 << 2)  // Extends ModR/M 'reg' field
#define REX_X (1 << 1)  // Extends SIB 'index' field
#define REX_B (1 << 0)  // Extends ModR/M 'r/m' or SIB 'base' field

/**
 * @internal
 * @brief Emits `endbr64` (Terminate Indirect Branch 64-bit) for Intel IBT / CET.
 * @details Opcode: F3 0F 1E FA
 */
INFIX_INTERNAL void emit_endbr64(code_buffer * buf) {
    EMIT_BYTES(buf, 0xF3, 0x0F, 0x1E, 0xFA);
}

// Instruction Encoding Helpers
/*
 * @internal
 * @brief Emits an x86-64 REX prefix byte.

infix/src/arch/x64/abi_x64_emitters.h  view on Meta::CPAN

 * This header provides the function prototypes for all low-level x86-64
 * instruction emitters. These functions are the fundamental building blocks
 * used by both the Windows x64 and System V x64 ABI implementations to generate
 * machine code. Each function corresponds to a specific machine instruction
 * or a common addressing mode, encapsulating the complexities of x86-64 encoding.
 * @endinternal
 */
#include "arch/x64/abi_x64_common.h"
#include "common/infix_internals.h"

/** @internal @brief Emits `endbr64` (terminate indirect branch) for Intel IBT / CET. */
INFIX_INTERNAL void emit_endbr64(code_buffer * buf);

// GPR <-> Immediate Value Emitters
/** @internal @brief Emits `mov r64, imm64` to load a 64-bit immediate value into a register. */
INFIX_INTERNAL void emit_mov_reg_imm64(code_buffer * buf, x64_gpr reg, uint64_t value);
/** @internal @brief Emits `mov r64, imm32` (sign-extended) to load a 32-bit immediate into a register. */
INFIX_INTERNAL void emit_mov_reg_imm32(code_buffer * buf, x64_gpr reg, int32_t imm);

// GPR <-> GPR Move Emitters
/** @internal @brief Emits `mov r64, r64` for a register-to-register move. */



( run in 2.857 seconds using v1.01-cache-2.11-cpan-1bcd28dbaf1 )