OpenASIP  2.0
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
TCEDAGToDAGISel Class Reference
Inheritance diagram for TCEDAGToDAGISel:
Inheritance graph
Collaboration diagram for TCEDAGToDAGISel:
Collaboration graph

Public Member Functions

 TCEDAGToDAGISel (llvm::TCETargetMachine &tm)
 
virtual ~TCEDAGToDAGISel ()
 
bool SelectADDRrr (SDValue N, SDValue &R1, SDValue &R2)
 
bool SelectADDRri (SDValue N, SDValue &Base, SDValue &Offset)
 
void Select (llvm::SDNode *op) override
 
virtual StringRef getPassName () const override
 

Private Member Functions

void SelectOptimizedBuildVector (SDNode *n)
 
EVT getIntegerVectorVT (EVT vt)
 
MachineSDNode * createPackNode (SDNode *n, const EVT &vt, int laneCount, SDValue *vals)
 

Static Private Member Functions

static bool isBroadcast (SDNode *n)
 
static bool isConstantBuild (SDNode *n)
 
static bool isConstantFPBuild (SDNode *n)
 

Private Attributes

llvm::TCETargetLoweringlowering_
 
const llvm::TCESubtargetsubtarget_
 
llvm::TCETargetMachinetm_
 

Detailed Description

Definition at line 57 of file TCEDAGToDAGISel.cc.

Constructor & Destructor Documentation

◆ TCEDAGToDAGISel()

TCEDAGToDAGISel::TCEDAGToDAGISel ( llvm::TCETargetMachine tm)
explicit

Constructor.

Definition at line 93 of file TCEDAGToDAGISel.cc.

93  :
94  SelectionDAGISel(tm),
95  lowering_(*static_cast<TCETargetLowering*>(tm.getTargetLowering())),
96  subtarget_(*tm.getSubtargetImpl()), tm_(&tm) {
97 }

◆ ~TCEDAGToDAGISel()

TCEDAGToDAGISel::~TCEDAGToDAGISel ( )
virtual

Destructor.

Definition at line 102 of file TCEDAGToDAGISel.cc.

102  {
103 }

Member Function Documentation

◆ createPackNode()

MachineSDNode* TCEDAGToDAGISel::createPackNode ( SDNode *  n,
const EVT &  vt,
int  laneCount,
SDValue *  vals 
)
private

◆ getIntegerVectorVT()

EVT TCEDAGToDAGISel::getIntegerVectorVT ( EVT  vt)
private

◆ getPassName()

virtual StringRef TCEDAGToDAGISel::getPassName ( ) const
inlineoverridevirtual

Definition at line 67 of file TCEDAGToDAGISel.cc.

67  {
68  return "TCE DAG->DAG Pattern Instruction Selection";
69  }

◆ isBroadcast()

bool TCEDAGToDAGISel::isBroadcast ( SDNode *  n)
staticprivate

Definition at line 289 of file TCEDAGToDAGISel.cc.

289  {
290  return TCETargetLowering::isBroadcast(n);
291 }

◆ isConstantBuild()

bool TCEDAGToDAGISel::isConstantBuild ( SDNode *  n)
staticprivate

Definition at line 294 of file TCEDAGToDAGISel.cc.

294  {
295  int operandCount = n->getNumOperands();
296  for (unsigned i = 1; i <operandCount; i++) {
297  SDValue val2 = n->getOperand(i);
298  SDNode *n2 = val2.getNode();
299  if (n2->getOpcode() != ISD::Constant ) {
300  return false;
301  }
302  }
303  return true;
304 }

◆ isConstantFPBuild()

bool TCEDAGToDAGISel::isConstantFPBuild ( SDNode *  n)
staticprivate

Definition at line 307 of file TCEDAGToDAGISel.cc.

307  {
308  int operandCount = n->getNumOperands();
309  for (unsigned i = 1; i <operandCount; i++) {
310  SDValue val2 = n->getOperand(i);
311  SDNode *n2 = val2.getNode();
312  if (n2->getOpcode() != ISD::ConstantFP) {
313  return false;
314  }
315  }
316  return true;
317 }

◆ Select()

void TCEDAGToDAGISel::Select ( llvm::SDNode *  op)
override

Handles custom instruction selections.

Parameters
opOperation to select.

Definition at line 120 of file TCEDAGToDAGISel.cc.

