Skip to content

v.gen.x64 #

Register type for type safety

fn Gen.new #

fn Gen.new(m &ssa.Module) &Gen

new creates an x86-64 generator for an SSA module without runtime optimizations.

fn Gen.new_with_options #

fn Gen.new_with_options(m &ssa.Module, opts GenOptions) &Gen

new_with_options creates an x86-64 generator with explicit optimization options.

struct Gen #

struct Gen {
	m &ssa.Module
mut:
	elf              &elf.ElfObject
	optimize_runtime bool

	stack_map      map[int]int
	alloca_offsets map[int]int
	stack_size     int
	curr_offset    int

	block_offsets  map[int]int
	pending_labels map[int][]int

	// Register allocation
	reg_map         map[int]int
	used_regs       []int
	reg_use_counts  []int
	reg_use_stamps  []int
	reg_seen_stamps []int
	reg_stamp       int

	cur_func_ret_type         int
	cur_func_abi_ret_indirect bool
	cur_func_param_indirect   []bool
	sret_save_offset          int
}

fn (Gen) validate_c_extern_calls #

fn (g &Gen) validate_c_extern_calls() !

validate_c_extern_calls rejects C calling conventions that this backend cannot yet lower.

fn (Gen) gen #

fn (mut g Gen) gen()

gen emits all functions, data, and relocations for the module.

fn (Gen) write_file #

fn (mut g Gen) write_file(path string)

write_file writes the generated ELF64 relocatable object to path.

struct GenOptions #

struct GenOptions {
pub:
	optimize_runtime bool
}

GenOptions controls optional x64 code-generation optimizations.