OpenASIP  2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
TTAProgram::Program Class Reference

#include <Program.hh>

Inheritance diagram for TTAProgram::Program:
Inheritance graph
Collaboration diagram for TTAProgram::Program:
Collaboration graph

Public Types

typedef std::vector< Instruction * > InstructionVector
 Vector for instructions. More...
 

Public Member Functions

 Program (const TTAMachine::AddressSpace &space)
 
 Program (const TTAMachine::AddressSpace &space, Address start)
 
 Program (const TTAMachine::AddressSpace &space, Address start, Address entry)
 
virtual ~Program ()
 
GlobalScopeglobalScope ()
 
const GlobalScopeglobalScopeConst () const
 
TTAMachine::MachinetargetProcessor () const
 
UniversalMachineuniversalMachine () const
 
void setUniversalMachine (UniversalMachine *umach)
 
Address startAddress () const
 
void setStartAddress (Address start)
 
Address entryAddress () const
 
void setEntryAddress (Address address)
 
void addProcedure (Procedure *proc)
 
void addInstruction (Instruction *ins)
 
void moveProcedure (Procedure &proc, int howMuch)
 
ProcedurefirstProcedure () const
 
ProcedurelastProcedure () const
 
ProcedurenextProcedure (const Procedure &proc) const
 
int procedureCount () const
 
Procedureprocedure (int index) const
 
Procedureoperator[] (size_t index)
 
Procedureprocedure (const std::string &name) const
 
bool hasProcedure (const std::string &name) const
 
InstructionfirstInstruction () const
 
InstructioninstructionAt (InstructionAddress address) const
 
int instructionCount () const
 
const MovemoveAt (int number) const
 
int moveCount () const
 
const ProcedureprocedureAtIndex (int index) const
 
InstructionnextInstruction (const Instruction &) const
 
InstructionlastInstruction () const
 
InstructionReferenceManagerinstructionReferenceManager () const
 
Programoperator= (const Program &old)
 
Programcopy () const
 
void removeProcedure (Procedure &proc)
 
int dataMemoryCount () const
 
DataMemorydataMemory (int index) const
 
DataMemorydataMemory (const std::string &aSpaceName) const
 
void addDataMemory (DataMemory *dataMem)
 
void replaceUniversalAddressSpaces (const TTAMachine::AddressSpace &space)
 
InstructionVector instructionVector () const
 
void link (const TTAProgram::Program &other)
 
void convertSymbolRefsToInsRefs (bool ignoreUnfoundSymbols=false)
 
void fixInstructionReferences ()
 
TCEString toString () const
 
void finalize ()
 
bool isFinalized () const
 
bool isInstructionPerAddress () const
 

Static Public Member Functions

static ProgramloadFromUnscheduledTPEF (const std::string &tpefFileName, const TTAMachine::Machine &theMachine)
 
static ProgramloadFromTPEF (const std::string &tpefFileName, const TTAMachine::Machine &theMachine)
 
static ProgramloadFromUnscheduledTPEF (const std::string &tpefFileName)
 
static void writeToTPEF (const TTAProgram::Program &program, const std::string &tpefFileName)
 

Private Types

typedef std::vector< Procedure * > ProcList
 List for procedures. More...
 
typedef ProcList::const_iterator ProcIter
 Iterator for the procedure list. More...
 
typedef std::vector< DataMemory * > DataMemList
 List for data memories. More...
 
typedef std::vector< Move * > MoveList
 List for moves. More...
 

Private Member Functions

 Program (const Program &)
 Copying not allowed. More...
 
void copyDataMemoriesFrom (const Program &srcProg)
 
void copyCodeLabelsFrom (const Program &srcProg)
 
void copyDataLabelsFrom (const Program &srcProg)
 
void copyFrom (const Program &source)
 
void cleanup ()
 
TerminalImmediateconvertSymbolRef (Terminal &tsr)
 

Private Attributes

GlobalScopeglobalScope_
 Global scope of the program. More...
 
ProcList procedures_
 The procedures in the program. More...
 
DataMemList dataMems_
 The data memories in the program. More...
 
MoveList moves_
 List of all the moves of the program. More...
 
Address start_
 The start address of the program. More...
 
Address entry_
 The entry address of the program. More...
 
InstructionReferenceManagerrefManager_
 Keeps book of all instruction to instruction (jumps and calls) references in the program. More...
 
UniversalMachineumach_
 The UniversalMachine instance used to refer to in case of the unscheduled/unassigned parts of the program. More...
 
bool finalized_
 True in case the program is not (and must not be) updated anymore and it has its final instruction addresses computed. More...
 
bool instructionPerAddress_
 True in case the program is instruction indexed, that is, each instruction is assumed to be in a single instruction memory location. More...
 

Detailed Description

Represents a TTA program.

Definition at line 63 of file Program.hh.

Member Typedef Documentation

◆ DataMemList

typedef std::vector<DataMemory*> TTAProgram::Program::DataMemList
private

List for data memories.

Definition at line 158 of file Program.hh.

◆ InstructionVector

Vector for instructions.

Definition at line 66 of file Program.hh.

◆ MoveList

typedef std::vector<Move*> TTAProgram::Program::MoveList
private

List for moves.

Definition at line 160 of file Program.hh.

◆ ProcIter

typedef ProcList::const_iterator TTAProgram::Program::ProcIter
private

Iterator for the procedure list.

Definition at line 156 of file Program.hh.

◆ ProcList

typedef std::vector<Procedure*> TTAProgram::Program::ProcList
private

List for procedures.

Definition at line 154 of file Program.hh.

Constructor & Destructor Documentation

◆ Program() [1/4]

TTAProgram::Program::Program ( const TTAMachine::AddressSpace space)

Constructor.

Creates an empty program in given address space. A default value zero is used for start and entry addresses. Automatically creates an empty global scope to store all program symbols with external linkage.

Parameters
spaceThe address space of the program.

Definition at line 91 of file Program.cc.

91  :
92  start_(0, space), entry_(0, space), umach_(NULL), finalized_(false),
94  globalScope_ = new GlobalScope();
95  refManager_ = new InstructionReferenceManager();
96 }

References globalScope_, and refManager_.

Referenced by copy().

◆ Program() [2/4]

TTAProgram::Program::Program ( const TTAMachine::AddressSpace space,
Address  start 
)

Constructor.

Alternative constructor that takes the start address as a parameter.

Parameters
spaceThe address space of the program.
startThe start address of the program.

Definition at line 116 of file Program.cc.

116  :
117  start_(start), entry_(0, space), umach_(NULL), finalized_(false),
118  instructionPerAddress_(true) {
119  globalScope_ = new GlobalScope();
120  refManager_ = new InstructionReferenceManager();
121 }

References globalScope_, and refManager_.

◆ Program() [3/4]

TTAProgram::Program::Program ( const TTAMachine::AddressSpace space,
Address  start,
Address  entry 
)

Constructor.

Alternative constructor that takes the start and entry addresses as parameters.

Parameters
spaceThe address space of the program.
startThe start address of the program.
entryThe entry address of the program.

Definition at line 133 of file Program.cc.

134  :
135  start_(start), entry_(entry), umach_(NULL), finalized_(false),
136  instructionPerAddress_(true) {
137  globalScope_ = new GlobalScope();
138  refManager_ = new InstructionReferenceManager();
139 }

References globalScope_, and refManager_.

◆ ~Program()

TTAProgram::Program::~Program ( )
virtual

The destructor.

Definition at line 144 of file Program.cc.

144  {
145  cleanup();
146  delete globalScope_;
147  globalScope_ = NULL;
148  delete refManager_;
149  refManager_ = NULL;
150  // NOTE: we cannot delete universal machine anymore because after linking
151  // the Program to another Program, the new Program refers to the,
152  // TODO: make UniversalMachine a singleton and start hiding it from APIs.
153  // delete umach_;
154  // umach_ = NULL;
155 }

References cleanup(), globalScope_, and refManager_.

Here is the call graph for this function:

◆ Program() [4/4]

TTAProgram::Program::Program ( const Program )
private

Copying not allowed.

Member Function Documentation

◆ addDataMemory()

void TTAProgram::Program::addDataMemory ( DataMemory dataMem)

Insert the given data memory to the program.

Parameters
dataMemThe data memory to be inserted.
Exceptions
IllegalRegistrationMemory with the same address space is found from the program.

Definition at line 954 of file Program.cc.

954  {
955  // TODO: check that there is no another data mem with same address space...
956  dataMems_.push_back(dataMem);
957 }

References dataMems_.

Referenced by copyDataMemoriesFrom(), TTAProgram::TPEFProgramFactory::createDataMemories(), and llvm::LLVMTCEBuilder::doFinalization().

◆ addInstruction()

void TTAProgram::Program::addInstruction ( Instruction ins)

Insert the given instruction as the instruction of the last procedure of the program.

The ownership of the instruction will be passed to the procedure in which the instruction is inserted.

Parameters
insThe instruction to be inserted.
Exceptions
IllegalRegistrationif the instruction belongs to a procedure or there are no procedures in the program.

Definition at line 554 of file Program.cc.

554  {
555  if (procedures_.empty()) {
556  throw IllegalRegistration(
557  __FILE__, __LINE__, __func__,
558  "No procedures in the program.");
559  }
560 
561  // add all moves of an instruction to the move list
562  for (int i = 0; i < ins->moveCount(); ++i) {
563  moves_.push_back(&ins->move(i));
564  }
565 
566  if (!ins->isInProcedure()) {
567  procedures_.back()->add(ins);
568  } else {
569  throw IllegalRegistration(
570  __FILE__, __LINE__, __func__,
571  "Instruction already belongs to a procedure.");
572  }
573 }

