OpenASIP  2.0
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
llvm::LLVMTCEIRBuilder Class Reference

#include <LLVMTCEIRBuilder.hh>

Inheritance diagram for llvm::LLVMTCEIRBuilder:
Inheritance graph
Collaboration diagram for llvm::LLVMTCEIRBuilder:
Collaboration graph

Public Member Functions

 LLVMTCEIRBuilder (const TargetMachine &tm, TTAMachine::Machine *mach, InterPassData &ipd, AliasAnalysis *AA, bool functionAtATime=false, bool modifyMF=false)
 
bool writeMachineFunction (MachineFunction &mf)
 
virtual ~LLVMTCEIRBuilder ()
 
virtual bool doInitialization (Module &m)
 
virtual bool doFinalization (Module &m)
 
virtual void emitSPInitialization ()
 
void getAnalysisUsage (AnalysisUsage &AU) const
 
virtual StringRef getPassName () const
 
void setInnerLoopFinder (InnerLoopFinder *loopFinder)
 
- Public Member Functions inherited from llvm::LLVMTCEBuilder
 LLVMTCEBuilder (char &ID)
 
 LLVMTCEBuilder (const TargetMachine &tm, TTAMachine::Machine *mach, char &ID, bool functionAtATime=false)
 
virtual ~LLVMTCEBuilder ()
 
TTAProgram::Programresult ()
 
TTAProgram::InstructionfirstInstructionOfBasicBlock (const llvm::BasicBlock *bb)
 
bool isProgramUsingRestrictedPointers () const
 
virtual bool isTTATarget () const
 
void deleteDeadProcedures ()
 
void setInitialStackPointerValue (unsigned value)
 

Static Public Attributes

static char ID = -1
 
- Static Public Attributes inherited from llvm::LLVMTCEBuilder
static char ID = 0
 

Protected Member Functions

virtual unsigned spDRegNum () const
 
virtual unsigned raPortDRegNum () const
 
virtual TCEString registerFileName (unsigned llvmRegNum) const
 
virtual int registerIndex (unsigned llvmRegNum) const
 
virtual TCEString operationName (const MachineInstr &mi) const
 
virtual TTAProgram::TerminalcreateFUTerminal (const MachineOperand &) const
 
virtual TTAProgram::TerminalcreateMBBReference (const MachineOperand &mo)
 
virtual TTAProgram::TerminalcreateSymbolReference (const TCEString &symbolName)
 
virtual void createMoveNode (ProgramOperationPtr &po, std::shared_ptr< TTAProgram::Move > m, bool isDestination) override
 
- Protected Member Functions inherited from llvm::LLVMTCEBuilder
bool doInitialization (Module &M)
 
bool runOnMachineFunction (MachineFunction &MF)
 
bool doFinalization (Module &M)
 
bool hasAmbiguousASpaceRefs (const TTAProgram::Instruction &instr) const
 
void initDataSections ()
 
std::shared_ptr< TTAProgram::MovecreateMove (const MachineOperand &src, const MachineOperand &dst, TTAProgram::MoveGuard *guard)
 
const TargetMachine & targetMachine () const
 
TCEString registerName (unsigned llvmRegNum) const
 
std::string mbbName (const MachineBasicBlock &mbb)
 
const TTAMachine::HWOperationgetHWOperation (std::string opName)
 
TTAProgram::TerminalRegistercreateTerminalRegister (const std::string &rfName, int index)
 
TTAProgram::TerminalcreateTerminal (const MachineOperand &mo, int bitLimit=0)
 
std::shared_ptr< TTAProgram::MovecreateMove (TTAProgram::Terminal *src, TTAProgram::Terminal *dst, const TTAMachine::Bus &bus, TTAProgram::MoveGuard *guard=NULL)
 
void emitConstantPool (const llvm::MachineConstantPool &cp)
 
virtual TTAProgram::TerminalcreateSymbolReference (const MachineOperand &mo)
 
virtual TTAProgram::TerminalcreateProgramOperationReference (const MachineOperand &mo)
 
TTAProgram::InstructionemitInstruction (const MachineInstr *mi, TTAProgram::CodeSnippet *proc)
 
virtual TTAProgram::InstructionemitMove (const MachineInstr *mi, TTAProgram::CodeSnippet *proc, bool conditional=false, bool trueGuard=true)
 
TTAProgram::InstructionemitInlineAsm (const MachineFunction &mf, const MachineInstr *mi, TTAProgram::BasicBlock *bb, TTAProgram::InstructionReferenceManager &irm)
 
void fixProgramOperationReferences ()
 
void addLabelForProgramOperation (TCEString label, ProgramOperationPtr po)
 
void emitSPInitialization (TTAProgram::CodeSnippet &target)
 
void clearFunctionBookkeeping ()
 

Private Member Functions

bool isHotFunction (llvm::MachineFunction &mf) const
 
bool isRealInstruction (const MachineInstr &instr) const
 
bool hasRealInstructions (MachineBasicBlock::const_iterator i, const MachineBasicBlock &mbb)
 
void convertProcedureToMachineFunction (const TTAProgram::Procedure &proc, llvm::MachineFunction &mf)
 
void compileFast (ControlFlowGraph &cfg)
 
void compileOptimized (ControlFlowGraph &cfg, llvm::AliasAnalysis *llvmAA)
 
bool isExplicitReturn (const llvm::MachineInstr &mi) const
 
CopyingDelaySlotFillerdelaySlotFiller ()
 
BBSchedulerControllerscheduler ()
 
ControlFlowGraphbuildTCECFG (llvm::MachineFunction &mf)
 
void markJumpTableDestinations (llvm::MachineFunction &mf, ControlFlowGraph &cfg)
 
void fixJumpTableDestinations (llvm::MachineFunction &mf, ControlFlowGraph &cfg)
 

Private Attributes

InterPassDataipData_
 
std::set< TCEStringallParamRegs_
 
DataDependenceGraphBuilder ddgBuilder_
 
std::map< const MachineBasicBlock *, BasicBlockNode * > bbMapping_
 
std::vector< std::vector< BasicBlockNode * > > jumpTableRecord_
 
AliasAnalysisAA_
 
bool modifyMF_
 
std::map< const MachineBasicBlock *, BasicBlockNode * > skippedBBs_
 
bool delaySlotFilling_
 
BBSchedulerControllerscheduler_
 
CopyingDelaySlotFillerdsf_
 
CycleLookBackSoftwareBypasserbypasser_
 
InnerLoopFinderloopFinder_
 

Additional Inherited Members

- Static Protected Member Functions inherited from llvm::LLVMTCEBuilder
static bool isInlineAsm (const MachineInstr &instr)
 
- Protected Attributes inherited from llvm::LLVMTCEBuilder
std::map< std::string, TTAProgram::Instruction * > codeLabels_
 Code labels. More...
 
TTAMachine::Machinemach_
 Machine for building the program. More...
 
const llvm::TargetMachine * tm_
 Target machine description. More...
 
llvm::Mangler * mang_
 Mangler for mangling label strings. More...
 
TTAProgram::Programprog_
 Current program being built. More...
 
std::set< std::string > opset_
 The operations supported by the current target machine. More...
 
bool functionAtATime_
 
PRegionMarkerAnalyzerpregions_
 
int spillMoveCount_
 
unsigned initialStackPointerValue_
 
MachineFrameInfo * curFrameInfo_
 
LLVMTCECmdLineOptionsoptions_ = nullptr
 The compiler options. More...
 

Detailed Description

Definition at line 60 of file LLVMTCEIRBuilder.hh.

Constructor & Destructor Documentation

◆ LLVMTCEIRBuilder()

llvm::LLVMTCEIRBuilder::LLVMTCEIRBuilder ( const TargetMachine &  tm,
TTAMachine::Machine mach,
InterPassData ipd,
AliasAnalysis AA,
bool  functionAtATime = false,
bool  modifyMF = false 
)

Definition at line 103 of file LLVMTCEIRBuilder.cc.

