OpenASIP 2.2
Loading...
Searching...
No Matches
TCEISelLowering.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 TCETargetLowering.h
26 *
27 * Declaration of TCETargetLowering class.
28 *
29 * @author Veli-Pekka J��skel�inen 2007 (vjaaskel-no.spam-cs.tut.fi)
30 * @author Mikael Lepist� 2009 (mikael.lepisto-no.spam-tut.fi)
31 */
32
33#ifndef TCE_TARGET_LOWERING_H
34#define TCE_TARGET_LOWERING_H
35
36#include <llvm/CodeGen/TargetLowering.h>
37#include "TCEPlugin.hh"
38#include "TCESubtarget.hh"
39#include "tce_config.h"
40#include "TCEString.hh"
41#include <map>
42#include <iostream>
43
44namespace TCEISD {
45 enum {
46 FIRST_NUMBER = llvm::ISD::BUILTIN_OP_END,
55
59
60 Hi, Lo, // Hi/Lo operations, typically on a global address.
61
62 FTOI, // FP to Int within a FP register.
63 ITOF, // Int to FP within a FP register.
64
65 CALL, // A call instruction.
66 RET_FLAG , // Return with a flag operand.
71 };
72}
73
74namespace llvm {
75
76#define SDLOC_PARAM_TYPE const SDLoc&
77
78 class TCETargetMachine;
79
80 /**
81 * Lowers LLVM code to SelectionDAG for the TCE backend.
82 */
83 class TCETargetLowering : public llvm::TargetLowering {
84 mutable int VarArgsFrameOffset; // Frame offset to start of varargs area.
85 public:
86 TCETargetLowering(TargetMachine &TM, const TCESubtarget &subt);
87
88 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
89 virtual SDValue PerformDAGCombine(
90 SDNode *N, DAGCombinerInfo &DCI) const override;
91
92 int getVarArgsFrameOffset() const /* override */ { return VarArgsFrameOffset; }
93
94 virtual const char* getTargetNodeName(unsigned opcode) const override;
95
96 ConstraintType getConstraintType(StringRef Constraint) const override;
97 std::pair<unsigned, const TargetRegisterClass *>
98 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
99 StringRef Constraint, MVT VT) const override;
100
102 SDValue Op,
103 std::string& Constraint,
104 std::vector<SDValue>& Ops,
105 SelectionDAG& DAG) const override;
106
107 //TODO: this is from some old version - which?
108 std::vector<unsigned>
109 getRegClassForInlineAsmConstraint(const std::string &Constraint,
110 EVT VT) const;
111 virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
112
113 /// getFunctionAlignment - Return the Log2 alignment of this function.
114
115 virtual SDValue
116 LowerFormalArguments(SDValue Chain,
117 CallingConv::ID CallConv,
118 bool isVarArg,
119 const SmallVectorImpl<ISD::InputArg> &Ins,
120 SDLOC_PARAM_TYPE dl, SelectionDAG &DAG,
121 SmallVectorImpl<SDValue> &InVals) const override;
122
123 SDValue LowerTRAP(SDValue Op, SelectionDAG &DAG) const;
124 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
125 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
126 SDValue LowerConstant(SDValue Op, SelectionDAG &DAG) const;
127 SDValue LowerBuildVector(SDValue Op, SelectionDAG &DAG) const;
128 SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
129 SDValue LowerShift(SDValue op, SelectionDAG& dag) const;
131 SDValue Op, MVT newElementVT, int elemCount, SelectionDAG &DAG) const;
132 SDValue lowerHWLoops(SDValue op, SelectionDAG &dag) const;
133 SDValue lowerFABS(SDValue op, SelectionDAG &dag) const;
134
135 SDValue lowerExtOrBoolLoad(SDValue op, SelectionDAG& DAG) const;
136
137 std::pair<int, TCEString> getConstShiftNodeAndTCEOP(SDValue op) const;
138
139 virtual SDValue
140 LowerCall(TargetLowering::CallLoweringInfo &CLI,
141 SmallVectorImpl<SDValue> &InVals) const override;
142
143 virtual SDValue
144 LowerReturn(SDValue Chain,
145 CallingConv::ID CallConv, bool isVarArg,
146 const SmallVectorImpl<ISD::OutputArg> &Outs,
147 const SmallVectorImpl<SDValue> &OutVals,
148 SDLOC_PARAM_TYPE dl, SelectionDAG &DAG) const override;
149
150 bool isConstantOrUndefBuild(const SDNode& node) const;
151 bool canEncodeConstantOperands(const SDNode& node) const;
152 bool canEncodeImmediate(const ConstantSDNode& node) const;
153
154 bool shouldLoadFromConstantPool(unsigned addressSpace) const;
155
156// virtual bool allowsMisalignedMemoryAccesses(EVT VT, unsigned as, unsigned align, MachineMemOperand::Flags flags, bool* ) const override;
157 // We can ignore the bitwidth differences between the pointers
158 // for now. It's the programmer's responsibility to ensure they
159 // fit.
160 // ----------------------------------------------------
161 //
162 // Below here TCE specific stuff is added, which is not copied from Sparc
163 //
164 // ----------------------------------------------------
165
166 SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const;
167
168 static bool isBroadcast(SDNode *n);
169
170 private:
171
172 bool hasI1RegisterClass() const;
173
174 /// Tells if the target machine has boolean register file.
175 bool hasI1RC_ = false;
176
178
179 /// Predicates to tell whenever the addresses belonging to a address
180 /// space should be loaded from constant pool instead of immediates.
181 /// Address space as index maps to the predicate.
182 std::map<unsigned, bool> loadGAFromConstantPool_;
183
184 const TargetRegisterClass*
186 const TargetRegisterInfo* TRI, MVT VT) const;
187
188 /// Implementation generated to Backend.inc from TDGenSIMD.cc.
190
191 /// Implementation generated to Backend.inc from TDGenSIMD.cc.
192 std::pair<unsigned, const TargetRegisterClass *>
193 associatedVectorRegClass(const EVT &vt) const;
194
195 /// Implementation generated to Backend.inc from TDGenSIMD.cc.
196 virtual llvm::EVT getSetCCResultVT(const EVT &VT) const;
197
198 /// Implementation generated to Backend.inc from TDGenSIMD.cc.
200
201 public:
202 llvm::EVT getSetCCResultType(
203 const DataLayout &DL, LLVMContext &Context,
204 EVT VT) const override;
205
206 virtual bool isFPImmLegal(
207 const APFloat& apf, EVT VT, bool forCodeSize) const override;
208
209 SDValue ExpandLibCall(
210 RTLIB::Libcall LC, SDNode *Node, bool isSigned, SelectionDAG &DAG)
211 const;
212
213 void ReplaceNodeResults(SDNode * node,
214 SmallVectorImpl< SDValue > &,
215 SelectionDAG &) const override;
216
217 };
218}
219
220#endif
#define SDLOC_PARAM_TYPE
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const
SDValue lowerFABS(SDValue op, SelectionDAG &dag) const
static bool isBroadcast(SDNode *n)
SDValue LowerShift(SDValue op, SelectionDAG &dag) const
void ReplaceNodeResults(SDNode *node, SmallVectorImpl< SDValue > &, SelectionDAG &) const override
virtual SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, SDLOC_PARAM_TYPE dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
getFunctionAlignment - Return the Log2 alignment of this function.
virtual bool isFPImmLegal(const APFloat &apf, EVT VT, bool forCodeSize) const override
SDValue LowerTRAP(SDValue Op, SelectionDAG &DAG) const
SDValue LowerConstant(SDValue Op, SelectionDAG &DAG) const
virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
llvm::EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const override
SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const
virtual const char * getTargetNodeName(unsigned opcode) const override
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
bool hasI1RC_
Tells if the target machine has boolean register file.
std::pair< unsigned, const TargetRegisterClass * > associatedVectorRegClass(const EVT &vt) const
Implementation generated to Backend.inc from TDGenSIMD.cc.
const TargetRegisterClass * getVectorRegClassForInlineAsmConstraint(const TargetRegisterInfo *TRI, MVT VT) const
void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, std::vector< SDValue > &Ops, SelectionDAG &DAG) const override
void addVectorRegisterClasses()
Implementation generated to Backend.inc from TDGenSIMD.cc.
bool canEncodeImmediate(const ConstantSDNode &node) const
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
virtual SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, SDLOC_PARAM_TYPE dl, SelectionDAG &DAG) const override
virtual SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
SDValue lowerExtOrBoolLoad(SDValue op, SelectionDAG &DAG) const
std::vector< unsigned > getRegClassForInlineAsmConstraint(const std::string &Constraint, EVT VT) const
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const
bool canEncodeConstantOperands(const SDNode &node) const
SDValue lowerHWLoops(SDValue op, SelectionDAG &dag) const
SDValue LowerBuildVector(SDValue Op, SelectionDAG &DAG) const
virtual llvm::EVT getSetCCResultVT(const EVT &VT) const
Implementation generated to Backend.inc from TDGenSIMD.cc.
bool isConstantOrUndefBuild(const SDNode &node) const
ConstraintType getConstraintType(StringRef Constraint) const override
getConstraintType - Given a constraint letter, return the type of constraint it is for this target.
bool shouldLoadFromConstantPool(unsigned addressSpace) const
SDValue LowerBuildBooleanVectorVector(SDValue Op, MVT newElementVT, int elemCount, SelectionDAG &DAG) const
std::map< unsigned, bool > loadGAFromConstantPool_
Predicates to tell whenever the addresses belonging to a address space should be loaded from constant...
SDValue ExpandLibCall(RTLIB::Libcall LC, SDNode *Node, bool isSigned, SelectionDAG &DAG) const
void addVectorLowerings()
Implementation generated to Backend.inc from TDGenSIMD.cc.
std::pair< int, TCEString > getConstShiftNodeAndTCEOP(SDValue op) const