120  {
121  // Custom nodes are already selected
122  if (n->isMachineOpcode()) {
123  n->setNodeId(-1);
124  return;
125  }
126 
127  SDLoc dl(n);
128  if (n->getOpcode() >= ISD::BUILTIN_OP_END &&
129  n->getOpcode() < TCEISD::FIRST_NUMBER) {
130  // Already selected.
131  return;
132  } else if (n->getOpcode() == ISD::BR) {
133  SDValue chain = n->getOperand(0);
134 
135  MachineBasicBlock* dest =
136  cast<BasicBlockSDNode>(n->getOperand(1))->getBasicBlock();
138  n, TCE::TCEBR, MVT::Other, CurDAG->getBasicBlock(dest), chain);
139  } else if (n->getOpcode() == ISD::FrameIndex) {
140  int fi = cast<FrameIndexSDNode>(n)->getIndex();
141 
142  if (n->hasOneUse()) {
145  CurDAG->getTargetFrameIndex(fi, DEFAULT_TYPE));
146  } else {
147  auto fiN = CurDAG->getMachineNode(
148  MOVE_IMM, dl, DEFAULT_TYPE,
149  CurDAG->getTargetFrameIndex(fi, DEFAULT_TYPE));
150  ReplaceNode(n, fiN);
151  return;
152  }
153  } else if (n->getOpcode() == ISD::VSELECT ||
154  (n->getOpcode() == ISD::SELECT &&
155  !n->getOperand(1).getValueType().isVector())) {
156  SDNode* node2 = dyn_cast<SDNode>(n->getOperand(0));
157  if (node2->getOpcode() == ISD::SETCC) {
158  SDValue val1 = n->getOperand(1);
159  SDValue val2 = n->getOperand(2);
160 
161  SDValue n2val1 = node2->getOperand(0);
162  SDValue n2val2 = node2->getOperand(1);
163 
164  if (val1 == n2val1 && val2 == n2val2 && node2->hasOneUse()) {
165  int opc;
166  ISD::CondCode cc = cast<CondCodeSDNode>(
167  node2->getOperand(2))->get();
168 
169  switch (cc) {
170  case ISD::SETLT:
171  case ISD::SETLE:
172  case ISD::SETOLT:
173  case ISD::SETOLE:
174  opc = tm_->getMinOpcode(n);
175  if (opc != -1) {
177  n,opc, n->getSimpleValueType(0), val1, val2);
178  }
179  break;
180  case ISD::SETGT:
181  case ISD::SETGE:
182  case ISD::SETOGT:
183  case ISD::SETOGE: // todo: what is ordered here? nan handling?
184  opc = tm_->getMaxOpcode(n);
185  if (opc != -1) {
187  n, opc, n->getSimpleValueType(0), val1, val2);
188  }
189  break;
190  case ISD::SETULT:
191  case ISD::SETULE:
192  opc = tm_->getMinuOpcode(n);
193  if (opc != -1) {
195  n, opc, n->getSimpleValueType(0), val1, val2);
196  }
197  break;
198  case ISD::SETUGT:
199  case ISD::SETUGE:
200  opc = tm_->getMaxuOpcode(n);
201  if (opc != -1) {
203  n, opc, n->getSimpleValueType(0), val1, val2);
204  }
205  break;
206  default:
207  break;
208  }
209  }
210  }
211  } else if (n->getOpcode() == ISD::SHL ||
212  n->getOpcode() == ISD::SRA ||
213  n->getOpcode() == ISD::SRL) {
214  SDValue shifted = n->getOperand(0);
215  SDValue shifter = n->getOperand(1);
216  EVT shiftedVt = shifted.getValueType();
217  EVT shifterVt = shifter.getValueType();
218 
219  } else if (n->getOpcode() == ISD::AND ||
220  n->getOpcode() == ISD::OR ||
221  n->getOpcode() == ISD::XOR) {
222  SDValue lhs = n->getOperand(0);
223  SDValue rhs = n->getOperand(1);
224  EVT lhsVt = lhs.getValueType();
225  EVT rhsVt = rhs.getValueType();
226  }
227 
228  SelectCode(n);
229 }

References DEFAULT_TYPE, TCEISD::FIRST_NUMBER, llvm::TCETargetMachine::getMaxOpcode(), llvm::TCETargetMachine::getMaxuOpcode(), llvm::TCETargetMachine::getMinOpcode(), llvm::TCETargetMachine::getMinuOpcode(), MOVE_IMM, SELECT_NODE_AND_RETURN, and tm_.

