LLVM 24.0.0git
LoongArchISelDAGToDAG.cpp
Go to the documentation of this file.
1//=- LoongArchISelDAGToDAG.cpp - A dag to dag inst selector for LoongArch -===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines an instruction selector for the LoongArch target.
10//
11//===----------------------------------------------------------------------===//
12
14#include "LoongArch.h"
22
23using namespace llvm;
24
25#define DEBUG_TYPE "loongarch-isel"
26#define PASS_NAME "LoongArch DAG->DAG Pattern Instruction Selection"
27
29
34
36 false)
37
39 // If we have a custom node, we have already selected.
40 if (Node->isMachineOpcode()) {
41 LLVM_DEBUG(dbgs() << "== "; Node->dump(CurDAG); dbgs() << "\n");
42 Node->setNodeId(-1);
43 return;
44 }
45
46 // Instruction Selection not handled by the auto-generated tablegen selection
47 // should be handled here.
48 unsigned Opcode = Node->getOpcode();
49 MVT GRLenVT = Subtarget->getGRLenVT();
50 SDLoc DL(Node);
51 MVT VT = Node->getSimpleValueType(0);
52
53 switch (Opcode) {
54 default:
55 break;
56 case ISD::Constant: {
57 int64_t Imm = cast<ConstantSDNode>(Node)->getSExtValue();
58 if (Imm == 0 && VT == GRLenVT) {
59 SDValue New = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL,
60 LoongArch::R0, GRLenVT);
61 ReplaceNode(Node, New.getNode());
62 return;
63 }
64 SDNode *Result = nullptr;
65 SDValue SrcReg = CurDAG->getRegister(LoongArch::R0, GRLenVT);
66 // The instructions in the sequence are handled here.
68 SDValue SDImm = CurDAG->getSignedTargetConstant(Inst.Imm, DL, GRLenVT);
69 switch (Inst.Opc) {
70 case LoongArch::LU12I_W:
71 Result = CurDAG->getMachineNode(Inst.Opc, DL, GRLenVT, SDImm);
72 break;
73 case LoongArch::ADDI_W:
74 case LoongArch::ORI:
75 case LoongArch::LU32I_D:
76 case LoongArch::LU52I_D:
77 case LoongArch::SLLI_D:
78 Result = CurDAG->getMachineNode(Inst.Opc, DL, GRLenVT, SrcReg, SDImm);
79 break;
80 case LoongArch::BSTRINS_D:
81 Result = CurDAG->getMachineNode(
82 Inst.Opc, DL, GRLenVT,
83 {SrcReg, SrcReg,
84 CurDAG->getSignedTargetConstant(Inst.Imm >> 32, DL, GRLenVT),
85 CurDAG->getTargetConstant(Inst.Imm & 0xFF, DL, GRLenVT)});
86 break;
87 default:
88 llvm_unreachable("unexpected opcode generated by LoongArchMatInt");
89 }
90 SrcReg = SDValue(Result, 0);
91 }
92
93 ReplaceNode(Node, Result);
94 return;
95 }
96 case ISD::FrameIndex: {
97 SDValue Imm = CurDAG->getTargetConstant(0, DL, GRLenVT);
98 int FI = cast<FrameIndexSDNode>(Node)->getIndex();
99 SDValue TFI = CurDAG->getTargetFrameIndex(FI, VT);
100 unsigned ADDIOp =
101 Subtarget->is64Bit() ? LoongArch::ADDI_D : LoongArch::ADDI_W;
102 ReplaceNode(Node, CurDAG->getMachineNode(ADDIOp, DL, VT, TFI, Imm));
103 return;
104 }
105 case ISD::BITCAST: {
106 if (VT.is128BitVector() || VT.is256BitVector()) {
107 ReplaceUses(SDValue(Node, 0), Node->getOperand(0));
108 CurDAG->RemoveDeadNode(Node);
109 return;
110 }
111 break;
112 }
113 case ISD::BUILD_VECTOR: {
114 // Select appropriate [x]vrepli.[bhwd] instructions for constant splats of
115 // 128/256-bit when LSX/LASX is enabled.
117 APInt SplatValue, SplatUndef;
118 unsigned SplatBitSize;
119 bool HasAnyUndefs;
120 unsigned Op = 0;
121 EVT ResTy = BVN->getValueType(0);
122 bool Is128Vec = BVN->getValueType(0).is128BitVector();
123 bool Is256Vec = BVN->getValueType(0).is256BitVector();
124 SDNode *Res;
125
126 if (!Subtarget->hasExtLSX() || (!Is128Vec && !Is256Vec))
127 break;
128 if (!BVN->isConstantSplat(SplatValue, SplatUndef, SplatBitSize,
129 HasAnyUndefs, 8))
130 break;
131
132 // If we have a signed 10 bit integer, we can splat it directly.
133 if (SplatValue.isSignedIntN(10)) {
134 switch (SplatBitSize) {
135 default:
136 break;
137 case 8:
138 Op = Is256Vec ? LoongArch::PseudoXVREPLI_B : LoongArch::PseudoVREPLI_B;
139 break;
140 case 16:
141 Op = Is256Vec ? LoongArch::PseudoXVREPLI_H : LoongArch::PseudoVREPLI_H;
142 break;
143 case 32:
144 Op = Is256Vec ? LoongArch::PseudoXVREPLI_W : LoongArch::PseudoVREPLI_W;
145 break;
146 case 64:
147 Op = Is256Vec ? LoongArch::PseudoXVREPLI_D : LoongArch::PseudoVREPLI_D;
148 break;
149 }
150
151 EVT EleType = ResTy.getVectorElementType();
152 APInt Val = SplatValue.sextOrTrunc(EleType.getSizeInBits());
153 SDValue Imm = CurDAG->getTargetConstant(Val, DL, EleType);
154 Res = CurDAG->getMachineNode(Op, DL, ResTy, Imm);
155 ReplaceNode(Node, Res);
156 return;
157 }
158
159 // Select appropriate [x]vldi instructions for some special constant splats,
160 // where the immediate value `imm[12] == 1` for used [x]vldi instructions.
161 const auto &TLI =
162 *static_cast<const LoongArchTargetLowering *>(getTargetLowering());
163 std::pair<bool, uint64_t> ConvertVLDI =
164 TLI.isImmVLDILegalForMode1(SplatValue, SplatBitSize);
165 if (ConvertVLDI.first) {
166 Op = Is256Vec ? LoongArch::XVLDI : LoongArch::VLDI;
167 SDValue Imm = CurDAG->getSignedTargetConstant(
168 SignExtend32<13>(ConvertVLDI.second), DL, MVT::i32);
169 Res = CurDAG->getMachineNode(Op, DL, ResTy, Imm);
170 ReplaceNode(Node, Res);
171 return;
172 }
173 break;
174 }
175 }
176
177 // Select the default instruction.
178 SelectCode(Node);
179}
180
182 const SDValue &Op, InlineAsm::ConstraintCode ConstraintID,
183 std::vector<SDValue> &OutOps) {
184 SDValue Base = Op;
186 CurDAG->getTargetConstant(0, SDLoc(Op), Subtarget->getGRLenVT());
187 switch (ConstraintID) {
188 default:
189 llvm_unreachable("unexpected asm memory constraint");
190 // Reg+Reg addressing.
192 Base = Op.getOperand(0);
193 Offset = Op.getOperand(1);
194 break;
195 // Reg+simm12 addressing.
197 if (CurDAG->isBaseWithConstantOffset(Op)) {
198 ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Op.getOperand(1));
199 if (isIntN(12, CN->getSExtValue())) {
200 Base = Op.getOperand(0);
201 Offset = CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(Op),
202 Op.getValueType());
203 }
204 }
205 break;
206 // Reg+0 addressing.
208 break;
209 // Reg+(simm14<<2) addressing.
211 if (CurDAG->isBaseWithConstantOffset(Op)) {
212 ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Op.getOperand(1));
213 if (isIntN(16, CN->getSExtValue()) &&
214 isAligned(Align(4ULL), CN->getZExtValue())) {
215 Base = Op.getOperand(0);
216 Offset = CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(Op),
217 Op.getValueType());
218 }
219 }
220 break;
221 }
222 OutOps.push_back(Base);
223 OutOps.push_back(Offset);
224 return false;
225}
226
228 // If this is FrameIndex, select it directly. Otherwise just let it get
229 // selected to a register independently.
230 if (auto *FIN = dyn_cast<FrameIndexSDNode>(Addr))
231 Base =
232 CurDAG->getTargetFrameIndex(FIN->getIndex(), Subtarget->getGRLenVT());
233 else
234 Base = Addr;
235 return true;
236}
237
238// Fold constant addresses.
240 SDValue &Offset) {
241 SDLoc DL(Addr);
242 MVT VT = Addr.getSimpleValueType();
243
244 if (!isa<ConstantSDNode>(Addr))
245 return false;
246
247 // If the constant is a simm12, we can fold the whole constant and use R0 as
248 // the base.
249 int64_t CVal = cast<ConstantSDNode>(Addr)->getSExtValue();
250 if (!isInt<12>(CVal))
251 return false;
252 Base = CurDAG->getRegister(LoongArch::R0, VT);
253 Offset = CurDAG->getSignedTargetConstant(SignExtend64<12>(CVal), DL, VT);
254 return true;
255}
256
257// Return true if the address (add Base, Index) should be selected as a
258// register-register addressed access. If Index is a shift that ALSL can fold
259// and the address is materialized anyway, e.g. because it is also the base of
260// another access with an offset, accessing it with offset 0 avoids the extra
261// shift instruction for the index of LDX/STX:
262//
263// alsl.d $a2, $a1, $a0, 4 alsl.d $a2, $a1, $a0, 4
264// slli.d $a1, $a1, 4 => ld.d $a0, $a2, 0
265// ldx.d $a0, $a0, $a1 ld.d $a1, $a2, 8
266// ld.d $a1, $a2, 8
268 auto IsAlslShift = [](SDValue V) {
269 // The shift is needed anyway if it has other users.
270 if (V.getOpcode() != ISD::SHL || !V.hasOneUse())
271 return false;
272 auto *C = dyn_cast<ConstantSDNode>(V.getOperand(1));
273 return C && C->getZExtValue() >= 1 && C->getZExtValue() <= 4;
274 };
275 if (!IsAlslShift(Add->getOperand(0)) && !IsAlslShift(Add->getOperand(1)))
276 return true;
277
278 for (SDNode *User : Add->users()) {
279 if (auto *LD = dyn_cast<LoadSDNode>(User))
280 if (LD->getBasePtr().getNode() == Add && LD->isUnindexed())
281 continue;
282 if (auto *ST = dyn_cast<StoreSDNode>(User))
283 if (ST->getBasePtr().getNode() == Add &&
284 ST->getValue().getNode() != Add && ST->isUnindexed())
285 continue;
286 // The address is materialized for this user.
287 return false;
288 }
289 return true;
290}
291
293 // If this is FrameIndex, don't select it.
294 if (isa<FrameIndexSDNode>(Addr))
295 return false;
296 Base = Addr;
297 return true;
298}
299
301 SDValue &Offset) {
302 SDLoc DL(Addr);
303 MVT VT = Addr.getSimpleValueType();
304
305 // The address is the result of an ADD. Here we only consider reg+simm12.
306 if (CurDAG->isBaseWithConstantOffset(Addr)) {
307 int64_t Imm = cast<ConstantSDNode>(Addr.getOperand(1))->getSExtValue();
308 if (isInt<12>(Imm)) {
309 Base = Addr.getOperand(0);
310 Offset = CurDAG->getSignedTargetConstant(SignExtend64<12>(Imm), DL, VT);
311 return true;
312 }
313 }
314
315 // Otherwise, we assume Addr as the base address and use constant 0 as the
316 // offset.
317 Base = Addr;
318 Offset = CurDAG->getTargetConstant(0, DL, VT);
319 return true;
320}
321
323 SDValue &ShAmt) {
324 // Shift instructions on LoongArch only read the lower 5 or 6 bits of the
325 // shift amount. If there is an AND on the shift amount, we can bypass it if
326 // it doesn't affect any of those bits.
327 if (N.getOpcode() == ISD::AND && isa<ConstantSDNode>(N.getOperand(1))) {
328 const APInt &AndMask = N->getConstantOperandAPInt(1);
329
330 // Since the max shift amount is a power of 2 we can subtract 1 to make a
331 // mask that covers the bits needed to represent all shift amounts.
332 assert(isPowerOf2_32(ShiftWidth) && "Unexpected max shift amount!");
333 APInt ShMask(AndMask.getBitWidth(), ShiftWidth - 1);
334
335 if (ShMask.isSubsetOf(AndMask)) {
336 ShAmt = N.getOperand(0);
337 return true;
338 }
339
340 // SimplifyDemandedBits may have optimized the mask so try restoring any
341 // bits that are known zero.
342 KnownBits Known = CurDAG->computeKnownBits(N->getOperand(0));
343 if (ShMask.isSubsetOf(AndMask | Known.Zero)) {
344 ShAmt = N.getOperand(0);
345 return true;
346 }
347 } else if (N.getOpcode() == LoongArchISD::BSTRPICK) {
348 // Similar to the above AND, if there is a BSTRPICK on the shift amount, we
349 // can bypass it.
350 assert(isPowerOf2_32(ShiftWidth) && "Unexpected max shift amount!");
351 assert(isa<ConstantSDNode>(N.getOperand(1)) && "Illegal msb operand!");
352 assert(isa<ConstantSDNode>(N.getOperand(2)) && "Illegal lsb operand!");
353 uint64_t msb = N.getConstantOperandVal(1), lsb = N.getConstantOperandVal(2);
354 if (lsb == 0 && Log2_32(ShiftWidth) <= msb + 1) {
355 ShAmt = N.getOperand(0);
356 return true;
357 }
358 } else if (N.getOpcode() == ISD::SUB &&
359 isa<ConstantSDNode>(N.getOperand(0))) {
360 uint64_t Imm = N.getConstantOperandVal(0);
361 // If we are shifting by N-X where N == 0 mod Size, then just shift by -X to
362 // generate a NEG instead of a SUB of a constant.
363 if (Imm != 0 && Imm % ShiftWidth == 0) {
364 SDLoc DL(N);
365 EVT VT = N.getValueType();
366 SDValue Zero =
367 CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, LoongArch::R0, VT);
368 unsigned NegOpc = VT == MVT::i64 ? LoongArch::SUB_D : LoongArch::SUB_W;
369 MachineSDNode *Neg =
370 CurDAG->getMachineNode(NegOpc, DL, VT, Zero, N.getOperand(1));
371 ShAmt = SDValue(Neg, 0);
372 return true;
373 }
374 }
375
376 ShAmt = N;
377 return true;
378}
379
381 if (N.getOpcode() == ISD::SIGN_EXTEND_INREG &&
382 cast<VTSDNode>(N.getOperand(1))->getVT() == MVT::i32) {
383 Val = N.getOperand(0);
384 return true;
385 }
386 if (N.getOpcode() == LoongArchISD::BSTRPICK &&
387 N.getConstantOperandVal(1) < UINT64_C(0X1F) &&
388 N.getConstantOperandVal(2) == UINT64_C(0)) {
389 Val = N;
390 return true;
391 }
392 MVT VT = N.getSimpleValueType();
393 if (CurDAG->ComputeNumSignBits(N) > (VT.getSizeInBits() - 32)) {
394 Val = N;
395 return true;
396 }
397
398 return false;
399}
400
402 if (N.getOpcode() == ISD::AND) {
403 auto *C = dyn_cast<ConstantSDNode>(N.getOperand(1));
404 if (C && C->getZExtValue() == UINT64_C(0xFFFFFFFF)) {
405 Val = N.getOperand(0);
406 return true;
407 }
408 }
409 MVT VT = N.getSimpleValueType();
411 if (CurDAG->MaskedValueIsZero(N, Mask)) {
412 Val = N;
413 return true;
414 }
415
416 return false;
417}
418
420 unsigned MinSizeInBits) const {
421 if (!Subtarget->hasExtLSX())
422 return false;
423
425
426 if (!Node)
427 return false;
428
429 APInt SplatValue, SplatUndef;
430 unsigned SplatBitSize;
431 bool HasAnyUndefs;
432
433 if (!Node->isConstantSplat(SplatValue, SplatUndef, SplatBitSize, HasAnyUndefs,
434 MinSizeInBits, /*IsBigEndian=*/false))
435 return false;
436
437 Imm = SplatValue;
438
439 return true;
440}
441
442template <unsigned ImmBitSize, unsigned EltBitSize, bool IsSigned>
444 APInt ImmValue;
445 EVT EltTy = N->getValueType(0).getVectorElementType();
446 unsigned EltBitWidth = EltBitSize ? EltBitSize : EltTy.getSizeInBits();
447
448 if (N->getOpcode() == ISD::BITCAST)
449 N = N->getOperand(0);
450
451 if (selectVSplat(N.getNode(), ImmValue, EltBitWidth) &&
452 ImmValue.getBitWidth() == EltBitWidth) {
453 if (IsSigned && ImmValue.isSignedIntN(ImmBitSize)) {
454 SplatVal = CurDAG->getSignedTargetConstant(
455 ImmValue.getSExtValue(), SDLoc(N), Subtarget->getGRLenVT());
456 return true;
457 }
458 if (!IsSigned && ImmValue.isIntN(ImmBitSize)) {
459 SplatVal = CurDAG->getTargetConstant(ImmValue.getZExtValue(), SDLoc(N),
460 Subtarget->getGRLenVT());
461 return true;
462 }
463 }
464
465 return false;
466}
467
468template <unsigned ImmBitSize>
470 SDValue &SplatVal) const {
471 APInt ImmValue;
472 EVT EltTy = N->getValueType(0).getVectorElementType();
473
474 if (N->getOpcode() == ISD::BITCAST)
475 N = N->getOperand(0);
476
477 if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) &&
478 ImmValue.getBitWidth() == EltTy.getSizeInBits()) {
479 if ((-ImmValue).isIntN(ImmBitSize)) {
480 SplatVal = CurDAG->getTargetConstant(-ImmValue.getSExtValue(), SDLoc(N),
481 Subtarget->getGRLenVT());
482 return true;
483 }
484 }
485
486 return false;
487}
488
489template <unsigned EltBitSize>
491 SDValue &SplatImm) const {
492 APInt ImmValue;
493 EVT EltTy = N->getValueType(0).getVectorElementType();
494 unsigned EltBitWidth = EltBitSize ? EltBitSize : EltTy.getSizeInBits();
495
496 if (N->getOpcode() == ISD::BITCAST)
497 N = N->getOperand(0);
498
499 if (selectVSplat(N.getNode(), ImmValue, EltBitWidth) &&
500 ImmValue.getBitWidth() == EltBitWidth) {
501 int32_t Log2 = (~ImmValue).exactLogBase2();
502
503 if (Log2 != -1) {
504 SplatImm = CurDAG->getSignedTargetConstant(Log2, SDLoc(N), EltTy);
505 return true;
506 }
507 }
508
509 return false;
510}
511
512template <unsigned EltBitSize>
514 SDValue &SplatImm) const {
515 APInt ImmValue;
516 EVT EltTy = N->getValueType(0).getVectorElementType();
517 unsigned EltBitWidth = EltBitSize ? EltBitSize : EltTy.getSizeInBits();
518
519 if (N->getOpcode() == ISD::BITCAST)
520 N = N->getOperand(0);
521
522 if (selectVSplat(N.getNode(), ImmValue, EltBitWidth) &&
523 ImmValue.getBitWidth() == EltBitWidth) {
524 int32_t Log2 = ImmValue.exactLogBase2();
525
526 if (Log2 != -1) {
527 SplatImm = CurDAG->getSignedTargetConstant(Log2, SDLoc(N), EltTy);
528 return true;
529 }
530 }
531
532 return false;
533}
534
539
540// This pass converts a legalized DAG into a LoongArch-specific DAG, ready
541// for instruction scheduling.
return SDValue()
const AArch64Subtarget & Subtarget
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t Imm
AMDGPU Register Bank Select
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define DEBUG_TYPE
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
#define PASS_NAME
Class for arbitrary precision integers.
Definition APInt.h:78
uint64_t getZExtValue() const
Get zero extended value.
Definition APInt.h:1560
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition APInt.h:1508
int32_t exactLogBase2() const
Definition APInt.h:1803
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
Definition APInt.h:431
LLVM_ABI APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
Definition APInt.cpp:1086
bool isSubsetOf(const APInt &RHS) const
This operation checks that all bits set in this APInt are also set in RHS.
Definition APInt.h:1261
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
Definition APInt.h:292
bool isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
Definition APInt.h:428
int64_t getSExtValue() const
Get sign extended value.
Definition APInt.h:1582
A "pseudo-class" with methods for operating on BUILD_VECTORs.
LLVM_ABI bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, unsigned &SplatBitSize, bool &HasAnyUndefs, unsigned MinSplatBits=0, bool isBigEndian=false) const
Check if this is a constant splat, and if so, find the smallest element size that splats the vector.
uint64_t getZExtValue() const
int64_t getSExtValue() const
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:312
LoongArchDAGToDAGISelLegacy(LoongArchTargetMachine &TM, CodeGenOptLevel OptLevel)
bool selectNonFIBaseAddr(SDValue Addr, SDValue &Base)
bool selectSExti32(SDValue N, SDValue &Val)
bool SelectInlineAsmMemoryOperand(const SDValue &Op, InlineAsm::ConstraintCode ConstraintID, std::vector< SDValue > &OutOps) override
SelectInlineAsmMemoryOperand - Select the specified address as a target addressing mode,...
bool selectVSplatImm(SDValue N, SDValue &SplatVal)
bool selectShiftMask(SDValue N, unsigned ShiftWidth, SDValue &ShAmt)
bool selectZExti32(SDValue N, SDValue &Val)
bool SelectAddrRegImm12(SDValue Addr, SDValue &Base, SDValue &Offset)
bool selectVSplatImmNeg(SDValue N, SDValue &SplatVal) const
bool SelectAddrConstant(SDValue Addr, SDValue &Base, SDValue &Offset)
bool selectVSplatUimmPow2(SDValue N, SDValue &SplatImm) const
bool selectVSplat(SDNode *N, APInt &Imm, unsigned MinSizeInBits) const
bool selectVSplatUimmInvPow2(SDValue N, SDValue &SplatImm) const
bool isRegRegAddrProfitable(SDNode *Add) const
bool SelectBaseAddr(SDValue Addr, SDValue &Base)
LoongArchISelDAGToDAGPass(LoongArchTargetMachine &TM, CodeGenOptLevel OptLevel)
Machine Value Type.
bool is128BitVector() const
Return true if this is a 128-bit vector type.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
bool is256BitVector() const
Return true if this is a 256-bit vector type.
An SDNode that represents everything that will be needed to construct a MachineInstr.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
const SDValue & getOperand(unsigned i) const
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
SelectionDAGISelLegacy(char &ID, std::unique_ptr< SelectionDAGISel > S)
SelectionDAGISelPass(std::unique_ptr< SelectionDAGISel > Selector)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ SHL
Shift and rotation operations.
Definition ISDOpcodes.h:793
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
Definition ISDOpcodes.h:920
@ AND
Bitwise operators - logical and, logical or, logical xor.
Definition ISDOpcodes.h:763
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
Definition ISDOpcodes.h:561
InstSeq generateInstSeq(int64_t Val)
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition MathExtras.h:166
@ Known
Known to have no common set bits.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
Definition Alignment.h:139
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Definition MathExtras.h:326
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:280
FunctionPass * createLoongArchISelDagLegacyPass(LoongArchTargetMachine &TM, CodeGenOptLevel OptLevel)
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
@ Add
Sum of integers.
DWARFExpression::Operation Op
constexpr int32_t SignExtend32(uint32_t X)
Sign-extend the number in the bottom B bits of X to a 32-bit integer.
Definition MathExtras.h:554
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Definition MathExtras.h:249
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
Definition MathExtras.h:572
unsigned Log2(Align A)
Returns the log2 of the alignment.
Definition Alignment.h:202
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:879
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Extended Value Type.
Definition ValueTypes.h:35
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
Definition ValueTypes.h:411
bool is128BitVector() const
Return true if this is a 128-bit vector type.
Definition ValueTypes.h:245
bool is256BitVector() const
Return true if this is a 256-bit vector type.
Definition ValueTypes.h:250
EVT getVectorElementType() const
Given a vector type, return the type of each element.
Definition ValueTypes.h:366