13#ifndef ETISS_INCLUDE_CODEPART_H_
14#define ETISS_INCLUDE_CODEPART_H_
24#include "etiss/jit/types.h"
47 inline RegisterPart(
const std::string &
name,
unsigned registerWidth, etiss::uintMax
bits = (uintMax)((intMax)-1))
51 for (
unsigned i = 0; i <
regWidth; i++)
53 mask |= ((uintMax)1) << i;
59 this->name = cpy.
name;
70 if (this->name != rp.
name)
75 std::cout <<
"Serve Warning: RegisterPart definitions exist with same name (=same register) but different "
76 "register width values"
88 if (this->name != rp.
name)
93 std::cout <<
"Serve Warning: RegisterPart definitions exist with same name (=same register) but different "
94 "register width values"
140 std::cout <<
"Serve Warning: RegisterPart definitions exist with same name (=same register) but different "
141 "register width values"
188 std::set<RegisterPart, lex_compare>::iterator iter =
set_.find(rp);
189 if (iter !=
set_.end())
205 inline void add(
const std::string &name,
unsigned registerWidth, etiss::uintMax bits = (uintMax)((intMax)-1))
214 std::set<RegisterPart, lex_compare>::iterator iter =
set_.begin();
215 std::set<RegisterPart, lex_compare>::const_iterator oiter;
216 while (iter !=
set_.end())
218 oiter = rs.
set_.find(*iter);
219 if (oiter != rs.
set_.end())
221 iter->applyShadow(*oiter);
243 std::set<RegisterPart, lex_compare>::const_iterator iter = rs.
set_.begin();
244 while (iter != rs.
set_.end())
255 std::set<RegisterPart, lex_compare>::iterator iter =
set_.begin();
256 while (iter !=
set_.end())
258 std::set<RegisterPart, lex_compare>::const_iterator f = rs.
set_.find(*iter);
259 if (f != rs.
set_.end())
282 std::set<RegisterPart, lex_compare>::const_iterator iter =
set_.begin();
283 while (iter !=
set_.end())
285 std::set<RegisterPart, lex_compare>::const_iterator f = rs.
set_.find(*iter);
286 if (f != rs.
set_.end())
299 std::set<RegisterPart, lex_compare>::const_iterator iter =
set_.begin();
300 while (iter !=
set_.end())
302 std::set<RegisterPart, lex_compare>::const_iterator oiter = rs.
set_.find(*iter);
303 if (oiter != rs.
set_.end())
305 if (!iter->maskedBy(*oiter))
325 std::stringstream ss;
326 std::set<RegisterPart, lex_compare>::const_iterator iter =
set_.begin();
327 while (iter !=
set_.end())
329 ss << iter->getName() <<
": " << std::hex << iter->getAffectedBits() <<
"\n";
336 std::set<RegisterPart, lex_compare>
set_;
379 inline const std::string &
code()
const {
return code_; }
459 std::cout <<
"ERROR: etiss::CodePart::append called with invalid etiss::CodePart::TYPE parameter"
488 std::cout <<
"ERROR: etiss::CodePart::prepend called with invalid etiss::CodePart::TYPE parameter"
568 void toCode(std::stringstream &out,
const std::string &funcname, std::set<std::string> *fileglobalcode);
general configuration and logging
equivalent of a translated instruction
const etiss::uint64 & getAddress()
void toCode(std::stringstream &out, const std::string &funcname, std::set< std::string > *fileglobalcode)
Line & get(unsigned index)
std::set< std::string > functionglobal_code
std::vector< Line > lines_
std::set< std::string > & functionglobalCode()
etiss::uint64 endaddress_
CodeBlock(etiss::uint64 startindex)
std::set< std::string > & fileglobalCode()
etiss::uint64 startindex_
Line & append(etiss::uint64 addr)
std::set< std::string > fileglobal_code
Contains a small code snipped.
const std::string & code() const
TYPE
defines position,optionality and the ability to return a code for a CodePart.
@ APPENDEDRETURNINGREQUIRED
@ PREINITIALDEBUGRETURNING
const bool & fullRegistersDependency() const
CodePart(const std::string &code, const RegisterSet ®isterDependencies=RegisterSet(), const RegisterSet &affectedRegisters=RegisterSet())
RegisterSet & getRegisterDependencies()
const RegisterSet & getRegisterDependencies() const
const RegisterSet & getAffectedRegisters() const
RegisterSet & getAffectedRegisters()
RegisterSet registerDependencies_
const std::string & getCode() const
RegisterSet affectedRegisters_
CodePart & append(CodePart::TYPE type)
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_
CodeSet(const CodeSet &cs)
std::list< CodePart > inireq_parts_
void append(const CodePart &part, CodePart::TYPE type)
static void writeCodeParts(std::string &code, const std::list< CodePart > &parts, bool required, RegisterSet &ignored, bool intersect)
CodePart & prepend(CodePart::TYPE type)
std::list< CodePart > appopt_parts_
abstract description of needed or affected register bits.
void intersect(const RegisterPart &rp) const
this is not a const function in the usual sense.
RegisterPart(const RegisterPart &cpy)
const unsigned & getRegisterWidth() const
bool contains(const RegisterPart &rp) const
check if passed RegisterPart is a subset of relevant bits of the same register
const std::string & getName() const
const etiss::uintMax & getAffectedBits() const
bool matches(const RegisterPart &rp) const
check for equality
void applyShadow(const RegisterPart &rp) const
this is not a const function in the usual sense.
void merge(const RegisterPart &rp) const
this is not a const function in the usual sense.
RegisterPart(const std::string &name, unsigned registerWidth, etiss::uintMax bits=(uintMax)((intMax) -1))
bool isEmpty() const
true if unnamed or no relevant bits
bool operator<(const RegisterPart &other) const
bool maskedBy(const RegisterPart &rp) const
bool operator==(const RegisterPart &other) const
same as matches(const RegisterPart & other)
void add(const std::string &name, unsigned registerWidth, etiss::uintMax bits=(uintMax)((intMax) -1))
bool disjoint(const RegisterSet &rs) const
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 ...
std::set< RegisterPart, lex_compare > set_
bool maskedBy(const RegisterSet &rs) const
void add(const RegisterPart &rp)
add a registerPart to the set or just its relevant bits if a register with the same name is already p...
RegisterSet(const RegisterSet &rs)
void intersect(const RegisterSet &rs)
only register bits set in this AND the passed RegisterSet remain set in this RegisterSet
std::string _dbg_print() const
writes a human readable string listing all set bit of every register in this RegisterSet
special comparison function that only takes register name into account.
bool operator()(const RegisterPart &lhs, const RegisterPart &rhs) const