Go to the documentation of this file.
42 #include "ADFSerializer.hh"
67 #include "tce_config.h"
74 typedef std::map<TCEString, std::map<int, TCEString>>
PasmPacket;
84 "outputfile",
"Name of the output file.",
"o");
87 "stdout",
"Print to standard output",
"s");
110 std::cout <<
"tcedisasm - OpenASIP TTA parallel disassembler "
128 for (
int i = 0; i < fuNav.
count(); i++) {
129 if (fuNav.
item(i)->name().ciEqual(fuName))
return fuNav.
item(i);
145 for (
int i = 0; i < rfNav.
count(); i++) {
146 if (rfNav.
item(i)->name().ciEqual(rfName))
return rfNav.
item(i);
163 bool printHeader =
false) {
164 const int width = 32;
169 for (
auto& fu : fuSet) {
171 int ntabs = width/4 - (pasm_col.size()+1)/4;
172 for (
int i = 0; i < ntabs; i++) pasm_col +=
"\t";
173 pasm += pasm_col +
"|";
179 for (
auto& fu : fuSet) {
181 for (
int i = 0; i < ntabs; i++) pasm +=
"\t";
188 for (
auto& fu : fuSet) {
190 int ntabs = width/4 - (pasm_col.size()+1)/4;
191 for (
int i = 0; i < ntabs; i++) pasm_col +=
"\t";
192 pasm += pasm_col +
"|";
198 for (
auto& fu : fuSet) {
200 for (
int i = 0; i < ntabs; i++) pasm +=
"\t";
209 for (
auto& fu : fuSet) {
216 if (pkt[fu][0] ==
"jump" && pkt[fu][1] == fu+
".ra") {
220 TCEString instr =
" " + pkt[fu][0] +
" ";
221 for (
unsigned op = 1; op < pkt[fu].size(); op++) {
223 if (pkt[fu][op] !=
"" && op < pkt[fu].size() - 1) instr +=
", ";
229 if (!label.empty() && col_idx++ == 0) {
230 pasm_col +=
" ; " + label;
234 int ntabs = width/4 - (pasm_col.size()+1)/4;
235 for (
int i = 0; i < ntabs; i++) pasm_col +=
"\t";
236 pasm += pasm_col +
"|";
269 std::cerr <<
"Error: Illegal commandline: " << e.
errorMessage()
278 std::cerr <<
"Error: Illegal number of parameters." << endl << endl;
311 std::set<TCEString> blocksFU;
319 for (
int i = 0; i < fuNav.
count(); i++) {
321 blocksFU.insert(fuName.
split(
"_out")[0]);
323 for (
int i = 0; i < rfNav.
count(); i++)
324 blocksFU.insert(rfNav.
item(i)->name());
325 for (
int i = 0; i < immNav.
count(); i++)
326 blocksFU.insert(immNav.
item(i)->name());
327 blocksFU.insert(abu->
name());
350 std::ostream* output = &std::cout;
354 : inputFileName +
".pasm";
355 if (!
options.printToStdout()) {
361 std::fstream::trunc | std::fstream::out);
366 std::fstream::trunc | std::fstream::out);
367 if (file.is_open()) output = &file;
379 for (
int p = 0; p <
program->procedureCount(); p++) {
398 for (
int j = 0; j < instr->
moveCount(); j++) {
408 TCEString srcPort = srcFUName +
"." + srcPortName;
419 if (!asmMap.count(srcRF->
name())) {
420 asmMap[srcRF->
name()][0] =
"lrm";
421 }
else if(asmMap[srcRF->
name()][0] ==
"srm") {
422 asmMap[srcRF->
name()][0] =
"lrm_srm";
424 asmMap[srcRF->
name()][1] =
429 if (!asmMap.count(dstRF->
name())) {
430 asmMap[dstRF->
name()][0] =
"srm";
431 }
else if (asmMap[dstRF->
name()][0] ==
"lrm") {
432 asmMap[dstRF->
name()][0] =
"lrm_srm";
434 asmMap[dstRF->
name()][2] =
436 asmMap[dstRF->
name()][3] = srcPort;
443 asmMap[dstFUName][0] = opName;
445 if (!outPort.empty())
446 asmMap[dstFUName][0] +=
" " + outPort +
",";
448 int inputPortID = std::stoi(dstPort.
split(
"t")[0]);
449 asmMap[dstFUName][inputPortID] = srcPort;
452 std::vector<TCEString> abuParm =
457 asmMap[dstFUName][0] =
"srm";
458 asmMap[dstFUName][1] =
"r1";
459 asmMap[dstFUName][2] = srcPort;
462 asmMap[dstFUName][0] = abuParm[2];
463 asmMap[dstFUName][1] = srcPort;
464 }
else if (abuParm[1].ciEqual(
"value")) {
466 asmMap[dstFUName][2] = srcPort;
468 std::cout <<
"Parsing failed for: " + dst.
toString()
470 assert(
false &&
"unknown format for abu op\n");
virtual bool isTriggering() const
virtual void printHelp() const
TTAMachine::RegisterFile * getRegisterFile(TTAMachine::Machine *machine, TCEString rfName)
int main(int argc, char *argv[])
virtual TCEString name() const
std::vector< TCEString > split(const std::string &delim) const
void setSourceFile(const std::string &fileName)
static std::string outputFileName(const std::string &adfFile)
TTAMachine::Machine * machine
the architecture definition of the estimated processor
virtual int numberOfArguments() const
Terminal & destination() const
static UniversalMachine & instance()
virtual bool isFlagOn() const
static bool fileIsCreatable(const std::string fileName)
TCEString getPasmPacket(PasmPacket pkt, std::set< TCEString > fuSet, TCEString label="", bool printHeader=false)
#define assert(condition)
virtual ~DisasmCmdLineOptions()
virtual FUPort * port(int operand) const
virtual ControlUnit * controlUnit() const
void addOption(CmdLineOptionParser *opt)
TCEString getOutputPort(TTAMachine::FunctionUnit *fu, TCEString op)
static bool fileIsWritable(const std::string fileName)
virtual int instructionCount() const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
virtual FunctionUnitNavigator functionUnitNavigator() const
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
std::map< TCEString, std::map< int, TCEString > > PasmPacket
virtual bool isOutput() const
static bool createFile(const std::string &file)
Immediate & immediate(int i) const
std::string errorMessage() const
void parse(char *argv[], int argc)
TCEString & replaceString(const std::string &old, const std::string &newString)
static MachInfoCmdLineOptions options
virtual std::string String(int index=0) const
void printVersion() const
virtual RegisterFileNavigator registerFileNavigator() const
#define IGNORE_COMPILER_WARNING(X)
virtual TCEString toString() const =0
static bool fileExists(const std::string fileName)
virtual std::string name() const
int immediateCount() const
TTAMachine::Machine * readMachine()
TTAMachine::FunctionUnit * getFunctionUnit(TTAMachine::Machine *machine, TCEString fuName)
virtual Instruction & instructionAtIndex(int index) const
Terminal & source() const
virtual const TTAMachine::Port & port() const
ComponentType * item(int index) const
virtual HWOperation * operation(const std::string &name) const
find Finds info of the inner loops in the program
CmdLineOptionParser * findOption(std::string name) const
virtual bool isRA() const
virtual std::string argument(int index) const
static std::string TCEVersionString()
static Binary * readBinary(BinaryStream &stream)
Unit * parentUnit() const