mirror of
https://github.com/open-goal/jak-project
synced 2026-05-23 15:02:01 -04:00
64bcd8c030
This PR does the following: - Designs a mechanism by which arm64 instructions can be encoded and emitted - Dispatch our higher-level instruction emitting calls to either x86 or arm64 instructions depending on what the compiler is set to (defaults to x86) - Bare minimum scaffolding to get the arm64 instructions successfully executing atleast on apple silicon - Implement enough instructions to get the codetester test suite passing on arm
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
/*!
|
|
* @file CodeGenerator.h
|
|
* Generate object files from a FileEnv using an emitter::ObjectGenerator.
|
|
* Populates a DebugInfo.
|
|
* Currently owns the logic for emitting the function prologues.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "Env.h"
|
|
|
|
#include "common/versions/versions.h"
|
|
|
|
#include "goalc/emitter/ObjectGenerator.h"
|
|
|
|
class DebugInfo;
|
|
class TypeSystem;
|
|
|
|
class CodeGenerator {
|
|
public:
|
|
CodeGenerator(FileEnv* env,
|
|
DebugInfo* debug_info,
|
|
GameVersion version,
|
|
emitter::InstructionSet instruction_set);
|
|
std::vector<u8> run(const TypeSystem* ts);
|
|
emitter::ObjectGeneratorStats get_obj_stats() const { return m_gen.get_stats(); }
|
|
|
|
private:
|
|
void do_function(FunctionEnv* env, int f_idx);
|
|
void do_goal_function_x86(FunctionEnv* env, int f_idx);
|
|
void do_goal_function_arm64(FunctionEnv* env, int f_idx);
|
|
void do_asm_function_x86(FunctionEnv* env, int f_idx, bool allow_saved_regs);
|
|
void do_asm_function_arm64(FunctionEnv* env, int f_idx, bool allow_saved_regs);
|
|
emitter::ObjectGenerator m_gen;
|
|
FileEnv* m_fe = nullptr;
|
|
DebugInfo* m_debug_info = nullptr;
|
|
};
|