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

#include <LLVMTCEPOMBuilder.hh>

Inheritance diagram for llvm::LLVMTCEPOMBuilder:
Inheritance graph
Collaboration diagram for llvm::LLVMTCEPOMBuilder:
Collaboration graph

Public Member Functions

 LLVMTCEPOMBuilder ()
 
virtual ~LLVMTCEPOMBuilder ()
 
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
 
bool doFinalization (Module &m)
 
bool doInitialization (Module &M)
 
TTAProgram::InstructionemitMove (const MachineInstr *mi, TTAProgram::CodeSnippet *proc, bool conditional=false, bool trueGuard=true)
 
- 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 void getAnalysisUsage (AnalysisUsage &AU) const
 
virtual bool isTTATarget () const
 
void deleteDeadProcedures ()
 
void setInitialStackPointerValue (unsigned value)
 

Static Public Attributes

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

Additional Inherited Members

- 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
 
virtual bool writeMachineFunction (MachineFunction &MF)
 
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::TerminalcreateMBBReference (const MachineOperand &mo)
 
virtual TTAProgram::TerminalcreateSymbolReference (const MachineOperand &mo)
 
virtual TTAProgram::TerminalcreateProgramOperationReference (const MachineOperand &mo)
 
virtual TTAProgram::TerminalcreateSymbolReference (const TCEString &symbolName)
 
TTAProgram::InstructionemitInstruction (const MachineInstr *mi, TTAProgram::CodeSnippet *proc)
 
TTAProgram::InstructionemitInlineAsm (const MachineFunction &mf, const MachineInstr *mi, TTAProgram::BasicBlock *bb, TTAProgram::InstructionReferenceManager &irm)
 
void fixProgramOperationReferences ()
 
void addLabelForProgramOperation (TCEString label, ProgramOperationPtr po)
 
virtual void emitSPInitialization ()
 
void emitSPInitialization (TTAProgram::CodeSnippet &target)
 
void clearFunctionBookkeeping ()
 
- 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

Implements building TCE POM from TTA-style (MOVE) sequential input from LLVM codegen.

Note
Experimental and still lots to do before can be considered for real use.

Definition at line 81 of file LLVMTCEPOMBuilder.hh.

Constructor & Destructor Documentation

◆ LLVMTCEPOMBuilder()

llvm::LLVMTCEPOMBuilder::LLVMTCEPOMBuilder ( )

Definition at line 67 of file LLVMTCEPOMBuilder.cc.

67  :
69 }

◆ ~LLVMTCEPOMBuilder()

virtual llvm::LLVMTCEPOMBuilder::~LLVMTCEPOMBuilder ( )
inlinevirtual

Definition at line 85 of file LLVMTCEPOMBuilder.hh.

85 {}

Member Function Documentation

◆ createFUTerminal()

TTAProgram::Terminal * llvm::LLVMTCEPOMBuilder::createFUTerminal ( const MachineOperand &  mo) const
virtual

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 131 of file LLVMTCEPOMBuilder.cc.

131  {
132  TCEString regName(
133  targetMachine().getSubtargetImpl(
134  mo.getParent()->getParent()->getParent()->getFunction())->
135  getRegisterInfo()->getName(mo.getReg()));
136 
137  // test for _number which indicates a RF access
138  std::vector<TCEString> pieces = regName.split("_");
139  if (pieces.size() == 2) {
140  TCEString indexStr = pieces.at(1);
141  try {
142  Conversion::toInt(indexStr);
143  return NULL;
144  } catch (Exception&) {
145  }
146  }
147 
148  assert(pieces.size() > 0);
149 
150  TCEString fuName = pieces.at(0);
151  TCEString portName = pieces.at(1);
153  if (pieces.size() == 3) {
154  // FU_triggerport_OP
155  operationName = pieces.at(2);
156  }
157 
158  // always assume it's the ALU of minimal.adf for now
159  // should be parsed from the regName
161  mach_->functionUnitNavigator().item(fuName);
162 
163  assert(fu != NULL);
164 
165  TTAMachine::FUPort* fuPort =
166  dynamic_cast<TTAMachine::FUPort*>(fu->port(portName));
167  assert(fuPort != NULL);
168  if (operationName != "") {
169  assert(fuPort->isTriggering());
171  return new TTAProgram::TerminalFUPort(hwOp, hwOp.io(*fuPort));
172  } else {
174  new TTAProgram::TerminalFUPort(*fuPort);
175  return term;
176  }
177 }

