OpenASIP 2.2
Loading...
Searching...
No Matches
LLVMTCEIRBuilder.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2015 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file LLVMTCEIRBuilder.hh
26 *
27 * This builder builds a CFG and DDG from the new LLVM TTA backend format.
28 *
29 * @author Heikki Kultala 2011
30 * @author Pekka Jääskeläinen 2011,2015
31 * @note reting: red
32 */
33
34#ifndef LLVM_TCE_IR_BUILDER_H
35#define LLVM_TCE_IR_BUILDER_H
36
37#include <llvm/CodeGen/MachineFunctionPass.h>
38#include <llvm/Analysis/AliasAnalysis.h>
39
40#include "LLVMTCEBuilder.hh"
43
44class InterPassData;
49struct InnerLoopFinder;
50
51namespace TTAMachine {
52 class Machine;
53}
54
55namespace llvm {
56
59
61 public:
62 static char ID;
63
65 const TargetMachine& tm, TTAMachine::Machine* mach,
67 bool functionAtATime=false, bool modifyMF=false);
68
69 bool writeMachineFunction(MachineFunction& mf);
70
71 virtual ~LLVMTCEIRBuilder();
72
73 virtual bool doInitialization(Module& m );
74 virtual bool doFinalization(Module& m );
75
76 virtual void emitSPInitialization() {}
77
78 void getAnalysisUsage(AnalysisUsage &AU) const;
79
80 virtual StringRef getPassName() const {
81 return "TCE: build TCE scheduler IR from MachineFunctions";
82 }
83
85 loopFinder_ = loopFinder; }
86
87 protected:
88
89 // TODO: copy-paste from LLVMPomBuilder.hh
90 virtual unsigned spDRegNum() const {
91 return dynamic_cast<const TCETargetMachine&>(
93 }
94
95 // the return address register's llvm reg number
96 virtual unsigned raPortDRegNum() const {
97 if (isTTATarget()) {
98 return dynamic_cast<const TCETargetMachine&>(
100 } else {
101 abortWithError("Unimplemented for non-TTA targets.");
102 }
103 }
104
105 // the ADF register file name of the llvm reg number
106 virtual TCEString registerFileName(unsigned llvmRegNum) const;
107
108 // the ADF register index of the llvm reg number
109 virtual int registerIndex(unsigned llvmRegNum) const;
110
111 // operation name from a LLVM MachineInstr or OSAL Operation
112 virtual TCEString operationName(const MachineInstr& mi) const;
113
115 const MachineOperand&) const {
116 // no FU terminals in the RISC-style backend, always through GPRs
117 return NULL;
118 }
119
121 const MachineOperand& mo);
122
124 const TCEString& symbolName);
125
126 virtual void createMoveNode(
128 std::shared_ptr<TTAProgram::Move> m,
129 bool isDestination) override;
130
131 private:
132
133 bool isHotFunction(llvm::MachineFunction& mf) const;
134 bool isRealInstruction(const MachineInstr& instr) const;
136 MachineBasicBlock::const_iterator i,
137 const MachineBasicBlock& mbb);
138
140 const TTAProgram::Procedure& proc,
141 llvm::MachineFunction& mf);
142
143 void compileFast(ControlFlowGraph& cfg);
144 void compileOptimized(
145 ControlFlowGraph& cfg,
146 llvm::AliasAnalysis* llvmAA);
147
148 bool isExplicitReturn(const llvm::MachineInstr& mi) const;
149
152
153 ControlFlowGraph* buildTCECFG(llvm::MachineFunction& mf);
155 llvm::MachineFunction& mf,
156 ControlFlowGraph& cfg);
158 llvm::MachineFunction& mf,
159 ControlFlowGraph& cfg);
160
162 // TODO: how to get these?
163 std::set<TCEString> allParamRegs_;
164
165 // todo: information about sp and param regs, how to give?
167
168 std::map<const MachineBasicBlock*,BasicBlockNode*> bbMapping_;
169
170 std::vector<std::vector<BasicBlockNode*> > jumpTableRecord_;
171
173
174 // write back the scheduled instructions to the machine function?
176
177 std::map<const MachineBasicBlock*, BasicBlockNode*> skippedBBs_;
178
180
184
186 };
187}
188
189#endif
#define abortWithError(message)
std::shared_ptr< ProgramOperation > ProgramOperationPtr
Definition MoveNode.hh:53
const TargetMachine & targetMachine() const
virtual bool isTTATarget() const
virtual TTAProgram::Terminal * createSymbolReference(const TCEString &symbolName)
virtual unsigned raPortDRegNum() const
void markJumpTableDestinations(llvm::MachineFunction &mf, ControlFlowGraph &cfg)
virtual StringRef getPassName() const
bool isRealInstruction(const MachineInstr &instr) const
BBSchedulerController * scheduler_
CopyingDelaySlotFiller & delaySlotFiller()
void compileFast(ControlFlowGraph &cfg)
DataDependenceGraphBuilder ddgBuilder_
bool hasRealInstructions(MachineBasicBlock::const_iterator i, const MachineBasicBlock &mbb)
void setInnerLoopFinder(InnerLoopFinder *loopFinder)
virtual TTAProgram::Terminal * createFUTerminal(const MachineOperand &) const
std::vector< std::vector< BasicBlockNode * > > jumpTableRecord_
virtual TCEString registerFileName(unsigned llvmRegNum) const
bool isHotFunction(llvm::MachineFunction &mf) const
virtual unsigned spDRegNum() const
CopyingDelaySlotFiller * dsf_
bool writeMachineFunction(MachineFunction &mf)
std::map< const MachineBasicBlock *, BasicBlockNode * > skippedBBs_
virtual TCEString operationName(const MachineInstr &mi) const
void compileOptimized(ControlFlowGraph &cfg, llvm::AliasAnalysis *llvmAA)
void convertProcedureToMachineFunction(const TTAProgram::Procedure &proc, llvm::MachineFunction &mf)
virtual void emitSPInitialization()
CycleLookBackSoftwareBypasser * bypasser_
virtual bool doInitialization(Module &m)
virtual TTAProgram::Terminal * createMBBReference(const MachineOperand &mo)
void fixJumpTableDestinations(llvm::MachineFunction &mf, ControlFlowGraph &cfg)
std::set< TCEString > allParamRegs_
std::map< const MachineBasicBlock *, BasicBlockNode * > bbMapping_
void getAnalysisUsage(AnalysisUsage &AU) const
virtual int registerIndex(unsigned llvmRegNum) const
virtual bool doFinalization(Module &m)
virtual void createMoveNode(ProgramOperationPtr &po, std::shared_ptr< TTAProgram::Move > m, bool isDestination) override
BBSchedulerController & scheduler()
bool isExplicitReturn(const llvm::MachineInstr &mi) const
InnerLoopFinder * loopFinder_
ControlFlowGraph * buildTCECFG(llvm::MachineFunction &mf)
FunctionPass * createLLVMTCECFGBuilderPass(TCETargetMachine &tm, TTAMachine::Machine *mach, InterPassData &ipd)
AAResults AliasAnalysis