OpenASIP  2.0
TCEInstrInfo.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 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 TCEInstrInfo.h
26  *
27  * Declaration of TCEInstrInfo class.
28  *
29  * @author Veli-Pekka Jaaskelainen 2007 (vjaaskel-no.spam-cs.tut.fi)
30  * @author Heikki Kultala 2011 (heikki.kultala-no.spam-tut.fi)
31  */
32 
33 #ifndef TCE_INSTR_INFO_H
34 #define TCE_INSTR_INFO_H
35 
36 #include <llvm/Support/ErrorHandling.h>
37 #include "tce_config.h"
38 #include <llvm/CodeGen/TargetInstrInfo.h>
39 #include "TCERegisterInfo.hh"
40 
41 #define GET_INSTRINFO_HEADER
42 #include "TCEGenInstrInfo.inc"
43 
44 namespace llvm {
45 
46  class TCETargetMachine;
47  class TCETargetMachinePlugin;
48  /** !! Important !! *************
49  * ON EVERY LLVM UPDATE CHECK THESE INTERFACES VERY CAREFULLY
50  * FROM include/llvm/Target/TargetInstrInfo.h
51  *
52  * Compiler doesn warn or give error if parameter lists are changed.
53  * Many times also base class implementation works, but does not do
54  * very good job.
55  */
56 
57  class TCEInstrInfo : public TCEGenInstrInfo {
58  public:
59  TCEInstrInfo(const TCETargetMachinePlugin* plugin);
60  virtual ~TCEInstrInfo();
61 
62  const InstrItineraryData *
64  return &InstrItins;
65  }
66 
67  virtual const TargetRegisterInfo& getRegisterInfo() const {
68  return ri_;
69  }
70 
71  virtual unsigned insertBranch(
72  MachineBasicBlock &MBB, MachineBasicBlock *TBB,
73  MachineBasicBlock *FBB,
74  ArrayRef<MachineOperand> Cond,
75  const DebugLoc& DL
76  , int *BytesAdded = nullptr) const override;
77  unsigned removeBranch(
78  MachineBasicBlock &mbb,
79  int *BytesRemoved = nullptr) const override;
80 
81  virtual bool BlockHasNoFallThrough(
82  const MachineBasicBlock &MBB) const;
83 
84  virtual void storeRegToStackSlot(
85  MachineBasicBlock& mbb,
86  MachineBasicBlock::iterator mbbi,
87  unsigned srcReg, bool isKill, int frameIndex,
88  const TargetRegisterClass* rc) const;
89 
90  // changed in LLVM 2.8:
91  virtual void storeRegToStackSlot(
92  MachineBasicBlock& mbb,
93  MachineBasicBlock::iterator mbbi,
94  Register srcReg, bool isKill, int frameIndex,
95  const TargetRegisterClass* rc, const TargetRegisterInfo*) const override {
96  storeRegToStackSlot(mbb, mbbi, srcReg, isKill, frameIndex, rc);
97  }
98 
99  // TODO: this is in the form of the llvm 2.7 version of this method.
100  // this is however called by the newer version of the function.
101  virtual void loadRegFromStackSlot(
102  MachineBasicBlock& mbb,
103  MachineBasicBlock::iterator mbbi,
104  unsigned destReg, int frameIndex,
105  const TargetRegisterClass* rc) const;
106 
107  // changed in LLVM 2.8:
108  virtual void loadRegFromStackSlot(
109  MachineBasicBlock& mbb,
110  MachineBasicBlock::iterator mbbi,
111  Register destReg, int frameIndex,
112  const TargetRegisterClass* rc, const TargetRegisterInfo*) const override {
113  loadRegFromStackSlot(mbb, mbbi, destReg, frameIndex, rc);
114  }
115 
116  virtual void copyPhysReg(
117  MachineBasicBlock& mbb,
118  MachineBasicBlock::iterator mbbi,
119  const DebugLoc& DL,
120  MCRegister destReg, MCRegister srcReg,
121  bool KillSrc) const override;
122 
123  virtual bool reverseBranchCondition(
124  llvm::SmallVectorImpl<llvm::MachineOperand>& cond) const override;
125 
126  virtual bool analyzeBranch(
127  MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
128  MachineBasicBlock *&FBB,
129  llvm::SmallVectorImpl<llvm::MachineOperand>& cond,
130  bool allowModify = false)
131  const override;
132 
133  /// Analyze loop L, which must be a single-basic-block loop, and if
134  /// the conditions can be understood enough produce a
135  /// PipelinerLoopInfo object.
136  std::unique_ptr<PipelinerLoopInfo> analyzeLoopForPipelining(
137  MachineBasicBlock *LoopBB) const override;
138 
139  virtual bool isPredicated(const MachineInstr& MI) const override;
140  virtual bool isPredicable(const MachineInstr& MI) const override;
141 
142  virtual bool PredicateInstruction(
143  MachineInstr &mi,
144  ArrayRef<MachineOperand> cond) const override;
145 
146  virtual bool ClobbersPredicate(
147  MachineInstr& MI, std::vector<MachineOperand>& Pred,
148  bool SkipDead) const override;
149 
150  virtual bool
152  ArrayRef<MachineOperand> Pred1,
153  ArrayRef<MachineOperand> Pred2) const override {
154  return false;
155  }
156 
157  virtual void insertCCBranch(
158  MachineBasicBlock& mbb,
159  MachineBasicBlock& tbb,
160  ArrayRef<MachineOperand> cond,
161  const DebugLoc& dl) const;
162 
163  virtual bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
164  unsigned ExtraPredCycles,
165  BranchProbability Probability) const override;
166 
167  virtual bool isProfitableToIfCvt(MachineBasicBlock &TMBB,
168  unsigned NumTCycles, unsigned ExtraTCycles,
169  MachineBasicBlock &FMBB,
170  unsigned NumFCycles, unsigned ExtraFCycles,
171  BranchProbability Probability) const override;
172 
173  /**
174  * Return opcode for pointer adjustment and new offset.
175  *
176  * Returns opcode available or suitable for pointer adjustment with
177  * constant offset value.
178  *
179  * @param offset The offset for the pointer.
180  * @return (opcode, new offset) tuple.
181  */
182  std::tuple<int, int> getPointerAdjustment(int offset) const;
183 
184  virtual DFAPacketizer *CreateTargetScheduleState(
185  const TargetSubtargetInfo &) const override;
186 
187 private:
188  InstrItineraryData InstrItins;
189 
190  int getMatchingCondBranchOpcode(int Opc, bool inverted) const;
191 
194 
195  // implementation generated to Backend.inc from TDGen.cc
196  bool copyPhysVectorReg(
197  MachineBasicBlock& mbb,
198  MachineBasicBlock::iterator mbbi,
199  const DebugLoc& DL,
200  MCRegister destReg, MCRegister srcReg,
201  bool killSrc) const;
202  };
203 }
204 
205 #endif
llvm
Definition: InlineAsmParser.hh:49
llvm::TCEInstrInfo::isPredicated
virtual bool isPredicated(const MachineInstr &MI) const override
Definition: TCEInstrInfo.cc:559
llvm::TCEInstrInfo
Definition: TCEInstrInfo.hh:57
llvm::TCEInstrInfo::loadRegFromStackSlot
virtual void loadRegFromStackSlot(MachineBasicBlock &mbb, MachineBasicBlock::iterator mbbi, unsigned destReg, int frameIndex, const TargetRegisterClass *rc) const
Definition: TCEInstrInfo.cc:229
llvm::TCEInstrInfo::TCEInstrInfo
TCEInstrInfo(const TCETargetMachinePlugin *plugin)
Definition: TCEInstrInfo.cc:73
llvm::TCEInstrInfo::isPredicable
virtual bool isPredicable(const MachineInstr &MI) const override
Definition: TCEInstrInfo.cc:576
llvm::TCEInstrInfo::PredicateInstruction
virtual bool PredicateInstruction(MachineInstr &mi, ArrayRef< MachineOperand > cond) const override
Definition: TCEInstrInfo.cc:612
llvm::TCEInstrInfo::~TCEInstrInfo
virtual ~TCEInstrInfo()
Definition: TCEInstrInfo.cc:82
TCERegisterInfo.hh
llvm::TCEInstrInfo::loadRegFromStackSlot
virtual void loadRegFromStackSlot(MachineBasicBlock &mbb, MachineBasicBlock::iterator mbbi, Register destReg, int frameIndex, const TargetRegisterClass *rc, const TargetRegisterInfo *) const override
Definition: TCEInstrInfo.hh:108
llvm::TCEInstrInfo::storeRegToStackSlot
virtual void storeRegToStackSlot(MachineBasicBlock &mbb, MachineBasicBlock::iterator mbbi, Register srcReg, bool isKill, int frameIndex, const TargetRegisterClass *rc, const TargetRegisterInfo *) const override
Definition: TCEInstrInfo.hh:91
llvm::TCEInstrInfo::isProfitableToIfCvt
virtual bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
Definition: TCEInstrInfo.cc:699
llvm::TCEInstrInfo::CreateTargetScheduleState
virtual DFAPacketizer * CreateTargetScheduleState(const TargetSubtargetInfo &) const override
Definition: TCEInstrInfo.cc:726
llvm::TCEInstrInfo::copyPhysReg
virtual void copyPhysReg(MachineBasicBlock &mbb, MachineBasicBlock::iterator mbbi, const DebugLoc &DL, MCRegister destReg, MCRegister srcReg, bool KillSrc) const override
Definition: TCEInstrInfo.cc:256
llvm::TCEInstrInfo::insertCCBranch
virtual void insertCCBranch(MachineBasicBlock &mbb, MachineBasicBlock &tbb, ArrayRef< MachineOperand > cond, const DebugLoc &dl) const
llvm::TCEInstrInfo::plugin_
const TCETargetMachinePlugin * plugin_
Definition: TCEInstrInfo.hh:193
llvm::TCEInstrInfo::SubsumesPredicate
virtual bool SubsumesPredicate(ArrayRef< MachineOperand > Pred1, ArrayRef< MachineOperand > Pred2) const override
Definition: TCEInstrInfo.hh:151
llvm::TCEInstrInfo::analyzeBranch
virtual bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, llvm::SmallVectorImpl< llvm::MachineOperand > &cond, bool allowModify=false) const override
Definition: TCEInstrInfo.cc:449
llvm::TCEInstrInfo::getRegisterInfo
virtual const TargetRegisterInfo & getRegisterInfo() const
Definition: TCEInstrInfo.hh:67
llvm::TCEInstrInfo::getInstrItineraryData
const InstrItineraryData * getInstrItineraryData() const
Definition: TCEInstrInfo.hh:63
llvm::TCEInstrInfo::insertBranch
virtual unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
Definition: TCEInstrInfo.cc:97
llvm::TCEInstrInfo::storeRegToStackSlot
virtual void storeRegToStackSlot(MachineBasicBlock &mbb, MachineBasicBlock::iterator mbbi, unsigned srcReg, bool isKill, int frameIndex, const TargetRegisterClass *rc) const
Definition: TCEInstrInfo.cc:209
llvm::TCETargetMachinePlugin
Definition: TCETargetMachinePlugin.hh:109
llvm::TCEInstrInfo::copyPhysVectorReg
bool copyPhysVectorReg(MachineBasicBlock &mbb, MachineBasicBlock::iterator mbbi, const DebugLoc &DL, MCRegister destReg, MCRegister srcReg, bool killSrc) const
llvm::TCEInstrInfo::getMatchingCondBranchOpcode
int getMatchingCondBranchOpcode(int Opc, bool inverted) const
Definition: TCEInstrInfo.cc:669
llvm::TCEInstrInfo::InstrItins
InstrItineraryData InstrItins
Definition: TCEInstrInfo.hh:188
llvm::TCEInstrInfo::removeBranch
unsigned removeBranch(MachineBasicBlock &mbb, int *BytesRemoved=nullptr) const override
Definition: TCEInstrInfo.cc:174
llvm::TCEInstrInfo::analyzeLoopForPipelining
std::unique_ptr< PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
Analyze loop L, which must be a single-basic-block loop, and if the conditions can be understood enou...
Definition: TCEInstrInfo.cc:554
llvm::TCEInstrInfo::getPointerAdjustment
std::tuple< int, int > getPointerAdjustment(int offset) const
Definition: TCEInstrInfo.cc:721
llvm::TCEInstrInfo::ri_
const TCERegisterInfo ri_
Definition: TCEInstrInfo.hh:192
llvm::TCEInstrInfo::reverseBranchCondition
virtual bool reverseBranchCondition(llvm::SmallVectorImpl< llvm::MachineOperand > &cond) const override
Definition: TCEInstrInfo.cc:331
llvm::TCERegisterInfo
Definition: TCERegisterInfo.hh:53
llvm::TCEInstrInfo::ClobbersPredicate
virtual bool ClobbersPredicate(MachineInstr &MI, std::vector< MachineOperand > &Pred, bool SkipDead) const override
Definition: TCEInstrInfo.cc:680
llvm::TCEInstrInfo::BlockHasNoFallThrough
virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const
Definition: TCEInstrInfo.cc:196