37 #define DEBUG_TYPE "mips-isel"
46 std::pair<SDNode*, SDNode*>
47 Mips16DAGToDAGISel::selectMULT(
SDNode *
N,
unsigned Opc,
SDLoc DL,
EVT Ty,
48 bool HasLo,
bool HasHi) {
55 unsigned Opcode = Mips::Mflo16;
60 unsigned Opcode = Mips::Mfhi16;
63 return std::make_pair(Lo,
Hi);
84 BuildMI(MBB, I, DL, TII.
get(Mips::GotPrologue16), V0).
109 BuildMI(MBB, I, DL, TII.
get(Mips::MoveR3216), Mips16SPAliasReg)
113 void Mips16DAGToDAGISel::processFunctionAfterISel(
MachineFunction &MF) {
114 initGlobalBaseReg(MF);
115 initMips16SPAliasReg(MF);
120 SDValue Mips16DAGToDAGISel::getMips16SPAliasReg() {
121 unsigned Mips16SPAliasReg =
127 void Mips16DAGToDAGISel::getMips16SPRefReg(
SDNode *Parent,
SDValue &AliasReg) {
139 : getMips16SPAliasReg();
151 : getMips16SPAliasReg();
163 bool Mips16DAGToDAGISel::selectAddr16(
175 getMips16SPRefReg(Parent, Alias);
198 getMips16SPRefReg(Parent, Alias);
220 if (isa<ConstantPoolSDNode>(Opnd0) || isa<GlobalAddressSDNode>(Opnd0) ||
221 isa<JumpTableSDNode>(Opnd0)) {
245 std::pair<bool, SDNode*> Mips16DAGToDAGISel::selectNode(
SDNode *Node) {
262 unsigned Opc = InFlag.
getOpcode(); (void)Opc;
265 "(ADD|SUB)E flag operand must come from (ADD|SUB)C/E insn");
270 MOp = Mips::AdduRxRyRz16;
273 MOp = Mips::SubuRxRyRz16;
283 unsigned Sltu_op = Mips::SltuRxRyRz16;
285 unsigned Addu_op = Mips::AdduRxRyRz16;
291 return std::make_pair(
true, Result);
297 MultOpc = (Opcode ==
ISD::UMUL_LOHI ? Mips::MultuRxRy16 : Mips::MultRxRy16);
298 std::pair<SDNode*, SDNode*> LoHi = selectMULT(Node, MultOpc, DL, NodeTy,
300 if (!
SDValue(Node, 0).use_empty())
303 if (!
SDValue(Node, 1).use_empty())
306 return std::make_pair(
true,
nullptr);
311 MultOpc = (Opcode ==
ISD::MULHU ? Mips::MultuRxRy16 : Mips::MultRxRy16);
312 SDNode *Result = selectMULT(Node, MultOpc, DL, NodeTy,
false,
true).second;
313 return std::make_pair(
true, Result);
317 return std::make_pair(
false,
nullptr);
SDValue getValue(unsigned R) const
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
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...
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 ...
bool mips16SPAliasRegSet() const
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register...
Base class for LoadSDNode and StoreSDNode.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
const TargetLowering * getTargetLowering() const
const MachineInstrBuilder & addImm(int64_t Val) const
addImm - 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.
EVT getMemoryVT() const
Return the type of the in-memory value.
const DataLayout & getDataLayout() const
This class is used to represent ISD::STORE nodes.
const TargetFrameLowering * getFrameLowering() const override
TargetInstrInfo - Interface to description of machine instruction set.
MachineRegisterInfo * RegInfo
bundle_iterator< MachineInstr, instr_iterator > iterator
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.
SDValue getTargetConstant(uint64_t Val, SDLoc DL, EVT VT, bool isOpaque=false)
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.
bool inMips16Mode() const
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
BuildMI - Builder interface.
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.
bool hasMips4_32r2() const
int64_t getSExtValue() const
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
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.
unsigned getMips16SPAliasReg()
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
unsigned getSizeInBits() const
getSizeInBits - Return the size of the specified value type in bits.
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
MachineSDNode * getMachineNode(unsigned Opcode, SDLoc dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s), MachineInstr opcode, and operands.
bool isInt< 16 >(int64_t x)
bool globalBaseRegSet() const
EVT getValueType() const
Return the ValueType of the referenced return value.
MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
SDValue getRegister(unsigned Reg, EVT VT)
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
addReg - Add a new virtual register operand...
const TargetInstrInfo * TII
FunctionPass * createMips16ISelDag(MipsTargetMachine &TM)
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...
This class is used to represent ISD::LOAD nodes.