OpenASIP
2.0
|
#include <Program.hh>
Public Types | |
typedef std::vector< Instruction * > | InstructionVector |
Vector for instructions. More... | |
Static Public Member Functions | |
static Program * | loadFromUnscheduledTPEF (const std::string &tpefFileName, const TTAMachine::Machine &theMachine) |
static Program * | loadFromTPEF (const std::string &tpefFileName, const TTAMachine::Machine &theMachine) |
static Program * | loadFromUnscheduledTPEF (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 () |
TerminalImmediate * | convertSymbolRef (Terminal &tsr) |
Private Attributes | |
GlobalScope * | globalScope_ |
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... | |
InstructionReferenceManager * | refManager_ |
Keeps book of all instruction to instruction (jumps and calls) references in the program. More... | |
UniversalMachine * | umach_ |
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... | |
Represents a TTA program.
Definition at line 63 of file Program.hh.
|
private |
List for data memories.
Definition at line 158 of file Program.hh.
typedef std::vector<Instruction*> TTAProgram::Program::InstructionVector |
Vector for instructions.
Definition at line 66 of file Program.hh.
|
private |
List for moves.
Definition at line 160 of file Program.hh.
|
private |
Iterator for the procedure list.
Definition at line 156 of file Program.hh.
|
private |
List for procedures.
Definition at line 154 of file Program.hh.
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.
space | The address space of the program. |
Definition at line 91 of file Program.cc.
References globalScope_, and refManager_.
Referenced by copy().
TTAProgram::Program::Program | ( | const TTAMachine::AddressSpace & | space, |
Address | start | ||
) |
Constructor.
Alternative constructor that takes the start address as a parameter.
space | The address space of the program. |
start | The start address of the program. |
Definition at line 116 of file Program.cc.
References globalScope_, and refManager_.
TTAProgram::Program::Program | ( | const TTAMachine::AddressSpace & | space, |
Address | start, | ||
Address | entry | ||
) |
Constructor.
Alternative constructor that takes the start and entry addresses as parameters.
space | The address space of the program. |
start | The start address of the program. |
entry | The entry address of the program. |
Definition at line 133 of file Program.cc.
References globalScope_, and refManager_.
|
virtual |
The destructor.
Definition at line 144 of file Program.cc.
References cleanup(), globalScope_, and refManager_.
|
private |
Copying not allowed.
void TTAProgram::Program::addDataMemory | ( | DataMemory * | dataMem | ) |
Insert the given data memory to the program.
dataMem | The data memory to be inserted. |
IllegalRegistration | Memory with the same address space is found from the program. |
Definition at line 954 of file Program.cc.
References dataMems_.
Referenced by copyDataMemoriesFrom(), TTAProgram::TPEFProgramFactory::createDataMemories(), and llvm::LLVMTCEBuilder::doFinalization().
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.
ins | The instruction to be inserted. |
IllegalRegistration | if the instruction belongs to a procedure or there are no procedures in the program. |
Definition at line 554 of file Program.cc.
References __func__, TTAProgram::Instruction::isInProcedure(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), moves_, and procedures_.
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.
proc | The procedure to be inserted. |
IllegalRegistration | if the procedure belongs to another program. |
Definition at line 524 of file Program.cc.
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().
|
private |
Cleans up the program to a state it was at the construction.
Definition at line 161 of file Program.cc.
References dataMems_, SequenceTools::deleteAllItems(), globalScope_, procedures_, and refManager_.
Referenced by copyFrom(), and ~Program().
|
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.
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().
void TTAProgram::Program::convertSymbolRefsToInsRefs | ( | bool | ignoreUnfoundSymbols = false | ) |
Converts all TerminalSymbolReferences into InstructionReferences pointing to instructions or TerminalImmediates into data label.
ignoreUnfoundSymbols | if 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.
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().
Program * TTAProgram::Program::copy | ( | ) | const |
Creates an exact copy of the program.
References to external object models will remain untouched.
Definition at line 714 of file Program.cc.
References copyFrom(), entryAddress(), Program(), and startAddress().
|
private |
|
private |
|
private |
Copy data memories from source program to destination and fixes data->code references to use InstructionReferenceManager of the instance.
srcProg | Program from which data is copied. |
Definition at line 845 of file Program.cc.
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().
|
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.
Definition at line 732 of file Program.cc.
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=().
DataMemory & TTAProgram::Program::dataMemory | ( | const std::string & | aSpaceName | ) | const |
Returns the data memory with the given address space name.
aSpaceName | The address space name of the memory. |
KeyNotFound | if the data memory cannot be found. |
Definition at line 987 of file Program.cc.
References __func__, TTAProgram::DataMemory::addressSpace(), dataMemory(), dataMemoryCount(), and TTAMachine::Component::name().
DataMemory & TTAProgram::Program::dataMemory | ( | int | index | ) | const |
Returns the data memory at the given index.
index | The position index. |
OutOfRange | the index is out of range. |
Definition at line 967 of file Program.cc.
References __func__, dataMems_, and Conversion::toString().
Referenced by ControlFlowGraph::computeLeadersFromRelocations(), copyDataMemoriesFrom(), TTAProgram::ProgramWriter::createDataSections(), dataMemory(), llvm::LLVMTCEBuilder::deleteDeadProcedures(), POMDisassembler::disassembleProgram(), SimulatorFrontend::initializeDataMemories(), and replaceUniversalAddressSpaces().
int TTAProgram::Program::dataMemoryCount | ( | ) | const |
Returns the number of data memories accessed by the program.
Definition at line 942 of file Program.cc.
References dataMems_.
Referenced by ControlFlowGraph::computeLeadersFromRelocations(), copyDataMemoriesFrom(), TTAProgram::ProgramWriter::createDataSections(), dataMemory(), llvm::LLVMTCEBuilder::deleteDeadProcedures(), POMDisassembler::disassembleProgram(), SimulatorFrontend::initializeDataMemories(), and replaceUniversalAddressSpaces().
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.
Definition at line 330 of file Program.cc.
References entry_.
Referenced by copy(), copyFrom(), and CompiledSimController::reset().
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.
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().
Instruction & TTAProgram::Program::firstInstruction | ( | ) | const |
Returns the first instruction of the program.
InstanceNotFound | There is no instructions in program. |
Definition at line 353 of file Program.cc.
References __func__, TTAProgram::CodeSnippet::firstInstruction(), firstProcedure(), and procedures_.
Referenced by DEFAULT_Compressor::compress(), llvm::LLVMTCEBuilder::emitSPInitialization(), DisassemblyGridTable::GetNumberRows(), and CodeCompressorPlugin::initializeRelocations().
Procedure & TTAProgram::Program::firstProcedure | ( | ) | const |
Returns the first procedure of the program.
InstanceNotFound | if there are no procedures. |
Definition at line 213 of file Program.cc.
References __func__, procedureCount(), and procedures_.
Referenced by firstInstruction(), SimControlLanguageCommand::parseInstructionAddressExpression(), and setStartAddress().
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.
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().
GlobalScope & TTAProgram::Program::globalScope | ( | ) |
Returns the global scope of the program.
Definition at line 180 of file Program.cc.
References globalScope_.
Referenced by TTAProgram::CodeLabel::CodeLabel(), TTAProgram::TPEFProgramFactory::createLabels(), llvm::LLVMTCEBuilder::doFinalization(), llvm::LLVMTCEBuilder::initDataSections(), TTAProgram::Procedure::remove(), and llvm::LLVMTCEBuilder::writeMachineFunction().
const GlobalScope & TTAProgram::Program::globalScopeConst | ( | ) | const |
Returns the global scope of the program.
Const version.
Definition at line 192 of file Program.cc.
References globalScope_.
Referenced by copyFrom(), TTAProgram::ProgramWriter::createBinary(), SymbolAddressCommand::execute(), DisassemblyGridTable::loadProgram(), SimControlLanguageCommand::parseDataAddressExpression(), and SimControlLanguageCommand::parseInstructionAddressExpression().
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.
References procedures_.
Referenced by convertSymbolRef(), convertSymbolRefsToInsRefs(), and ControlFlowGraph::createBBEdges().
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.
address | The address of the instruction. |
KeyNotFound | if given address is illegal. |
Definition at line 374 of file Program.cc.
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().
int TTAProgram::Program::instructionCount | ( | ) | const |
Definition at line 1209 of file Program.cc.
References TTAProgram::CodeSnippet::instructionCount(), lastProcedure(), TTAProgram::Address::location(), procedureCount(), start_, and TTAProgram::CodeSnippet::startAddress().
Referenced by TTAProgram::ProgramWriter::createBinary(), and ProgramImageGenerator::generateProgramImage().
InstructionReferenceManager & TTAProgram::Program::instructionReferenceManager | ( | ) | const |
Return the instruction reference manager.
Definition at line 688 of file Program.cc.
References refManager_.
Referenced by TTAProgram::TPEFProgramFactory::build(), llvm::LLVMTCEIRBuilder::buildTCECFG(), ControlFlowGraph::computeLeadersFromRefManager(), SequentialScheduler::copyBasicBlocksToProcedure(), ProcedurePass::copyCfgToProcedure(), copyDataMemoriesFrom(), ControlFlowGraph::copyToLLVMMachineFunction(), ControlFlowGraph::copyToProcedure(), SequentialScheduler::createBasicBlocks(), TTAProgram::TPEFProgramFactory::createDataMemories(), llvm::LLVMTCEBuilder::createGlobalValueDataDefinition(), ProgramDependenceGraph::createJump(), TTAProgram::TPEFProgramFactory::createLabels(), llvm::LLVMTCEBuilder::doFinalization(), llvm::LLVMTCEBuilder::emitSetjmp(), llvm::LLVMTCEBuilder::emitSPInitialization(), fixInstructionReferences(), AbsoluteToRelativeJumps::handleProcedure(), SimpleIfConverter::handleProcedure(), SequentialScheduler::handleProcedure(), TTAProgram::CodeLabel::instructionReference(), ControlFlowGraph::instructionReferenceManager(), TTAProgram::Procedure::remove(), BasicBlockNode::updateReferencesFromProcToCfg(), ControlFlowGraph::updateReferencesFromProcToCfg(), and llvm::LLVMTCEIRBuilder::writeMachineFunction().
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.
References TTAProgram::CodeSnippet::instructionAtIndex(), TTAProgram::CodeSnippet::instructionCount(), and procedures_.
Referenced by TTAProgram::TPEFProgramFactory::build(), finalize(), and ProgramImageGenerator::generateProgramImage().
|
inline |
|
inline |
Instruction & TTAProgram::Program::lastInstruction | ( | ) | const |
Returns the last instruction of the program.
InstanceNotFound | There is no instructions in the program. |
Definition at line 463 of file Program.cc.
References __func__, TTAProgram::CodeSnippet::lastInstruction(), lastProcedure(), and procedures_.
Referenced by SimulatorFrontend::currentProcedure(), SimulatorFrontend::finishSimulation(), CompiledSimCodeGenerator::generateInstruction(), DisassemblyGridTable::GetNumberRows(), and CompiledSimController::reset().
Procedure & TTAProgram::Program::lastProcedure | ( | ) | const |
Returns the last procedure of the program.
InstanceNotFound | if there are no procedures. |
Definition at line 230 of file Program.cc.
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().
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.
References addProcedure(), convertSymbolRefsToInsRefs(), TTAProgram::Procedure::copy(), copyDataMemoriesFrom(), fixInstructionReferences(), procedure(), and procedureCount().
|
static |
A shortcut for loading a scheduled program from a TPEF file.
tpefFileName | The file name of the TPEF. |
theMachine | The target machine. |
Definition at line 1112 of file Program.cc.
References __func__, TTAProgram::TPEFProgramFactory::build(), and TPEF::BinaryReader::readBinary().
Referenced by SimpleICOptimizer::explore(), main(), and DesignSpaceExplorer::schedule().
|
static |
A shortcut for loading a sequential program (from the old gcc 2.7.0 frontend) from a TPEF file.
tpefFileName | The file name of the TPEF. |
umach | The universal machine for the unscheduled parts. |
Definition at line 1142 of file Program.cc.
References __func__, TTAProgram::TPEFProgramFactory::build(), UniversalMachine::instance(), and TPEF::BinaryReader::readBinary().
|
static |
A shortcut for loading a partially scheduled program from a TPEF file.
tpefFileName | The file name of the TPEF. |
theMachine | The target machine. |
Definition at line 1083 of file Program.cc.
References __func__, TTAProgram::TPEFProgramFactory::build(), and TPEF::BinaryReader::readBinary().
const TTAProgram::Move & TTAProgram::Program::moveAt | ( | int | number | ) | const |
Returns a move at given location, counting from beginning, zero
number | zero-beginning count of move's location |
KeyNotFound | if the move wasn't found at the given location |
Definition at line 480 of file Program.cc.
References moves_, and Conversion::toString().
Referenced by ProgramImageGenerator::generateProgramImage().
int TTAProgram::Program::moveCount | ( | ) | const |
Returns the total count of moves used in the program
Definition at line 494 of file Program.cc.
References moves_.
Referenced by CompiledSimulation::CompiledSimulation(), and ProgramImageGenerator::generateProgramImage().
void TTAProgram::Program::moveProcedure | ( | Procedure & | proc, |
int | howMuch | ||
) |
Moves the given procedure and its succeeding procedures the given count of instructions.
proc | The procedure to move. |
howMuch | How many instructions the procedure should be moved. |
Definition at line 588 of file Program.cc.
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().
Instruction & TTAProgram::Program::nextInstruction | ( | const Instruction & | ins | ) | const |
Returns the next instruction in the instruction stream.
IllegalRegistration | If given instruction does not belong to the program. |
Definition at line 403 of file Program.cc.
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().
Returns the procedure following the given procedure.
proc | The following procedure of this parameter is returned. |
IllegalRegistration | if the given procedure does not belong to this program. |
Definition at line 250 of file Program.cc.
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().
Assignment operator.
Replaces the contents of this program with the given program.
newProgram | The Program instance to be assigned |
Definition at line 701 of file Program.cc.
References copyFrom().
Procedure & TTAProgram::Program::operator[] | ( | size_t | index | ) |
Returns the procedure at the given index.
index | The position index. |
OutOfRange | if the index is out of range. |
Definition at line 642 of file Program.cc.
References procedures_.
Procedure & TTAProgram::Program::procedure | ( | const std::string & | name | ) | const |
Returns the procedure with the given name.
name | The procedure name. |
KeyNotFound | if the procedure cannot be found. |
Definition at line 654 of file Program.cc.
References __func__, and procedures_.
Procedure & TTAProgram::Program::procedure | ( | int | index | ) | const |
Returns the procedure at the given index.
index | The position index. |
OutOfRange | if the index is out of range. |
Definition at line 622 of file Program.cc.
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().
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.
index | The procedure index in the list of procedures. |
Definition at line 508 of file Program.cc.
References procedures_.
Referenced by SimProgramBuilder::build(), InlineAsmParser::copyInstructions(), and POMDisassembler::disassembleProcedures().
int TTAProgram::Program::procedureCount | ( | ) | const |
Returns the number of procedures in the program.
Definition at line 610 of file Program.cc.
References procedures_.
Referenced by SimpleICOptimizer::addConnections(), SimProgramBuilder::build(), llvm::LLVMTCEIRBuilder::buildTCECFG(), convertSymbolRefsToInsRefs(), copyFrom(), InlineAsmParser::copyInstructions(), TTAProgram::ProgramWriter::createBinary(), TTAProgram::ProgramWriter::createCodeSection(), POMDisassembler::disassembleProcedures(), llvm::LLVMTCEIRBuilder::doFinalization(), CompiledSimCodeGenerator::findBasicBlocks(), SimulatorFrontend::finishSimulation(), firstProcedure(), fixInstructionReferences(), CompiledSimCodeGenerator::generateSimulationCode(), POMDisassembler::instructionCount(), instructionCount(), lastProcedure(), link(), nextProcedure(), replaceUniversalAddressSpaces(), and setStartAddress().
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.
proc | Procedure to remove. |
IllegalRegistration | If procedure does not belong to the program. |
Definition at line 901 of file Program.cc.
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().
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.
space | New data address space. |
Definition at line 1012 of file Program.cc.
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().
void TTAProgram::Program::setEntryAddress | ( | Address | address | ) |
Sets the entry address of the program.
Definition at line 342 of file Program.cc.
References entry_.
Referenced by copyFrom().
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.
start | The start (lowest) address of the program. |
Definition at line 304 of file Program.cc.
References firstProcedure(), TTAProgram::Address::location(), moveProcedure(), procedureCount(), start_, and startAddress().
Referenced by copyFrom().
|
inline |
Definition at line 81 of file Program.hh.
References umach_.
Referenced by TTAProgram::TPEFProgramFactory::build().
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.
Definition at line 286 of file Program.cc.
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().
Machine & TTAProgram::Program::targetProcessor | ( | ) | const |
Returns the target TTA processor of the program.
Definition at line 202 of file Program.cc.
References TTAMachine::Component::machine(), TTAProgram::Address::space(), and start_.
Referenced by SimProgramBuilder::build(), copyDataMemoriesFrom(), TTAProgram::ProgramWriter::createASpaceElement(), TTAProgram::ProgramWriter::createBinary(), TTAProgram::ProgramWriter::createCodeSection(), TTAProgram::TPEFProgramFactory::createDataMemories(), finalize(), ProgramImageGenerator::generateProgramImage(), DisassemblyGridTable::GetColLabelValue(), DisassemblyGridTable::GetNumberCols(), and DisassemblyGridTable::GetValue().
TCEString TTAProgram::Program::toString | ( | ) | const |
Dump the Program as a disassembly string.
Definition at line 1327 of file Program.cc.
References POMDisassembler::disassemble().
UniversalMachine & TTAProgram::Program::universalMachine | ( | ) | const |
Deprecated.
Use UniversalMachine::instance() directly.
Definition at line 104 of file Program.cc.
References UniversalMachine::instance().
Referenced by ProgramDependenceGraph::createJump(), ProgramDependenceGraph::disassemble(), and llvm::LLVMTCEPOMBuilder::emitMove().
|
static |
A shortcut for writing a program to a TPEF file.
program | The program to write. |
tpefFileName | The file name of the TPEF. |
Definition at line 1169 of file Program.cc.
References TTAProgram::ProgramWriter::createBinary(), TPEF::TPEFWriter::instance(), program, and TPEF::BinaryWriter::writeBinary().
Referenced by main().
|
private |
The data memories in the program.
Definition at line 180 of file Program.hh.
Referenced by addDataMemory(), cleanup(), dataMemory(), and dataMemoryCount().
|
private |
The entry address of the program.
Definition at line 188 of file Program.hh.
Referenced by entryAddress(), replaceUniversalAddressSpaces(), and setEntryAddress().
|
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().
|
private |
Global scope of the program.
Definition at line 174 of file Program.hh.
Referenced by cleanup(), convertSymbolRef(), copyFrom(), globalScope(), globalScopeConst(), Program(), removeProcedure(), replaceUniversalAddressSpaces(), and ~Program().
|
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().
|
private |
List of all the moves of the program.
Definition at line 183 of file Program.hh.
Referenced by addInstruction(), moveAt(), and moveCount().
|
private |
The procedures in the program.
Definition at line 177 of file Program.hh.
Referenced by addInstruction(), addProcedure(), cleanup(), finalize(), firstInstruction(), firstProcedure(), hasProcedure(), instructionAt(), instructionVector(), lastInstruction(), lastProcedure(), moveProcedure(), nextInstruction(), nextProcedure(), operator[](), procedure(), procedureAtIndex(), procedureCount(), and removeProcedure().
|
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().
|
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().
|
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().