References assert, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::HWOperation::io(), TTAMachine::FUPort::isTriggering(), TTAMachine::Machine::Navigator< ComponentType >::item(), llvm::LLVMTCEBuilder::mach_, TTAMachine::FunctionUnit::operation(), operationName(), TTAMachine::FunctionUnit::port(), TCEString::split(), llvm::LLVMTCEBuilder::targetMachine(), and Conversion::toInt().

Here is the call graph for this function:

◆ doFinalization()

bool llvm::LLVMTCEPOMBuilder::doFinalization ( Module &  m)

Definition at line 190 of file LLVMTCEPOMBuilder.cc.

190  {
191 
194 
195  return true;
196 }

References TTAProgram::Program::convertSymbolRefsToInsRefs(), llvm::LLVMTCEBuilder::doFinalization(), and llvm::LLVMTCEBuilder::prog_.

Here is the call graph for this function:

◆ doInitialization()

bool llvm::LLVMTCEPOMBuilder::doInitialization ( Module &  M)

Definition at line 184 of file LLVMTCEPOMBuilder.cc.

184  {
185  mach_ = TTAMachine::Machine::loadFromADF("tta/4bus_minimal.adf");
187 }

References llvm::LLVMTCEBuilder::doInitialization(), TTAMachine::Machine::loadFromADF(), and llvm::LLVMTCEBuilder::mach_.

Here is the call graph for this function:

◆ emitMove()

TTAProgram::Instruction * llvm::LLVMTCEPOMBuilder::emitMove ( const MachineInstr *  mi,
TTAProgram::CodeSnippet proc,
bool  conditional = false,
bool  trueGuard = true 
)
virtual

Creates POM instruction for a move.

Parameters
miMove machine instruction.
procPOM procedure to add the move to.
Returns
Emitted POM instruction.

Reimplemented from llvm::LLVMTCEBuilder.

Definition at line 98 of file LLVMTCEPOMBuilder.cc.

100  {
101  TCEString opName(targetMachine().getSubtargetImpl(
102  mi->getParent()->getParent()->getFunction())->
103  getInstrInfo()->getName(mi->getOpcode()).str());
104  /* Non-trigger move. */
105  if (opName == "MOVE")
106  return LLVMTCEBuilder::emitMove(mi, proc);
107 
108  /* A trigger move. The source is the 2nd last argument. */
109  TTAProgram::Terminal* src =
110  createTerminal(mi->getOperand(mi->getNumOperands() - 2));
111  TTAProgram::Terminal* dst = /* defined as implicit def */
112  createTerminal(mi->getOperand(mi->getNumOperands() - 1));
113 
115  auto move = createMove(src, dst, bus);
116 
118 
119  instr->addMove(move);
120  proc->add(instr);
121  return instr;
122 }

References TTAProgram::CodeSnippet::add(), TTAProgram::Instruction::addMove(), llvm::LLVMTCEBuilder::createMove(), llvm::LLVMTCEBuilder::createTerminal(), llvm::LLVMTCEBuilder::emitMove(), llvm::LLVMTCEBuilder::result(), llvm::LLVMTCEBuilder::targetMachine(), UniversalMachine::universalBus(), and TTAProgram::Program::universalMachine().

Here is the call graph for this function:

◆ operationName()

TCEString llvm::LLVMTCEPOMBuilder::operationName ( const MachineInstr &  mi) const
virtual

Implements llvm::LLVMTCEBuilder.

Definition at line 126 of file LLVMTCEPOMBuilder.cc.

126  {
127  return "MOVE";
128 }

Referenced by createFUTerminal().

◆ raPortDRegNum()

unsigned llvm::LLVMTCEPOMBuilder::raPortDRegNum ( ) const
virtual

Implements llvm::LLVMTCEBuilder.

Definition at line 77 of file LLVMTCEPOMBuilder.cc.

77  {
78  return 1000001; // ;D
79 }

◆ registerFileName()

TCEString llvm::LLVMTCEPOMBuilder::registerFileName ( unsigned  llvmRegNum) const
virtual

Implements llvm::LLVMTCEBuilder.

Definition at line 82 of file LLVMTCEPOMBuilder.cc.

82  {
83 
84  if (llvmRegNum == 1000000)
85  return "RF"; /* temp hack, always assume SP is the RF.4 */
86  abortWithError("Unimplemented.");
87 }

References abortWithError.

◆ registerIndex()

int llvm::LLVMTCEPOMBuilder::registerIndex ( unsigned  llvmRegNum) const
virtual

Implements llvm::LLVMTCEBuilder.