References __func__, TTAProgram::Instruction::isInProcedure(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), moves_, and procedures_.

Here is the call graph for this function:

◆ addProcedure()

void TTAProgram::Program::addProcedure ( Procedure proc)

Insert the given procedure as the last procedure of the program.

The ownership of the procedure will be passed to the program. Labels must be added explicitely by client because only it knows the scope where to add the labels.

Parameters
procThe procedure to be inserted.
Exceptions
IllegalRegistrationif the procedure belongs to another program.

Definition at line 524 of file Program.cc.

524  {
525  if (proc->isInProgram()) {
526  throw IllegalRegistration(
527  __FILE__, __LINE__, __func__,
528  "Procedure is already in program.");
529  } else {
530 
531  proc->setParent(*this);
532  if (!procedures_.empty()) {
533  proc->setStartAddress(procedures_.back()->endAddress());
534  } else {
535  proc->setStartAddress(start_);
536  }
537 
538  procedures_.push_back(proc);
539  }
540 }

References __func__, TTAProgram::CodeSnippet::isInProgram(), procedures_, TTAProgram::CodeSnippet::setParent(), TTAProgram::CodeSnippet::setStartAddress(), and start_.

Referenced by copyFrom(), ProgramDependenceGraph::disassemble(), link(), ProgrammabilityValidator::ProgrammabilityValidator(), llvm::LLVMTCEIRBuilder::writeMachineFunction(), and llvm::LLVMTCEBuilder::writeMachineFunction().

Here is the call graph for this function:

◆ cleanup()

void TTAProgram::Program::cleanup ( )
private

Cleans up the program to a state it was at the construction.

Definition at line 161 of file Program.cc.

161  {
162 
165 
166  delete globalScope_;
167  globalScope_ = NULL;
168  delete refManager_;
169  refManager_ = NULL;
170  globalScope_ = new GlobalScope();
171  refManager_ = new InstructionReferenceManager();
172 }

References dataMems_, SequenceTools::deleteAllItems(), globalScope_, procedures_, and refManager_.

Referenced by copyFrom(), and ~Program().

Here is the call graph for this function:

◆ convertSymbolRef()

TerminalImmediate * TTAProgram::Program::convertSymbolRef ( Terminal tsr)
private

Converts single TerminalSymbolReference into InstructionReference to the symbol or TerminalImmediate into the data label.

@TODO: Use CodeLabels instead of procedure?

Definition at line 1226 of file Program.cc.

1226  {
1227  TCEString procName = tsr.toString();
1228  if (!hasProcedure(procName)) {
1229  if (procName == "_end") {
1230  for (int i = 0; i < globalScope_->globalDataLabelCount(); i++) {
1231  const DataLabel& dl = globalScope_->globalDataLabel(i);
1232  if (dl.name() == "_end") {
1233  // we do not know if this is going to sing- or zero
1234  // extending immediate, lets be sure it fits and use
1235  // signed. zero extends broke sign-extending ADFs
1236  return new TTAProgram::TerminalImmediate(
1237  SimValue(
1238  dl.address().location(),
1239  MathTools::requiredBitsSigned(dl.address().location())));
1240  }
1241  }
1242  throw InstanceNotFound(__FILE__,__LINE__,__func__,
1243  "_end not found in program!");
1244  }
1245  throw InstanceNotFound(__FILE__,__LINE__,__func__,
1246  TCEString("procedure '")
1247  + procName + TCEString("' not found!"));
1248  }
1249  const Procedure& target = procedure(procName);
1250  assert(target.instructionCount() > 0);
1253  target.firstInstruction()));
1254 }