Here is the call graph for this function:

◆ SelectADDRri()

bool TCEDAGToDAGISel::SelectADDRri ( SDValue  addr,
SDValue &  base,
SDValue &  offset 
)

Handles ADDRri operands.

Definition at line 237 of file TCEDAGToDAGISel.cc.

238  {
239 
240  if (FrameIndexSDNode* fin = dyn_cast<FrameIndexSDNode>(addr)) {
241  base = CurDAG->getTargetFrameIndex(fin->getIndex(), DEFAULT_TYPE);
242  offset = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
243  return true;
244  } else if (addr.getOpcode() == ISD::TargetExternalSymbol ||
245  addr.getOpcode() == ISD::TargetGlobalAddress) {
246 
247  return false; // direct calls.
248  }
249  base = addr;
250  offset = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
251  return true;
252 }

References DEFAULT_TYPE.

◆ SelectADDRrr()

bool TCEDAGToDAGISel::SelectADDRrr ( SDValue  addr,
SDValue &  r1,
SDValue &  r2 
)

Handles ADDRrr operands.

Definition at line 258 of file TCEDAGToDAGISel.cc.

259  {
260 
261  if (addr.getOpcode() == ISD::TargetGlobalAddress) {
262  //r1 = addr.getOperand(0);
263  //r2 = CurDAG->getTargetConstant(cn->getValue(), MVT::i32);
264  //return true:
265  return false;
266  } else if (addr.getOpcode() == ISD::TargetExternalSymbol) {
267  return false;
268  } else if (addr.getOpcode() == ISD::FrameIndex) {
269  return false;
270  }
271 
272  r1 = addr;
273 
274  r2 = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
275  return true;
276 }

References DEFAULT_TYPE.

◆ SelectOptimizedBuildVector()

void TCEDAGToDAGISel::SelectOptimizedBuildVector ( SDNode *  n)
private

Member Data Documentation

◆ lowering_

llvm::TCETargetLowering& TCEDAGToDAGISel::lowering_
private

Definition at line 83 of file TCEDAGToDAGISel.cc.

◆ subtarget_

const llvm::TCESubtarget& TCEDAGToDAGISel::subtarget_
private

Definition at line 84 of file TCEDAGToDAGISel.cc.

◆ tm_

llvm::TCETargetMachine* TCEDAGToDAGISel::tm_
private

Definition at line 85 of file TCEDAGToDAGISel.cc.

Referenced by Select().


The documentation for this class was generated from the following file:
llvm::TCETargetMachine::getMinuOpcode
int getMinuOpcode(llvm::SDNode *n)
Definition: TCETargetMachine.hh:249
llvm::TCETargetMachine::getMaxOpcode
int getMaxOpcode(llvm::SDNode *n)
Definition: TCETargetMachine.hh:253
TCEISD::FIRST_NUMBER
@ FIRST_NUMBER
Definition: TCEISelLowering.hh:46
llvm::TCETargetMachine::getMaxuOpcode
int getMaxuOpcode(llvm::SDNode *n)
Definition: TCETargetMachine.hh:257
TCEDAGToDAGISel::tm_
llvm::TCETargetMachine * tm_
Definition: TCEDAGToDAGISel.cc:85
llvm::TCETargetMachine::getSubtargetImpl
virtual const TCESubtarget * getSubtargetImpl() const
Definition: TCETargetMachine.hh:144
llvm::TCETargetMachine::getTargetLowering
virtual TargetLowering * getTargetLowering() const
Definition: TCETargetMachine.hh:169
llvm::TCETargetLowering
Definition: TCEISelLowering.hh:83
TCEDAGToDAGISel::subtarget_
const llvm::TCESubtarget & subtarget_
Definition: TCEDAGToDAGISel.cc:84
DEFAULT_TYPE
#define DEFAULT_TYPE
Definition: TCEDAGToDAGISel.cc:51
SELECT_NODE_AND_RETURN
#define SELECT_NODE_AND_RETURN(args...)
Definition: TCEDAGToDAGISel.cc:106
llvm::TCETargetMachine::getMinOpcode
int getMinOpcode(llvm::SDNode *n)
Definition: TCETargetMachine.hh:245
TCEDAGToDAGISel::lowering_
llvm::TCETargetLowering & lowering_
Definition: TCEDAGToDAGISel.cc:83
MOVE_IMM
#define MOVE_IMM
Definition: TCEDAGToDAGISel.cc:52