Definition at line 90 of file LLVMTCEPOMBuilder.cc.

90  {
91 
92  if (llvmRegNum == 1000000)
93  return 4; /* temp hack, always assume SP is the RF.4 */
94  abortWithError("Unimplemented.");
95 }

References abortWithError.

◆ spDRegNum()

unsigned llvm::LLVMTCEPOMBuilder::spDRegNum ( ) const
virtual

Implements llvm::LLVMTCEBuilder.

Definition at line 72 of file LLVMTCEPOMBuilder.cc.

72  {
73  return 1000000; // ;)
74 }

Member Data Documentation

◆ ID

char llvm::LLVMTCEPOMBuilder::ID = 0
static

Definition at line 83 of file LLVMTCEPOMBuilder.hh.


The documentation for this class was generated from the following files:
TTAProgram::Instruction::addMove
void addMove(std::shared_ptr< Move > move)
Definition: Instruction.cc:147
llvm::LLVMTCEBuilder::doFinalization
bool doFinalization(Module &M)
Definition: LLVMTCEBuilder.cc:1090
llvm::LLVMTCEBuilder::LLVMTCEBuilder
LLVMTCEBuilder(char &ID)
Definition: LLVMTCEBuilder.cc:167
llvm::LLVMTCEBuilder::prog_
TTAProgram::Program * prog_
Current program being built.
Definition: LLVMTCEBuilder.hh:250
llvm::LLVMTCEBuilder::result
TTAProgram::Program * result()
Definition: LLVMTCEBuilder.cc:3713
llvm::LLVMTCEBuilder::emitMove
virtual TTAProgram::Instruction * emitMove(const MachineInstr *mi, TTAProgram::CodeSnippet *proc, bool conditional=false, bool trueGuard=true)
Definition: LLVMTCEBuilder.cc:2418
TTAMachine::HWOperation
Definition: HWOperation.hh:52
UniversalMachine::universalBus
TTAMachine::Bus & universalBus() const
Definition: UniversalMachine.cc:306
TTAProgram::Instruction
Definition: Instruction.hh:57
TTAMachine::Bus
Definition: Bus.hh:53
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
llvm::LLVMTCEBuilder::mach_
TTAMachine::Machine * mach_
Machine for building the program.
Definition: LLVMTCEBuilder.hh:242
TTAMachine::FUPort::isTriggering
virtual bool isTriggering() const
Definition: FUPort.cc:182
llvm::LLVMTCEBuilder::createTerminal
TTAProgram::Terminal * createTerminal(const MachineOperand &mo, int bitLimit=0)
Definition: LLVMTCEBuilder.cc:2149
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::FUPort
Definition: FUPort.hh:46
TTAMachine::HWOperation::io
int io(const FUPort &port) const
Definition: HWOperation.cc:364
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
TTAProgram::CodeSnippet::add
virtual void add(Instruction *ins)
Definition: CodeSnippet.cc:432
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
llvm::LLVMTCEPOMBuilder::ID
static char ID
Definition: LLVMTCEPOMBuilder.hh:83
Exception
Definition: Exception.hh:54
TTAProgram::Program::universalMachine
UniversalMachine & universalMachine() const
Definition: Program.cc:104
TTAProgram::TerminalFUPort
Definition: TerminalFUPort.hh:56
llvm::LLVMTCEBuilder::doInitialization
bool doInitialization(Module &M)
Definition: LLVMTCEBuilder.cc:429
TCEString
Definition: TCEString.hh:53
llvm::LLVMTCEPOMBuilder::operationName
virtual TCEString operationName(const MachineInstr &mi) const
Definition: LLVMTCEPOMBuilder.cc:126
TTAProgram::Terminal
Definition: Terminal.hh:60
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
Conversion::toInt
static int toInt(const T &source)
llvm::LLVMTCEBuilder::targetMachine
const TargetMachine & targetMachine() const
Definition: LLVMTCEBuilder.hh:157
TTAProgram::Program::convertSymbolRefsToInsRefs
void convertSymbolRefsToInsRefs(bool ignoreUnfoundSymbols=false)
Definition: Program.cc:1264
llvm::LLVMTCEBuilder::createMove
std::shared_ptr< TTAProgram::Move > createMove(const MachineOperand &src, const MachineOperand &dst, TTAProgram::MoveGuard *guard)
Definition: LLVMTCEBuilder.cc:2389
TTAMachine::Machine::loadFromADF
static Machine * loadFromADF(const std::string &adfFileName)
Definition: Machine.cc:905