References __func__, TTAProgram::Label::address(), assert, TTAProgram::InstructionReferenceManager::createReference(), TTAProgram::CodeSnippet::firstInstruction(), TTAProgram::GlobalScope::globalDataLabel(), TTAProgram::GlobalScope::globalDataLabelCount(), globalScope_, hasProcedure(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Address::location(), TTAProgram::Label::name(), procedure(), refManager_, MathTools::requiredBitsSigned(), and TTAProgram::Terminal::toString().

Referenced by convertSymbolRefsToInsRefs().

Here is the call graph for this function:

◆ convertSymbolRefsToInsRefs()

void TTAProgram::Program::convertSymbolRefsToInsRefs ( bool  ignoreUnfoundSymbols = false)

Converts all TerminalSymbolReferences into InstructionReferences pointing to instructions or TerminalImmediates into data label.

Parameters
ignoreUnfoundSymbolsif set to true, just skips symbol references for which the symbol is not found. Otherwise throws in that case.

Definition at line 1264 of file Program.cc.

1264  {
1265  for (int i = 0; i < procedureCount();i++) {
1266  Procedure& proc = procedure(i);
1267  for (int j = 0; j < proc.instructionCount(); j++) {
1268  TTAProgram::Instruction& ins = proc.instructionAtIndex(j);
1269  for (int k = 0; k < ins.moveCount(); k++) {
1270  TTAProgram::Move& move = ins.move(k);
1271  TTAProgram::Terminal& src = move.source();
1272 
1273  if (src.isCodeSymbolReference()) {
1274 
1275  TCEString procName = src.toString();
1276  if (!hasProcedure(procName) && ignoreUnfoundSymbols)
1277  continue;
1278 
1279  move.setSource(convertSymbolRef(src));
1280  }
1281  }
1282  for (int k = 0; k < ins.immediateCount(); k++) {
1283  TTAProgram::Immediate& imm = ins.immediate(k);
1284  TTAProgram::Terminal& immVal = imm.value();
1285 
1286  if (immVal.isCodeSymbolReference()) {
1287 
1288  TCEString procName = immVal.toString();
1289  if (!hasProcedure(procName) && ignoreUnfoundSymbols)
1290  continue;
1291 
1292  imm.setValue(convertSymbolRef(immVal));
1293  }
1294  }
1295  }
1296  }
1297 }

References convertSymbolRef(), hasProcedure(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Terminal::isCodeSymbolReference(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), procedure(), procedureCount(), TTAProgram::Move::setSource(), TTAProgram::Immediate::setValue(), TTAProgram::Move::source(), TTAProgram::Terminal::toString(), and TTAProgram::Immediate::value().

Referenced by llvm::LLVMTCEIRBuilder::doFinalization(), llvm::LLVMTCEPOMBuilder::doFinalization(), and link().

Here is the call graph for this function:

◆ copy()

Program * TTAProgram::Program::copy ( ) const

Creates an exact copy of the program.

References to external object models will remain untouched.

Returns
An exact copy of the program.

Definition at line 714 of file Program.cc.

714  {
715 
716  Program* newProgram = new Program(
717  startAddress().space(), startAddress(), entryAddress());
718 
719  newProgram->copyFrom(*this);
720  return newProgram;
721 }

References copyFrom(), entryAddress(), Program(), and startAddress().

Here is the call graph for this function:

◆ copyCodeLabelsFrom()

void TTAProgram::Program::copyCodeLabelsFrom ( const Program srcProg)
private

◆ copyDataLabelsFrom()

void TTAProgram::Program::copyDataLabelsFrom ( const Program srcProg)
private

◆ copyDataMemoriesFrom()

void TTAProgram::Program::copyDataMemoriesFrom ( const Program srcProg)
private

Copy data memories from source program to destination and fixes data->code references to use InstructionReferenceManager of the instance.

Parameters
srcProgProgram from which data is copied.

Definition at line 845 of file Program.cc.

845  {
846 
847  // copy data memories
848  for (int i = 0; i < srcProg.dataMemoryCount(); i++) {
849  DataMemory& currMem = srcProg.dataMemory(i);
850 
851  DataMemory* newDataMem = new DataMemory(currMem.addressSpace());
852 
853  for (int j = 0; j < currMem.dataDefinitionCount(); j++) {
854  DataDefinition& currDef = currMem.dataDefinition(j);
855 
856  DataDefinition* newDef = NULL;
857 
858  if (currDef.isInstructionAddress()) {
859  Instruction& dstInstr = instructionAt(
860  currDef.destinationAddress().location());
861 
862  InstructionReference dstRef =
864  dstInstr);
865 
866  newDef = new DataInstructionAddressDef(
867  currDef.startAddress(), currDef.size(), dstRef,
868  targetProcessor().isLittleEndian());
869 
870  } else {
871  newDef = currDef.copy();
872  }
873 
874  newDataMem->addDataDefinition(newDef);
875  }
876 
877  addDataMemory(newDataMem);
878  }
879 }

References TTAProgram::DataMemory::addDataDefinition(), addDataMemory(), TTAProgram::DataMemory::addressSpace(), TTAProgram::DataDefinition::copy(), TTAProgram::InstructionReferenceManager::createReference(), TTAProgram::DataMemory::dataDefinition(), TTAProgram::DataMemory::dataDefinitionCount(), dataMemory(), dataMemoryCount(), TTAProgram::DataDefinition::destinationAddress(), instructionAt(), instructionReferenceManager(), TTAProgram::DataDefinition::isInstructionAddress(), TTAProgram::Address::location(), TTAProgram::DataDefinition::size(), TTAProgram::DataDefinition::startAddress(), and targetProcessor().

Referenced by copyFrom(), and link().

Here is the call graph for this function:

◆ copyFrom()

void TTAProgram::Program::copyFrom ( const Program source)
private

Copies data from another program to itself.

References to external object models will remain untouched. The old data is cleaned first. this->copyFrom(another) is equivalent to *this = another.

Returns
source The other program to copy from.

Definition at line 732 of file Program.cc.

732  {
733 
734  // cleanup the old data first
735  cleanup();
736 
737  for (int k = 0; k < source.procedureCount(); k++) {
738  Procedure& proc = source.procedure(k);
739  Procedure* newProc =
740  new Procedure(
741  proc.name(), proc.startAddress().space(),
742  proc.startAddress().location());
743  addProcedure(newProc);
744 
745  for (int j = 0; j < proc.instructionCount(); j++) {
746  Instruction &ins = proc.instructionAtIndex(j);
747 
748  Instruction* newIns = ins.copy();
749  newProc->add(newIns);
750  }
751  }
752 
754  copyDataMemoriesFrom(source);
755 
756  // set addresses
757  setStartAddress(source.startAddress());
758  setEntryAddress(source.entryAddress());
759 
760  delete globalScope_;
761  globalScope_ = dynamic_cast<GlobalScope*>(
762  source.globalScopeConst().copyAndRelocate(*this));
763 
764 }

References TTAProgram::Procedure::add(), addProcedure(), cleanup(), TTAProgram::Instruction::copy(), TTAProgram::GlobalScope::copyAndRelocate(), copyDataMemoriesFrom(), entryAddress(), fixInstructionReferences(), globalScope_, globalScopeConst(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Address::location(), TTAProgram::Procedure::name(), procedure(), procedureCount(), setEntryAddress(), setStartAddress(), TTAProgram::Address::space(), TTAProgram::CodeSnippet::startAddress(), and startAddress().

Referenced by copy(), and operator=().

Here is the call graph for this function:

◆ dataMemory() [1/2]

DataMemory & TTAProgram::Program::dataMemory ( const std::string &  aSpaceName) const

Returns the data memory with the given address space name.

Parameters
aSpaceNameThe address space name of the memory.
Returns
The data memory with given address space name.
Exceptions
KeyNotFoundif the data memory cannot be found.

Definition at line 987 of file Program.cc.

987  {
988  for (int i = 0; i < dataMemoryCount(); i++) {
989  if (dataMemory(i).addressSpace().name() == aSpaceName) {
990  return dataMemory(i);
991  }
992  }
993 
994  throw KeyNotFound(
995  __FILE__, __LINE__, __func__,
996  "No data memory found by address space name: " +
997  aSpaceName);
998 }

References __func__, TTAProgram::DataMemory::addressSpace(), dataMemory(), dataMemoryCount(), and TTAMachine::Component::name().

Here is the call graph for this function:

◆ dataMemory() [2/2]

DataMemory & TTAProgram::Program::dataMemory ( int  index) const

Returns the data memory at the given index.

Parameters
indexThe position index.
Returns
The data memory at the given index.
Exceptions
OutOfRangethe index is out of range.

Definition at line 967 of file Program.cc.

967  {
968  if (index >= 0 &&
969  static_cast<unsigned int>(index) < dataMems_.size()) {
970  return *dataMems_.at(index);
971  } else {
972  throw OutOfRange(
973  __FILE__, __LINE__, __func__,
974  "There is no data memory with index: " +
975  Conversion::toString(index));
976  }
977 }

References __func__, dataMems_, and Conversion::toString().

Referenced by ControlFlowGraph::computeLeadersFromRelocations(), copyDataMemoriesFrom(), TTAProgram::ProgramWriter::createDataSections(), dataMemory(), llvm::LLVMTCEBuilder::deleteDeadProcedures(), POMDisassembler::disassembleProgram(), SimulatorFrontend::initializeDataMemories(), and replaceUniversalAddressSpaces().

Here is the call graph for this function:

◆ dataMemoryCount()

int TTAProgram::Program::dataMemoryCount ( ) const

Returns the number of data memories accessed by the program.

Returns
The number of data memories accessed by the program.

Definition at line 942 of file Program.cc.

942  {
943  return dataMems_.size();
944 }

References dataMems_.

Referenced by ControlFlowGraph::computeLeadersFromRelocations(), copyDataMemoriesFrom(), TTAProgram::ProgramWriter::createDataSections(), dataMemory(), llvm::LLVMTCEBuilder::deleteDeadProcedures(), POMDisassembler::disassembleProgram(), SimulatorFrontend::initializeDataMemories(), and replaceUniversalAddressSpaces().

◆ entryAddress()

Address TTAProgram::Program::entryAddress ( ) const

Returns the address of the program entry point.

The entry point is not necessarily the instruction of the program with the lowest address.

Note
Preserving this value is not implemented in TPEFProgramFactory and ProgramWriter, however implementation of property is already specified in TPEF specs.
Returns
The address of the program entry point.

Definition at line 330 of file Program.cc.

330  {
331  return entry_;
332 }

References entry_.

Referenced by copy(), copyFrom(), and CompiledSimController::reset().

◆ finalize()

void TTAProgram::Program::finalize ( )

This should be called if the program has been fully constructed and won't get new instructions added anymore.

Computes and updates the final Instruction addresses with the best available accuracy. Before this method is called, instruction per address indexing is used, which is fast but might not reflect the final instruction addresses. After this method has been called, the user of the Program can also assume all the Instructions are attached to a Procedure and Procedures to the Program.

Definition at line 1343 of file Program.cc.

1343  {
1344 
1345  InstructionVector instructions = instructionVector();
1346 
1347  if (instructions.size() == 0) return;
1348 
1349  InstructionAddress previousAddress = startAddress().location();
1350 
1351  POMDisassembler* disasm =
1353 
1354  InstructionAddress currentSize =
1355  disasm->instructionSize(*instructions[0]);
1356 
1357  instructions[0]->setFinalAddress(previousAddress);
1358  instructions[0]->setSize(currentSize);
1359 
1360  bool newInstructionPerAddress = instructionPerAddress_;
1361  // From now on assume there's not an instruction per address layout.
1362  instructionPerAddress_ = false;
1363 
1364  if (currentSize != 1)
1365  newInstructionPerAddress = false;
1366 
1367  for (size_t i = 1; i < instructions.size(); ++i) {
1368  TTAProgram::Instruction* instr = instructions[i];
1369  currentSize = disasm->instructionSize(*instr);
1370  instr->setSize(currentSize);
1371  InstructionAddress newAddress = previousAddress + currentSize;
1372  instr->setFinalAddress(newAddress);
1373  previousAddress = newAddress;
1374  if (currentSize != 1)
1375  newInstructionPerAddress = false;
1376  }
1377 
1378  instructionPerAddress_ = newInstructionPerAddress;
1379 
1380  // Fix the procedure start and end addresses.
1381  ProcIter iter = procedures_.begin();
1382  while (iter != procedures_.end()) {
1383  Procedure& proc = **iter;
1384  proc.setStartAddress(proc.firstInstruction().address());
1385  // End address is the first address that doesn't store
1386  // instructions of the procedure.
1387  proc.setEndAddress(
1388  Address(proc.lastInstruction().address().location() +
1389  proc.lastInstruction().size(),
1390  proc.lastInstruction().address().space()));
1391  ++iter;
1392  }
1393 
1394  finalized_ = true;
1395  delete disasm;
1396 }

References TTAProgram::Instruction::address(), POMDisassembler::disassembler(), finalized_, TTAProgram::CodeSnippet::firstInstruction(), instructionPerAddress_, POMDisassembler::instructionSize(), instructionVector(), TTAProgram::CodeSnippet::lastInstruction(), TTAProgram::Address::location(), procedures_, TTAProgram::CodeSnippet::setEndAddress(), TTAProgram::Instruction::setFinalAddress(), TTAProgram::Instruction::setSize(), TTAProgram::CodeSnippet::setStartAddress(), TTAProgram::Instruction::size(), TTAProgram::Address::space(), startAddress(), and targetProcessor().

Referenced by SimulatorFrontend::loadProgram().

Here is the call graph for this function:

◆ firstInstruction()

Instruction & TTAProgram::Program::firstInstruction ( ) const

Returns the first instruction of the program.

Returns
The first instruction of the program.
Exceptions
InstanceNotFoundThere is no instructions in program.

Definition at line 353 of file Program.cc.

353  {
354  if (!procedures_.empty()) {
355  return firstProcedure().firstInstruction();
356  } else {
357  throw InstanceNotFound(
358  __FILE__, __LINE__, __func__,
359  "There is no instructions in the program.");
360  }
361 }

References __func__, TTAProgram::CodeSnippet::firstInstruction(), firstProcedure(), and procedures_.

Referenced by DEFAULT_Compressor::compress(), llvm::LLVMTCEBuilder::emitSPInitialization(), DisassemblyGridTable::GetNumberRows(), and CodeCompressorPlugin::initializeRelocations().

Here is the call graph for this function:

◆ firstProcedure()

Procedure & TTAProgram::Program::firstProcedure ( ) const

Returns the first procedure of the program.

Returns
The first procedure of the prgram.
Exceptions
InstanceNotFoundif there are no procedures.

Definition at line 213 of file Program.cc.

213  {
214  if (procedureCount() > 0) {
215  return *procedures_.at(0);
216  } else {
217  throw InstanceNotFound(
218  __FILE__, __LINE__, __func__,
219  "There are no procedures in the program.");
220  }
221 }

References __func__, procedureCount(), and procedures_.

Referenced by firstInstruction(), SimControlLanguageCommand::parseInstructionAddressExpression(), and setStartAddress().

Here is the call graph for this function:

◆ fixInstructionReferences()

void TTAProgram::Program::fixInstructionReferences ( )

Fix instruction references to point to the corresponding instructions of this Program.

This should be called after copying procedures from other programs to transform the instruction references to point to the current program instead of the old one.

Definition at line 775 of file Program.cc.

775  {
776  for (int k = 0; k < procedureCount(); k++) {
777  Procedure& proc = procedure(k);
778  for (int j = 0; j < proc.instructionCount(); j++) {
779  Instruction& ins = proc.instructionAtIndex(j);
780 
781  // sources of all moves.
782  for (int i = 0; i < ins.moveCount(); i++) {
783  Terminal& source = ins.move(i).source();
784 
785  if (source.isInstructionAddress()) {
786  Instruction& oldRefIns =
787  source.instructionReference().instruction();
788 
789  // Fix the reference via
790  // a procedure offset to not break references
791  // inside Procedures copied from another Program
792  InstructionAddress procStartAddr =
793  procedure(dynamic_cast<Procedure&>(oldRefIns.parent()).name()).
795 
796  Instruction& newRefIns =
798  procStartAddr +
799  oldRefIns.address().location() -
800  oldRefIns.parent().startAddress().location());
801 
802  InstructionReference newRef =
804  newRefIns);
805  source.setInstructionReference(newRef);
806  }
807  }
808  // values of all immediates
809  for (int i = 0; i < ins.immediateCount(); i++) {
810  Terminal& value = ins.immediate(i).value();
811  if (value.isInstructionAddress()) {
812 
813  Instruction& oldRefIns =
814  value.instructionReference().instruction();
815 
816 
817  InstructionAddress procStartAddr =
818  procedure(dynamic_cast<Procedure&>(oldRefIns.parent()).name()).
820 
821  Instruction& newRefIns =
823  procStartAddr +
824  oldRefIns.address().location() -
825  oldRefIns.parent().startAddress().location());
826 
827  InstructionReference newRef =
829  newRefIns);
830  value.setInstructionReference(newRef);
831  }
832  }
833  }
834  }
835 }

