Go to the documentation of this file.
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;
void setAddressSpace(const TTAMachine::AddressSpace &space)
Instruction & instruction() const
void addProcedure(Procedure *proc)
Instruction & firstInstruction() const
UInt32 InstructionAddress
Procedure & operator[](size_t index)
virtual Instruction & firstInstruction() const
void addInstruction(Instruction *ins)
virtual void setParent(Program &prog)
virtual TCEString name() const
virtual bool isInstructionAddress() const
int procedureCount() const
virtual Address startAddress() const
Procedure & firstProcedure() const
Address entryAddress() const
Address startAddress() const
virtual bool isAddress() const
void writeBinary(BinaryStream &stream, const Binary *bin) const
virtual void setEndAddress(Address end)
Instruction & nextInstruction(const Instruction &) const
static NullProcedure & instance()
const TTAMachine::AddressSpace & addressSpace() const
bool finalized_
True in case the program is not (and must not be) updated anymore and it has its final instruction ad...
virtual bool isAddress() const
virtual Scope * copyAndRelocate(const TTAProgram::Program &program) const
bool instructionPerAddress_
True in case the program is instruction indexed, that is, each instruction is assumed to be in a sing...
InstructionReference createReference(Instruction &ins)
const TTAMachine::AddressSpace & space() const
static UniversalMachine & instance()
int dataDefinitionCount() const
static POMDisassembler * disassembler(const TTAMachine::Machine &mach, const TTAProgram::Program &program)
const Move & moveAt(int number) const
virtual Instruction & nextInstruction(const Instruction &ins) const
virtual AddressSpace * addressSpace() const
virtual Address startAddress() const
DataMemList dataMems_
The data memories in the program.
virtual void setStartAddress(Address start)
virtual const InstructionReference & instructionReference() const
CodeSnippet * copy() const
const DataLabel & globalDataLabel(Address address, int index) const
static std::string toString(const T &source)
std::vector< Instruction * > InstructionVector
Vector for instructions.
InstructionReferenceManager * refManager_
Keeps book of all instruction to instruction (jumps and calls) references in the program.
const Procedure & procedureAtIndex(int index) const
bool hasProcedure(const std::string &name) const
const GlobalScope & globalScopeConst() const
static NullProgram & instance()
#define assert(condition)
Instruction & instructionAt(InstructionAddress address) const
void addDataMemory(DataMemory *dataMem)
Procedure & nextProcedure(const Procedure &proc) const
virtual ControlUnit * controlUnit() const
#define abortWithError(message)
void setEntryAddress(Address address)
void moveProcedure(Procedure &proc, int howMuch)
void addDataDefinition(DataDefinition *dataDef)
virtual int instructionCount() const
virtual void setDataLabelAddressSpace(const TTAMachine::AddressSpace &space)
virtual Address destinationAddress() const
void link(const TTAProgram::Program &other)
Instruction * copy() const
DataMemory & dataMemory(int index) const
CodeSnippet & parent() const
virtual void setDestinationAddress(Address dest)
virtual Instruction & lastInstruction() const
static const BinaryWriter & instance()
virtual SimValue value() const
int globalDataLabelCount(Address address) const
InstructionAddress location() const
void copyDataMemoriesFrom(const Program &srcProg)
static NullInstruction & instance()
virtual Address address() const
Program(const TTAMachine::AddressSpace &space)
UniversalMachine & universalMachine() const
Immediate & immediate(int i) const
Program & operator=(const Program &old)
virtual void removeCodeLabels(InstructionAddress address)
int dataMemoryCount() const
TCEString toString() const
MoveList moves_
List of all the moves of the program.
int instructionCount() const
void setStartAddress(Address start)
bool isInProcedure() const
static std::string disassemble(const TTAProgram::Move &move)
void add(Instruction *ins)
InstructionReferenceManager & instructionReferenceManager() const
ProcList procedures_
The procedures in the program.
virtual TCEString toString() const =0
find Finds info of the inner loops in the false
virtual Machine * machine() const
void replaceUniversalAddressSpaces(const TTAMachine::AddressSpace &space)
virtual Program & parent() const
int immediateCount() const
static void writeToTPEF(const TTAProgram::Program &program, const std::string &tpefFileName)
DataDefinition & dataDefinition(Address address) const
Address entry_
The entry address of the program.
TTAMachine::Machine & targetProcessor() const
static Program * loadFromTPEF(const std::string &tpefFileName, const TTAMachine::Machine &theMachine)
TerminalImmediate * convertSymbolRef(Terminal &tsr)
virtual Address endAddress() const
virtual Instruction & instructionAtIndex(int index) const
Terminal & source() const
GlobalScope * globalScope_
Global scope of the program.
find Finds info of the inner loops in the program
virtual bool isCodeSymbolReference() const
Instruction & lastInstruction() const
virtual void setInstructionReference(InstructionReference ref)
Procedure & lastProcedure() const
GlobalScope & globalScope()
virtual size_t instructionSize(const TTAProgram::Instruction &)
Returns the size of the instruction in memory addresses, if known. Falls back to address per instruct...
void fixInstructionReferences()
void removeProcedure(Procedure &proc)
ProcList::const_iterator ProcIter
Iterator for the procedure list.
void setFinalAddress(InstructionAddress addr)
TPEF::Binary * createBinary() const
void copyFrom(const Program &source)
Address start_
The start address of the program.
virtual DataDefinition * copy() const
InstructionVector instructionVector() const
Procedure & procedure(int index) const
virtual bool isInstructionAddress() const
static Program * loadFromUnscheduledTPEF(const std::string &tpefFileName, const TTAMachine::Machine &theMachine)
void convertSymbolRefsToInsRefs(bool ignoreUnfoundSymbols=false)
static Binary * readBinary(BinaryStream &stream)
void setSource(Terminal *src)
virtual bool isInProgram() const