36 #define DEBUG_TYPE "mips-isel" 45 std::pair<SDNode *, SDNode *>
46 Mips16DAGToDAGISel::selectMULT(
SDNode *
N,
unsigned Opc,
const SDLoc &DL,
EVT Ty,
47 bool HasLo,
bool HasHi) {
54 unsigned Opcode = Mips::Mflo16;
59 unsigned Opcode = Mips::Mfhi16;
62 return std::make_pair(Lo,
Hi);
84 BuildMI(MBB, I, DL, TII.
get(Mips::LiRxImmX16), V0)
86 BuildMI(MBB, I, DL, TII.
get(Mips::AddiuRxPcImmX16), V1)
95 void Mips16DAGToDAGISel::processFunctionAfterISel(
MachineFunction &MF) {
96 initGlobalBaseReg(MF);
130 dyn_cast<FrameIndexSDNode>(Addr.
getOperand(0))) {
155 if (isa<ConstantPoolSDNode>(Opnd0) || isa<GlobalAddressSDNode>(Opnd0) ||
156 isa<JumpTableSDNode>(Opnd0)) {
168 bool Mips16DAGToDAGISel::selectAddr16(
SDValue Addr,
SDValue &Base,
170 return selectAddr(
false, Addr, Base, Offset);
173 bool Mips16DAGToDAGISel::selectAddr16SP(
SDValue Addr,
SDValue &Base,
175 return selectAddr(
true, Addr, Base, Offset);
180 bool Mips16DAGToDAGISel::trySelect(
SDNode *Node) {
198 MultOpc = (Opcode ==
ISD::UMUL_LOHI ? Mips::MultuRxRy16 : Mips::MultRxRy16);
199 std::pair<SDNode *, SDNode *> LoHi =
200 selectMULT(Node, MultOpc, DL, NodeTy,
true,
true);
201 if (!
SDValue(Node, 0).use_empty())
204 if (!
SDValue(Node, 1).use_empty())
213 MultOpc = (Opcode ==
ISD::MULHU ? Mips::MultuRxRy16 : Mips::MultRxRy16);
214 auto LoHi = selectMULT(Node, MultOpc, DL, NodeTy,
false,
true);
EVT getValueType() const
Return the ValueType of the referenced return value.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents lattice values for constants.
bool inMips16Mode() const
void ReplaceUses(SDValue F, SDValue T)
ReplaceUses - replace all uses of the old node F with the use of the new node T.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
const MipsInstrInfo * getInstrInfo() const override
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
constexpr bool isInt< 16 >(int64_t x)
GlobalBaseReg - On Darwin, this node represents the result of the mflr at function entry...
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
bool globalBaseRegSet() const
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
MO_ABS_HI/LO - Represents the hi or low part of an absolute symbol address.
int64_t getSExtValue() const
SDValue getTargetFrameIndex(int FI, EVT VT)
Simple integer binary arithmetic operators.
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
TargetInstrInfo - Interface to description of machine instruction set.
MachineRegisterInfo * RegInfo
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
CodeGenOpt::Level OptLevel
const MipsSubtarget * Subtarget
Keep a pointer to the MipsSubtarget around so that we can make the right decision when generating cod...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const SDValue & getOperand(unsigned Num) const
bool isBaseWithConstantOffset(SDValue Op) const
Return true if the specified operand is an ISD::ADD with a ConstantSDNode on the right-hand side...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
FunctionPass class - This class is used to implement most global optimizations.
void RemoveDeadNode(SDNode *N)
Remove the specified node from the system.
FunctionPass * createMips16ISelDag(MipsTargetMachine &TM, CodeGenOpt::Level OptLevel)
const MachineBasicBlock & front() const
Mips16DAGToDAGISel(MipsTargetMachine &TM, CodeGenOpt::Level OL)
unsigned getGlobalBaseReg()
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
bool isPositionIndependent() const
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
unsigned getOpcode() const
void ReplaceNode(SDNode *F, SDNode *T)
Replace all uses of F with T, then remove F from the DAG.
const SDValue & getOperand(unsigned i) const
uint64_t getZExtValue() const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
const TargetInstrInfo * TII
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...