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