OpenASIP 2.2
Loading...
Searching...
No Matches
Classes | Macros
TCEDAGToDAGISel.cc File Reference
#include "tce_config.h"
#include <llvm/IR/Intrinsics.h>
#include <llvm/Support/Debug.h>
#include <llvm/Support/Compiler.h>
#include <llvm/Support/raw_ostream.h>
#include "TCEDAGToDAGISel.hh"
#include "TCETargetMachine.hh"
#include "TCESubtarget.hh"
#include "TCEISelLowering.hh"
#include "Conversion.hh"
#include "MathTools.hh"
#include "TCEGenDAGISel.inc"
Include dependency graph for TCEDAGToDAGISel.cc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TCEDAGToDAGISel
 

Macros

#define DEFAULT_TYPE   MVT::i32
 
#define MOVE_IMM   TCE::MOVI32ri
 
#define SELECT_NODE_AND_RETURN(args...)
 
#define RETURN_SELECTED_NODE(node)
 

Macro Definition Documentation

◆ DEFAULT_TYPE

#define DEFAULT_TYPE   MVT::i32

Definition at line 51 of file TCEDAGToDAGISel.cc.

◆ MOVE_IMM

#define MOVE_IMM   TCE::MOVI32ri

Definition at line 52 of file TCEDAGToDAGISel.cc.

◆ RETURN_SELECTED_NODE

#define RETURN_SELECTED_NODE (   node)
Value:
(void)(node); \
return

Definition at line 121 of file TCEDAGToDAGISel.cc.

