Go to the documentation of this file.
34 #ifndef COMPILED_SIM_CODE_GENERATOR_HH
35 #define COMPILED_SIM_CODE_GENERATOR_HH
82 typedef std::multimap<InstructionAddress, InstructionAddress>
104 typedef std::map<InstructionAddress, InstructionAddress>
AddressMap;
110 bool fuResourceConflictDetection,
112 bool dynamicCompilation,
113 bool basicBlockPerFile =
false,
114 bool functionPerFile =
true,
115 const TCEString& globalSymbolPrefix =
"");
184 const std::string& regSymbolName, std::ostream& stream);
192 const std::string& value,
196 const std::string& destination,
197 const std::string& resultSymbol);
308 #endif // include once
std::string headerFile_
Header filename.
std::map< std::string, std::string > usedGuardSymbols_
Temporary list of the used guard bool symbols per instruction.
std::set< InstructionAddress > exitPoints_
Program exit point addresses.
std::string guardPipelineTopSymbol(const TTAMachine::RegisterGuard &guard)
static TCETools::CIStringSet supportedMemoryOperations()
std::map< std::string, int > GuardPipeline
int instructionNumber_
Absolute instruction # being processed.
void generateInstruction(const TTAProgram::Instruction &instruction)
std::map< InstructionAddress, InstructionAddress > procedureStart
Procedure start per basic block starts.
bool isProcedureBegin_
Are we at the beginning of a new procedure?
UInt32 InstructionAddress
virtual AddressMap basicBlocks() const
std::string handleOperationWithoutDag(const TTAMachine::HWOperation &op)
virtual StringSet createdFiles() const
GuardPipeline guardPipeline_
void generateConstructorCode()
TTAMachine::Machine * machine
the architecture definition of the estimated processor
std::map< InstructionAddress, InstructionAddress > AddressMap
A type for storing address-to-address combinations.
std::string generateTriggerCode(const TTAMachine::HWOperation &op)
ProcedureBBRelations procedureBBRelations_
Basic blocks relations to procedures and vice versa.
std::string sourceSymbol
The source symbol.
std::string lastGuardBool_
name of the last used guard variable
void generateConstructorParameters()
std::string generateGuardRead(const TTAProgram::Move &move)
void generateFUOutputUpdater()
void generateJumpTableCode()
const TTAMachine::Machine & machine_
The machine used for simulation.
void generateAdvanceClockCode()
bool handleCycleEnd_
Should we let frontend handle each cycle end.
CompiledSimCodeGenerator & operator=(const CompiledSimCodeGenerator &)
Assignment not allowed.
static bool isStoreOperation(const std::string &opName)
const TTAProgram::Procedure * currentProcedure_
Pointer to the current Procedure being processed.
std::vector< TTAMachine::Port * > fuOutputPorts(const TTAMachine::FunctionUnit &fu) const
std::multimap< InstructionAddress, InstructionAddress > BasicBlockStarts
unsigned maxInstructionsPerFile_
Maximum number of instructions per engine source code file, computed from the instruction width (bus ...
StringSet createdFiles_
A list of the code files created during the process.
std::string currentFileName_
Name of the current file being processed.
std::string handleJump(const TTAMachine::HWOperation &op)
std::string generateGuardCondition(const TTAProgram::Move &move)
SimValueSymbolDeclarations declaredSymbols_
A list of all symbols that are declared after the program code is ready.
CompiledSimCodeGenerator(const TTAMachine::Machine &machine, const TTAProgram::Program &program, const TTASimulationController &controller, bool fuResourceConflictDetection, bool handleCycleEnd, bool dynamicCompilation, bool basicBlockPerFile=false, bool functionPerFile=true, const TCEString &globalSymbolPrefix="")
int moveCounter_
How many moves have we been through with?
void generateSymbolDeclarations()
bool handleRegisterWrite(const std::string ®SymbolName, std::ostream &stream)
InstructionAddress lastInstructionOfBB_
last instruction of the current basic block
std::map< std::string, int > SimValueSymbolDeclarations
Type for SimValue symbol declarations: string=symbolname, int=width.
std::string generateFUResultRead(const std::string &destination, const std::string &resultSymbol)
std::map< InstructionAddress, std::string > basicBlockFiles
Basic block starts and their corresponding .cpp files.
FUResultWrites lastFUWrites_
Last known FU result writes.
ConflictDetectionCodeGenerator conflictDetectionGenerator_
Conflict detection code generator.
DelayedAssignments delayedFUResultWrites_
Delayed FU Result assignments.
std::string detectConflicts(const TTAMachine::HWOperation &op)
std::string generateAddFUResult(const TTAMachine::FUPort &resultPort, const std::string &value, int latency)
std::map< std::string, int > FUResultWrites
void generateGuardPipelineVariables(std::ostream &stream)
std::string handleOperation(const TTAMachine::HWOperation &op)
void generateShutdownCode(InstructionAddress address)
std::string fuResultSymbol
The FU result symbol.
const TTAMachine::ControlUnit & gcu_
GCU.
void generateHeaderAndMainCode()
std::string mainFile_
Main source filename. This includes the constructor and the simulateCycle().
OperationPool operationPool_
The operation pool.
BasicBlockStarts basicBlockStarts
All basic block start addresses per procedure start.
std::ostream * os_
Current output stream i.e. the above file.
std::string className_
Name of the class to be created.
std::fstream currentFile_
Current file being processed.
std::set< std::string > StringSet
A type for std::string sets.
void findBasicBlocks() const
OperationSymbolDeclarations usedOperations_
A list of used operations.
unsigned maxInstructionsPerSimulationFunction_
Max for each simulation function.
bool functionPerFile_
Should the generator start with a new file after function end.
std::string targetDirectory_
Directory where to write the source files of the engine.
AddressMap bbStarts_
The basic block map referred by start of the block as a key.
virtual void generateToDirectory(const std::string &dirName)
std::multimap< int, DelayedAssignment > DelayedAssignments
FU Result writes.
static bool isLoadOperation(const std::string &opName)
bool dynamicCompilation_
Is this a dynamic compiled simulation?
CompiledSimSymbolGenerator symbolGen_
The symbol generator.
AddressMap bbEnds_
The basic block map referred by end of the block as a key.
find Finds info of the inner loops in the program
virtual ProcedureBBRelations procedureBBRelations() const
A struct for tracking basic blocks and their relation to their procedures.
void generateGuardPipelineAdvance(std::ostream &stream)
void generateSimulationGetter()
const TTASimulationController & simController_
The simulator frontend.
bool basicBlockPerFile_
Should the generator generate only one basic block per code file.
std::string generateLoadTrigger(const TTAMachine::HWOperation &op)
std::string generateStoreTrigger(const TTAMachine::HWOperation &op)
int instructionCounter_
Istruction counter for checking how many instructions to put per file.
void generateSimulationCode()
std::multimap< std::string, std::string > OperationSymbolDeclarations
A type for operation symbol declarations: 1=op.name 2=op.symbol.
void updateDeclaredSymbolsList()
TCEString globalSymbolSuffix_
std::string targetSymbol
The target symbol.
std::string generateHaltCode(const std::string &message="")
const TTAProgram::Program & program_
The simulated program.
void generateProcedureCode(const TTAProgram::Procedure &procedure)
StringSet declaredFunctions_
A set of all the declared functions.
virtual ~CompiledSimCodeGenerator()
void addDeclaredSymbol(const std::string &name, int width)