OpenASIP  2.0
Functions | Variables
TDGen.cc File Reference
#include <fstream>
#include <algorithm>
#include "TDGen.hh"
#include "Machine.hh"
#include "ADFSerializer.hh"
#include "ControlUnit.hh"
#include "Operation.hh"
#include "HWOperation.hh"
#include "FUPort.hh"
#include "Conversion.hh"
#include "MachineConnectivityCheck.hh"
#include "ImmediateAnalyzer.hh"
#include "ImmInfo.hh"
#include "Bus.hh"
#include "Guard.hh"
#include "StringTools.hh"
#include "OperationPool.hh"
#include "OperationNode.hh"
#include "TerminalNode.hh"
#include "ConstantNode.hh"
#include "OperationDAG.hh"
#include "OperationDAGEdge.hh"
#include "OperationDAGSelector.hh"
#include "TCEString.hh"
#include "Operand.hh"
#include "Application.hh"
#include "LLVMBackend.hh"
#include "MathTools.hh"
#include "tce_config.h"
#include "LLVMTCECmdLineOptions.hh"
#include "MachineInfo.hh"
#include "boost/assign.hpp"
Include dependency graph for TDGen.cc:

Go to the source code of this file.

Functions

bool numbersToAscending (const TCEString &lhs, const TCEString &rhs)
 
char regOperandCharToImmOperandChar (char c)
 

Variables

static const unsigned REG_RENAMER_PART = 0
 

Function Documentation

◆ numbersToAscending()

bool numbersToAscending ( const TCEString lhs,
const TCEString rhs 
)

Custom comparator that orders operation names correctly number-wise.

For instance, in an std::set operation names are ordered followingly: ADD32X16, ADD32X4, ADD32X8, XOR1024, XOR512, XOR64

This function corrects the operation name order to be the following: ADD32X4, ADD32X8, ADD32X16, XOR64, XOR512, XOR1024

Definition at line 292 of file TDGen.cc.

292  {
293  size_t lhsI = lhs.length() - 1;
294  size_t rhsI = rhs.length() - 1;
295 
296  // Reverse operation name to the position where the last number begins.
297  while (lhsI > 0 && std::isdigit(lhs[lhsI])) --lhsI;
298  while (rhsI > 0 && std::isdigit(rhs[rhsI])) --rhsI;
299 
300  // Make sure both strings contain a number.
301  if (lhsI > 0 && lhsI != lhs.length() - 1 && rhsI > 0 &&
302  rhsI != rhs.length() - 1) {
303  // The string part before the number must match between both names.
304  if (lhs.substr(0, lhsI + 1) == rhs.substr(0, rhsI + 1)) {
305  // Make the smaller number precede the larger one.
306  try {
307  int lhsNumber = Conversion::toInt(lhs.substr(lhsI + 1));
308  int rhsNumber = Conversion::toInt(rhs.substr(rhsI + 1));
309  return lhsNumber < rhsNumber;
310  } catch (const NumberFormatException& e) {
312  }
313  }
314  }
315 
316  // Basic comparison for std::string.
317  return lhs < rhs;
318 }

References abortWithError, Exception::errorMessage(), and Conversion::toInt().

Here is the call graph for this function:

◆ regOperandCharToImmOperandChar()

char regOperandCharToImmOperandChar ( char  c)

Definition at line 4450 of file TDGen.cc.

4450  {
4451  switch(c) {
4452  case TDGen::OT_REG_LONG:
4453  return TDGen::OT_IMM_LONG;
4454  case TDGen::OT_REG_INT:
4455  return TDGen::OT_IMM_INT;
4456  case TDGen::OT_REG_BOOL:
4457  return TDGen::OT_IMM_BOOL;
4458  case TDGen::OT_REG_FP:
4459  return TDGen::OT_IMM_FP;
4460  case TDGen::OT_REG_HFP:
4461  return TDGen::OT_IMM_HFP;
4462  default:
4463  return 0;
4464  }
4465 }

References TDGen::OT_IMM_BOOL, TDGen::OT_IMM_FP, TDGen::OT_IMM_HFP, TDGen::OT_IMM_INT, TDGen::OT_IMM_LONG, TDGen::OT_REG_BOOL, TDGen::OT_REG_FP, TDGen::OT_REG_HFP, TDGen::OT_REG_INT, and TDGen::OT_REG_LONG.

Referenced by TDGen::writeOperationDefs().

Variable Documentation

◆ REG_RENAMER_PART

const unsigned REG_RENAMER_PART = 0
static

Definition at line 332 of file TDGen.cc.

Referenced by TDGen::analyzeRegisters().

TDGen::OT_REG_FP
static const char OT_REG_FP
Definition: TDGen.hh:485
TDGen::OT_REG_INT
static const char OT_REG_INT
Definition: TDGen.hh:483
TDGen::OT_IMM_HFP
static const char OT_IMM_HFP
Definition: TDGen.hh:491
NumberFormatException
Definition: Exception.hh:421
TDGen::OT_IMM_INT
static const char OT_IMM_INT
Definition: TDGen.hh:489
TDGen::OT_REG_BOOL
static const char OT_REG_BOOL
Definition: TDGen.hh:482
TDGen::OT_REG_LONG
static const char OT_REG_LONG
Definition: TDGen.hh:484
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
TDGen::OT_IMM_LONG
static const char OT_IMM_LONG
Definition: TDGen.hh:492
Conversion::toInt
static int toInt(const T &source)
TDGen::OT_IMM_BOOL
static const char OT_IMM_BOOL
Definition: TDGen.hh:488
TDGen::OT_IMM_FP
static const char OT_IMM_FP
Definition: TDGen.hh:490
TDGen::OT_REG_HFP
static const char OT_REG_HFP
Definition: TDGen.hh:486