92 start_(0, space), entry_(0, space), umach_(NULL), finalized_(
false),
93 instructionPerAddress_(true) {
117 start_(start), entry_(0, space), umach_(NULL), finalized_(
false),
118 instructionPerAddress_(true) {
135 start_(start), entry_(entry), umach_(NULL), finalized_(
false),
136 instructionPerAddress_(true) {
219 "There are no procedures in the program.");
236 "There are no procedures in the program.");
254 "The procedure given in parameter doesn't "
255 "belong to this program.");
359 "There is no instructions in the program.");
378 if ((*iter)->startAddress().location() <= address &&
379 (*iter)->endAddress().location() > address) {
380 return (*iter)->instructionAt(address);
386 "No instruction at address: " +
409 "Instruction in parameter doesn't belong to this program.");
425 if ((*iter)->startAddress().location() <= insAddress &&
426 (*iter)->endAddress().location() > insAddress) {
429 if ((*iter)->hasNextInstruction(ins)) {
430 return (*iter)->nextInstruction(ins);
437 if ((*iter)->instructionCount() != 0) {
438 return (*iter)->instructionAt(
439 (*iter)->startAddress().location());
469 "There is no instructions in the program.");
481 if (number < 0 || number >=
static_cast<int>(
moves_.size())) {
482 throw KeyNotFound(__FILE__, __LINE__, __FUNCTION__,
485 return *
moves_.at(number);
495 return static_cast<int>(
moves_.size());
528 "Procedure is already in program.");
558 "No procedures in the program.");
562 for (
int i = 0; i < ins->
moveCount(); ++i) {
571 "Instruction already belongs to a procedure.");
591 for (index = 0; index <
procedures_.size(); index++) {
624 static_cast<unsigned int>(index) <
procedures_.size()) {
629 "There is no procedure by index: " +
657 if ((*i)->name() == name) {
665 "No procedure found with name: " +
676 if ((*i)->name() == name) {
749 newProc->
add(newIns);
782 for (
int i = 0; i < ins.
moveCount(); i++) {
871 newDef = currDef.
copy();
902 if (&proc.
parent() !=
this) {
905 "Procedure doesn't belong to this program.");
924 for (ProcList::iterator iter =
procedures_.begin();
927 if ((*iter) == &proc) {
969 static_cast<unsigned int>(index) <
dataMems_.size()) {
974 "There is no data memory with index: " +
996 "No data memory found by address space name: " +
1029 for (
int i = 0; i < ins.
moveCount(); i++) {
1044 "There should be less than two data memories. Number of memories: " +
1069 "There should be less than two data memories. Number of memories: " +
1092 __FILE__, __LINE__,
__func__,
"Loading TPEF failed.");
1121 __FILE__, __LINE__,
__func__,
"Loading TPEF failed.");
1150 __FILE__, __LINE__,
__func__,
"Loading TPEF failed.");
1171 std::ofstream outputFile(
1172 tpefFileName.c_str(),
1173 std::ios_base::out|std::ios_base::trunc|std::ios_base::binary);
1198 for (std::size_t p = 0; p <
procedures_.size(); ++p) {
1202 instructions.push_back(instr);
1205 return instructions;
1229 if (procName ==
"_end") {
1232 if (dl.
name() ==
"_end") {
1243 "_end not found in program!");
1247 + procName +
TCEString(
"' not found!"));
1269 for (
int k = 0; k < ins.
moveCount(); k++) {
1347 if (instructions.size() == 0)
return;
1357 instructions[0]->setFinalAddress(previousAddress);
1358 instructions[0]->setSize(currentSize);
1364 if (currentSize != 1)
1365 newInstructionPerAddress =
false;
1367 for (
size_t i = 1; i < instructions.size(); ++i) {
1373 previousAddress = newAddress;
1374 if (currentSize != 1)
1375 newInstructionPerAddress =
false;
#define abortWithError(message)
#define assert(condition)
UInt32 InstructionAddress
find Finds info of the inner loops in the program
find Finds info of the inner loops in the false
static std::string toString(const T &source)
static POMDisassembler * disassembler(const TTAMachine::Machine &mach, const TTAProgram::Program &program)
static std::string disassemble(const TTAProgram::Move &move)
virtual size_t instructionSize(const TTAProgram::Instruction &)
Returns the size of the instruction in memory addresses, if known. Falls back to address per instruct...
static Binary * readBinary(BinaryStream &stream)
void writeBinary(BinaryStream &stream, const Binary *bin) const
static const BinaryWriter & instance()
virtual Machine * machine() const
virtual TCEString name() const
virtual AddressSpace * addressSpace() const
virtual ControlUnit * controlUnit() const
const TTAMachine::AddressSpace & space() const
InstructionAddress location() const
virtual Instruction & nextInstruction(const Instruction &ins) const
virtual void setParent(Program &prog)
virtual Address endAddress() const
virtual Instruction & firstInstruction() const
virtual bool isInProgram() const
virtual int instructionCount() const
virtual void setStartAddress(Address start)
virtual Program & parent() const
virtual Address startAddress() const
virtual Instruction & lastInstruction() const
virtual void setEndAddress(Address end)
virtual Instruction & instructionAtIndex(int index) const
virtual Address startAddress() const
virtual bool isAddress() const
virtual Address destinationAddress() const
virtual bool isInstructionAddress() const
virtual void setDestinationAddress(Address dest)
virtual DataDefinition * copy() const
void setAddressSpace(const TTAMachine::AddressSpace &space)
void addDataDefinition(DataDefinition *dataDef)
DataDefinition & dataDefinition(Address address) const
int dataDefinitionCount() const
const TTAMachine::AddressSpace & addressSpace() const
virtual void setDataLabelAddressSpace(const TTAMachine::AddressSpace &space)
const DataLabel & globalDataLabel(Address address, int index) const
virtual Scope * copyAndRelocate(const TTAProgram::Program &program) const
virtual void removeCodeLabels(InstructionAddress address)
int globalDataLabelCount(Address address) const
InstructionReference createReference(Instruction &ins)
Instruction & instruction() const
Instruction * copy() const
int immediateCount() const
Immediate & immediate(int i) const
void setFinalAddress(InstructionAddress addr)
CodeSnippet & parent() const
bool isInProcedure() const
virtual Address address() const
void setSource(Terminal *src)
Terminal & source() const
static NullInstruction & instance()
static NullProcedure & instance()
static NullProgram & instance()
void add(Instruction *ins)
CodeSnippet * copy() const
TPEF::Binary * createBinary() const
std::vector< Instruction * > InstructionVector
Vector for instructions.
static Program * loadFromTPEF(const std::string &tpefFileName, const TTAMachine::Machine &theMachine)
GlobalScope & globalScope()
Procedure & procedure(int index) const
Program(const TTAMachine::AddressSpace &space)
static void writeToTPEF(const TTAProgram::Program &program, const std::string &tpefFileName)
Instruction & nextInstruction(const Instruction &) const
Instruction & firstInstruction() const
ProcList::const_iterator ProcIter
Iterator for the procedure list.
TerminalImmediate * convertSymbolRef(Terminal &tsr)
bool hasProcedure(const std::string &name) const
ProcList procedures_
The procedures in the program.
bool finalized_
True in case the program is not (and must not be) updated anymore and it has its final instruction ad...
GlobalScope * globalScope_
Global scope of the program.
void moveProcedure(Procedure &proc, int howMuch)
TCEString toString() const
InstructionReferenceManager * refManager_
Keeps book of all instruction to instruction (jumps and calls) references in the program.
void fixInstructionReferences()
const Move & moveAt(int number) const
Address entryAddress() const
Instruction & lastInstruction() const
const Procedure & procedureAtIndex(int index) const
void replaceUniversalAddressSpaces(const TTAMachine::AddressSpace &space)
Procedure & operator[](size_t index)
Address startAddress() const
MoveList moves_
List of all the moves of the program.
void copyDataMemoriesFrom(const Program &srcProg)
Program & operator=(const Program &old)
const GlobalScope & globalScopeConst() const
TTAMachine::Machine & targetProcessor() const
void setEntryAddress(Address address)
DataMemory & dataMemory(int index) const
void removeProcedure(Procedure &proc)
Procedure & nextProcedure(const Procedure &proc) const
void addDataMemory(DataMemory *dataMem)
void addProcedure(Procedure *proc)
Instruction & instructionAt(InstructionAddress address) const
bool instructionPerAddress_
True in case the program is instruction indexed, that is, each instruction is assumed to be in a sing...
int procedureCount() const
void addInstruction(Instruction *ins)
InstructionReferenceManager & instructionReferenceManager() const
UniversalMachine & universalMachine() const
void setStartAddress(Address start)
Address entry_
The entry address of the program.
int instructionCount() const
static Program * loadFromUnscheduledTPEF(const std::string &tpefFileName, const TTAMachine::Machine &theMachine)
void link(const TTAProgram::Program &other)
DataMemList dataMems_
The data memories in the program.
void convertSymbolRefsToInsRefs(bool ignoreUnfoundSymbols=false)
InstructionVector instructionVector() const
Procedure & lastProcedure() const
void copyFrom(const Program &source)
Procedure & firstProcedure() const
int dataMemoryCount() const
Address start_
The start address of the program.
virtual SimValue value() const
virtual bool isAddress() const
virtual bool isCodeSymbolReference() const
virtual const InstructionReference & instructionReference() const
virtual void setInstructionReference(InstructionReference ref)
virtual bool isInstructionAddress() const
virtual TCEString toString() const =0
static UniversalMachine & instance()