selfpatch-slr/patchcompile/accumulation.h

55 lines
1.1 KiB
C++

#pragma once
#include <string>
#include <cstddef>
#include <unordered_map>
#include <map>
#include <list>
#include <optional>
#include <cstdint>
#include <vector>
struct IPIN {
std::string symbol;
std::size_t local_target;
std::size_t field_offset;
std::size_t imm_size;
};
struct DPIN {
struct COMPONENT {
std::size_t offset;
std::size_t level;
std::size_t target; // local pin -> local target
};
std::string symbol;
std::list<COMPONENT> components;
};
struct FIELD {
std::size_t offset;
std::size_t size;
std::size_t alignment;
std::size_t flags;
std::size_t idx;
};
struct TARGET {
std::string name;
std::size_t size;
std::map<std::size_t, FIELD> fields;
};
struct CU {
std::unordered_map<std::size_t, std::size_t> local_targets;
std::unordered_map<std::string, IPIN> ipins;
std::unordered_map<std::string, DPIN> dpins;
};
extern std::unordered_map<std::size_t, TARGET> targets;
extern std::unordered_map<std::string, CU> units;
bool accumulate(const std::vector<std::string>& spslr_files, bool no_new_targets);
bool dump_target_map(const std::string& path);
bool load_target_map(const std::string& path);