References TTAProgram::Instruction::address(), TTAProgram::InstructionReferenceManager::createReference(), TTAProgram::Instruction::immediate(), TTAProgram::Instruction::immediateCount(), TTAProgram::InstructionReference::instruction(), instructionAt(), TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Terminal::instructionReference(), instructionReferenceManager(), TTAProgram::Terminal::isInstructionAddress(), TTAProgram::Address::location(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), TTAProgram::Procedure::name(), TTAProgram::Instruction::parent(), procedure(), procedureCount(), TTAProgram::Terminal::setInstructionReference(), TTAProgram::Move::source(), TTAProgram::CodeSnippet::startAddress(), startAddress(), and TTAProgram::Immediate::value().

Referenced by copyFrom(), and link().

Here is the call graph for this function:

◆ globalScope()

GlobalScope & TTAProgram::Program::globalScope ( )

Returns the global scope of the program.

Returns
The global scope of the program.

Definition at line 180 of file Program.cc.

180  {
181  return *globalScope_;
182 }

References globalScope_.

Referenced by TTAProgram::CodeLabel::CodeLabel(), TTAProgram::TPEFProgramFactory::createLabels(), llvm::LLVMTCEBuilder::doFinalization(), llvm::LLVMTCEBuilder::initDataSections(), TTAProgram::Procedure::remove(), and llvm::LLVMTCEBuilder::writeMachineFunction().

◆ globalScopeConst()

const GlobalScope & TTAProgram::Program::globalScopeConst ( ) const

Returns the global scope of the program.

Const version.

Returns
The global scope of the program.

Definition at line 192 of file Program.cc.

192  {
193  return *globalScope_;
194 }

References globalScope_.

Referenced by copyFrom(), TTAProgram::ProgramWriter::createBinary(), SymbolAddressCommand::execute(), DisassemblyGridTable::loadProgram(), SimControlLanguageCommand::parseDataAddressExpression(), and SimControlLanguageCommand::parseInstructionAddressExpression().

◆ hasProcedure()

bool TTAProgram::Program::hasProcedure ( const std::string &  name) const

Returns true in case the program has a procedure with the given name.

Definition at line 673 of file Program.cc.

673  {
674  ProcList::const_iterator i = procedures_.begin();
675  while (i != procedures_.end()) {
676  if ((*i)->name() == name) {
677  return true;
678  }
679  ++i;
680  }
681  return false;
682 }

References procedures_.

Referenced by convertSymbolRef(), convertSymbolRefsToInsRefs(), and ControlFlowGraph::createBBEdges().

◆ instructionAt()

Instruction & TTAProgram::Program::instructionAt ( InstructionAddress  address) const

Returns the instruction at a given address.

The address space of the address is implied, since there is only one address space for instructions.

Parameters
addressThe address of the instruction.
Exceptions
KeyNotFoundif given address is illegal.
Returns
The instruction at the given address.

Definition at line 374 of file Program.cc.

374  {
375  for (ProcIter iter = procedures_.begin(); iter != procedures_.end();
376  iter++) {
377 
378  if ((*iter)->startAddress().location() <= address &&
379  (*iter)->endAddress().location() > address) {
380  return (*iter)->instructionAt(address);
381  }
382  }
383 
384  throw KeyNotFound(
385  __FILE__, __LINE__, __func__,
386  "No instruction at address: " +
387  Conversion::toString(address));
388 }

References __func__, procedures_, and Conversion::toString().

Referenced by ProximMachineStateWindow::addMoves(), SimulationStatistics::calculate(), SimulatorFrontend::compareState(), copyDataMemoriesFrom(), POMDisassembler::createInstruction(), SimulatorFrontend::currentProcedure(), SimulatorFrontend::disassembleInstruction(), CodeCompressorPlugin::encodeImmediateTerminal(), CodeCompressorPlugin::encodeLongImmediate(), BackTraceCommand::execute(), DisassembleCommand::execute(), fixInstructionReferences(), CompiledSimCodeGenerator::generateAddFUResult(), ProcedureTransferTracker::handleEvent(), RFAccessTracker::handleEvent(), SimulationController::next(), SimulatorFrontend::programLocationDescription(), ProximDebuggerWindow::updateAnnotations(), BasicBlockNode::updateReferencesFromProcToCfg(), and ProgramImageGenerator::writeDataSection().

Here is the call graph for this function:

◆ instructionCount()

int TTAProgram::Program::instructionCount ( ) const

Definition at line 1209 of file Program.cc.

1209  {
1210  if (procedureCount() == 0) {
1211  return 0;
1212  }
1213  return lastProcedure().startAddress().location() +
1215  start_.location();
1216 }

References TTAProgram::CodeSnippet::instructionCount(), lastProcedure(), TTAProgram::Address::location(), procedureCount(), start_, and TTAProgram::CodeSnippet::startAddress().

Referenced by TTAProgram::ProgramWriter::createBinary(), and ProgramImageGenerator::generateProgramImage().

Here is the call graph for this function:

◆ instructionReferenceManager()

InstructionReferenceManager & TTAProgram::Program::instructionReferenceManager ( ) const

◆ instructionVector()

Program::InstructionVector TTAProgram::Program::instructionVector ( ) const

Returns all Instructions in the program as random accessible vector.

The returned vector can be used for faster traversal of the program's instruction. It should be used instead of nextInstruction() or similar very slow methods when traversing through the whole program. Note that the Instruction* inside the vector should not be destroyed by the client as they are owned by the Program. The InstructionVector is not updated automatically as the Program changes!

Definition at line 1196 of file Program.cc.

1196  {
1197  InstructionVector instructions;
1198  for (std::size_t p = 0; p < procedures_.size(); ++p) {
1199  Procedure& proc = *procedures_.at(p);
1200  for (int i = 0; i < proc.instructionCount(); ++i) {
1201  Instruction* instr = &proc.instructionAtIndex(i);
1202  instructions.push_back(instr);
1203  }
1204  }
1205  return instructions;
1206 }

References TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), and procedures_.

Referenced by TTAProgram::TPEFProgramFactory::build(), finalize(), and ProgramImageGenerator::generateProgramImage().

Here is the call graph for this function:

◆ isFinalized()

bool TTAProgram::Program::isFinalized ( ) const
inline

Definition at line 149 of file Program.hh.

149 { return finalized_; }

References finalized_.

◆ isInstructionPerAddress()

bool TTAProgram::Program::isInstructionPerAddress ( ) const
inline

Definition at line 151 of file Program.hh.

151 { return instructionPerAddress_; }

References instructionPerAddress_.

◆ lastInstruction()

Instruction & TTAProgram::Program::lastInstruction ( ) const

Returns the last instruction of the program.

Returns
The last instruction of the program.
Exceptions
InstanceNotFoundThere is no instructions in the program.

Definition at line 463 of file Program.cc.

463  {
464  if (!procedures_.empty()) {
465  return lastProcedure().lastInstruction();
466  } else {
467  throw InstanceNotFound(
468  __FILE__, __LINE__, __func__,
469  "There is no instructions in the program.");
470  }
471 }

References __func__, TTAProgram::CodeSnippet::lastInstruction(), lastProcedure(), and procedures_.

Referenced by SimulatorFrontend::currentProcedure(), SimulatorFrontend::finishSimulation(), CompiledSimCodeGenerator::generateInstruction(), DisassemblyGridTable::GetNumberRows(), and CompiledSimController::reset().

Here is the call graph for this function:

◆ lastProcedure()

Procedure & TTAProgram::Program::lastProcedure ( ) const

Returns the last procedure of the program.

Returns
The last procedure of the prgram.
Exceptions
InstanceNotFoundif there are no procedures.

Definition at line 230 of file Program.cc.

230  {
231  if (procedureCount() > 0) {
232  return *procedures_.at(procedureCount() - 1);
233  } else {
234  throw InstanceNotFound(
235  __FILE__, __LINE__, __func__,
236  "There are no procedures in the program.");
237  }
238 }

References __func__, procedureCount(), and procedures_.

