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);
99 bool Mips16DAGToDAGISel::selectAddr(
bool SPAllowed,
SDValue Addr,
SDValue &Base,
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) {
202 "(ADD|SUB)E flag operand must come from (ADD|SUB)C/E insn");
207 MOp = Mips::AdduRxRyRz16;
210 MOp = Mips::SubuRxRyRz16;
220 unsigned Sltu_op = Mips::SltuRxRyRz16;
222 unsigned Addu_op = Mips::AdduRxRyRz16;
233 MultOpc = (Opcode ==
ISD::UMUL_LOHI ? Mips::MultuRxRy16 : Mips::MultRxRy16);
234 std::pair<SDNode *, SDNode *> LoHi =
235 selectMULT(Node, MultOpc, DL, NodeTy,
true,
true);
236 if (!
SDValue(Node, 0).use_empty())
239 if (!
SDValue(Node, 1).use_empty())
248 MultOpc = (Opcode ==
ISD::MULHU ? Mips::MultuRxRy16 : Mips::MultRxRy16);
249 auto LoHi = selectMULT(Node, MultOpc, DL, NodeTy,
false,
true);
SDValue getValue(unsigned R) const
void ReplaceUses(SDValue F, SDValue T)
ReplaceUses - replace all uses of the old node F with the use of the new node T.
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Carry-setting nodes for multiple precision addition and subtraction.
const MipsInstrInfo * getInstrInfo() const override
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
constexpr bool isInt< 16 >(int64_t x)
const SDValue & getOperand(unsigned Num) const
GlobalBaseReg - On Darwin, this node represents the result of the mflr at function entry...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
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.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MO_ABS_HI/LO - Represents the hi or low part of an absolute symbol address.
const MachineBasicBlock & front() 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.
const MipsSubtarget * Subtarget
Keep a pointer to the MipsSubtarget around so that we can make the right decision when generating cod...
const SDValue & getOperand(unsigned i) const
Carry-using nodes for multiple precision addition and subtraction.
bool isPositionIndependent() const
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
unsigned getOpcode() const
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)
bool inMips16Mode() const
EVT - Extended Value Type.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
bool isBaseWithConstantOffset(SDValue Op) const
Return true if the specified operand is an ISD::ADD with a ConstantSDNode on the right-hand side...
unsigned getGlobalBaseReg()
SDNode * SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT)
These are used for target selectors to mutate the specified node to have the specified return type...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
int64_t getSExtValue() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
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...
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)
bool globalBaseRegSet() const
EVT getValueType() const
Return the ValueType of the referenced return value.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void ReplaceNode(SDNode *F, SDNode *T)
Replace all uses of F with T, then remove F from the DAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const TargetInstrInfo * TII
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
uint64_t getZExtValue() const
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...