131 {
132 // Custom nodes are already selected
133 if (n->isMachineOpcode()) {
134 n->setNodeId(-1);
135 return;
136 }
137
138 SDLoc dl(n);
139 if (n->getOpcode() >= ISD::BUILTIN_OP_END &&
140 n->getOpcode() < TCEISD::FIRST_NUMBER) {
141 // Already selected.
142 return;
143 } else if (n->getOpcode() == ISD::BR) {
144 SDValue chain = n->getOperand(0);
145
146 MachineBasicBlock* dest =
147 cast<BasicBlockSDNode>(n->getOperand(1))->getBasicBlock();
149 n, TCE::TCEBR, MVT::Other, CurDAG->getBasicBlock(dest), chain);
150 } else if (n->getOpcode() == ISD::FrameIndex) {
151 int fi = cast<FrameIndexSDNode>(n)->getIndex();
152
153 if (n->hasOneUse()) {
156 CurDAG->getTargetFrameIndex(fi, DEFAULT_TYPE));
157 } else {
158 auto fiN = CurDAG->getMachineNode(
160 CurDAG->getTargetFrameIndex(fi, DEFAULT_TYPE));
161 ReplaceNode(n, fiN);
162 return;
163 }
164 } else if (n->getOpcode() == ISD::VSELECT ||
165 (n->getOpcode() == ISD::SELECT &&
166 !n->getOperand(1).getValueType().isVector())) {
167 SDNode* node2 = dyn_cast<SDNode>(n->getOperand(0));
168 if (node2->getOpcode() == ISD::SETCC) {
169 SDValue val1 = n->getOperand(1);
170 SDValue val2 = n->getOperand(2);
171
172 SDValue n2val1 = node2->getOperand(0);
173 SDValue n2val2 = node2->getOperand(1);
174
175 if (val1 == n2val1 && val2 == n2val2 && node2->hasOneUse()) {
176 int opc;
177 ISD::CondCode cc = cast<CondCodeSDNode>(
178 node2->getOperand(2))->get();
179
180 switch (cc) {
181 case ISD::SETLT:
182 case ISD::SETLE:
183 case ISD::SETOLT:
184 case ISD::SETOLE:
185 opc = tm_->getMinOpcode(n);
186 if (opc != -1) {
188 n,opc, n->getSimpleValueType(0), val1, val2);
189 }
190 break;
191 case ISD::SETGT:
192 case ISD::SETGE:
193 case ISD::SETOGT:
194 case ISD::SETOGE: // todo: what is ordered here? nan handling?
195 opc = tm_->getMaxOpcode(n);
196 if (opc != -1) {
198 n, opc, n->getSimpleValueType(0), val1, val2);
199 }
200 break;
201 case ISD::SETULT:
202 case ISD::SETULE:
203 opc = tm_->getMinuOpcode(n);
204 if (opc != -1) {
206 n, opc, n->getSimpleValueType(0), val1, val2);
207 }
208 break;
209 case ISD::SETUGT:
210 case ISD::SETUGE:
211 opc = tm_->getMaxuOpcode(n);
212 if (opc != -1) {
214 n, opc, n->getSimpleValueType(0), val1, val2);
215 }
216 break;
217 default:
218 break;
219 }
220 }
221 }
222 } else if (n->getOpcode() == ISD::SHL ||
223 n->getOpcode() == ISD::SRA ||
224 n->getOpcode() == ISD::SRL) {
225 SDValue shifted = n->getOperand(0);
226 SDValue shifter = n->getOperand(1);
227 EVT shiftedVt = shifted.getValueType();
228 EVT shifterVt = shifter.getValueType();
229
230 } else if (n->getOpcode() == ISD::AND ||
231 n->getOpcode() == ISD::OR ||
232 n->getOpcode() == ISD::XOR) {
233 SDValue lhs = n->getOperand(0);
234 SDValue rhs = n->getOperand(1);
235 EVT lhsVt = lhs.getValueType();
236 EVT rhsVt = rhs.getValueType();
237 }
238
239 SelectCode(n);
240}
241#undef SELECT_NODE_AND_RETURN
242#undef RETURN_SELECTED_NODE
243
244/**
245 * Handles ADDRri operands.
246 */
247bool
249 SDValue addr, SDValue& base, SDValue& offset) {
250
251 if (FrameIndexSDNode* fin = dyn_cast<FrameIndexSDNode>(addr)) {
252 base = CurDAG->getTargetFrameIndex(fin->getIndex(), DEFAULT_TYPE);
253 offset = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
254 return true;
255 } else if (addr.getOpcode() == ISD::TargetExternalSymbol ||
256 addr.getOpcode() == ISD::TargetGlobalAddress) {
257
258 return false; // direct calls.
259 }
260 base = addr;
261 offset = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
262 return true;
263}
264
265/**
266 * Handles ADDRrr operands.
267 */
268bool
270 SDValue addr, SDValue& r1, SDValue& r2) {
271
272 if (addr.getOpcode() == ISD::TargetGlobalAddress) {
273 //r1 = addr.getOperand(0);
274 //r2 = CurDAG->getTargetConstant(cn->getValue(), MVT::i32);
275 //return true:
276 return false;
277 } else if (addr.getOpcode() == ISD::TargetExternalSymbol) {
278 return false;
279 } else if (addr.getOpcode() == ISD::FrameIndex) {
280 return false;
281 }
282
283 r1 = addr;
284
285 r2 = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
286 return true;
287}
288
289/**
290 * Returns an instance of the instruction selector.
291 *
292 * @param tm Target machine description.
293 */
294FunctionPass*
296 return new TCEDAGToDAGISel(tm);
297}
298
299bool
302}
303
304bool
306 int operandCount = n->getNumOperands();
307 for (unsigned i = 1; i <operandCount; i++) {
308 SDValue val2 = n->getOperand(i);
309 SDNode *n2 = val2.getNode();
310 if (n2->getOpcode() != ISD::Constant ) {
311 return false;
312 }
313 }
314 return true;
315}
316
317bool
319 int operandCount = n->getNumOperands();
320 for (unsigned i = 1; i <operandCount; i++) {
321 SDValue val2 = n->getOperand(i);
322 SDNode *n2 = val2.getNode();
323 if (n2->getOpcode() != ISD::ConstantFP) {
324 return false;
325 }
326 }
327 return true;
328}
#define MOVE_IMM
#define DEFAULT_TYPE
#define SELECT_NODE_AND_RETURN(args...)
static bool isConstantFPBuild(SDNode *n)
bool SelectADDRrr(SDValue N, SDValue &R1, SDValue &R2)
static bool isConstantBuild(SDNode *n)
bool SelectADDRri(SDValue N, SDValue &Base, SDValue &Offset)
static bool isBroadcast(SDNode *n)
static bool isBroadcast(SDNode *n)
FunctionPass * createTCEISelDag(TCETargetMachine &tm)

◆ SELECT_NODE_AND_RETURN

#define SELECT_NODE_AND_RETURN (   args...)
Value:
CurDAG->SelectNodeTo(args); \
return

Definition at line 118 of file TCEDAGToDAGISel.cc.