OpenASIP 2.2
Loading...
Searching...
No Matches
TCETargetMachinePlugin.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 TCETargetMachinePlugin.hh
26 *
27 * Declaration of TCETargetMachinePlugin class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2007 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TCE_TARGET_MACHINE_PLUGIN_HH
34#define TCE_TARGET_MACHINE_PLUGIN_HH
35
36#include <iostream>
37
38#include "tce_config.h"
39
40#define TCELE64DLString \
41 "E-p:64:64:64" \
42 "-a0:0:64" \
43 "-i1:8:8" \
44 "-i8:8:64" \
45 "-i16:16:64" \
46 "-i32:32:64" \
47 "-i64:64:64" \
48 "-f16:16:64" \
49 "-f32:32:64" \
50 "-f64:64:64" \
51 "-v64:64:64" \
52 "-v128:128:128" \
53 "-v256:256:256" \
54 "-v512:512:512" \
55 "-v1024:1024:1024" \
56 "-v2048:2048:2048" \
57 "-v4096:4096:4096"
58
59#define TCEBEDLString \
60 "E-p:32:32:32" \
61 "-a0:0:32" \
62 "-i1:8:8" \
63 "-i8:8:32" \
64 "-i16:16:32" \
65 "-i32:32:32" \
66 "-i64:32:32" \
67 "-f16:16:16" \
68 "-f32:32:32" \
69 "-f64:32:64" \
70 "-v64:32:64" \
71 "-v128:32:128" \
72 "-v512:32:512" \
73 "-v1024:32:1024"
74
75#include <llvm/IR/DataLayout.h>
76#include <llvm/CodeGen/SelectionDAGTargetInfo.h>
77
78typedef llvm::DataLayout TargetData;
79
80#include "TCEString.hh"
81
82namespace llvm {
83 class MachineOperand;
84}
85
86namespace TTAMachine {
87 class Machine;
88}
89
90/**
91 * TCE target machine plugin interface.
92 */
93namespace llvm {
94 class TargetInstrInfo;
95 class TCEInstrInfo;
96 class TargetLowering;
97 class TargetRegisterInfo;
98 class TargetFrameLowering;
99 class TargetSubtargetInfo;
100 class TargetTransformInfo;
101 class TCESubtarget;
102 class FunctionPass;
103 class TCETargetMachine;
104 class TargetRegisterClass;
105 class MachineInstr;
106 class SDNode;
107 struct EVT;
108
110 public:
111 // TODO: why is here this default??
114 // this is overwritten anyway later
115
117
118 virtual const TargetInstrInfo* getInstrInfo() const = 0;
119 virtual const TargetRegisterInfo* getRegisterInfo() const = 0;
120 virtual const TargetFrameLowering* getFrameLowering() const = 0;
121 virtual TargetLowering* getTargetLowering() const = 0;
122 virtual const TargetSubtargetInfo* getSubtarget() const = 0;
123 virtual TargetTransformInfo getTargetTransformInfo(
124 const Function& F) const = 0;
125
126 virtual FunctionPass* createISelPass(TCETargetMachine* tm) = 0;
127
128 /// Returns name of the physical register file corresponding
129 /// to a generated register ID.
130 virtual std::string rfName(unsigned dwarfRegNum) = 0;
131
132 /// Returns name of the physical register index corresponding
133 /// to a generated register ID.
134 virtual unsigned registerIndex(unsigned dwarfRegNum) = 0;
135
136 /** Returns LLVM register ID corresponding to TTA register name.
137 *
138 * @param ttaRegister The name of the TTA register. For example "RF.5".
139 * @returns The register number if it exists in the target.
140 * Otherwise, returns TCE::NoRegister.
141 */
142 virtual unsigned llvmRegisterId(const TCEString& ttaRegister) = 0;
143
144 /// Returns operation name corresponding to llvm target opcode.
145 virtual std::string operationName(unsigned opc) const = 0;
146 /// Returns true if OSAL operation is valid for stack accesses.
148 const std::string& opName) const = 0;
149 /// Returns true in case the target supports the given osal operation
150 virtual bool hasOperation(TCEString operationName) const = 0;
151 /// Returns the opcode for the given osal operation, undefined if not found.
152 virtual unsigned opcode(TCEString operationName) const = 0;
153 virtual unsigned int extractElementLane(const MachineInstr& mi) const = 0;
154
155 virtual int getTruePredicateOpcode(unsigned opc) const = 0;
156 virtual int getFalsePredicateOpcode(unsigned opc) const = 0;
157
158 /// Returns name of the data address space.
159 virtual std::string dataASName() = 0;
160 /// Returns ID number of the return address register.
161 virtual unsigned raPortDRegNum() = 0;
162 /// Returns ID number of the stack pointer register.
163 virtual unsigned spDRegNum() = 0;
164 /// Returns ID number of the frame pointer register.
165 virtual unsigned fpDRegNum() = 0;
166
167 virtual unsigned rvDRegNum() = 0;
168
169 virtual unsigned rvHighDRegNum() = 0;
170
171 virtual std::vector<unsigned> getParamDRegNums() const = 0;
172
173 virtual std::vector<unsigned> getVectorRVDRegNums() const = 0;
174
175 virtual bool hasUDIV() const = 0;
176 virtual bool hasSDIV() const = 0;
177 virtual bool hasUREM() const = 0;
178 virtual bool hasSREM() const = 0;
179 virtual bool hasMUL() const = 0;
180 virtual bool hasROTL() const = 0;
181 virtual bool hasROTR() const = 0;
182 virtual bool hasSXHW() const = 0;
183 virtual bool hasSXQW() const = 0;
184 virtual bool hasSQRTF() const = 0;
185 virtual bool hasSHR() const = 0;
186 virtual bool hasSHL() const = 0;
187 virtual bool hasSHRU() const = 0;
188
189 virtual bool has8bitLoads() const = 0;
190 virtual bool has16bitLoads() const = 0;
191
192 virtual int maxVectorSize() const = 0;
193 /// Plugin needs target machine for TragetLowering generation
195 // if not found, return -1;
196 virtual int getMinOpcode(llvm::SDNode* n) const = 0;
197 virtual int getMaxOpcode(llvm::SDNode* n) const = 0;
198 virtual int getMinuOpcode(llvm::SDNode* n) const = 0;
199 virtual int getMaxuOpcode(llvm::SDNode* n) const = 0;
200
201 virtual int getLoad(const TargetRegisterClass *rc) const = 0;
202 virtual int getStore(const TargetRegisterClass *rc) const = 0;
203
204 virtual int getLoadOpcode(const llvm::EVT& vt) const = 0;
205 // -1 or add opcode. Implementation generated to Backend.inc
206 virtual int getAddOpcode(const llvm::EVT& vt) const = 0;
207 // -1 or shl opcode. Implementation generated to Backend.inc
208 virtual int getShlOpcode(const llvm::EVT& vt) const = 0;
209 // -1 or ior opcode. Implementation generated to Backend.inc
210 virtual int getIorOpcode(const llvm::EVT& vt) const = 0;
211
212 /// Clustered-TTA-subtemplate related methods.
213 virtual const llvm::TargetRegisterClass* extrasRegClass(
214 const llvm::TargetRegisterClass* current) const = 0;
215 virtual const llvm::TargetRegisterClass* nodeRegClass(
216 unsigned nodeId, const llvm::TargetRegisterClass* current) const = 0;
217
218 virtual bool isLittleEndian() const = 0;
219 virtual bool is64bit() const = 0;
220
221 virtual const DataLayout* getDataLayout() const {
222 return &dl_;
223 }
224
225 virtual DataLayout* getDataLayout() {
226 return &dl_;
227 }
228
230 return tm_;
231 }
233 return tm_;
234 }
235
236 virtual bool analyzeCCBranch(
237 llvm::MachineInstr& i,
238 llvm::SmallVectorImpl<llvm::MachineOperand>& cond) const {
239 return true;
240 }
241
242 virtual const SelectionDAGTargetInfo* getSelectionDAGInfo() const {
243 return &tsInfo_;
244 }
245
246 // Implementation generated to Backend.inc
247 virtual bool canMaterializeConstant(const ConstantInt& ci) const = 0;
248
249 virtual std::tuple<int, int> getPointerAdjustment(
250 int offset) const = 0;
251
252 virtual MVT::SimpleValueType getDefaultType() const = 0;
253 protected:
254 /// Target machine instruction info for the llvm framework.
256 TargetLowering* lowering_;
257 TargetFrameLowering* frameInfo_;
260 DataLayout dl_; // Calculates type size & alignment
261 SelectionDAGTargetInfo tsInfo_;
262 };
263
264}
265#endif
llvm::DataLayout TargetData
#define TCELE64DLString
virtual int getStore(const TargetRegisterClass *rc) const =0
virtual int getMinuOpcode(llvm::SDNode *n) const =0
virtual bool hasUREM() const =0
virtual bool hasUDIV() const =0
virtual bool validStackAccessOperation(const std::string &opName) const =0
Returns true if OSAL operation is valid for stack accesses.
virtual const TargetFrameLowering * getFrameLowering() const =0
virtual TargetLowering * getTargetLowering() const =0
virtual int getMaxOpcode(llvm::SDNode *n) const =0
virtual int getTruePredicateOpcode(unsigned opc) const =0
virtual unsigned rvHighDRegNum()=0
virtual bool is64bit() const =0
virtual bool hasSDIV() const =0
virtual bool analyzeCCBranch(llvm::MachineInstr &i, llvm::SmallVectorImpl< llvm::MachineOperand > &cond) const
virtual bool has16bitLoads() const =0
virtual bool hasSHR() const =0
virtual bool hasSQRTF() const =0
virtual const TargetRegisterInfo * getRegisterInfo() const =0
virtual std::string dataASName()=0
Returns name of the data address space.
virtual int getFalsePredicateOpcode(unsigned opc) const =0
virtual std::vector< unsigned > getParamDRegNums() const =0
virtual const TargetInstrInfo * getInstrInfo() const =0
virtual unsigned opcode(TCEString operationName) const =0
Returns the opcode for the given osal operation, undefined if not found.
virtual std::tuple< int, int > getPointerAdjustment(int offset) const =0
virtual bool canMaterializeConstant(const ConstantInt &ci) const =0
virtual TCETargetMachine * getCurrentTargetMachine()
virtual unsigned int extractElementLane(const MachineInstr &mi) const =0
virtual std::string operationName(unsigned opc) const =0
Returns operation name corresponding to llvm target opcode.
virtual const SelectionDAGTargetInfo * getSelectionDAGInfo() const
virtual int getAddOpcode(const llvm::EVT &vt) const =0
virtual std::string rfName(unsigned dwarfRegNum)=0
Returns name of the physical register file corresponding to a generated register ID.
virtual MVT::SimpleValueType getDefaultType() const =0
virtual int getShlOpcode(const llvm::EVT &vt) const =0
virtual const TargetSubtargetInfo * getSubtarget() const =0
virtual void registerTargetMachine(TCETargetMachine &tm)=0
Plugin needs target machine for TragetLowering generation.
virtual const DataLayout * getDataLayout() const
virtual bool hasROTL() const =0
virtual int getLoad(const TargetRegisterClass *rc) const =0
virtual std::vector< unsigned > getVectorRVDRegNums() const =0
virtual int getMinOpcode(llvm::SDNode *n) const =0
virtual const TCETargetMachine * getCurrentTargetMachine() const
virtual bool hasSHRU() const =0
virtual int maxVectorSize() const =0
virtual unsigned registerIndex(unsigned dwarfRegNum)=0
Returns name of the physical register index corresponding to a generated register ID.
virtual bool hasOperation(TCEString operationName) const =0
Returns true in case the target supports the given osal operation.
virtual bool hasSHL() const =0
virtual FunctionPass * createISelPass(TCETargetMachine *tm)=0
virtual bool hasSREM() const =0
virtual bool has8bitLoads() const =0
TCEInstrInfo * instrInfo_
Target machine instruction info for the llvm framework.
virtual bool hasSXHW() const =0
virtual const llvm::TargetRegisterClass * nodeRegClass(unsigned nodeId, const llvm::TargetRegisterClass *current) const =0
virtual unsigned rvDRegNum()=0
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const =0
virtual unsigned raPortDRegNum()=0
Returns ID number of the return address register.
virtual bool isLittleEndian() const =0
virtual bool hasROTR() const =0
virtual unsigned llvmRegisterId(const TCEString &ttaRegister)=0
virtual unsigned spDRegNum()=0
Returns ID number of the stack pointer register.
virtual int getIorOpcode(const llvm::EVT &vt) const =0
virtual int getLoadOpcode(const llvm::EVT &vt) const =0
virtual unsigned fpDRegNum()=0
Returns ID number of the frame pointer register.
virtual bool hasSXQW() const =0
virtual int getMaxuOpcode(llvm::SDNode *n) const =0
virtual bool hasMUL() const =0
virtual const llvm::TargetRegisterClass * extrasRegClass(const llvm::TargetRegisterClass *current) const =0
Clustered-TTA-subtemplate related methods.