jak-project/decompiler/Disasm/InstructionParser.h
water111 2b6684aa5c
[decompiler] Working toward bsp (#717)
* clean up

* before int to float stuff

* before trying to eliminate the separate read and write maps

* partial fix for register issues

* add missing include
2021-07-25 15:30:37 -04:00

31 lines
918 B
C++

/*!
* The InstructionParser converts a string like "daddu a0, s7, r0" into an Instruction.
* It is used to generate test sequences of instructions for decompiler algorithms.
*/
#pragma once
#include <string>
#include <unordered_map>
#include "Instruction.h"
#include "DecompilerLabel.h"
namespace decompiler {
struct ParsedProgram {
std::vector<DecompilerLabel> labels;
std::vector<Instruction> instructions;
std::string print();
};
class InstructionParser {
public:
InstructionParser();
Instruction parse_single_instruction(std::string str, const std::vector<DecompilerLabel>& labels);
ParsedProgram parse_program(const std::string& str,
const std::vector<std::string>& predefined_labels = {});
private:
std::unordered_map<std::string, int> m_opcode_name_lookup;
std::unordered_map<std::string, int> m_opcode_name_broadcast_lookup;
};
} // namespace decompiler