Referenced by TTAProgram::Procedure::add(), TTAProgram::Procedure::clear(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::copyToProcedure(), SimulatorFrontend::currentProcedure(), DisassembleCommand::execute(), TTAProgram::Procedure::insertAfter(), TTAProgram::Procedure::insertBefore(), instructionCount(), lastInstruction(), nextProcedure(), SimControlLanguageCommand::parseInstructionAddressExpression(), SimulatorFrontend::programLocationDescription(), TTAProgram::Procedure::remove(), and removeProcedure().

Here is the call graph for this function:

◆ link()

void TTAProgram::Program::link ( const TTAProgram::Program other)

Links the given Program with this one.

"Linking" here means copying all the procedures to this Program and fixing all fixable (external) symbol references. That is, in case either this or the other Program contained calls to external functions that are now found, the references are fixed to point to the actual Procedures.

Definition at line 1309 of file Program.cc.

1309  {
1310 
1311  if (other.procedureCount() == 0) return;
1312 
1313  for (int i = 0; i < other.procedureCount(); ++i) {
1314  addProcedure(dynamic_cast<Procedure*>(other.procedure(i).copy()));
1315  }
1316  copyDataMemoriesFrom(other);
1319 
1320  // todo merge GlobalScope (to retain labels)
1321 }

References addProcedure(), convertSymbolRefsToInsRefs(), TTAProgram::Procedure::copy(), copyDataMemoriesFrom(), fixInstructionReferences(), procedure(), and procedureCount().

Here is the call graph for this function:

◆ loadFromTPEF()

Program * TTAProgram::Program::loadFromTPEF ( const std::string &  tpefFileName,
const TTAMachine::Machine theMachine 
)
static

A shortcut for loading a scheduled program from a TPEF file.

Parameters
tpefFileNameThe file name of the TPEF.
theMachineThe target machine.
Returns
Created program.
Exceptions
Exceptionif the TPEF or program in it is somehow broken.

Definition at line 1112 of file Program.cc.

1113  {
1114  TPEF::BinaryStream binaryStream(tpefFileName);
1115 
1116  // read to TPEF Handler Module
1117  TPEF::Binary* tpef = TPEF::BinaryReader::readBinary(binaryStream);
1118 
1119  if (tpef == NULL) {
1120  throw IOException(
1121  __FILE__, __LINE__, __func__, "Loading TPEF failed.");
1122  }
1123 
1124  // convert the loaded TPEF to POM
1125  TTAProgram::TPEFProgramFactory factory(*tpef, theMachine);
1126  Program* prog = factory.build();
1127  delete tpef;
1128  tpef = NULL;
1129  return prog;
1130 }

References __func__, TTAProgram::TPEFProgramFactory::build(), and TPEF::BinaryReader::readBinary().

Referenced by SimpleICOptimizer::explore(), main(), and DesignSpaceExplorer::schedule().

Here is the call graph for this function:

◆ loadFromUnscheduledTPEF() [1/2]

Program * TTAProgram::Program::loadFromUnscheduledTPEF ( const std::string &  tpefFileName)
static

A shortcut for loading a sequential program (from the old gcc 2.7.0 frontend) from a TPEF file.

Parameters
tpefFileNameThe file name of the TPEF.
umachThe universal machine for the unscheduled parts.
Returns
Created program.
Exceptions
Exceptionif the TPEF or program in it is somehow broken.

Definition at line 1142 of file Program.cc.

1142  {
1143  TPEF::BinaryStream binaryStream(tpefFileName);
1144 
1145  // read to TPEF Handler Module
1146  TPEF::Binary* tpef = TPEF::BinaryReader::readBinary(binaryStream);
1147 
1148  if (tpef == NULL) {
1149  throw IOException(
1150  __FILE__, __LINE__, __func__, "Loading TPEF failed.");
1151  }
1152 
1153  // convert the loaded TPEF to POM
1155  Program* prog = factory.build();
1156  delete tpef;
1157  tpef = NULL;
1158  return prog;
1159 }

References __func__, TTAProgram::TPEFProgramFactory::build(), UniversalMachine::instance(), and TPEF::BinaryReader::readBinary().

Here is the call graph for this function:

◆ loadFromUnscheduledTPEF() [2/2]

Program * TTAProgram::Program::loadFromUnscheduledTPEF ( const std::string &  tpefFileName,
const TTAMachine::Machine theMachine 
)
static

A shortcut for loading a partially scheduled program from a TPEF file.

Parameters
tpefFileNameThe file name of the TPEF.
theMachineThe target machine.
Returns
Created program.
Exceptions
Exceptionif the TPEF or program in it is somehow broken.

Definition at line 1083 of file Program.cc.

1084  {
1085  TPEF::BinaryStream binaryStream(tpefFileName);
1086 
1087  // read to TPEF Handler Module
1088  TPEF::Binary* tpef = TPEF::BinaryReader::readBinary(binaryStream);
1089 
1090  if (tpef == NULL) {
1091  throw IOException(
1092  __FILE__, __LINE__, __func__, "Loading TPEF failed.");
1093  }
1094 
1095  // convert the loaded TPEF to POM
1096  TTAProgram::TPEFProgramFactory factory(*tpef, theMachine);
1097  Program* prog = factory.build();
1098  delete tpef;
1099  tpef = NULL;
1100  return prog;
1101 }

References __func__, TTAProgram::TPEFProgramFactory::build(), and TPEF::BinaryReader::readBinary().

Here is the call graph for this function:

◆ moveAt()

const TTAProgram::Move & TTAProgram::Program::moveAt ( int  number) const

Returns a move at given location, counting from beginning, zero

Parameters
numberzero-beginning count of move's location
Returns
a reference to the found move
Exceptions
KeyNotFoundif the move wasn't found at the given location

Definition at line 480 of file Program.cc.

480  {
481  if (number < 0 || number >= static_cast<int>(moves_.size())) {
482  throw KeyNotFound(__FILE__, __LINE__, __FUNCTION__,
483  "Move not found at location: " + Conversion::toString(number));
484  }
485  return *moves_.at(number);
486 }

References moves_, and Conversion::toString().

Referenced by ProgramImageGenerator::generateProgramImage().

Here is the call graph for this function:

◆ moveCount()

int TTAProgram::Program::moveCount ( ) const

Returns the total count of moves used in the program

Returns
the total count of moves used in the program

Definition at line 494 of file Program.cc.

494  {
495  return static_cast<int>(moves_.size());
496 }

References moves_.

Referenced by CompiledSimulation::CompiledSimulation(), and ProgramImageGenerator::generateProgramImage().

◆ moveProcedure()

void TTAProgram::Program::moveProcedure ( Procedure proc,
int  howMuch 
)

Moves the given procedure and its succeeding procedures the given count of instructions.

Note
If the given count is negative, does not perform any checking for overlapping procedures, thus the relocated procedure might end up sharing instruction indices with the preceeding procedure, which means a corrupted program.
Parameters
procThe procedure to move.
howMuchHow many instructions the procedure should be moved.

Definition at line 588 of file Program.cc.

588  {
589  unsigned int index;
590  // skip procedures before given procedure
591  for (index = 0; index < procedures_.size(); index++) {
592  if (procedures_[index] == &proc) {
593  break;
594  }
595  }
596  // only update procedures after.
597  for (;index < procedures_.size(); index++) {
598  Procedure* p2 = procedures_[index];
599  UIntWord oldAddr = p2->startAddress().location();
600  p2->setStartAddress(Address(oldAddr + howMuch, start_.space()));
601  }
602 }

References TTAProgram::Address::location(), procedures_, TTAProgram::CodeSnippet::setStartAddress(), TTAProgram::Address::space(), start_, and TTAProgram::CodeSnippet::startAddress().

Referenced by TTAProgram::Procedure::add(), TTAProgram::Procedure::clear(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::copyToProcedure(), TTAProgram::Procedure::insertAfter(), TTAProgram::Procedure::insertBefore(), TTAProgram::Procedure::remove(), removeProcedure(), and setStartAddress().

Here is the call graph for this function:

◆ nextInstruction()

Instruction & TTAProgram::Program::nextInstruction ( const Instruction ins) const

Returns the next instruction in the instruction stream.

Returns
The next instruction in the instruction stream or a special null instruction if the given instruction is the last instruction of the program.
Exceptions
IllegalRegistrationIf given instruction does not belong to the program.
Note
This method is very slow, do not use it for traversing the whole program!

Definition at line 403 of file Program.cc.

403  {
404  if (!ins.isInProcedure() || !ins.parent().isInProgram() ||
405  &ins.parent().parent() != this) {
406 
407  throw IllegalRegistration(
408  __FILE__, __LINE__, __func__,
409  "Instruction in parameter doesn't belong to this program.");
410  }
411 
412  unsigned int insAddress = ins.address().location();
413 
414  // Check first the basic case of having the next instruction in the same
415  // procedure. Find the instruction and return its next iterator.
416  Instruction* nextInstr = &ins.parent().nextInstruction(ins);
417  if (nextInstr != &NullInstruction::instance())
418  return *nextInstr;
419 
420  ProcIter iter = procedures_.begin();
421  while (iter != procedures_.end()) {
422 
423  // if the current instruction address fits procedure's
424  // address space
425  if ((*iter)->startAddress().location() <= insAddress &&
426  (*iter)->endAddress().location() > insAddress) {
427 
428  // return next instruction, if it's in the same procedure
429  if ((*iter)->hasNextInstruction(ins)) {
430  return (*iter)->nextInstruction(ins);
431 
432  // otherwise find the next non-empty procedure and return
433  // its first instruction
434  } else {
435  iter++;
436  while (iter != procedures_.end()) {
437  if ((*iter)->instructionCount() != 0) {
438  return (*iter)->instructionAt(
439  (*iter)->startAddress().location());
440  }
441  iter++;
442  }
443 
444  // if no non-empty procedures found, return null instruction
445  return NullInstruction::instance();
446  }
447  }
448  iter++;
449  }
450 
451  // no procedure where current instruction fits was found
452  // (should throw exception?)
453  return NullInstruction::instance();
454 }

References __func__, TTAProgram::Instruction::address(), TTAProgram::NullInstruction::instance(), TTAProgram::Instruction::isInProcedure(), TTAProgram::CodeSnippet::isInProgram(), TTAProgram::Address::location(), TTAProgram::CodeSnippet::nextInstruction(), TTAProgram::CodeSnippet::parent(), TTAProgram::Instruction::parent(), and procedures_.

Referenced by SimulationStatistics::calculate(), DEFAULT_Compressor::compress(), and CodeCompressorPlugin::initializeRelocations().

Here is the call graph for this function:

◆ nextProcedure()

Procedure & TTAProgram::Program::nextProcedure ( const Procedure proc) const

Returns the procedure following the given procedure.

Returns
The procedure following the given procedure or a null procedure, if the given procedure is the last procedure in the program.
Parameters
procThe following procedure of this parameter is returned.
Exceptions
IllegalRegistrationif the given procedure does not belong to this program.

Definition at line 250 of file Program.cc.

250  {
251  if (!proc.isInProgram() || &proc.parent() != this) {
252  throw IllegalRegistration(
253  __FILE__, __LINE__, __func__,
254  "The procedure given in parameter doesn't "
255  "belong to this program.");
256  }
257 
258  if (&proc != &lastProcedure()) {
259  int i = 0;
260  for (; i < procedureCount(); i++) {
261  if (procedures_.at(i) == &proc) {
262  break;
263  }
264  }
265  assert(i < procedureCount() - 1);
266  return *procedures_.at(i + 1);
267 
268  } else {
269  return NullProcedure::instance();
270  }
271 }

References __func__, assert, TTAProgram::NullProcedure::instance(), TTAProgram::CodeSnippet::isInProgram(), lastProcedure(), TTAProgram::CodeSnippet::parent(), procedureCount(), and procedures_.

Referenced by TTAProgram::Procedure::add(), TTAProgram::Procedure::clear(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), ControlFlowGraph::copyToProcedure(), TTAProgram::Procedure::insertAfter(), TTAProgram::Procedure::insertBefore(), TTAProgram::Procedure::remove(), and removeProcedure().

Here is the call graph for this function:

◆ operator=()

Program & TTAProgram::Program::operator= ( const Program newProgram)

Assignment operator.

Replaces the contents of this program with the given program.

Parameters
newProgramThe Program instance to be assigned
Returns
The assigned Program instance.

Definition at line 701 of file Program.cc.

701  {
702  copyFrom(newProgram);
703  return *this;
704 }

References copyFrom().

Here is the call graph for this function:

◆ operator[]()

Procedure & TTAProgram::Program::operator[] ( size_t  index)

Returns the procedure at the given index.

Parameters
indexThe position index.
Returns
The procedure at the given index.
Exceptions
OutOfRangeif the index is out of range.

Definition at line 642 of file Program.cc.

642  {
643  return *procedures_[index];
644 }

References procedures_.

◆ procedure() [1/2]

Procedure & TTAProgram::Program::procedure ( const std::string &  name) const

Returns the procedure with the given name.

Parameters
nameThe procedure name.
Returns
The procedure with given name.
Exceptions
KeyNotFoundif the procedure cannot be found.

Definition at line 654 of file Program.cc.

654  {
655  ProcList::const_iterator i = procedures_.begin();
656  while (i != procedures_.end()) {
657  if ((*i)->name() == name) {
658  return *(*i);
659  }
660  ++i;
661  }
662 
663  throw KeyNotFound(
664  __FILE__, __LINE__, __func__,
665  "No procedure found with name: " +
666  name);
667 }

References __func__, and procedures_.

◆ procedure() [2/2]

Procedure & TTAProgram::Program::procedure ( int  index) const

Returns the procedure at the given index.

Parameters
indexThe position index.
Returns
The procedure at the given index.
Exceptions
OutOfRangeif the index is out of range.

Definition at line 622 of file Program.cc.

622  {
623  if (index >= 0 &&
624  static_cast<unsigned int>(index) < procedures_.size()) {
625  return *procedures_.at(index);
626  } else {
627  throw OutOfRange(
628  __FILE__, __LINE__, __func__,
629  "There is no procedure by index: " +
630  Conversion::toString(index));
631  }
632 }

References __func__, procedures_, and Conversion::toString().

Referenced by SimpleICOptimizer::addConnections(), convertSymbolRef(), convertSymbolRefsToInsRefs(), copyFrom(), ControlFlowGraph::createBBEdges(), TTAProgram::ProgramWriter::createBinary(), TTAProgram::ProgramWriter::createCodeSection(), llvm::LLVMTCEBuilder::deleteDeadProcedures(), llvm::LLVMTCEIRBuilder::doFinalization(), CompiledSimCodeGenerator::findBasicBlocks(), SimulatorFrontend::finishSimulation(), fixInstructionReferences(), CompiledSimCodeGenerator::generateSimulationCode(), POMDisassembler::instructionCount(), link(), SimControlLanguageCommand::parseInstructionAddressExpression(), and replaceUniversalAddressSpaces().

Here is the call graph for this function:

◆ procedureAtIndex()

const Procedure & TTAProgram::Program::procedureAtIndex ( int  index) const

Returns the procedure at a given index in the container of procedures.

This method is for quickly traversing through all the procedures within time critical loops.

Parameters
indexThe procedure index in the list of procedures.
Returns
The Procedure at the given index.

Definition at line 508 of file Program.cc.

508  {
509  return *procedures_.at(index);
510 }

References procedures_.

Referenced by SimProgramBuilder::build(), InlineAsmParser::copyInstructions(), and POMDisassembler::disassembleProcedures().

◆ procedureCount()

int TTAProgram::Program::procedureCount ( ) const

◆ removeProcedure()

void TTAProgram::Program::removeProcedure ( Procedure proc)

Remove procedure from the program.

The procedure becomes independent (it is not deleted). All instructions following the removed procedure are relocated appropriately. All code labels attached to the removed procedure are deleted from the Program.

Note
Possible references to instructions in this procedure elsewhere in the program are not automatically fixed! It's a responsibility of the caller to fix the Program back to a consistent state.
Todo:
Copy the deleted CodeLabels to the removed procedure's own Scope objects.
Parameters
procProcedure to remove.
Exceptions
IllegalRegistrationIf procedure does not belong to the program.

Definition at line 901 of file Program.cc.

901  {
902  if (&proc.parent() != this) {
903  throw IllegalRegistration(
904  __FILE__, __LINE__, __func__,
905  "Procedure doesn't belong to this program.");
906  }
907 
908  const InstructionAddress firstAddress = proc.startAddress().location();
909  const InstructionAddress lastAddress = proc.endAddress().location() - 1;
910 
911  for (InstructionAddress addr = firstAddress;
912  addr <= lastAddress;
913  ++addr) {
914 
916  }
917 
918  if (&proc != &lastProcedure()) {
920  nextProcedure(proc),
921  proc.startAddress().location() - proc.endAddress().location());
922  }
923 
924  for (ProcList::iterator iter = procedures_.begin();
925  iter != procedures_.end(); iter++) {
926 
927  if ((*iter) == &proc) {
928  procedures_.erase(iter);
929  break;
930  }
931  }
932 
933  proc.setParent(NullProgram::instance());
934 }

References __func__, TTAProgram::CodeSnippet::endAddress(), globalScope_, TTAProgram::NullProgram::instance(), lastProcedure(), TTAProgram::Address::location(), moveProcedure(), nextProcedure(), TTAProgram::CodeSnippet::parent(), procedures_, TTAProgram::GlobalScope::removeCodeLabels(), TTAProgram::CodeSnippet::setParent(), and TTAProgram::CodeSnippet::startAddress().

Referenced by llvm::LLVMTCEBuilder::deleteDeadProcedures(), and ProgramDependenceGraph::disassemble().

Here is the call graph for this function:

◆ replaceUniversalAddressSpaces()

void TTAProgram::Program::replaceUniversalAddressSpaces ( const TTAMachine::AddressSpace space)

Replace instruction and data address space of a sequential program with real ones of the target machine.

Only the data address space of the target machine that corresponds to the universal data address space is required. Target machine and instruction address space are replaced implicitly.

Parameters
spaceNew data address space.
Note
Use only to convert a sequential program to use a real machine!

Definition at line 1012 of file Program.cc.

1012  {
1013 
1014  if (dynamic_cast<UniversalMachine*>(start_.space().machine()) == NULL) {
1015  abortWithError("Address space not connected to a machine.");
1016  }
1017 
1018  AddressSpace& instructionAS =
1019  *space.machine()->controlUnit()->addressSpace();
1020 
1021  start_ = Address(start_.location(), instructionAS);
1022  entry_ = Address(entry_.location(), instructionAS);
1023 
1024 
1025  for (int k = 0; k < procedureCount(); k++) {
1026  Procedure& proc = procedure(k);
1027  for (int j = 0; j < proc.instructionCount(); j++) {
1028  Instruction &ins = proc.instructionAtIndex(j);
1029  for (int i = 0; i < ins.moveCount(); i++) {
1030  Move& move = ins.move(i);
1031  Terminal& source = move.source();
1032  if (source.isAddress() && !source.isInstructionAddress()) {
1033  TerminalAddress* newSource = new TerminalAddress(
1034  source.value(), const_cast<AddressSpace&>(space));
1035  move.setSource(newSource);
1036  }
1037  }
1038  }
1039  }
1040 
1041  if (dataMemoryCount() > 1) {
1042  throw IllegalProgram(
1043  __FILE__, __LINE__, __func__,
1044  "There should be less than two data memories. Number of memories: " +
1046  }
1047 
1048  if (dataMemoryCount() == 0) {
1049  // TODO: what to do when there is no data used in program...
1050  } else if (dataMemoryCount() == 1) {
1051  DataMemory& dataMem = dataMemory(0);
1052  dataMem.setAddressSpace(const_cast<AddressSpace&>(space));
1053 
1054  // fix dest addresses in data defs to point to the new single data AS
1055  for (int i = 0; i < dataMem.dataDefinitionCount(); i++) {
1056  DataDefinition& def = dataMem.dataDefinition(i);
1057  if (def.isAddress() && !def.isInstructionAddress()) {
1058  def.setDestinationAddress(
1059  Address(def.destinationAddress().location(), space));
1060  }
1061  }
1062 
1063  assert(dataMemoryCount() == 1);
1065 
1066  } else {
1067  throw IllegalProgram(
1068  __FILE__, __LINE__, __func__,
1069  "There should be less than two data memories. Number of memories: " +
1071  }
1072 }

References __func__, abortWithError, TTAMachine::FunctionUnit::addressSpace(), assert, TTAMachine::Machine::controlUnit(), TTAProgram::DataMemory::dataDefinition(), TTAProgram::DataMemory::dataDefinitionCount(), dataMemory(), dataMemoryCount(), TTAProgram::DataDefinition::destinationAddress(), entry_, globalScope_, TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Terminal::isAddress(), TTAProgram::DataDefinition::isAddress(), TTAProgram::Terminal::isInstructionAddress(), TTAProgram::DataDefinition::isInstructionAddress(), TTAProgram::Address::location(), TTAMachine::Component::machine(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), procedure(), procedureCount(), TTAProgram::DataMemory::setAddressSpace(), TTAProgram::GlobalScope::setDataLabelAddressSpace(), TTAProgram::DataDefinition::setDestinationAddress(), TTAProgram::Move::setSource(), TTAProgram::Move::source(), TTAProgram::Address::space(), start_, Conversion::toString(), and TTAProgram::Terminal::value().

Here is the call graph for this function:

◆ setEntryAddress()

void TTAProgram::Program::setEntryAddress ( Address  address)

Sets the entry address of the program.

Note
Preserving this value is not implemented in TPEFProgramFactory and ProgramWriter, however implementation of property is already specified in TPEF specs.

Definition at line 342 of file Program.cc.

342  {
343  entry_ = address;
344 }

References entry_.

Referenced by copyFrom().

◆ setStartAddress()

void TTAProgram::Program::setStartAddress ( Address  start)

Sets the start (lowest) address of the program.

The start address of the program is not necessarily the lowest address of the instruction address space. Relocates instructions to start from the address.

Note
Preserving this value is not implemented in TPEFProgramFactory and ProgramWriter, however implementation of property is already specified in TPEF specs.
Parameters
startThe start (lowest) address of the program.

Definition at line 304 of file Program.cc.

304  {
305 
306  start_ = start;
307 
308  // move procedures before the new starting address
309  if (procedureCount() > 0 &&
310  firstProcedure().startAddress().location() < start_.location()) {
312  firstProcedure(),
313  start_.location() - firstProcedure().startAddress().location());
314  }
315 }

References firstProcedure(), TTAProgram::Address::location(), moveProcedure(), procedureCount(), start_, and startAddress().

Referenced by copyFrom().

Here is the call graph for this function:

◆ setUniversalMachine()

void TTAProgram::Program::setUniversalMachine ( UniversalMachine umach)
inline

Definition at line 81 of file Program.hh.

81 { umach_ = umach; }

References umach_.

Referenced by TTAProgram::TPEFProgramFactory::build().

◆ startAddress()

Address TTAProgram::Program::startAddress ( ) const

Returns the start (lowest) address of the program.

The start address of the program is not necessarily the lowest address of the instruction address space.

Note
Preserving this value is not implemented in TPEFProgramFactory and ProgramWriter, however implementation of property is already specified in TPEF specs.
Returns
The start (lowest) address of the program.

Definition at line 286 of file Program.cc.

286  {
287  return start_;
288 }

References start_.

Referenced by SimProgramBuilder::build(), TTAProgram::TPEFProgramFactory::build(), SimulationStatistics::calculate(), copy(), copyFrom(), TTAProgram::ProgramWriter::createBinary(), TTAProgram::ProgramWriter::createCodeSection(), finalize(), SimulatorFrontend::finishSimulation(), fixInstructionReferences(), setStartAddress(), and POMDisassembler::startAddress().

◆ targetProcessor()

Machine & TTAProgram::Program::targetProcessor ( ) const

◆ toString()

TCEString TTAProgram::Program::toString ( ) const

Dump the Program as a disassembly string.

Definition at line 1327 of file Program.cc.

1327  {
1328  return POMDisassembler::disassemble(*this, true);
1329 }

References POMDisassembler::disassemble().

Here is the call graph for this function:

◆ universalMachine()

UniversalMachine & TTAProgram::Program::universalMachine ( ) const

Deprecated.

Use UniversalMachine::instance() directly.

Definition at line 104 of file Program.cc.

104  {
106 }

References UniversalMachine::instance().

Referenced by ProgramDependenceGraph::createJump(), ProgramDependenceGraph::disassemble(), and llvm::LLVMTCEPOMBuilder::emitMove().

Here is the call graph for this function:

◆ writeToTPEF()

void TTAProgram::Program::writeToTPEF ( const TTAProgram::Program program,
const std::string &  tpefFileName 
)
static

A shortcut for writing a program to a TPEF file.

Parameters
programThe program to write.
tpefFileNameThe file name of the TPEF.
Exceptions
Exceptionif the TPEF or program in it is somehow broken.

Definition at line 1169 of file Program.cc.

1170  {
1171  std::ofstream outputFile(
1172  tpefFileName.c_str(),
1173  std::ios_base::out|std::ios_base::trunc|std::ios_base::binary);
1174  TPEF::BinaryStream binaryStream(outputFile);
1175 
1177  TPEF::Binary* tpefBin = writer.createBinary();
1178 
1179  TPEF::TPEFWriter::instance().writeBinary(binaryStream, tpefBin);
1180 
1181  delete tpefBin;
1182  tpefBin = NULL;
1183 }

References TTAProgram::ProgramWriter::createBinary(), TPEF::TPEFWriter::instance(), program, and TPEF::BinaryWriter::writeBinary().

Referenced by main().

Here is the call graph for this function:

Member Data Documentation

◆ dataMems_

DataMemList TTAProgram::Program::dataMems_
private

The data memories in the program.

Definition at line 180 of file Program.hh.

Referenced by addDataMemory(), cleanup(), dataMemory(), and dataMemoryCount().

◆ entry_

Address TTAProgram::Program::entry_
private

The entry address of the program.

Definition at line 188 of file Program.hh.

Referenced by entryAddress(), replaceUniversalAddressSpaces(), and setEntryAddress().

◆ finalized_

bool TTAProgram::Program::finalized_
private

True in case the program is not (and must not be) updated anymore and it has its final instruction addresses computed.

Definition at line 200 of file Program.hh.

Referenced by finalize(), and isFinalized().

◆ globalScope_

GlobalScope* TTAProgram::Program::globalScope_
private

◆ instructionPerAddress_

bool TTAProgram::Program::instructionPerAddress_
private

True in case the program is instruction indexed, that is, each instruction is assumed to be in a single instruction memory location.

Definition at line 204 of file Program.hh.

Referenced by finalize(), and isInstructionPerAddress().

◆ moves_

MoveList TTAProgram::Program::moves_
private

List of all the moves of the program.

Definition at line 183 of file Program.hh.

Referenced by addInstruction(), moveAt(), and moveCount().

◆ procedures_

ProcList TTAProgram::Program::procedures_
private

◆ refManager_

InstructionReferenceManager* TTAProgram::Program::refManager_
private

Keeps book of all instruction to instruction (jumps and calls) references in the program.

Definition at line 192 of file Program.hh.

Referenced by cleanup(), convertSymbolRef(), instructionReferenceManager(), Program(), and ~Program().

◆ start_

Address TTAProgram::Program::start_
private

The start address of the program.

Definition at line 186 of file Program.hh.

Referenced by addProcedure(), instructionCount(), moveProcedure(), replaceUniversalAddressSpaces(), setStartAddress(), startAddress(), and targetProcessor().

◆ umach_

UniversalMachine* TTAProgram::Program::umach_
mutableprivate

The UniversalMachine instance used to refer to in case of the unscheduled/unassigned parts of the program.

Definition at line 196 of file Program.hh.

Referenced by setUniversalMachine().


The documentation for this class was generated from the following files:
TTAProgram::Immediate::value
TerminalImmediate & value() const
Definition: Immediate.cc:103
UIntWord
Word UIntWord
Definition: BaseType.hh:144
TTAProgram::InstructionReference::instruction
Instruction & instruction() const
Definition: InstructionReference.cc:138
TTAProgram::Program::addProcedure
void addProcedure(Procedure *proc)
Definition: Program.cc:524
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
TTAProgram::CodeSnippet::firstInstruction
virtual Instruction & firstInstruction() const
Definition: CodeSnippet.cc:216
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAProgram::Instruction::move
Move & move(int i) const
Definition: Instruction.cc:193
TTAProgram::Program::procedureCount
int procedureCount() const
Definition: Program.cc:610
TTAProgram::Program::firstProcedure
Procedure & firstProcedure() const
Definition: Program.cc:213
TTAProgram::Program::entryAddress
Address entryAddress() const
Definition: Program.cc:330
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
TTAProgram::Program::startAddress
Address startAddress() const
Definition: Program.cc:286
TPEF::BinaryWriter::writeBinary
void writeBinary(BinaryStream &stream, const Binary *bin) const
Definition: BinaryWriter.cc:64
TPEF::Binary
Definition: Binary.hh:49
TTAProgram::Instruction
Definition: Instruction.hh:57
OutOfRange
Definition: Exception.hh:320
TPEF::BinaryStream
Definition: BinaryStream.hh:59
TTAProgram::ProgramWriter
Definition: ProgramWriter.hh:141
TTAProgram::NullProcedure::instance
static NullProcedure & instance()
Definition: NullProcedure.cc:68
TTAProgram::DataMemory::addressSpace
const TTAMachine::AddressSpace & addressSpace() const
Definition: DataMemory.cc:182
TTAProgram::Program::finalized_
bool finalized_
True in case the program is not (and must not be) updated anymore and it has its final instruction ad...
Definition: Program.hh:200
TTAProgram::Program::instructionPerAddress_
bool instructionPerAddress_
True in case the program is instruction indexed, that is, each instruction is assumed to be in a sing...
Definition: Program.hh:204
TTAProgram::InstructionReferenceManager::createReference
InstructionReference createReference(Instruction &ins)
Definition: InstructionReferenceManager.cc:73
TTAProgram::Address::space
const TTAMachine::AddressSpace & space() const
UniversalMachine::instance
static UniversalMachine & instance()
Definition: UniversalMachine.cc:73
POMDisassembler::disassembler
static POMDisassembler * disassembler(const TTAMachine::Machine &mach, const TTAProgram::Program &program)
Definition: POMDisassembler.cc:1022
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
TTAProgram::CodeSnippet::startAddress
virtual Address startAddress() const
Definition: CodeSnippet.cc:780
TTAProgram::Program::dataMems_
DataMemList dataMems_
The data memories in the program.
Definition: Program.hh:180
TTAProgram::Procedure::copy
CodeSnippet * copy() const
Definition: Procedure.cc:137
TTAProgram::Program::umach_
UniversalMachine * umach_
The UniversalMachine instance used to refer to in case of the unscheduled/unassigned parts of the pro...
Definition: Program.hh:196
TTAProgram::GlobalScope::globalDataLabel
const DataLabel & globalDataLabel(Address address, int index) const
Definition: GlobalScope.cc:220
Conversion::toString
static std::string toString(const T &source)
TTAProgram::Program::InstructionVector
std::vector< Instruction * > InstructionVector
Vector for instructions.
Definition: Program.hh:66
TTAProgram::Program::refManager_
InstructionReferenceManager * refManager_
Keeps book of all instruction to instruction (jumps and calls) references in the program.
Definition: Program.hh:192
SimValue
Definition: SimValue.hh:96
TTAProgram::Program::hasProcedure
bool hasProcedure(const std::string &name) const
Definition: Program.cc:673
TTAProgram::TPEFProgramFactory
Definition: TPEFProgramFactory.hh:87
TTAProgram::NullProgram::instance
static NullProgram & instance()
Definition: NullProgram.cc:72
assert
#define assert(condition)
Definition: Application.hh:86
TTAProgram::Program::instructionAt
Instruction & instructionAt(InstructionAddress address) const
Definition: Program.cc:374
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
TTAProgram::Program::addDataMemory
void addDataMemory(DataMemory *dataMem)
Definition: Program.cc:954
TTAProgram::Program::nextProcedure
Procedure & nextProcedure(const Procedure &proc) const
Definition: Program.cc:250
TTAProgram::Immediate
Definition: Immediate.hh:54
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
TTAProgram::Program::setEntryAddress
void setEntryAddress(Address address)
Definition: Program.cc:342
TTAProgram::Program::moveProcedure
void moveProcedure(Procedure &proc, int howMuch)
Definition: Program.cc:588
TTAProgram::CodeSnippet::instructionCount
virtual int instructionCount() const
Definition: CodeSnippet.cc:205
TTAProgram::GlobalScope::setDataLabelAddressSpace
virtual void setDataLabelAddressSpace(const TTAMachine::AddressSpace &space)
Definition: GlobalScope.cc:305
UniversalMachine
Definition: UniversalMachine.hh:56
TTAProgram::Program::dataMemory
DataMemory & dataMemory(int index) const
Definition: Program.cc:967
POMDisassembler
Definition: POMDisassembler.hh:70
IllegalProgram
Definition: Exception.hh:895
__func__
#define __func__
Definition: Application.hh:67
TTAProgram::TerminalInstructionReference
Definition: TerminalInstructionReference.hh:48
TTAProgram::CodeSnippet::lastInstruction
virtual Instruction & lastInstruction() const
Definition: CodeSnippet.cc:387
TPEF::TPEFWriter::instance
static const BinaryWriter & instance()
Definition: TPEFWriter.cc:70
TTAProgram::Program::cleanup
void cleanup()
Definition: Program.cc:161
TTAProgram::GlobalScope::globalDataLabelCount
int globalDataLabelCount(Address address) const
Definition: GlobalScope.cc:195
TTAProgram::Address::location
InstructionAddress location() const
TTAProgram::Instruction::setSize
void setSize(short size)
Definition: Instruction.hh:104
TTAProgram::Move
Definition: Move.hh:55
TTAProgram::Program::copyDataMemoriesFrom
void copyDataMemoriesFrom(const Program &srcProg)
Definition: Program.cc:845
TTAProgram::NullInstruction::instance
static NullInstruction & instance()
Definition: NullInstruction.cc:66
TTAProgram::Program::Program
Program(const TTAMachine::AddressSpace &space)
Definition: Program.cc:91
TTAProgram::Instruction::immediate
Immediate & immediate(int i) const
Definition: Instruction.cc:285
TTAProgram::Immediate::setValue
void setValue(TerminalImmediate *value)
Definition: Immediate.cc:114
TTAProgram::GlobalScope::removeCodeLabels
virtual void removeCodeLabels(InstructionAddress address)
Definition: GlobalScope.cc:363
TTAProgram::Program::dataMemoryCount
int dataMemoryCount() const
Definition: Program.cc:942
IllegalRegistration
Definition: Exception.hh:532
TTAProgram::Program::moves_
MoveList moves_
List of all the moves of the program.
Definition: Program.hh:183
TTAProgram::TerminalImmediate
Definition: TerminalImmediate.hh:44
TTAProgram::Program::setStartAddress
void setStartAddress(Address start)
Definition: Program.cc:304
POMDisassembler::disassemble
static std::string disassemble(const TTAProgram::Move &move)
Definition: POMDisassembler.cc:629
TTAProgram::Program::instructionReferenceManager
InstructionReferenceManager & instructionReferenceManager() const
Definition: Program.cc:688
TTAProgram::Program::procedures_
ProcList procedures_
The procedures in the program.
Definition: Program.hh:177
TTAProgram::Terminal::toString
virtual TCEString toString() const =0
TTAMachine::Component::machine
virtual Machine * machine() const
TCEString
Definition: TCEString.hh:53
TTAProgram::Instruction::immediateCount
int immediateCount() const
Definition: Instruction.cc:267
TTAProgram::Program::entry_
Address entry_
The entry address of the program.
Definition: Program.hh:188
TTAProgram::Program::targetProcessor
TTAMachine::Machine & targetProcessor() const
Definition: Program.cc:202
TTAProgram::Program::convertSymbolRef
TerminalImmediate * convertSymbolRef(Terminal &tsr)
Definition: Program.cc:1226
TTAProgram::Terminal
Definition: Terminal.hh:60
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
TTAProgram::Program::globalScope_
GlobalScope * globalScope_
Global scope of the program.
Definition: Program.hh:174
KeyNotFound
Definition: Exception.hh:285
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
TTAProgram::Terminal::isCodeSymbolReference
virtual bool isCodeSymbolReference() const
Definition: Terminal.cc:154
IOException
Definition: Exception.hh:130
TTAProgram::Program::lastProcedure
Procedure & lastProcedure() const
Definition: Program.cc:230
POMDisassembler::instructionSize
virtual size_t instructionSize(const TTAProgram::Instruction &)
Returns the size of the instruction in memory addresses, if known. Falls back to address per instruct...
Definition: POMDisassembler.hh:119
TTAProgram::Program::fixInstructionReferences
void fixInstructionReferences()
Definition: Program.cc:775
TTAProgram::Program::ProcIter
ProcList::const_iterator ProcIter
Iterator for the procedure list.
Definition: Program.hh:156
TTAProgram::Instruction::setFinalAddress
void setFinalAddress(InstructionAddress addr)
Definition: Instruction.hh:121
TTAProgram::Program::copyFrom
void copyFrom(const Program &source)
Definition: Program.cc:732
TTAProgram::Program::start_
Address start_
The start address of the program.
Definition: Program.hh:186
TTAProgram::Program::instructionVector
InstructionVector instructionVector() const
Definition: Program.cc:1196
TTAProgram::Program::procedure
Procedure & procedure(int index) const
Definition: Program.cc:622
MathTools::requiredBitsSigned
static int requiredBitsSigned(SLongWord number)
TTAProgram::Instruction::moveCount
int moveCount() const
Definition: Instruction.cc:176
TTAProgram::Program::convertSymbolRefsToInsRefs
void convertSymbolRefsToInsRefs(bool ignoreUnfoundSymbols=false)
Definition: Program.cc:1264
TPEF::BinaryReader::readBinary
static Binary * readBinary(BinaryStream &stream)
Definition: BinaryReader.cc:88
InstanceNotFound
Definition: Exception.hh:304
TTAProgram::Move::setSource
void setSource(Terminal *src)
Definition: Move.cc:312