106  :
107  LLVMTCEBuilder(tm, mach, ID, functionAtATime), ipData_(&ipd),
108  ddgBuilder_(ipd), AA_(AA), modifyMF_(modifyMF),
109  scheduler_(NULL), dsf_(NULL),
110  bypasser_(NULL), loopFinder_(NULL) {
112 
113  if (functionAtATime_) {
115  mach->functionUnitNavigator();
116 
117  // the supported operation set
118  for (int i = 0; i < fuNav.count(); i++) {
119  const TTAMachine::FunctionUnit& fu = *fuNav.item(i);
120  for (int o = 0; o < fu.operationCount(); o++) {
121  opset_.insert(
123  }
124  }
125 
126  }
128 }

References TTAMachine::Machine::Navigator< ComponentType >::count(), delaySlotFilling_, LLVMTCECmdLineOptions::disableDelaySlotFiller(), RegisterCopyAdder::findTempRegisters(), llvm::LLVMTCEBuilder::functionAtATime_, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::HWOperation::name(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), llvm::LLVMTCEBuilder::opset_, llvm::LLVMTCEBuilder::options_, and StringTools::stringToLower().

Here is the call graph for this function:

◆ ~LLVMTCEIRBuilder()

llvm::LLVMTCEIRBuilder::~LLVMTCEIRBuilder ( )
virtual

Definition at line 1285 of file LLVMTCEIRBuilder.cc.

1285  {
1286 
1288  if (Application::cmdLineOptions() != NULL) {
1289  options =
1290  dynamic_cast<LLVMTCECmdLineOptions*>(
1293 // PostpassOperandSharer::printStats();
1294 // CycleLookBackSoftwareBypasser::printStats();
1295  }
1296  }
1297 
1298  delete scheduler_;
1299  delete bypasser_;
1300  delete dsf_;
1301 }

References bypasser_, Application::cmdLineOptions(), dsf_, CmdLineOptions::isVerboseSwitchDefined(), options, and scheduler_.

Here is the call graph for this function:

Member Function Documentation

◆ buildTCECFG()

ControlFlowGraph * llvm::LLVMTCEIRBuilder::buildTCECFG ( llvm::MachineFunction &  mf)
private

Definition at line 273 of file LLVMTCEIRBuilder.cc.

273  {
274 
275  SmallString<256> Buffer;
276  mang_->getNameWithPrefix(Buffer, &mf.getFunction(), false);
277  TCEString fnName(Buffer.c_str());
278 
279  ControlFlowGraph* cfg = new ControlFlowGraph(fnName, prog_);
280 
281  bbMapping_.clear();
282  skippedBBs_.clear();
283 
284  // TODO: these maps/sets with pointer keys are possible source of
285  // indeterminism.
286  std::set<const MachineBasicBlock*> endingCallBBs;
287  std::set<const MachineBasicBlock*> endingCondJumpBBs;
288  std::set<const MachineBasicBlock*> endingUncondJumpBBs;
289  std::set<const MachineBasicBlock*> endingInlineAsmBBs;
290  std::map<const BasicBlockNode*, BasicBlockNode*> callSuccs;
291  std::map<const BasicBlockNode*, const MachineBasicBlock*> condJumpSucc;
292  std::map<const BasicBlockNode*, BasicBlockNode*> ftSuccs;
293  // This holds BB -> inlineAsmBB mapping.
294  std::map<const BasicBlockNode*, BasicBlockNode*> ftSuccsToInlineAsm;
295  // This holds inlineAsmBB -> BB and inlineAsmBB -> inlineAsmBB mapping.
296  std::map<const BasicBlockNode*, BasicBlockNode*> inlineAsmSuccs;
297  std::set<const MachineBasicBlock*> emptyMBBs;
298  std::set<const MachineBasicBlock*> hwloopMBBs;
299  std::map<const BasicBlockNode*, bool> bbPredicates;
300  ControlFlowGraph::NodeSet returningBBs;
301 
302  BasicBlockNode* entry = new BasicBlockNode(0, 0, true);
303  cfg->addNode(*entry);
304  bool firstInsOfProc = true;
305 
307  hwloopMBBs.clear();
308 
309  // 1st loop create all BB's. do not fill them yet.
310  for (MachineFunction::const_iterator i = mf.begin(); i != mf.end(); i++) {
311  const MachineBasicBlock& mbb = *i;
312  //TODO: what does the parameter do? start address?
314 
315  // this doesn't seem robust: it assumes _start is added to
316  // the program first and the BBs added in their program
317  // order
318  bool firstBBofTheProgram =
319  !functionAtATime_ && prog_->procedureCount() == 1 &&
320  cfg->nodeCount() == 1;
321  // first BB of the program
322  if (firstBBofTheProgram) {
324  }
325 
326  TCEString bbName = mbbName(mbb);
327  BasicBlockNode* bbn = new BasicBlockNode(*bb);
328  bbn->setBBOwnership(true);
329 
330  // if the basic block is detected as an inner loop basic block,
331  // transform the info to the built TCE CFG
332  if (loopFinder_ != NULL) {
335 
336  InnerLoopFinder::InnerLoopInfoIndex::const_iterator loopInfoI =
337  loopInfos.find(mbb.getBasicBlock());
338  if (loopInfoI != loopInfos.end()) {
340  (*loopInfoI).second;
341  bb->setInInnerLoop();
342  if (loopInfo.isTripCountKnown()) {
343  bb->setTripCount(loopInfo.tripCount());
344  }
345  }
346  }
347 
348  bool newMBB = true;
349  bool newBB = true;
350  unsigned realInstructionCount = 0;
351  bool lastInstrWasInlineAsm = false;
352 
353  // 1st loop: create all BB's. Do not fill them with instructions.
354  for (MachineBasicBlock::const_iterator j = mbb.begin();
355  j != mbb.end(); j++) {
356 
357  if (!isRealInstruction(*j)) {
358  continue;
359  }
360 
361  // Put all instances of inline asm blocks to own BB.
362  // Split BB if there is instructions already added to BB.
363  if (isInlineAsm(*j)) {
364  // TODO check if inline asm does not have any instructions?
365  // Split BB before the inline asm unless first instruction in
366  // BB.
367  if (realInstructionCount > 0 && !lastInstrWasInlineAsm) {
368  bb = new TTAProgram::BasicBlock(0);
369  BasicBlockNode* succBBN = new BasicBlockNode(*bb);
370  ftSuccsToInlineAsm[bbn] = succBBN;
371  bbn = succBBN;
372  newBB = true;
373  }
374  lastInstrWasInlineAsm = true;
375  }
376 
377  if (newBB) {
378  realInstructionCount = 0;
379  newBB = false;
380  cfg->addNode(*bbn);
381  if (firstInsOfProc) {
382  ControlFlowEdge* edge = new ControlFlowEdge;
383  cfg->connectNodes(*entry, *bbn, *edge);
384  firstInsOfProc = false;
385  }
386 
387  if (newMBB) {
388  newMBB = false;
389  bbMapping_[&(mbb)] = bbn;
390  for (std::set<const MachineBasicBlock*>::iterator k =
391  emptyMBBs.begin(); k != emptyMBBs.end(); k++) {
392  skippedBBs_[*k] = bbn;
393  }
394  emptyMBBs.clear();
395  }
396  }
397  realInstructionCount++;
398 
399  // Put all instances of INLINEASM nodes to own BB.
400  // This one "closes" inline asm BB and creates new BB for rest
401  // of the instructions or next inline asm block.
402  if (isInlineAsm(*j)) {
403  // New BB after inline asm.
404  MachineBasicBlock::const_iterator afterInlineAsm = j;
405  ++afterInlineAsm;
406  if (hasRealInstructions(afterInlineAsm, mbb)) {
407  bb = new TTAProgram::BasicBlock(0);
408  BasicBlockNode* succBBN = new BasicBlockNode(*bb);
409  inlineAsmSuccs[bbn] = succBBN;
410  bbn = succBBN;
411  newBB = true;
412  } else {
413  endingInlineAsmBBs.insert(&mbb);
414  }
415  continue;
416  }
417  lastInstrWasInlineAsm = false;
418 
419  if (j->getDesc().isCall() || isExplicitReturn(*j)) {
420  if (j->getDesc().isCall() && j->getOperand(0).isGlobal()) {
421  // If it's a direct call (not via function pointer),
422  // check that the called function is defined. At this
423  // point we should have a fully linked program.
424  const Function* callee =
425  dyn_cast<Function>(j->getOperand(0).getGlobal());
426  assert(callee != NULL);
427  if (callee->size() == 0) {
428  TCEString errorMsg =
429  "error: call to undefined function '";
430  errorMsg << callee->getName().str() << "'.";
431  throw CompileError(
432  __FILE__, __LINE__, __func__, errorMsg);
433  }
434  }
435  // if last ins of bb is call, no need to create new bb.
436  if (&(*j) == &(mbb.back())) {
437  endingCallBBs.insert(&(*i));
438  } else {
439  MachineBasicBlock::const_iterator afterCall = j;
440  ++afterCall;
441  if (!hasRealInstructions(afterCall, mbb)) {
442  endingCallBBs.insert(&(*i));
443  } else {
444  // create a new BB for code after the call
445  bb = new TTAProgram::BasicBlock(0);
446  BasicBlockNode* succBBN = new BasicBlockNode(*bb);
447  succBBN->setBBOwnership(true);
448  callSuccs[bbn] = succBBN;
449  bbn = succBBN;
450  newBB = true;
451  }
452  }
453  continue;
454  }
455  // also need to split BB on cond branch.
456  // LLVM BB may contain 2 branches.
457  if (j->getDesc().isBranch()) {
458  TCEString opName = operationName(*j);
459  bool pred = false;
460  if (j->getDesc().isConditionalBranch()) {
461  if (opName == "?jump") pred = true;
462  if (opName == "BNZ") pred = true;
463  if (opName == "BNZ1") pred = true;
464  // TODO: Should this not have BZ/BZ1?
465  if (opName == "BEQ") pred = true;
466  if (opName == "BNE") pred = true;
467  if (opName == "BGT") pred = true;
468  if (opName == "BGTU") pred = true;
469  if (opName == "BLT") pred = true;
470  if (opName == "BLTU") pred = true;
471  if (opName == "BLE") pred = true;
472  if (opName == "BLEU") pred = true;
473  if (opName == "BGE") pred = true;
474  if (opName == "BGEU") pred = true;
475 
476  // TODO: what is the meaning of this?
477  if (opName.find("+") != std::string::npos) pred = true;
478  bbPredicates[bbn] = pred;
479  const MachineOperand& mo = j->getOperand(j->getNumOperands()-1);
480  assert(mo.isMBB());
481  condJumpSucc[bbn] = mo.getMBB();
482 
483  if (&(*j) == &(mbb.back())) {
484  endingCondJumpBBs.insert(&(*i));
485  } else {
486  if (!hasRealInstructions(j, mbb)) {
487  endingCondJumpBBs.insert(&(*i));
488  } else {
489  // create a new BB for the code after the conditional branch.
490  // this should only contain one uncond jump.
491  bb = new TTAProgram::BasicBlock(0);
492  BasicBlockNode* succBBN = new BasicBlockNode(*bb);
493  succBBN->setBBOwnership(true);
494  ftSuccs[bbn] = succBBN;
495  bbn = succBBN;
496  newBB = true;
497  }
498  }
499  } else {
500  // has to be uncond jump, and last ins of bb.
501  if (&(*j) != &(mbb.back())) {
502  Application::logStream() << " not at the end of ";
503  if (j->getDesc().isBranch())
504  Application::logStream() << " is branch";
505  abortWithError("Jump was not last ins of BB.");
506  }
507  endingUncondJumpBBs.insert(&(*i));
508  }
509  continue;
510  }
511  } // for loop
512  if (newMBB) {
513  assert(newBB);
514  emptyMBBs.insert(&mbb);
515  }
516  if (newBB) {
517  assert(firstBBofTheProgram || bb->instructionCount() == 0);
518  delete bbn;
519  }
520  }
521 
523  if (functionAtATime_) {
525  } else {
527  }
528 
529  // 2nd loop: create all instructions inside BB's.
530  // this can only come after the first loop so that BB's have
531  // already been generated.
532  for (MachineFunction::const_iterator i = mf.begin(); i != mf.end(); i++) {
533  const MachineBasicBlock& mbb = *i;
534 
535  BasicBlockNode* bbn = NULL;
536  std::map<const MachineBasicBlock*, BasicBlockNode*>::iterator
537  bbMapIter = bbMapping_.find(&mbb);
538  if (bbMapIter == bbMapping_.end()) {
539  continue;
540  } else {
541  bbn = bbMapIter->second;
542  }
543  TTAProgram::BasicBlock* bb = &bbn->basicBlock();
544 
545  /* If this is non-empty, the ProgramOperation of the next
546  instruction should be indexed with the given label. */
547  TCEString nextLabel = "";
548  for (MachineBasicBlock::const_iterator j = mbb.begin();
549  j != mbb.end(); j++) {
550 
551  if (!isTTATarget() &&
552  (operationName(*j) == "HBR_LABEL" ||
553  operationName(*j) == "PROLOG_LABEL")) {
554 
555  /*
556  FIXME: this code fails when there are multiple labels
557  pointing to the same instruction. Only the last label
558  will be indexed. */
559  assert(nextLabel == "");
560 
561  nextLabel = j->getOperand(0).getMCSymbol()->getName().str();
562  continue;
563  }
564 
565  if (isInlineAsm(*j)) {
566  if (AssocTools::containsKey(ftSuccsToInlineAsm, bbn)) {
567  bbn = ftSuccsToInlineAsm[bbn];
568  bb = &bbn->basicBlock();
569  }
570  emitInlineAsm(mf, &*j, bb, *irm);
571  bbn->setScheduled(true);
572  if (AssocTools::containsKey(inlineAsmSuccs, bbn)) {
573  bbn = inlineAsmSuccs[bbn];
574  bb = &bbn->basicBlock();
575  }
576  continue;
577  }
578 
579  TTAProgram::Instruction* instr = NULL;
580  instr = emitInstruction(&*j, bb);
581 
582  if (instr == NULL) {
583  continue;
584  }
585 
586  if (nextLabel != "") {
588  dynamic_cast<TTAProgram::TerminalFUPort&>(
589  instr->move(0).destination());
591  nextLabel = "";
592  }
593 
594  // basic blocks that contain return instruction will have jump
595  // edge to exit node in cfg, not callpass edge.
596  if (j->getDesc().isReturn()) {
597  returningBBs.insert(bbn);
598  }
599 
600  // if a call or an explicit return instruction,
601  // or an unconditional jump from inline asm, switch to the
602  // next TCE bb (in callsucc chain) that was created in the
603  // previous loop
604  if ((j->getDesc().isCall() || isExplicitReturn(*j) ||
605  (!j->getDesc().isBranch() && instr->hasControlFlowMove())) &&
606  &(*j) != &(mbb.back())) {
607  if (operationName(*j) == "hwloop") {
608  if (j->getNextNode() != nullptr &&
609  !j->getNextNode()->isBranch()) {
610  mbb.dump();
611  assert(false && "HWLOOP is not terminator in BB");
612  }
613  }
614  if (!AssocTools::containsKey(callSuccs, bbn)) {
615  // the call ends the basic block, after this only at most
616  // "non real" instructions (such as debug metadata), which
617  // we can simply ignore
618  break;
619  }
620  bbn = callSuccs[bbn];
621  bb = &bbn->basicBlock();
622  }
623 
624  // conditional jump or indirect jump that is not last ins splits
625  // a bb.
626  if (j->getDesc().isBranch() &&
627  &(*j) != &(mbb.back())) {
628  bbn = ftSuccs[bbn];
629  bb = &bbn->basicBlock();
630  }
631  if (operationName(*j) == "hwloop") {
632  assert(mbb.succ_size() == 1 &&
633  "HWLoop pre-header should have one succ MBB");
634 
635  // Validate loop pattern (one fall-through and one jump back).
636  auto loopBody = *mbb.succ_begin();
637  auto it = find(
638  loopBody->succ_begin(), loopBody->succ_end(), loopBody);
639  assert((loopBody->succ_size() == 2 &&
640  it != loopBody->succ_end()) &&
641  "HWLoop body should have one loop-back and exit edge");
642 
643  hwloopMBBs.insert(*mbb.succ_begin());
644  continue;
645  }
646  }
647 
648  assert(bb->instructionCount() != 0);
649  }
650 
651  // 3rd loop: create edges?
652  for (MachineFunction::const_iterator i = mf.begin(); i != mf.end(); i++) {
653  const MachineBasicBlock& mbb = *i;
654 
655  const BasicBlockNode* bbn = NULL;
656  std::map<const MachineBasicBlock*,BasicBlockNode*>::iterator
657  bbMapIter = bbMapping_.find(&mbb);
658  if (bbMapIter == bbMapping_.end()) {
659  continue;
660  } else {
661  bbn = bbMapIter->second;
662  }
663 
664  // is last ins a call?
665  bool callPass = AssocTools::containsKey(endingCallBBs, &mbb);
666  bool ftPass = AssocTools::containsKey(endingCondJumpBBs, &mbb);
667  bool hasUncondJump =
668  AssocTools::containsKey(endingUncondJumpBBs, &mbb);
669 
670  const MachineBasicBlock* jumpSucc = condJumpSucc[bbn];
671 
672  while (true) {
673  std::map<const BasicBlockNode*, BasicBlockNode*>::iterator j =
674  callSuccs.find(bbn);
675  std::map<const BasicBlockNode*, BasicBlockNode*>::iterator k =
676  ftSuccs.find(bbn);
677  std::map<const BasicBlockNode*, BasicBlockNode*>::iterator l =
678  inlineAsmSuccs.find(bbn);
679  std::map<const BasicBlockNode*, BasicBlockNode*>::iterator m =
680  ftSuccsToInlineAsm.find(bbn);
681 
682  // BB should not have 2+ fallthrough successors.
683  assert(((j != callSuccs.end())
684  + (k != ftSuccs.end())
685  + (l != inlineAsmSuccs.end())
686  + (m != ftSuccsToInlineAsm.end())) < 2);
687 
688  if (j != callSuccs.end()) {
689  const BasicBlockNode* callSucc = j->second;
690  assert(callSucc != NULL);
691  ControlFlowEdge* cfe = new ControlFlowEdge(
694  cfg->connectNodes(*bbn, *callSucc, *cfe);
695  bbn = callSucc;
696  jumpSucc = condJumpSucc[bbn];
697  continue;
698  }
699 
700  // BB has conditional jump which is not last ins.
701  if (k != ftSuccs.end()) {
702  assert(jumpSucc != NULL);
703  assert(MapTools::containsKey(bbPredicates,bbn));
704  ControlFlowEdge* cfe = new ControlFlowEdge(
705  bbPredicates[bbn] == true ?
709  if (MapTools::containsKey(bbMapping_, jumpSucc)) {
710  cfg->connectNodes(*bbn, *bbMapping_[jumpSucc], *cfe);
711  } else {
712  cfg->connectNodes(*bbn, *skippedBBs_[jumpSucc], *cfe);
713  }
714 
715  const BasicBlockNode* ftSucc = k->second;
716  assert(ftSucc != NULL);
717  cfe = new ControlFlowEdge(
718  bbPredicates[bbn] == true ?
722  cfg->connectNodes(*bbn, *ftSucc, *cfe);
723  bbn = ftSucc;
724  continue;
725  }
726 
727  if (l != inlineAsmSuccs.end()) {
728  const BasicBlockNode* inlineAsmSucc = l->second;
729  assert(inlineAsmSucc);
730  ControlFlowEdge* cfe = new ControlFlowEdge(
733  cfg->connectNodes(*bbn, *inlineAsmSucc, *cfe);
734  bbn = inlineAsmSucc;
735  jumpSucc = condJumpSucc[bbn];
736  continue;
737  }
738 
739  if (m != ftSuccsToInlineAsm.end()) {
740  const BasicBlockNode* inlineAsmPred = m->second;
741  assert(inlineAsmPred);
742  ControlFlowEdge* cfe = new ControlFlowEdge(
745  cfg->connectNodes(*bbn, *inlineAsmPred, *cfe);
746  bbn = inlineAsmPred;
747  jumpSucc = condJumpSucc[bbn];
748  continue;
749  }
750 
751  break;
752  }
753 
754  for (MachineBasicBlock::const_succ_iterator si = mbb.succ_begin();
755  si != mbb.succ_end(); si++) {
756  const MachineBasicBlock* succ = *si;
757 
758  BasicBlockNode* succBBN = NULL;
759  std::map<const MachineBasicBlock*,BasicBlockNode*>::iterator
760  bbMapIter = bbMapping_.find(succ);
761  if (bbMapIter == bbMapping_.end()) {
762  succBBN = skippedBBs_[succ];
763  } else {
764  succBBN = bbMapIter->second;
765  }
766 
767  // TODO: type of the edge
768  ControlFlowEdge* cfe = NULL;
769  // if last ins of bb was call, cheyte call-pass edge.
770  if (callPass) {
771  cfe = new ControlFlowEdge(
774  } else {
775  // do we have conditional jump?
776  if (jumpSucc != NULL) {
777  // fall-through is a pass to next mbb.
778  if (ftPass) {
779  assert(MapTools::containsKey(bbPredicates,bbn));
780  if (succ == jumpSucc) {
781  cfe = new ControlFlowEdge(
782  bbPredicates[bbn] == true ?
786  } else {
787  cfe = new ControlFlowEdge(
788  bbPredicates[bbn] == true ?
792  }
793  } else {
794  // split a bb. ft edges created earlier.
795  // cond.jump edge also created earlier.
796  // just needs to add the uncond jump edge.
797 
798  if (succ == jumpSucc) {
799  continue;
800  }
801  cfe = new ControlFlowEdge;
802  }
803  } else { // no conditional jump. ft to next bb.
804  // Insert hwloop jumps
805  if ((hwloopMBBs.find(&mbb) != hwloopMBBs.end()) &&
806  (&mbb == succ)) {
807  // Loop jump to same BB
808  cfe = new ControlFlowEdge(
811  succBBN->setHWLoop();
812  } else if (hasUncondJump) {
813  cfe = new ControlFlowEdge;
814  } else {
815  // no unconditional jump to next bb. limits bb
816  // reordering
817  cfe = new ControlFlowEdge(
820  }
821  }
822  }
823  cfg->connectNodes(*bbn, *succBBN, *cfe);
824  }
825  }
826 
828  // add back edge properties.
829  cfg->detectBackEdges();
830 
831  /* Split BBs with calls inside. These can be produced
832  from expanding the pseudo asm blocks. Currently at least
833  the call_global_[cd]tors expands to multiple calls to the
834  global object constructors and destructors. */
837 
838  // create jumps to exit node
839  cfg->addExit(returningBBs);
840 
841  delete pregions_;
842  pregions_ = NULL;
843 
844  // add back edge properties.
845  cfg->detectBackEdges();
846  //cfg->writeToDotFile(fnName + ".cfg.dot");
847  return cfg;
848 }

References __func__, abortWithError, ControlFlowGraph::addExit(), llvm::LLVMTCEBuilder::addLabelForProgramOperation(), BoostGraph< GraphNode, GraphEdge >::addNode(), assert, BasicBlockNode::basicBlock(), bbMapping_, ControlFlowEdge::CFLOW_EDGE_CALL, ControlFlowEdge::CFLOW_EDGE_FALLTHROUGH, ControlFlowEdge::CFLOW_EDGE_FALSE, ControlFlowEdge::CFLOW_EDGE_JUMP, ControlFlowEdge::CFLOW_EDGE_NORMAL, ControlFlowEdge::CFLOW_EDGE_TRUE, BoostGraph< GraphNode, GraphEdge >::connectNodes(), MapTools::containsKey(), AssocTools::containsKey(), TTAProgram::Move::destination(), ControlFlowGraph::detectBackEdges(), llvm::LLVMTCEBuilder::emitInlineAsm(), llvm::LLVMTCEBuilder::emitInstruction(), llvm::LLVMTCEBuilder::emitSPInitialization(), llvm::LLVMTCEBuilder::fixProgramOperationReferences(), llvm::LLVMTCEBuilder::functionAtATime_, TTAProgram::Instruction::hasControlFlowMove(), hasRealInstructions(), InnerLoopFinder::innerLoopInfo(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Program::instructionReferenceManager(), isExplicitReturn(), llvm::LLVMTCEBuilder::isInlineAsm(), isRealInstruction(), InnerLoopFinder::InnerLoopInfo::isTripCountKnown(), llvm::LLVMTCEBuilder::isTTATarget(), Application::logStream(), loopFinder_, llvm::LLVMTCEBuilder::mang_, llvm::LLVMTCEBuilder::mbbName(), TTAProgram::Instruction::move(), BoostGraph< GraphNode, GraphEdge >::nodeCount(), operationName(), llvm::LLVMTCEBuilder::pregions_, TTAProgram::Program::procedureCount(), llvm::LLVMTCEBuilder::prog_, TTAProgram::TerminalFUPort::programOperation(), BasicBlockNode::setBBOwnership(), BasicBlockNode::setHWLoop(), TTAProgram::BasicBlock::setInInnerLoop(), ControlFlowGraph::setInstructionReferenceManager(), BasicBlockNode::setScheduled(), TTAProgram::BasicBlock::setTripCount(), skippedBBs_, ControlFlowGraph::splitBasicBlocksWithCallsAndRefs(), and InnerLoopFinder::InnerLoopInfo::tripCount().

Referenced by writeMachineFunction().

Here is the call graph for this function:

◆ compileFast()

void llvm::LLVMTCEIRBuilder::compileFast ( ControlFlowGraph cfg)
private

Definition at line 883 of file LLVMTCEIRBuilder.cc.

883  {
885  sched.handleControlFlowGraph(cfg, *mach_);
886 }

References ControlFlowGraphPass::handleControlFlowGraph(), ipData_, and llvm::LLVMTCEBuilder::mach_.

Referenced by writeMachineFunction().

Here is the call graph for this function:

◆ compileOptimized()

void llvm::LLVMTCEIRBuilder::compileOptimized ( ControlFlowGraph cfg,
llvm::AliasAnalysis llvmAA 
)
private

Definition at line 911 of file LLVMTCEIRBuilder.cc.

913  {
914 
915  SimpleIfConverter ifConverter(*ipData_, *mach_);
916  ifConverter.handleControlFlowGraph(cfg, *mach_);
917  Peel2BBLoops peel2bbLoops(*ipData_, *mach_);
918  peel2bbLoops.handleControlFlowGraph(cfg, *mach_);
919 
920 #if 0
922  dynamic_cast<SchedulerCmdLineOptions*>(
924 #endif
925 
926  // TODO: on trunk single bb loop(swp), last param true(rr, threading)
928  cfg,
930  NULL, true, true, llvmAA);
931 
932  TCEString fnName = cfg.name();
933 #ifdef WRITE_DDG_DOTS
934  ddg->writeToDotFile(cfg.name() + "_ddg1.dot");
935 #endif
936  cfg.optimizeBBOrdering(true, cfg.instructionReferenceManager(), ddg);
937 
938  PreOptimizer preOpt(*ipData_);
939  preOpt.handleCFGDDG(cfg, *ddg);
940 
941  cfg.optimizeBBOrdering(true, cfg.instructionReferenceManager(), ddg);
942 
943 #ifdef WRITE_DDG_DOTS
944  ddg->writeToDotFile(cfg.name() + "_ddg2.dot");
945 #endif
946 
947  if (!modifyMF_) {
948  // BBReferences converted to Inst references
949  // break LLVM->POM ->LLVM chain because we
950  // need the BB refs to rebuild the LLVM CFG
952  }
953 
954  if (delaySlotFilling_)
955  delaySlotFiller().initialize(cfg, *ddg, *mach_);
956  scheduler().handleCFGDDG(cfg, ddg, *mach_ );
957 
958 #ifdef WRITE_CFG_DOTS
959  fnName = cfg.name();
960  cfg.writeToDotFile(fnName + "_cfg2.dot");
961 #endif
962 #ifdef WRITE_DDG_DOTS
963  ddg->writeToDotFile(fnName + "_ddg3.dot");
964 #endif
965 
966  if (!functionAtATime_) {
967  // TODO: make DS filler work with FAAT
968  // sched yield emitter does not work with the delay slot filler
969 
970  if (delaySlotFilling_) {
971  delaySlotFiller().fillDelaySlots(cfg, *ddg, *mach_);
972  }
973  }
974 
975 #ifdef WRITE_CFG_DOTS
976  cfg.writeToDotFile(fnName + "_cfg3.dot");
977 #endif
978 
980  ppos.handleControlFlowGraph(cfg, *mach_);
981 
982 #ifdef WRITE_DDG_DOTS
983  ddg->writeToDotFile(fnName + "_ddg4.dot");
984 #endif
985 
986 #ifdef WRITE_CFG_DOTS
987  cfg.writeToDotFile(fnName + "_cfg4.dot");
988 #endif
989  delete ddg;
990 }

References DataDependenceGraphBuilder::build(), Application::cmdLineOptions(), ControlFlowGraph::convertBBRefsToInstRefs(), ddgBuilder_, delaySlotFiller(), delaySlotFilling_, CopyingDelaySlotFiller::fillDelaySlots(), llvm::LLVMTCEBuilder::functionAtATime_, PreOptimizer::handleCFGDDG(), BBSchedulerController::handleCFGDDG(), Peel2BBLoops::handleControlFlowGraph(), SimpleIfConverter::handleControlFlowGraph(), ControlFlowGraphPass::handleControlFlowGraph(), CopyingDelaySlotFiller::initialize(), ControlFlowGraph::instructionReferenceManager(), DataDependenceGraph::INTRA_BB_ANTIDEPS, ipData_, llvm::LLVMTCEBuilder::mach_, modifyMF_, BoostGraph< GraphNode, GraphEdge >::name(), ControlFlowGraph::optimizeBBOrdering(), options, scheduler(), and GraphBase< GraphNode, GraphEdge >::writeToDotFile().

Referenced by writeMachineFunction().

Here is the call graph for this function:

◆ convertProcedureToMachineFunction()

void llvm::LLVMTCEIRBuilder::convertProcedureToMachineFunction ( const TTAProgram::Procedure proc,
llvm::MachineFunction &  mf 
)
private

◆ createFUTerminal()

virtual TTAProgram::Terminal* llvm::LLVMTCEIRBuilder::createFUTerminal ( const MachineOperand &  ) const
inlineprotectedvirtual

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 114 of file LLVMTCEIRBuilder.hh.

115  {
116  // no FU terminals in the RISC-style backend, always through GPRs
117  return NULL;
118  }

◆ createMBBReference()

TTAProgram::Terminal * llvm::LLVMTCEIRBuilder::createMBBReference ( const MachineOperand &  mo)
protectedvirtual

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 994 of file LLVMTCEIRBuilder.cc.

994  {
995  if (mo.isBlockAddress()) {
996  TTAProgram::BasicBlock* bb = NULL;
997  const MachineBasicBlock* mbb = NULL;
998 
999  std::map<const MachineBasicBlock*, BasicBlockNode*>::iterator i =
1000  bbMapping_.begin();
1001  for (; i != bbMapping_.end(); ++i) {
1002  const MachineBasicBlock* mbbt = i->first;
1003  TTAProgram::BasicBlock& bbt = i->second->basicBlock();
1004  if (mbbt->getBasicBlock() == mo.getBlockAddress()->getBasicBlock()) {
1005  if (bb != NULL) {
1006 #if 0
1008  << "LLVMTCEIRBuilder: found multiple potential BB references."
1009  << std::endl;
1011  << "first: " << bb->toString() << std::endl;
1013  << "another: " << bbt.toString() << std::endl;
1014 #endif
1015  // in case the original BB is split to multiple machine BBs,
1016  // refer to the first one in the chain because the original
1017  // BB reference could not have referred to middle of an BB
1018  if (mbbt->isSuccessor(mbb)) {
1019  bb = &bbt;
1020  mbb = mbbt;
1021  }
1022  } else {
1023  bb = &bbt;
1024  mbb = mbbt;
1025  }
1026  }
1027  }
1028 
1029  i = skippedBBs_.begin();
1030  for (; i != skippedBBs_.end(); ++i) {
1031  const MachineBasicBlock* mbbt = i->first;
1032  TTAProgram::BasicBlock& bbt = i->second->basicBlock();
1033  if (mbbt->getBasicBlock() == mo.getBlockAddress()->getBasicBlock()) {
1034  assert (bb == NULL);
1035  bb = &bbt;
1036  }
1037  }
1038 
1039  if (bb == NULL) {
1041  << "Could not find referred MBB matching the referred BB:"
1042  << std::endl;
1043  assert (bb != NULL);
1044  }
1046  }
1047  MachineBasicBlock* mbb = mo.getMBB();
1048  std::map<const MachineBasicBlock*,BasicBlockNode*>::iterator i =
1049  bbMapping_.find(mbb);
1050 
1051  if (i == bbMapping_.end()) {
1052  std::map<const MachineBasicBlock*, BasicBlockNode*>::iterator j =
1053  skippedBBs_.find(mbb);
1054  if (j == skippedBBs_.end()) {
1055  assert(j != skippedBBs_.end());
1056  }
1058  j->second->basicBlock());
1059  }
1060 
1062  i->second->basicBlock());
1063 }

References assert, bbMapping_, Application::logStream(), skippedBBs_, and TTAProgram::CodeSnippet::toString().

Here is the call graph for this function:

◆ createMoveNode()

void llvm::LLVMTCEIRBuilder::createMoveNode ( ProgramOperationPtr po,
std::shared_ptr< TTAProgram::Move m,
bool  isDestination 
)
overrideprotectedvirtual

Create MoveNode and attach it to TerminalFUs. The MoveNode will be owned by DDG.

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 1264 of file LLVMTCEIRBuilder.cc.

1267  {
1268  MoveNode* mn = new MoveNode(m);
1269 
1270  if (isDestination) {
1271  po->addInputNode(*mn);
1274  dynamic_cast<TTAProgram::TerminalFUPort&>(m->destination());
1275  term.setProgramOperation(po);
1276  } else {
1277  po->addOutputNode(*mn);
1278  mn->setSourceOperationPtr(po);
1280  dynamic_cast<TTAProgram::TerminalFUPort&>(m->source());
1281  term.setProgramOperation(po);
1282  }
1283 }

References MoveNode::addDestinationOperationPtr(), TTAProgram::Move::destination(), TTAProgram::TerminalFUPort::setProgramOperation(), MoveNode::setSourceOperationPtr(), and TTAProgram::Move::source().

Here is the call graph for this function:

◆ createSymbolReference()

TTAProgram::Terminal * llvm::LLVMTCEIRBuilder::createSymbolReference ( const TCEString symbolName)
protectedvirtual

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 1066 of file LLVMTCEIRBuilder.cc.

1066  {
1067  return new TTAProgram::TerminalSymbolReference(symbolName);
1068 }

◆ delaySlotFiller()

CopyingDelaySlotFiller & llvm::LLVMTCEIRBuilder::delaySlotFiller ( )
private

Definition at line 904 of file LLVMTCEIRBuilder.cc.

904  {
905  if (dsf_ == NULL)
907  return *dsf_;
908 }

References dsf_.

Referenced by compileOptimized(), and scheduler().

◆ doFinalization()

bool llvm::LLVMTCEIRBuilder::doFinalization ( Module &  m)
virtual

Definition at line 1124 of file LLVMTCEIRBuilder.cc.

1124  {
1125 
1126  // Catch the exception here as throwing exceptions
1127  // through library boundaries is flaky. It crashes
1128  // on x86-32 Linux at least. See:
1129  // https://bugs.launchpad.net/tce/+bug/894816
1132 
1133  // The Program can now have a bunch of unscheduled Procedures
1134  // created by the SchedYieldEmitter. Schedule them now.
1135  for (int p = 0; p < prog_->procedureCount(); ++p) {
1136  TTAProgram::Procedure& procedure = prog_->procedure(p);
1137  // assume all functions that were not in the original LLVM
1138  // module are new ones that need to be scheduled
1139 
1140  if (m.getFunction(procedure.name()) != NULL) continue;
1141  scheduler().handleProcedure(procedure, *mach_);
1142  }
1143  return false;
1144 }

References TTAProgram::Program::convertSymbolRefsToInsRefs(), llvm::LLVMTCEBuilder::doFinalization(), EXIT_IF_THROWS, BBSchedulerController::handleProcedure(), llvm::LLVMTCEBuilder::mach_, TTAProgram::Procedure::name(), TTAProgram::Program::procedure(), TTAProgram::Program::procedureCount(), llvm::LLVMTCEBuilder::prog_, and scheduler().

Here is the call graph for this function:

◆ doInitialization()

bool llvm::LLVMTCEIRBuilder::doInitialization ( Module &  m)
virtual

Definition at line 1118 of file LLVMTCEIRBuilder.cc.

1118  {
1120  return false;
1121 }

References llvm::LLVMTCEBuilder::doInitialization().

Referenced by llvm::LLVMTCEScheduler::runOnMachineFunction().

Here is the call graph for this function:

◆ emitSPInitialization()

virtual void llvm::LLVMTCEIRBuilder::emitSPInitialization ( )
inlinevirtual

Emit stack pointer initialization move to the begining of the program.

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 76 of file LLVMTCEIRBuilder.hh.

76 {}

◆ fixJumpTableDestinations()

void llvm::LLVMTCEIRBuilder::fixJumpTableDestinations ( llvm::MachineFunction &  mf,
ControlFlowGraph cfg 
)
private

Definition at line 1234 of file LLVMTCEIRBuilder.cc.

1236  {
1237 
1238  llvm::MachineJumpTableInfo* jtInfo = mf.getJumpTableInfo();
1239  if (jtInfo == NULL) {
1240  return;
1241  }
1242  for (unsigned int i = 0; i < jumpTableRecord_.size(); i++) {
1243  std::vector<BasicBlockNode*> nodes = jumpTableRecord_.at(i);
1244  std::vector<MachineBasicBlock*> oldTable =
1245  jtInfo->getJumpTables().at(i).MBBs;
1246  for (unsigned int j = 0; j < nodes.size(); j++) {
1247  const BasicBlockNode* bbn = nodes.at(j);
1248  MachineBasicBlock* newMBB = &cfg.getMBB(mf, bbn->basicBlock());
1249  MachineBasicBlock* oldMBB = oldTable.at(j);
1250  jtInfo->ReplaceMBBInJumpTable(i, oldMBB, newMBB);
1251  // Slight cheating to force LLVM to emit machine basic block label
1252  // to avoid missing references from Jump Table Records to basic
1253  // blocks. TODO: Proper fix is needed.
1254  newMBB->setIsEHPad();
1255  }
1256  }
1257 }

References BasicBlockNode::basicBlock(), ControlFlowGraph::getMBB(), and jumpTableRecord_.

Referenced by writeMachineFunction().

Here is the call graph for this function:

◆ getAnalysisUsage()

void llvm::LLVMTCEIRBuilder::getAnalysisUsage ( AnalysisUsage &  AU) const
virtual

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 131 of file LLVMTCEIRBuilder.cc.

131  {
133 }

References llvm::LLVMTCEBuilder::getAnalysisUsage().

Here is the call graph for this function:

◆ getPassName()

virtual StringRef llvm::LLVMTCEIRBuilder::getPassName ( ) const
inlinevirtual

Definition at line 80 of file LLVMTCEIRBuilder.hh.

80  {
81  return "TCE: build TCE scheduler IR from MachineFunctions";
82  }

◆ hasRealInstructions()

bool llvm::LLVMTCEIRBuilder::hasRealInstructions ( MachineBasicBlock::const_iterator  i,
const MachineBasicBlock &  mbb 
)
private

Definition at line 1106 of file LLVMTCEIRBuilder.cc.

1108  {
1109  for (; i != mbb.end(); i++) {
1110  if (isRealInstruction(*i)) {
1111  return true;
1112  }
1113  }
1114  return false;
1115 }

References isRealInstruction().

Referenced by buildTCECFG().

Here is the call graph for this function:

◆ isExplicitReturn()

bool llvm::LLVMTCEIRBuilder::isExplicitReturn ( const llvm::MachineInstr &  mi) const
private

Returns true in case the given MI is an explict return instruction generated from the pseudo assembly string ".return_to".

Definition at line 855 of file LLVMTCEIRBuilder.cc.

855  {
856 
857  if (!mi.isInlineAsm()) return false;
858 
859  // Copied from LLVM's AsmPrinterInlineAsm.cpp. There doesn't
860  // seem to be a cleaner way to get the inline assembly text
861  // but this hack.
862  unsigned numOperands = mi.getNumOperands();
863 
864  // Count the number of register definitions to find the asm string.
865  unsigned numDefs = 0;
866  for (; mi.getOperand(numDefs).isReg() &&
867  mi.getOperand(numDefs).isDef();
868  ++numDefs);
869 
870  TCEString asmStr = "";
871  if (mi.isInlineAsm() && numDefs < numOperands &&
872  mi.getOperand(numDefs).isSymbol()) {
873  asmStr = mi.getOperand(numDefs).getSymbolName();
874  }
875  // The .return_to pseudo assembly is used in threading code
876  // to switch execution to another thread when returning from
877  // the current function. A very special case.
878  return asmStr.startsWith(".return_to ") ||
879  asmStr == ".longjmp";
880 }

References TCEString::startsWith().

Referenced by buildTCECFG().

Here is the call graph for this function:

◆ isHotFunction()

bool llvm::LLVMTCEIRBuilder::isHotFunction ( llvm::MachineFunction &  mf) const
private

Returns false in case the given function should be compiled with fast settings without optimizations.

This looks into the tcecc –primary-functions function list if it's set. If not set, assumes all functions are "hot".

Definition at line 257 of file LLVMTCEIRBuilder.cc.

257  {
258 
259  if (options_ == NULL) return true;
260 
262 
263  if (funcs == NULL || funcs->size() == 0)
264  return true;
265 
266  SmallString<256> Buffer;
267  mang_->getNameWithPrefix(Buffer, &mf.getFunction(), false);
268  TCEString fnName(Buffer.c_str());
269  return AssocTools::containsKey(*funcs, fnName);
270 }

References AssocTools::containsKey(), llvm::LLVMTCEBuilder::mang_, llvm::LLVMTCEBuilder::options_, and LLVMTCECmdLineOptions::primaryFunctions().

Referenced by writeMachineFunction().

Here is the call graph for this function:

◆ isRealInstruction()

bool llvm::LLVMTCEIRBuilder::isRealInstruction ( const MachineInstr &  instr) const
private

Definition at line 1071 of file LLVMTCEIRBuilder.cc.

1071  {
1072  const llvm::MCInstrDesc* opDesc = &instr.getDesc();
1073  if (opDesc->isReturn()) {
1074  return true;
1075  }
1076 
1077  // when the -g option turn on, this will come up opc with this, therefore
1078  // add this to ignore however, it is uncertain whether the debug "-g" will
1079  // generate more opc, need to verify
1080  if (opDesc->getOpcode() == TargetOpcode::DBG_VALUE) {
1081  return false;
1082  }
1083 
1084  if (opDesc->getOpcode() == TargetOpcode::KILL) {
1085  return false;
1086  }
1087 
1088  std::string opName = operationName(instr);
1089 
1090  // Pseudo instrs or debug labels don't require any actual instructions.
1091  if (opName == "PSEUDO" || opName == "DEBUG_LABEL") {
1092  return false;
1093  }
1094 
1095  if (opName == "MOVE") {
1096  const MachineOperand& dst = instr.getOperand(0);
1097  const MachineOperand& src = instr.getOperand(1);
1098  if (dst.isReg() && src.isReg() && dst.getReg() == src.getReg()) {
1099  return false;
1100  }
1101  }
1102  return true;
1103 }

References operationName().

Referenced by buildTCECFG(), and hasRealInstructions().

Here is the call graph for this function:

◆ markJumpTableDestinations()

void llvm::LLVMTCEIRBuilder::markJumpTableDestinations ( llvm::MachineFunction &  mf,
ControlFlowGraph cfg 
)
private

Definition at line 1203 of file LLVMTCEIRBuilder.cc.

1205  {
1206 
1207  llvm::MachineJumpTableInfo* jtInfo = mf.getJumpTableInfo();
1208  if (jtInfo == NULL || jtInfo->isEmpty()) {
1209  return;
1210  }
1211 
1212  std::vector<llvm::MachineJumpTableEntry> entries = jtInfo->getJumpTables();
1213  jumpTableRecord_.clear();
1214  for (unsigned int i = 0; i < entries.size(); i++) {
1215  std::vector<BasicBlockNode*> nodes;
1216  jumpTableRecord_.push_back(nodes);
1217  std::vector<MachineBasicBlock*> blocks =
1218  entries.at(i).MBBs;
1219  for (unsigned j = 0; j < blocks.size(); j++) {
1220  MachineBasicBlock* mbb = blocks.at(j);
1221  BasicBlockNode* bbn = NULL;
1222  std::map<const MachineBasicBlock*, BasicBlockNode*>::iterator
1223  bbMapIter = bbMapping_.find(mbb);
1224  assert(bbMapIter != bbMapping_.end() &&
1225  "The Basic Block Node for Machine Basic Block is missing!");
1226  bbn = bbMapIter->second;
1227  jumpTableRecord_.at(i).push_back(bbn);
1228  }
1229  }
1230 
1231 }

References assert, bbMapping_, and jumpTableRecord_.

Referenced by writeMachineFunction().

◆ operationName()

TCEString llvm::LLVMTCEIRBuilder::operationName ( const MachineInstr &  mi) const
protectedvirtual

Implements llvm::LLVMTCEBuilder.

Definition at line 1147 of file LLVMTCEIRBuilder.cc.

1147  {
1148  if (dynamic_cast<const TCETargetMachine*>(&targetMachine())
1149  != NULL) {
1150  if (mi.getDesc().isReturn()) return "RET";
1151  return dynamic_cast<const TCETargetMachine&>(targetMachine())
1152  .operationName(mi.getDesc().getOpcode());
1153  } else {
1154  return targetMachine().getSubtargetImpl(
1155  mi.getParent()->getParent()->getFunction())->getInstrInfo()->
1156  getName(mi.getOpcode()).str();
1157  }
1158 }

References llvm::LLVMTCEBuilder::targetMachine().

Referenced by buildTCECFG(), and isRealInstruction().

Here is the call graph for this function:

◆ raPortDRegNum()

virtual unsigned llvm::LLVMTCEIRBuilder::raPortDRegNum ( ) const
inlineprotectedvirtual

Implements llvm::LLVMTCEBuilder.

Definition at line 96 of file LLVMTCEIRBuilder.hh.

96  {
97  if (isTTATarget()) {
98  return dynamic_cast<const TCETargetMachine&>(
100  } else {
101  abortWithError("Unimplemented for non-TTA targets.");
102  }
103  }

References abortWithError, llvm::LLVMTCEBuilder::isTTATarget(), and llvm::LLVMTCEBuilder::targetMachine().

Here is the call graph for this function:

◆ registerFileName()

TCEString llvm::LLVMTCEIRBuilder::registerFileName ( unsigned  llvmRegNum) const
protectedvirtual

Implements llvm::LLVMTCEBuilder.

Definition at line 1161 of file LLVMTCEIRBuilder.cc.

1161  {
1162  if (isTTATarget()) {
1163  return dynamic_cast<const TCETargetMachine&>(
1164  targetMachine()).rfName(llvmRegNum);
1165  } else {
1166  // LLVM does not support explicit register file info
1167  // at the moment, so we assume there's only one reg file
1168  // in the machine. Pick the first one that is not
1169  // a 1-bit reg file.
1172 
1173  for (int i = 0; i < rfNav.count(); i++) {
1174  const TTAMachine::RegisterFile& rf = *rfNav.item(i);
1175  if (rf.width() > 1)
1176  return rf.name();
1177  }
1179  TCEString("Unable to figure the RF for llvm reg num ") <<
1180  llvmRegNum);
1181 
1182  }
1183 }

References abortWithError, TTAMachine::Machine::Navigator< ComponentType >::count(), llvm::LLVMTCEBuilder::isTTATarget(), TTAMachine::Machine::Navigator< ComponentType >::item(), llvm::LLVMTCEBuilder::mach_, TTAMachine::Component::name(), TTAMachine::Machine::registerFileNavigator(), llvm::LLVMTCEBuilder::targetMachine(), and TTAMachine::BaseRegisterFile::width().

Here is the call graph for this function:

◆ registerIndex()

int llvm::LLVMTCEIRBuilder::registerIndex ( unsigned  llvmRegNum) const
protectedvirtual

Implements llvm::LLVMTCEBuilder.

Definition at line 1186 of file LLVMTCEIRBuilder.cc.

1186  {
1187  if (isTTATarget()) {
1188  return dynamic_cast<const TCETargetMachine&>(
1189  targetMachine()).registerIndex(llvmRegNum);
1190  } else {
1191  /* Assume for non-TTA targets the register index
1192  is the final and correct one and that there's only
1193  one register file. With TTA we have to do conversion
1194  due to the multiple register files option which LLVM
1195  does not support. */
1196  // LLVM index registers starting from 1, we start ours from 0
1197  // decrease index to avoid out of range error.
1198  return llvmRegNum - 1;
1199  }
1200 }

References llvm::LLVMTCEBuilder::isTTATarget(), and llvm::LLVMTCEBuilder::targetMachine().

Here is the call graph for this function:

◆ scheduler()

BBSchedulerController & llvm::LLVMTCEIRBuilder::scheduler ( )
private

Definition at line 889 of file LLVMTCEIRBuilder.cc.

889  {
890  if (scheduler_ == NULL) {
892  // disabled for the LLVM->TCE->LLVM scheduling chain as
893  // it crashes
894  CopyingDelaySlotFiller* dsf = NULL;
895  if (!modifyMF_ && delaySlotFilling_)
896  dsf = &delaySlotFiller();
897  scheduler_ =
899  }
900  return *scheduler_;
901 }

References bypasser_, delaySlotFiller(), delaySlotFilling_, ipData_, llvm::LLVMTCEBuilder::mach_, modifyMF_, and scheduler_.

Referenced by compileOptimized(), and doFinalization().

Here is the call graph for this function:

◆ setInnerLoopFinder()

void llvm::LLVMTCEIRBuilder::setInnerLoopFinder ( InnerLoopFinder loopFinder)
inline

Definition at line 84 of file LLVMTCEIRBuilder.hh.

84  {
85  loopFinder_ = loopFinder; }

References loopFinder_.

Referenced by LLVMBackend::compile().

◆ spDRegNum()

virtual unsigned llvm::LLVMTCEIRBuilder::spDRegNum ( ) const
inlineprotectedvirtual

Implements llvm::LLVMTCEBuilder.

Definition at line 90 of file LLVMTCEIRBuilder.hh.

90  {
91  return dynamic_cast<const TCETargetMachine&>(
93  }

References llvm::LLVMTCEBuilder::targetMachine().

Here is the call graph for this function:

◆ writeMachineFunction()

bool llvm::LLVMTCEIRBuilder::writeMachineFunction ( MachineFunction &  mf)
virtual

Writes machine function to POM.

Actually does things to MachineFunction which was supposed to be done in runOnMachineFunction, but which cannot be done during that, because MachineDCE is not ready yet at that time...

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 136 of file LLVMTCEIRBuilder.cc.

136  {
137 
138  if (tm_ == NULL)
139  tm_ = &mf.getTarget();
140 
142 
143  curFrameInfo_ = &mf.getFrameInfo();
144  assert(curFrameInfo_ != NULL);
145 
146  if (!functionAtATime_) {
147  // ensure data sections have been initialized when compiling
148  // the whole program at a time
150  emitConstantPool(*mf.getConstantPool());
151  } else {
152  mang_ = new llvm::Mangler();
153  }
154 
155  // omit empty functions..
156  if (mf.begin() == mf.end()) return true;
157 
159 
160  SmallString<256> Buffer;
161  mang_->getNameWithPrefix(Buffer, &mf.getFunction(), false);
162  TCEString fnName(Buffer.c_str());
163 
164  TTAProgram::Procedure* procedure =
165  new TTAProgram::Procedure(fnName, *as);
166 
167  if (!functionAtATime_) {
168  prog_->addProcedure(procedure);
169  }
170 
172  if (functionAtATime_) {
174  } else {
176  }
177 
178  ControlFlowGraph* cfg = buildTCECFG(mf);
180 #ifdef WRITE_CFG_DOTS
181  cfg->writeToDotFile(fnName + "_cfg1.dot");
182 #endif
183 
184  bool fastCompilation = options_ != NULL && options_->optLevel() == 0;
185 
186  markJumpTableDestinations(mf, *cfg);
187 
188  if (!mach_->controlUnit()->hasOperation("call")) {
189  CallsToJumps ctj(*ipData_);
190  ctj.handleControlFlowGraph(*cfg, *mach_);
191  }
192 
193  if (fastCompilation || !isHotFunction(mf)) {
194  verboseLog(TCEString("### compiling (fast): ") + fnName);
196  } else {
197  verboseLog(TCEString("### compiling (optimized): ") + fnName);
198  AliasAnalysis* AA = NULL;
199  if (!AA_) {
200  // Called through LLVMBackend. We are actual module and
201  // can get previous pass analysis!
202  AAResultsWrapperPass* AARWPass =
203  getAnalysisIfAvailable<AAResultsWrapperPass>();
204  if (AARWPass)
205  AA = &AARWPass->getAAResults();
206  } else {
207  // Called through LLVMTCEScheduler. We are not registered
208  // module in pass manager, so we do not have previous
209  // pass analysis data, but LLVMTCEScheduler kindly
210  // got them for us and passed through.
211  AA = AA_;
212  }
213  EXIT_IF_THROWS(compileOptimized(*cfg, AA));
214  }
215 
216  if (!modifyMF_) {
218  }
219  cfg->copyToProcedure(*procedure, irm);
220 #ifdef WRITE_CFG_DOTS
221  cfg->writeToDotFile(fnName + "_cfg4.dot");
222 #endif
223  if (procedure->instructionCount() > 0) {
224  codeLabels_[fnName] = &procedure->firstInstruction();
225  }
226 
227  if (modifyMF_) {
228  cfg->copyToLLVMMachineFunction(mf, irm);
229  fixJumpTableDestinations(mf, *cfg);
230  delete cfg;
231  return true;
232  }
233 
234  AbsoluteToRelativeJumps jumpConv(*ipData_);
235  jumpConv.handleProcedure(*procedure, *mach_);
236 
237  if (Application::verboseLevel() > 0 && spillMoveCount_ > 0) {
239  << "spill moves in " <<
240  (std::string)(mf.getFunction().getName()) << ": "
241  << spillMoveCount_ << std::endl;
242  }
243 
244  delete cfg;
245  if (functionAtATime_) delete irm;
246  return false;
247 }

References AA_, TTAProgram::Program::addProcedure(), TTAMachine::FunctionUnit::addressSpace(), assert, buildTCECFG(), llvm::LLVMTCEBuilder::clearFunctionBookkeeping(), llvm::LLVMTCEBuilder::codeLabels_, compileFast(), compileOptimized(), TTAMachine::Machine::controlUnit(), ControlFlowGraph::convertBBRefsToInstRefs(), ControlFlowGraph::copyToLLVMMachineFunction(), ControlFlowGraph::copyToProcedure(), llvm::LLVMTCEBuilder::curFrameInfo_, llvm::LLVMTCEBuilder::emitConstantPool(), EXIT_IF_THROWS, TTAProgram::CodeSnippet::firstInstruction(), fixJumpTableDestinations(), llvm::LLVMTCEBuilder::functionAtATime_, CallsToJumps::handleControlFlowGraph(), AbsoluteToRelativeJumps::handleProcedure(), TTAMachine::FunctionUnit::hasOperation(), llvm::LLVMTCEBuilder::initDataSections(), TTAProgram::CodeSnippet::instructionCount(), TTAProgram::Program::instructionReferenceManager(), ipData_, isHotFunction(), Application::logStream(), llvm::LLVMTCEBuilder::mach_, llvm::LLVMTCEBuilder::mang_, markJumpTableDestinations(), modifyMF_, llvm::LLVMTCEBuilder::options_, LLVMTCECmdLineOptions::optLevel(), llvm::LLVMTCEBuilder::prog_, ControlFlowGraph::setInstructionReferenceManager(), llvm::LLVMTCEBuilder::spillMoveCount_, llvm::LLVMTCEBuilder::tm_, Application::verboseLevel(), verboseLog, and GraphBase< GraphNode, GraphEdge >::writeToDotFile().

Referenced by llvm::LLVMTCEScheduler::runOnMachineFunction().

Here is the call graph for this function:

Member Data Documentation

◆ AA_

AliasAnalysis* llvm::LLVMTCEIRBuilder::AA_
private

Definition at line 172 of file LLVMTCEIRBuilder.hh.

Referenced by writeMachineFunction().

◆ allParamRegs_

std::set<TCEString> llvm::LLVMTCEIRBuilder::allParamRegs_
private

Definition at line 163 of file LLVMTCEIRBuilder.hh.

◆ bbMapping_

std::map<const MachineBasicBlock*,BasicBlockNode*> llvm::LLVMTCEIRBuilder::bbMapping_
private

Definition at line 168 of file LLVMTCEIRBuilder.hh.

Referenced by buildTCECFG(), createMBBReference(), and markJumpTableDestinations().

◆ bypasser_

CycleLookBackSoftwareBypasser* llvm::LLVMTCEIRBuilder::bypasser_
private

Definition at line 183 of file LLVMTCEIRBuilder.hh.

Referenced by scheduler(), and ~LLVMTCEIRBuilder().

◆ ddgBuilder_

DataDependenceGraphBuilder llvm::LLVMTCEIRBuilder::ddgBuilder_
private

Definition at line 166 of file LLVMTCEIRBuilder.hh.

Referenced by compileOptimized().

◆ delaySlotFilling_

bool llvm::LLVMTCEIRBuilder::delaySlotFilling_
private

Definition at line 179 of file LLVMTCEIRBuilder.hh.

Referenced by compileOptimized(), LLVMTCEIRBuilder(), and scheduler().

◆ dsf_

CopyingDelaySlotFiller* llvm::LLVMTCEIRBuilder::dsf_
private

Definition at line 182 of file LLVMTCEIRBuilder.hh.

Referenced by delaySlotFiller(), and ~LLVMTCEIRBuilder().

◆ ID

char llvm::LLVMTCEIRBuilder::ID = -1
static

Definition at line 62 of file LLVMTCEIRBuilder.hh.

◆ ipData_

InterPassData* llvm::LLVMTCEIRBuilder::ipData_
private

◆ jumpTableRecord_

std::vector<std::vector<BasicBlockNode*> > llvm::LLVMTCEIRBuilder::jumpTableRecord_
private

Definition at line 170 of file LLVMTCEIRBuilder.hh.

Referenced by fixJumpTableDestinations(), and markJumpTableDestinations().

◆ loopFinder_

InnerLoopFinder* llvm::LLVMTCEIRBuilder::loopFinder_
private

Definition at line 185 of file LLVMTCEIRBuilder.hh.

Referenced by buildTCECFG(), and setInnerLoopFinder().

◆ modifyMF_

bool llvm::LLVMTCEIRBuilder::modifyMF_
private

Definition at line 175 of file LLVMTCEIRBuilder.hh.

Referenced by compileOptimized(), scheduler(), and writeMachineFunction().

◆ scheduler_

BBSchedulerController* llvm::LLVMTCEIRBuilder::scheduler_
private

Definition at line 181 of file LLVMTCEIRBuilder.hh.

Referenced by scheduler(), and ~LLVMTCEIRBuilder().

◆ skippedBBs_

std::map<const MachineBasicBlock*, BasicBlockNode*> llvm::LLVMTCEIRBuilder::skippedBBs_
private

Definition at line 177 of file LLVMTCEIRBuilder.hh.

Referenced by buildTCECFG(), and createMBBReference().


The documentation for this class was generated from the following files:
llvm::LLVMTCEBuilder::spillMoveCount_
int spillMoveCount_
Definition: LLVMTCEBuilder.hh:261
SimpleInterPassDatum
Definition: InterPassDatum.hh:64
PRegionMarkerAnalyzer
Definition: PRegionMarkerAnalyzer.hh:42
BoostGraph::connectNodes
virtual void connectNodes(const Node &nTail, const Node &nHead, Edge &e)
TTAProgram::Program::addProcedure
void addProcedure(Procedure *proc)
Definition: Program.cc:524
llvm::LLVMTCEIRBuilder::registerIndex
virtual int registerIndex(unsigned llvmRegNum) const
Definition: LLVMTCEIRBuilder.cc:1186
llvm::LLVMTCEBuilder::doFinalization
bool doFinalization(Module &M)
Definition: LLVMTCEBuilder.cc:1090
TTAProgram::TerminalFUPort::setProgramOperation
void setProgramOperation(ProgramOperationPtr po)
Definition: TerminalFUPort.hh:94
llvm::LLVMTCEBuilder::LLVMTCEBuilder
LLVMTCEBuilder(char &ID)
Definition: LLVMTCEBuilder.cc:167
llvm::LLVMTCEBuilder::emitInstruction
TTAProgram::Instruction * emitInstruction(const MachineInstr *mi, TTAProgram::CodeSnippet *proc)
Definition: LLVMTCEBuilder.cc:1322
TTAProgram::CodeSnippet::firstInstruction
virtual Instruction & firstInstruction() const
Definition: CodeSnippet.cc:216
llvm::LLVMTCEBuilder::prog_
TTAProgram::Program * prog_
Current program being built.
Definition: LLVMTCEBuilder.hh:250
ControlFlowGraph::splitBasicBlocksWithCallsAndRefs
void splitBasicBlocksWithCallsAndRefs()
Definition: ControlFlowGraph.cc:2850
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
BBSchedulerController::handleCFGDDG
virtual void handleCFGDDG(ControlFlowGraph &cfg, DataDependenceGraph *ddg, const TTAMachine::Machine &targetMachine)
Definition: BBSchedulerController.cc:603
TTAProgram::Instruction::move
Move & move(int i) const
Definition: Instruction.cc:193
TTAProgram::Program::procedureCount
int procedureCount() const
Definition: Program.cc:610
TCEString::startsWith
bool startsWith(const std::string &str) const
InnerLoopFinder::InnerLoopInfo::isTripCountKnown
bool isTripCountKnown() const
Definition: InnerLoopFinder.hh:37
ControlFlowGraph::copyToProcedure
void copyToProcedure(TTAProgram::Procedure &proc, TTAProgram::InstructionReferenceManager *irm=NULL)
Definition: ControlFlowGraph.cc:1448
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
CycleLookBackSoftwareBypasser
Definition: CycleLookBackSoftwareBypasser.hh:52
LLVMTCECmdLineOptions::disableDelaySlotFiller
bool disableDelaySlotFiller() const
Definition: LLVMTCECmdLineOptions.cc:324
llvm::LLVMTCEBuilder::opset_
std::set< std::string > opset_
The operations supported by the current target machine.
Definition: LLVMTCEBuilder.hh:253
AssocTools::containsKey
static bool containsKey(const ContainerType &aContainer, const KeyType &aKey)
BoostGraph< BasicBlockNode, ControlFlowEdge >::NodeSet
std::set< BasicBlockNode *, typename BasicBlockNode ::Comparator > NodeSet
Definition: BoostGraph.hh:86
llvm::LLVMTCEBuilder::options_
LLVMTCECmdLineOptions * options_
The compiler options.
Definition: LLVMTCEBuilder.hh:268
TTAProgram::Instruction
Definition: Instruction.hh:57
llvm::LLVMTCEIRBuilder::bbMapping_
std::map< const MachineBasicBlock *, BasicBlockNode * > bbMapping_
Definition: LLVMTCEIRBuilder.hh:168
llvm::LLVMTCEIRBuilder::isHotFunction
bool isHotFunction(llvm::MachineFunction &mf) const
Definition: LLVMTCEIRBuilder.cc:257
llvm::LLVMTCEIRBuilder::hasRealInstructions
bool hasRealInstructions(MachineBasicBlock::const_iterator i, const MachineBasicBlock &mbb)
Definition: LLVMTCEIRBuilder.cc:1106
llvm::LLVMTCEIRBuilder::AA_
AliasAnalysis * AA_
Definition: LLVMTCEIRBuilder.hh:172
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
llvm::LLVMTCEBuilder::tm_
const llvm::TargetMachine * tm_
Target machine description.
Definition: LLVMTCEBuilder.hh:245
llvm::LLVMTCEIRBuilder::ipData_
InterPassData * ipData_
Definition: LLVMTCEIRBuilder.hh:161
PreOptimizer
Definition: PreOptimizer.hh:66
MoveNode
Definition: MoveNode.hh:65
InnerLoopFinder::innerLoopInfo
InnerLoopInfoIndex innerLoopInfo()
Definition: InnerLoopFinder.hh:58
llvm::LLVMTCEBuilder::curFrameInfo_
MachineFrameInfo * curFrameInfo_
Definition: LLVMTCEBuilder.hh:265
CompileError
Definition: Exception.hh:1019
Application::verboseLevel
static int verboseLevel()
Definition: Application.hh:176
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
llvm::LLVMTCEIRBuilder::delaySlotFiller
CopyingDelaySlotFiller & delaySlotFiller()
Definition: LLVMTCEIRBuilder.cc:904
Application::logStream
static std::ostream & logStream()
Definition: Application.cc:155
BoostGraph::addNode
virtual void addNode(Node &node)
llvm::LLVMTCEBuilder::functionAtATime_
bool functionAtATime_
Definition: LLVMTCEBuilder.hh:257
llvm::LLVMTCEBuilder::mach_
TTAMachine::Machine * mach_
Machine for building the program.
Definition: LLVMTCEBuilder.hh:242
llvm::LLVMTCEIRBuilder::fixJumpTableDestinations
void fixJumpTableDestinations(llvm::MachineFunction &mf, ControlFlowGraph &cfg)
Definition: LLVMTCEIRBuilder.cc:1234
TTAMachine::Machine::Navigator::count
int count() const
llvm::LLVMTCEBuilder::fixProgramOperationReferences
void fixProgramOperationReferences()
Definition: LLVMTCEBuilder.cc:2276
LLVMTCECmdLineOptions::optLevel
int optLevel() const
Definition: LLVMTCECmdLineOptions.cc:292
CopyingDelaySlotFiller::initialize
void initialize(ControlFlowGraph &cfg, DataDependenceGraph &ddg, const TTAMachine::Machine &machine)
Definition: CopyingDelaySlotFiller.cc:1937
ControlFlowGraph::instructionReferenceManager
TTAProgram::InstructionReferenceManager & instructionReferenceManager()
Definition: ControlFlowGraph.cc:2401
llvm::LLVMTCEBuilder::mang_
llvm::Mangler * mang_
Mangler for mangling label strings.
Definition: LLVMTCEBuilder.hh:247
SchedulerCmdLineOptions
Definition: SchedulerCmdLineOptions.hh:45
llvm::LLVMTCEBuilder::emitConstantPool
void emitConstantPool(const llvm::MachineConstantPool &cp)
Definition: LLVMTCEBuilder.cc:2346
verboseLog
#define verboseLog(text)
Definition: Application.hh:115
ControlFlowEdge
Definition: ControlFlowEdge.hh:50
ControlFlowEdge::CFLOW_EDGE_NORMAL
@ CFLOW_EDGE_NORMAL
Definition: ControlFlowEdge.hh:53
llvm::LLVMTCEBuilder::emitSPInitialization
virtual void emitSPInitialization()
Definition: LLVMTCEBuilder.cc:2669
MoveNode::setSourceOperationPtr
void setSourceOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:541
BasicBlockNode::basicBlock
TTAProgram::BasicBlock & basicBlock()
Definition: BasicBlockNode.cc:126
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
SimpleIfConverter
Definition: SimpleIfConverter.hh:40
llvm::LLVMTCEIRBuilder::scheduler
BBSchedulerController & scheduler()
Definition: LLVMTCEIRBuilder.cc:889
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
CopyingDelaySlotFiller::fillDelaySlots
void fillDelaySlots(ControlFlowGraph &cfg, DataDependenceGraph &ddg, const TTAMachine::Machine &machine)
Definition: CopyingDelaySlotFiller.cc:405
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
llvm::LLVMTCEIRBuilder::raPortDRegNum
virtual unsigned raPortDRegNum() const
Definition: LLVMTCEIRBuilder.hh:96
TTAProgram::BasicBlock::setTripCount
void setTripCount(unsigned count)
Definition: BasicBlock.hh:109
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
llvm::LLVMTCEBuilder::getAnalysisUsage
virtual void getAnalysisUsage(AnalysisUsage &AU) const
Definition: LLVMTCEBuilder.hh:125
llvm::LLVMTCEIRBuilder::compileOptimized
void compileOptimized(ControlFlowGraph &cfg, llvm::AliasAnalysis *llvmAA)
Definition: LLVMTCEIRBuilder.cc:911
llvm::LLVMTCEIRBuilder::ddgBuilder_
DataDependenceGraphBuilder ddgBuilder_
Definition: LLVMTCEIRBuilder.hh:166
MoveNode::addDestinationOperationPtr
void addDestinationOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:533
TTAProgram::CodeSnippet::instructionCount
virtual int instructionCount() const
Definition: CodeSnippet.cc:205
DataDependenceGraph::INTRA_BB_ANTIDEPS
@ INTRA_BB_ANTIDEPS
Definition: DataDependenceGraph.hh:80
RegisterCopyAdder::findTempRegisters
static void findTempRegisters(const TTAMachine::Machine &machine, InterPassData &ipd)
Definition: RegisterCopyAdder.cc:2136
InnerLoopFinder::InnerLoopInfo
Definition: InnerLoopFinder.hh:32
Application::cmdLineOptions
static CmdLineOptions * cmdLineOptions()
Definition: Application.cc:397
llvm::LLVMTCEIRBuilder::modifyMF_
bool modifyMF_
Definition: LLVMTCEIRBuilder.hh:175
__func__
#define __func__
Definition: Application.hh:67
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
CopyingDelaySlotFiller
Definition: CopyingDelaySlotFiller.hh:71
BasicBlockNode
Definition: BasicBlockNode.hh:64
ControlFlowGraph::addExit
void addExit(NodeSet &retSourceNodes)
llvm::LLVMTCEIRBuilder::isRealInstruction
bool isRealInstruction(const MachineInstr &instr) const
Definition: LLVMTCEIRBuilder.cc:1071
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
llvm::LLVMTCEBuilder::isInlineAsm
static bool isInlineAsm(const MachineInstr &instr)
Definition: LLVMTCEBuilder.cc:3908
llvm::LLVMTCEIRBuilder::jumpTableRecord_
std::vector< std::vector< BasicBlockNode * > > jumpTableRecord_
Definition: LLVMTCEIRBuilder.hh:170
BasicBlockNode::setBBOwnership
void setBBOwnership(bool ownership=true)
Definition: BasicBlockNode.hh:103
TTAMachine::FunctionUnit::hasOperation
virtual bool hasOperation(const std::string &name) const
Definition: FunctionUnit.cc:330
llvm::LLVMTCEIRBuilder::markJumpTableDestinations
void markJumpTableDestinations(llvm::MachineFunction &mf, ControlFlowGraph &cfg)
Definition: LLVMTCEIRBuilder.cc:1203
CmdLineOptions::isVerboseSwitchDefined
virtual bool isVerboseSwitchDefined() const
Definition: CmdLineOptions.cc:300
InnerLoopFinder::InnerLoopInfoIndex
std::map< const llvm::BasicBlock *, InnerLoopInfo > InnerLoopInfoIndex
Definition: InnerLoopFinder.hh:42
LLVMTCECmdLineOptions::primaryFunctions
virtual FunctionNameList * primaryFunctions() const
Definition: LLVMTCECmdLineOptions.cc:254
LLVMTCECmdLineOptions
Definition: LLVMTCECmdLineOptions.hh:48
ControlFlowGraph::convertBBRefsToInstRefs
void convertBBRefsToInstRefs()
Definition: ControlFlowGraph.cc:2436
SequentialScheduler
Definition: SequentialScheduler.hh:56
TTAProgram::TerminalBasicBlockReference
Definition: TerminalBasicBlockReference.hh:42
GraphBase::writeToDotFile
virtual void writeToDotFile(const TCEString &fileName) const
TTAProgram::TerminalFUPort
Definition: TerminalFUPort.hh:56
llvm::LLVMTCEIRBuilder::compileFast
void compileFast(ControlFlowGraph &cfg)
Definition: LLVMTCEIRBuilder.cc:883
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
Peel2BBLoops
Definition: Peel2BBLoops.hh:22
llvm::LLVMTCEIRBuilder::bypasser_
CycleLookBackSoftwareBypasser * bypasser_
Definition: LLVMTCEIRBuilder.hh:183
llvm::LLVMTCEIRBuilder::dsf_
CopyingDelaySlotFiller * dsf_
Definition: LLVMTCEIRBuilder.hh:182
llvm::LLVMTCEIRBuilder::delaySlotFilling_
bool delaySlotFilling_
Definition: LLVMTCEIRBuilder.hh:179
ControlFlowGraph::getMBB
llvm::MachineBasicBlock & getMBB(llvm::MachineFunction &mf, const TTAProgram::BasicBlock &bb) const
Definition: ControlFlowGraph.cc:2829
TTAProgram::TerminalFUPort::programOperation
ProgramOperationPtr programOperation() const
Definition: TerminalFUPort.hh:97
BasicBlockNode::setScheduled
void setScheduled(bool state=true)
Definition: BasicBlockNode.hh:94
TTAProgram::BasicBlock
Definition: BasicBlock.hh:85
llvm::LLVMTCEIRBuilder::isExplicitReturn
bool isExplicitReturn(const llvm::MachineInstr &mi) const
Definition: LLVMTCEIRBuilder.cc:855
TTAMachine::Machine::registerFileNavigator
virtual RegisterFileNavigator registerFileNavigator() const
Definition: Machine.cc:450
MapTools::containsKey
static bool containsKey(const MapType &aMap, const KeyType &aKey)
PostpassOperandSharer
Definition: PostpassOperandSharer.hh:47
llvm::LLVMTCEBuilder::doInitialization
bool doInitialization(Module &M)
Definition: LLVMTCEBuilder.cc:429
ControlFlowGraph::setInstructionReferenceManager
void setInstructionReferenceManager(TTAProgram::InstructionReferenceManager &irm)
Definition: ControlFlowGraph.hh:142
llvm::LLVMTCEIRBuilder::spDRegNum
virtual unsigned spDRegNum() const
Definition: LLVMTCEIRBuilder.hh:90
TTAProgram::InstructionReferenceManager
Definition: InstructionReferenceManager.hh:82
TTAProgram::Program::instructionReferenceManager
InstructionReferenceManager & instructionReferenceManager() const
Definition: Program.cc:688
ControlFlowGraph::detectBackEdges
void detectBackEdges()
Definition: ControlFlowGraph.cc:2426
ControlFlowGraph::copyToLLVMMachineFunction
void copyToLLVMMachineFunction(llvm::MachineFunction &mf, TTAProgram::InstructionReferenceManager *irm=NULL)
Definition: ControlFlowGraph.cc:1679
TCEString
Definition: TCEString.hh:53
llvm::LLVMTCEBuilder::codeLabels_
std::map< std::string, TTAProgram::Instruction * > codeLabels_
Code labels.
Definition: LLVMTCEBuilder.hh:239
CallsToJumps
Definition: CallsToJumps.hh:36
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
ControlFlowEdge::CFLOW_EDGE_FALSE
@ CFLOW_EDGE_FALSE
Definition: ControlFlowEdge.hh:55
DataDependenceGraphBuilder::build
virtual DataDependenceGraph * build(ControlFlowGraph &cGraph, DataDependenceGraph::AntidependenceLevel antidependenceLevel, const TTAMachine::Machine &mach, const UniversalMachine *um=NULL, bool createMemAndFUDeps=true, bool createDeathInformation=true, llvm::AliasAnalysis *AA=NULL)
Definition: DataDependenceGraphBuilder.cc:2120
llvm::LLVMTCEIRBuilder::ID
static char ID
Definition: LLVMTCEIRBuilder.hh:62
llvm::LLVMTCEBuilder::pregions_
PRegionMarkerAnalyzer * pregions_
Definition: LLVMTCEBuilder.hh:259
TTAProgram::Procedure::name
TCEString name() const
Definition: Procedure.hh:66
ControlFlowGraph::optimizeBBOrdering
void optimizeBBOrdering(bool removeDeadCode, TTAProgram::InstructionReferenceManager &irm, DataDependenceGraph *ddg)
Definition: ControlFlowGraph.cc:2522
llvm::LLVMTCEIRBuilder::skippedBBs_
std::map< const MachineBasicBlock *, BasicBlockNode * > skippedBBs_
Definition: LLVMTCEIRBuilder.hh:177
llvm::LLVMTCEIRBuilder::scheduler_
BBSchedulerController * scheduler_
Definition: LLVMTCEIRBuilder.hh:181
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
TTAProgram::Instruction::hasControlFlowMove
bool hasControlFlowMove() const
Definition: Instruction.cc:471
TTAProgram::CodeSnippet::toString
virtual std::string toString() const
Definition: CodeSnippet.hh:117
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
AbsoluteToRelativeJumps
Definition: AbsoluteToRelativeJumps.hh:39
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
EXIT_IF_THROWS
#define EXIT_IF_THROWS(__X__)
Definition: LLVMTCEIRBuilder.cc:86
InnerLoopFinder::InnerLoopInfo::tripCount
int tripCount() const
Definition: InnerLoopFinder.hh:36
TTAProgram::BasicBlock::setInInnerLoop
void setInInnerLoop(bool inner=true)
Definition: BasicBlock.hh:104
llvm::LLVMTCEIRBuilder::loopFinder_
InnerLoopFinder * loopFinder_
Definition: LLVMTCEIRBuilder.hh:185
BasicBlockNode::setHWLoop
void setHWLoop(bool hwloop=true)
Set true if the bbn is known to be a loop body of a hwloop with loop pattern- preheader BB -> loop bo...
Definition: BasicBlockNode.hh:110
llvm::LLVMTCEIRBuilder::operationName
virtual TCEString operationName(const MachineInstr &mi) const
Definition: LLVMTCEIRBuilder.cc:1147
BoostGraph::name
virtual const TCEString & name() const
TTAMachine::BaseRegisterFile::width
virtual int width() const
BBSchedulerController::handleProcedure
virtual void handleProcedure(TTAProgram::Procedure &procedure, const TTAMachine::Machine &targetMachine) override
Definition: BBSchedulerController.cc:284
ControlFlowEdge::CFLOW_EDGE_FALLTHROUGH
@ CFLOW_EDGE_FALLTHROUGH
Definition: ControlFlowEdge.hh:62
BoostGraph::nodeCount
int nodeCount() const
llvm::LLVMTCEBuilder::clearFunctionBookkeeping
void clearFunctionBookkeeping()
Definition: LLVMTCEBuilder.hh:231
ControlFlowEdge::CFLOW_EDGE_TRUE
@ CFLOW_EDGE_TRUE
Definition: ControlFlowEdge.hh:54
TTAProgram::TerminalSymbolReference
Definition: TerminalSymbolReference.hh:42
TTAProgram::Program::procedure
Procedure & procedure(int index) const
Definition: Program.cc:622
TTAProgram::Procedure
Definition: Procedure.hh:55
ControlFlowEdge::CFLOW_EDGE_CALL
@ CFLOW_EDGE_CALL
Definition: ControlFlowEdge.hh:61
llvm::LLVMTCEBuilder::targetMachine
const TargetMachine & targetMachine() const
Definition: LLVMTCEBuilder.hh:157
llvm::LLVMTCEBuilder::addLabelForProgramOperation
void addLabelForProgramOperation(TCEString label, ProgramOperationPtr po)
Definition: LLVMTCEBuilder.hh:222
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
llvm::AliasAnalysis
AAResults AliasAnalysis
Definition: DataDependenceGraphBuilder.hh:45
ControlFlowEdge::CFLOW_EDGE_JUMP
@ CFLOW_EDGE_JUMP
Definition: ControlFlowEdge.hh:60
llvm::LLVMTCEBuilder::initDataSections
void initDataSections()
Definition: LLVMTCEBuilder.cc:210
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
TTAProgram::Program::convertSymbolRefsToInsRefs
void convertSymbolRefsToInsRefs(bool ignoreUnfoundSymbols=false)
Definition: Program.cc:1264
llvm::LLVMTCEIRBuilder::buildTCECFG
ControlFlowGraph * buildTCECFG(llvm::MachineFunction &mf)
Definition: LLVMTCEIRBuilder.cc:273
ControlFlowGraph
Definition: ControlFlowGraph.hh:100
llvm::LLVMTCEBuilder::emitInlineAsm
TTAProgram::Instruction * emitInlineAsm(const MachineFunction &mf, const MachineInstr *mi, TTAProgram::BasicBlock *bb, TTAProgram::InstructionReferenceManager &irm)
Definition: LLVMTCEBuilder.cc:2786
BBSchedulerController
Definition: BBSchedulerController.hh:62
llvm::LLVMTCEBuilder::isTTATarget
virtual bool isTTATarget() const
Definition: LLVMTCEBuilder.hh:132
llvm::LLVMTCEBuilder::mbbName
std::string mbbName(const MachineBasicBlock &mbb)
Definition: LLVMTCEBuilder.cc:2632