52 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
53 unsigned ConstraintID,
54 std::vector<SDValue> &OutOps)
override;
57 return "SPARC DAG->DAG Pattern Instruction Selection";
61 #include "SparcGenDAGISel.inc" 64 SDNode* getGlobalBaseReg();
69 SDNode* SparcDAGToDAGISel::getGlobalBaseReg() {
70 unsigned GlobalBaseReg = Subtarget->getInstrInfo()->getGlobalBaseReg(MF);
71 return CurDAG->getRegister(GlobalBaseReg,
72 TLI->getPointerTy(CurDAG->getDataLayout()))
76 bool SparcDAGToDAGISel::SelectADDRri(
SDValue Addr,
79 Base = CurDAG->getTargetFrameIndex(
80 FIN->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout()));
91 if (isInt<13>(CN->getSExtValue())) {
93 dyn_cast<FrameIndexSDNode>(Addr.
getOperand(0))) {
95 Base = CurDAG->getTargetFrameIndex(
96 FIN->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout()));
100 Offset = CurDAG->getTargetConstant(CN->getZExtValue(),
SDLoc(Addr),
117 Offset = CurDAG->getTargetConstant(0,
SDLoc(Addr),
MVT::i32);
130 if (isInt<13>(CN->getSExtValue()))
141 R2 = CurDAG->getRegister(SP::G0, TLI->getPointerTy(CurDAG->getDataLayout()));
157 bool SparcDAGToDAGISel::tryInlineAsm(
SDNode *
N){
158 std::vector<SDValue> AsmNodeOperands;
160 bool Changed =
false;
177 for(
unsigned i = 0, e = N->
getGluedNode() ? NumOps - 1 : NumOps; i < e; ++i) {
179 AsmNodeOperands.push_back(op);
185 Flag =
C->getZExtValue();
197 AsmNodeOperands.push_back(op);
206 bool IsTiedToChangedOp =
false;
210 IsTiedToChangedOp = OpChanged[DefIdx];
218 if ((!IsTiedToChangedOp && (!HasRC || RC != SP::IntRegsRegClassID))
222 assert((i+2 < NumOps) &&
"Invalid number of operands in inline asm");
225 unsigned Reg0 = cast<RegisterSDNode>(V0)->
getReg();
226 unsigned Reg1 = cast<RegisterSDNode>(V1)->
getReg();
236 PairedReg = CurDAG->getRegister(GPVR,
MVT::v2i32);
244 SDValue Sub0 = CurDAG->getTargetExtractSubreg(SP::sub_even, dl,
MVT::i32,
246 SDValue Sub1 = CurDAG->getTargetExtractSubreg(SP::sub_odd, dl,
MVT::i32,
248 SDValue T0 = CurDAG->getCopyToReg(Sub0, dl, Reg0, Sub0,
255 CurDAG->UpdateNodeOperands(GU, Ops);
268 CurDAG->getMachineNode(
271 CurDAG->getTargetConstant(SP::IntPairRegClassID, dl,
274 CurDAG->getTargetConstant(SP::sub_even, dl, MVT::i32),
276 CurDAG->getTargetConstant(SP::sub_odd, dl, MVT::i32),
283 PairedReg = CurDAG->getRegister(GPVR,
MVT::v2i32);
284 Chain = CurDAG->getCopyToReg(T1, dl, GPVR, Pair, T1.
getValue(1));
293 OpChanged[OpChanged.
size() -1 ] =
true;
295 if (IsTiedToChangedOp)
300 AsmNodeOperands[AsmNodeOperands.size() -1] = CurDAG->getTargetConstant(
303 AsmNodeOperands.push_back(PairedReg);
310 AsmNodeOperands.push_back(Glue);
314 SelectInlineAsmMemoryOperands(AsmNodeOperands,
SDLoc(N));
338 ReplaceNode(N, getGlobalBaseReg());
353 TopPart =
SDValue(CurDAG->getMachineNode(SP::SRAri, dl,
MVT::i32, DivLHS,
354 CurDAG->getTargetConstant(31, dl,
MVT::i32)),
357 TopPart = CurDAG->getRegister(SP::G0,
MVT::i32);
359 TopPart = CurDAG->getCopyToReg(CurDAG->getEntryNode(), dl,
SP::Y, TopPart,
365 CurDAG->SelectNodeTo(N, Opcode,
MVT::i32, DivLHS, DivRHS, TopPart);
377 SparcDAGToDAGISel::SelectInlineAsmMemoryOperand(
const SDValue &
Op,
378 unsigned ConstraintID,
379 std::vector<SDValue> &OutOps) {
381 switch (ConstraintID) {
382 default:
return true;
386 if (!SelectADDRrr(Op, Op0, Op1))
387 SelectADDRri(Op, Op0, Op1);
391 OutOps.push_back(Op0);
392 OutOps.push_back(Op1);
400 return new SparcDAGToDAGISel(TM);
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents lattice values for constants.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
void push_back(const T &Elt)
static unsigned getFlagWord(unsigned Kind, unsigned NumOps)
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
void setNodeId(int Id)
Set unique node id.
SDNode * getNode() const
get the SDNode which holds the desired result
static bool isUseOperandTiedToDef(unsigned Flag, unsigned &Idx)
isUseOperandTiedToDef - Return true if the flag of the inline asm operand indicates it is an use oper...
GlobalBaseReg - On Darwin, this node represents the result of the mflr at function entry...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
static unsigned getFlagWordForRegClass(unsigned InputFlag, unsigned RC)
getFlagWordForRegClass - Augment an existing flag word returned by getFlagWord with the required regi...
op_iterator op_end() const
INLINEASM - Represents an inline asm block.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Simple integer binary arithmetic operators.
op_iterator op_begin() const
Flag
These should be considered private to the implementation of the MCInstrDesc class.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
SDNode * getGluedUser() const
If this node has a glue value with a user, return the user (there is at most one).
const SDValue & getOperand(unsigned Num) const
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
static unsigned getKind(unsigned Flags)
FunctionPass class - This class is used to implement most global optimizations.
SDNode * getGluedNode() const
If this node has a glue operand, return the node to which the glue operand points.
FunctionPass * createSparcISelDag(SparcTargetMachine &TM)
createSparcISelDag - This pass converts a legalized DAG into a SPARC-specific DAG, ready for instruction scheduling.
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
unsigned getNumOperands() const
Return the number of values used by this operation.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
static bool hasRegClassConstraint(unsigned Flag, unsigned &RC)
hasRegClassConstraint - Returns true if the flag contains a register class constraint.
unsigned getOpcode() const
SDValue getValue(unsigned R) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
const SDValue & getOperand(unsigned i) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
static unsigned getFlagWordForMatchingOp(unsigned InputFlag, unsigned MatchedOperandNo)
getFlagWordForMatchingOp - Augment an existing flag word returned by getFlagWord with information ind...