26#define DEBUG_TYPE "mips-isel"
35std::pair<SDNode *, SDNode *>
37 bool HasLo,
bool HasHi) {
38 SDNode *
Lo =
nullptr, *
Hi =
nullptr;
39 SDNode *
Mul =
CurDAG->getMachineNode(
Opc,
DL, MVT::Glue,
N->getOperand(0),
44 unsigned Opcode = Mips::Mflo16;
45 Lo =
CurDAG->getMachineNode(Opcode,
DL, Ty, MVT::Glue, InGlue);
49 unsigned Opcode = Mips::Mfhi16;
50 Hi =
CurDAG->getMachineNode(Opcode,
DL, Ty, InGlue);
52 return std::make_pair(
Lo,
Hi);
56 MipsFunctionInfo *MipsFI =
MF.getInfo<MipsFunctionInfo>();
61 MachineBasicBlock &
MBB =
MF.front();
63 MachineRegisterInfo &
RegInfo =
MF.getRegInfo();
67 const TargetRegisterClass *RC = &Mips::CPU16RegsRegClass;
69 V0 =
RegInfo.createVirtualRegister(RC);
70 V1 =
RegInfo.createVirtualRegister(RC);
71 V2 =
RegInfo.createVirtualRegister(RC);
86 initGlobalBaseReg(
MF);
97 Base =
CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
108 if (!
TM.isPositionIndependent()) {
114 if (
CurDAG->isBaseWithConstantOffset(Addr)) {
119 if (FrameIndexSDNode *FIN =
121 Base =
CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy);
122 Offset =
CurDAG->getTargetConstant(CN->getZExtValue(),
DL, ValTy);
128 Offset =
CurDAG->getTargetConstant(CN->getZExtValue(),
DL, ValTy);
170bool Mips16DAGToDAGISel::trySelect(
SDNode *Node) {
171 unsigned Opcode =
Node->getOpcode();
178 EVT NodeTy =
Node->getValueType(0);
188 MultOpc = (Opcode ==
ISD::UMUL_LOHI ? Mips::MultuRxRy16 : Mips::MultRxRy16);
189 std::pair<SDNode *, SDNode *> LoHi =
190 selectMULT(Node, MultOpc,
DL, NodeTy,
true,
true);
191 if (!
SDValue(Node, 0).use_empty())
194 if (!
SDValue(Node, 1).use_empty())
197 CurDAG->RemoveDeadNode(Node);
203 MultOpc = (Opcode ==
ISD::MULHU ? Mips::MultuRxRy16 : Mips::MultRxRy16);
204 auto LoHi = selectMULT(Node, MultOpc,
DL, NodeTy,
false,
true);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Promote Memory to Register
FunctionPass class - This class is used to implement most global optimizations.
MachineInstrBundleIterator< MachineInstr > iterator
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Mips16DAGToDAGISelLegacy(MipsTargetMachine &TM, CodeGenOptLevel OL)
MipsDAGToDAGISelLegacy(std::unique_ptr< SelectionDAGISel > S)
bool runOnMachineFunction(MachineFunction &MF) override
const MipsSubtarget * Subtarget
Keep a pointer to the MipsSubtarget around so that we can make the right decision when generating cod...
Register getGlobalBaseReg(MachineFunction &MF)
bool globalBaseRegSet() const
bool inMips16Mode() const
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
EVT getValueType() const
Return the ValueType of the referenced return value.
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
MachineRegisterInfo * RegInfo
const TargetInstrInfo * TII
void ReplaceUses(SDValue F, SDValue T)
ReplaceUses - replace all uses of the old node F with the use of the new node T.
void ReplaceNode(SDNode *F, SDNode *T)
Replace all uses of F with T, then remove F from the DAG.
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ ADD
Simple integer binary arithmetic operators.
@ TargetGlobalAddress
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ GlobalBaseReg
The result of the mflr at function entry, used for PIC code.
NodeAddr< NodeBase * > Node
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
CodeGenOptLevel
Code generation optimization level.
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...
@ Mul
Product of integers.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
FunctionPass * createMips16ISelDag(MipsTargetMachine &TM, CodeGenOptLevel OptLevel)
Implement std::hash so that hash_code can be used in STL containers.