#pragma once #ifndef JAK_ALLOCATOR_H #define JAK_ALLOCATOR_H #include #include "IRegSet.h" #include #include "IRegister.h" #include "allocate.h" struct RegAllocBasicBlock { std::vector instr_idx; std::vector succ; std::vector pred; std::vector live, dead; IRegSet use, defs, input, output; bool is_entry = false; bool is_exit = false; int idx = -1; void analyze_liveliness_phase1(const std::vector& instructions); bool analyze_liveliness_phase2(std::vector& blocks, const std::vector& instructions); void analyze_liveliness_phase3(std::vector& blocks, const std::vector& instructions); std::string print(const std::vector& insts); std::string print_summary(); }; struct RegAllocCache { std::vector basic_blocks; std::vector live_ranges; int max_var = -1; std::vector was_colored; std::vector iregs; std::vector stack_ops; std::unordered_map var_to_stack_slot; int current_stack_slot = 0; bool used_stack = false; bool is_asm_func = false; std::vector> live_ranges_by_instr; }; void find_basic_blocks(RegAllocCache* cache, const AllocationInput& in); void analyze_liveliness(RegAllocCache* cache, const AllocationInput& in); void do_constrained_alloc(RegAllocCache* cache, const AllocationInput& in, bool trace_debug); bool check_constrained_alloc(RegAllocCache* cache, const AllocationInput& in); bool run_allocator(RegAllocCache* cache, const AllocationInput& in, int debug_trace); #endif // JAK_ALLOCATOR_H