mirror of
https://github.com/open-goal/jak-project
synced 2026-06-15 06:31:22 -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
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <variant>
|
|
#include <vector>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "goalc/emitter/Instruction.h"
|
|
|
|
class FunctionEnv;
|
|
|
|
namespace goos {
|
|
class Reader;
|
|
class Object;
|
|
class HeapObject;
|
|
} // namespace goos
|
|
|
|
struct InstructionInfo {
|
|
emitter::Instruction instruction;
|
|
enum class Kind { PROLOGUE, IR, EPILOGUE } kind;
|
|
int ir_idx = -1;
|
|
int offset = -1;
|
|
|
|
InstructionInfo(const emitter::Instruction& _instruction, Kind _kind)
|
|
: instruction(_instruction), kind(_kind) {}
|
|
InstructionInfo(const emitter::Instruction& _instruction, Kind _kind, int _ir_idx)
|
|
: instruction(_instruction), kind(_kind), ir_idx(_ir_idx) {}
|
|
};
|
|
|
|
std::string disassemble_x86(u8* data, int len, u64 base_addr);
|
|
std::string disassemble_x86(u8* data, int len, u64 base_addr, u64 highlight_addr);
|
|
|
|
std::string disassemble_x86_function(
|
|
u8* data,
|
|
int len,
|
|
const goos::Reader* reader,
|
|
u64 base_addr,
|
|
u64 highlight_addr,
|
|
const std::vector<InstructionInfo>& x86_instructions,
|
|
const std::vector<std::shared_ptr<goos::HeapObject>>& code_sources,
|
|
const std::vector<std::string>& ir_strings,
|
|
bool* had_failure,
|
|
bool print_whole_function,
|
|
bool omit_ir);
|
|
|
|
// TODO ARM64 - disassemble arm64 functions as well
|