OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | 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
 

Static Public Attributes

static char ID = 0
 

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 101 of file TCEDAGToDAGISel.cc.

101 :
102 #ifdef LLVM_OLDER_THAN_16
103 SelectionDAGISel(tm),
104 #else
105 SelectionDAGISel(ID, tm),
106 #endif
107 lowering_(*static_cast<TCETargetLowering*>(tm.getTargetLowering())),
108 subtarget_(*tm.getSubtargetImpl()), tm_(&tm) {
109}
llvm::TCETargetLowering & lowering_
const llvm::TCESubtarget & subtarget_
llvm::TCETargetMachine * tm_
virtual const TCESubtarget * getSubtargetImpl() const
virtual TargetLowering * getTargetLowering() const

◆ ~TCEDAGToDAGISel()

TCEDAGToDAGISel::~TCEDAGToDAGISel ( )
virtual

Destructor.

Definition at line 114 of file TCEDAGToDAGISel.cc.

114 {
115}

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 71 of file TCEDAGToDAGISel.cc.

71 {
72 return "TCE DAG->DAG Pattern Instruction Selection";
73 }

◆ isBroadcast()

bool TCEDAGToDAGISel::isBroadcast ( SDNode *  n)
staticprivate

Definition at line 301 of file TCEDAGToDAGISel.cc.

301 {
303}
static bool isBroadcast(SDNode *n)

References llvm::TCETargetLowering::isBroadcast().

Here is the call graph for this function:

◆ isConstantBuild()

bool TCEDAGToDAGISel::isConstantBuild ( SDNode *  n)
staticprivate

Definition at line 306 of file TCEDAGToDAGISel.cc.

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

◆ isConstantFPBuild()

bool TCEDAGToDAGISel::isConstantFPBuild ( SDNode *  n)
staticprivate

Definition at line 319 of file TCEDAGToDAGISel.cc.

319 {
320 int operandCount = n->getNumOperands();
321 for (unsigned i = 1; i <operandCount; i++) {
322 SDValue val2 = n->getOperand(i);
323 SDNode *n2 = val2.getNode();
324 if (n2->getOpcode() != ISD::ConstantFP) {
325 return false;
326 }
327 }
328 return true;
329}

◆ Select()

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

Handles custom instruction selections.

Parameters
opOperation to select.

Definition at line 132 of file TCEDAGToDAGISel.cc.

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

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 249 of file TCEDAGToDAGISel.cc.

250 {
251
252 if (FrameIndexSDNode* fin = dyn_cast<FrameIndexSDNode>(addr)) {
253 base = CurDAG->getTargetFrameIndex(fin->getIndex(), DEFAULT_TYPE);
254 offset = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
255 return true;
256 } else if (addr.getOpcode() == ISD::TargetExternalSymbol ||
257 addr.getOpcode() == ISD::TargetGlobalAddress) {
258
259 return false; // direct calls.
260 }
261 base = addr;
262 offset = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
263 return true;
264}

References DEFAULT_TYPE.

◆ SelectADDRrr()

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

Handles ADDRrr operands.

Definition at line 270 of file TCEDAGToDAGISel.cc.

271 {
272
273 if (addr.getOpcode() == ISD::TargetGlobalAddress) {
274 //r1 = addr.getOperand(0);
275 //r2 = CurDAG->getTargetConstant(cn->getValue(), MVT::i32);
276 //return true:
277 return false;
278 } else if (addr.getOpcode() == ISD::TargetExternalSymbol) {
279 return false;
280 } else if (addr.getOpcode() == ISD::FrameIndex) {
281 return false;
282 }
283
284 r1 = addr;
285
286 r2 = CurDAG->getTargetConstant(0, SDLoc(), DEFAULT_TYPE);
287 return true;
288}

References DEFAULT_TYPE.

◆ SelectOptimizedBuildVector()

void TCEDAGToDAGISel::SelectOptimizedBuildVector ( SDNode *  n)
private

Member Data Documentation

◆ ID

char TCEDAGToDAGISel::ID = 0
static

Definition at line 60 of file TCEDAGToDAGISel.cc.

◆ lowering_

llvm::TCETargetLowering& TCEDAGToDAGISel::lowering_
private

Definition at line 87 of file TCEDAGToDAGISel.cc.

◆ subtarget_

const llvm::TCESubtarget& TCEDAGToDAGISel::subtarget_
private

Definition at line 88 of file TCEDAGToDAGISel.cc.

◆ tm_

llvm::TCETargetMachine* TCEDAGToDAGISel::tm_
private

Definition at line 89 of file TCEDAGToDAGISel.cc.

Referenced by Select().


The documentation for this class was generated from the following file: