LLVM 24.0.0git
LoongArchISelDAGToDAG.h
Go to the documentation of this file.
1//=- LoongArchISelDAGToDAG.h - 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
13#ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHISELDAGTODAG_H
14#define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHISELDAGTODAG_H
15
16#include "LoongArch.h"
20
21// LoongArch-specific code to select LoongArch machine instructions for
22// SelectionDAG operations.
23namespace llvm {
25 const LoongArchSubtarget *Subtarget = nullptr;
26
27public:
29
33
35 Subtarget = &MF.getSubtarget<LoongArchSubtarget>();
37 }
38
39 void Select(SDNode *Node) override;
40
42 InlineAsm::ConstraintCode ConstraintID,
43 std::vector<SDValue> &OutOps) override;
44
50
51 bool selectShiftMask(SDValue N, unsigned ShiftWidth, SDValue &ShAmt);
53 return selectShiftMask(N, Subtarget->getGRLen(), ShAmt);
54 }
56 return selectShiftMask(N, 32, ShAmt);
57 }
58
59 bool selectSExti32(SDValue N, SDValue &Val);
60 bool selectZExti32(SDValue N, SDValue &Val);
61
62 bool selectVSplat(SDNode *N, APInt &Imm, unsigned MinSizeInBits) const;
63
64 template <unsigned ImmSize, unsigned EltSize = 0, bool IsSigned = false>
65 bool selectVSplatImm(SDValue N, SDValue &SplatVal);
66 template <unsigned ImmSize>
67 bool selectVSplatImmNeg(SDValue N, SDValue &SplatVal) const;
68 template <unsigned EltSize = 0>
69 bool selectVSplatUimmInvPow2(SDValue N, SDValue &SplatImm) const;
70 template <unsigned EltSize = 0>
71 bool selectVSplatUimmPow2(SDValue N, SDValue &SplatImm) const;
72
73 // Return the LoongArch branch opcode that matches the given DAG integer
74 // condition code. The CondCode must be one of those supported by the
75 // LoongArch ISA (see translateSetCCForBranch).
77 switch (CC) {
78 default:
79 llvm_unreachable("Unsupported CondCode");
80 case ISD::SETEQ:
81 return LoongArch::BEQ;
82 case ISD::SETNE:
83 return LoongArch::BNE;
84 case ISD::SETLT:
85 return LoongArch::BLT;
86 case ISD::SETGE:
87 return LoongArch::BGE;
88 case ISD::SETULT:
89 return LoongArch::BLTU;
90 case ISD::SETUGE:
91 return LoongArch::BGEU;
92 }
93 }
94
95// Include the pieces autogenerated from the target description.
96#include "LoongArchGenDAGISel.inc"
97};
98
100public:
101 static char ID;
103 CodeGenOptLevel OptLevel);
104};
105
106} // end namespace llvm
107
108#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHISELDAGTODAG_H
uint64_t Imm
RISCVCC::CondCode CC
Class for arbitrary precision integers.
Definition APInt.h:78
LoongArchDAGToDAGISelLegacy(LoongArchTargetMachine &TM, CodeGenOptLevel OptLevel)
bool selectNonFIBaseAddr(SDValue Addr, SDValue &Base)
bool selectShiftMask32(SDValue N, SDValue &ShAmt)
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 selectShiftMaskGRLen(SDValue N, SDValue &ShAmt)
static unsigned getBranchOpcForIntCC(ISD::CondCode CC)
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)
LoongArchDAGToDAGISel(LoongArchTargetMachine &TM, CodeGenOptLevel OptLevel)
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
void Select(SDNode *Node) override
Main hook for targets to transform nodes into machine nodes.
bool selectVSplatUimmInvPow2(SDValue N, SDValue &SplatImm) const
bool runOnMachineFunction(MachineFunction &MF) override
bool isRegRegAddrProfitable(SDNode *Add) const
bool SelectBaseAddr(SDValue Addr, SDValue &Base)
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SelectionDAGISelLegacy(char &ID, std::unique_ptr< SelectionDAGISel > S)
SelectionDAGISel(TargetMachine &tm, CodeGenOptLevel OL=CodeGenOptLevel::Default)
virtual bool runOnMachineFunction(MachineFunction &mf)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
@ Add
Sum of integers.
DWARFExpression::Operation Op
#define N