#pragma once #include #include #include "BasicBlock.h" namespace evmcc { class Compiler { public: using ProgramCounter = uint64_t; Compiler(); std::unique_ptr compile(const dev::bytes& bytecode); private: void createBasicBlocks(const dev::bytes& bytecode); void linkBasicBlocks(); /** * Maps a program counter pc to a basic block which starts at pc (if any). */ std::map basicBlocks; /** * Maps a pc at which there is a JUMP or JUMPI to the target block of the jump. */ std::map m_directJumpTargets; /** * A list of possible blocks to which there may be indirect jumps. */ std::vector m_indirectJumpTargets; /// Collection of basic blocks in program //std::vector m_basicBlocks; /** * Final block for normal (non-exceptional) execution. */ std::unique_ptr m_finalBlock; /** * Default destination for indirect jumps. */ std::unique_ptr m_badJumpBlock; /// Main program function llvm::Function* m_mainFunc = nullptr; }; }