55 using namespace etiss;
61 std::list<CodePart>::const_iterator iter = parts.begin();
62 while (iter != parts.end())
67 if (iter->fullRegistersDependency())
75 ignored.
intersect(iter->getAffectedRegisters());
79 ignored.
merge(iter->getAffectedRegisters());
81 ignored.
applyShadow(iter->getRegisterDependencies());
83 code = iter->getCode() +
"\n" + code;
88 if (!iter->getAffectedRegisters().maskedBy(ignored))
91 if (iter->fullRegistersDependency())
99 ignored.
intersect(iter->getAffectedRegisters());
103 ignored.
merge(iter->getAffectedRegisters());
105 ignored.
applyShadow(iter->getRegisterDependencies());
108 code = iter->getCode() +
"\n" + code;
146 void CodeBlock::toCode(std::stringstream &out,
const std::string &funcname, std::set<std::string> *fileglobalcode)
153 if (fileglobalcode->find(*iter) == fileglobalcode->end())
156 fileglobalcode->insert(*iter);
168 out <<
"etiss_uint32 " << funcname
169 <<
"(ETISS_CPU * const cpu, ETISS_System * const system, void * const * const plugin_pointers) {\n"
170 " const etiss_uint64 blockglobal_startaddr = 0x"
173 " const etiss_uint64 blockglobal_jumpaddr = cpu->instructionPointer - blockglobal_startaddr;\n";
180 out <<
"\n\tswitch(blockglobal_jumpaddr){\n";
181 std::list<std::string> cases;
188 for (
auto iter =
lines_.rbegin(); iter !=
lines_.rend(); iter++)
191 if (last > iter->getAddress())
197 std::stringstream lss;
198 lss <<
" case " << (iter->getAddress() -
startindex_) <<
":\n";
200 lss << iter->getCodeSet().toString(ignored, ok);
202 cases.push_front(lss.str());
205 for (
auto iter = cases.begin(); iter != cases.end(); iter++)
207 out <<
"\n\t break;\n"
209 "\t\treturn ETISS_RETURNCODE_ILLEGALJUMP;\n"
211 "\treturn ETISS_RETURNCODE_NOERROR;\n"
classes to hold code and additional information used for optimization of instruction translations
void toCode(std::stringstream &out, const std::string &funcname, std::set< std::string > *fileglobalcode)
std::set< std::string > functionglobal_code
std::vector< Line > lines_
etiss::uint64 startindex_
std::set< std::string > fileglobal_code
std::string toString(RegisterSet &ignored, bool &ok) const
writes the contained CodeParts as needed with respect to the given RegisterSet of bits that are not r...
std::list< CodePart > appretreq_parts_
std::list< CodePart > midopt_parts_
std::list< CodePart > pindbgretreq_parts_
std::list< CodePart > appreq_parts_
std::list< CodePart > inireq_parts_
static void writeCodeParts(std::string &code, const std::list< CodePart > &parts, bool required, RegisterSet &ignored, bool intersect)
std::list< CodePart > appopt_parts_
void applyShadow(const RegisterSet &rs)
any register bits set in the passed RegisterSet won't be set in this RegisterSet
void merge(const RegisterSet &rs)
any register bits set in the passed RegisterSet will be set in this RegisterSet (plus previously set ...
void intersect(const RegisterSet &rs)
only register bits set in this AND the passed RegisterSet remain set in this RegisterSet
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
void log(Verbosity level, std::string msg)
write log message at the given level.