51 bool SelectInlineAsmMemoryOperand(
const SDValue &
Op,
52 unsigned ConstraintID,
53 std::vector<SDValue> &OutOps)
override;
56 return "SPARC DAG->DAG Pattern Instruction Selection";
60 #include "SparcGenDAGISel.inc" 63 SDNode* getGlobalBaseReg();
68 SDNode* SparcDAGToDAGISel::getGlobalBaseReg() {
69 unsigned GlobalBaseReg = Subtarget->getInstrInfo()->getGlobalBaseReg(MF);
70 return CurDAG->getRegister(GlobalBaseReg,
71 TLI->getPointerTy(CurDAG->getDataLayout()))
75 bool SparcDAGToDAGISel::SelectADDRri(
SDValue Addr,
78 Base = CurDAG->getTargetFrameIndex(
79 FIN->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout()));
90 if (isInt<13>(CN->getSExtValue())) {
92 dyn_cast<FrameIndexSDNode>(Addr.
getOperand(0))) {
94 Base = CurDAG->getTargetFrameIndex(
95 FIN->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout()));
99 Offset = CurDAG->getTargetConstant(CN->getZExtValue(),
SDLoc(Addr),
116 Offset = CurDAG->getTargetConstant(0,
SDLoc(Addr),
MVT::i32);
129 if (isInt<13>(CN->getSExtValue()))
140 R2 = CurDAG->getRegister(SP::G0, TLI->getPointerTy(CurDAG->getDataLayout()));
156 bool SparcDAGToDAGISel::tryInlineAsm(
SDNode *
N){
157 std::vector<SDValue> AsmNodeOperands;
159 bool Changed =
false;
176 for(
unsigned i = 0,
e = N->
getGluedNode() ? NumOps - 1 : NumOps; i <
e; ++i) {
178 AsmNodeOperands.push_back(op);
184 Flag =
C->getZExtValue();
196 AsmNodeOperands.push_back(op);
205 bool IsTiedToChangedOp =
false;
209 IsTiedToChangedOp = OpChanged[DefIdx];
217 if ((!IsTiedToChangedOp && (!HasRC || RC != SP::IntRegsRegClassID))
221 assert((i+2 < NumOps) &&
"Invalid number of operands in inline asm");
224 unsigned Reg0 = cast<RegisterSDNode>(V0)->
getReg();
225 unsigned Reg1 = cast<RegisterSDNode>(V1)->
getReg();
235 PairedReg = CurDAG->getRegister(GPVR,
MVT::v2i32);
243 SDValue Sub0 = CurDAG->getTargetExtractSubreg(SP::sub_even, dl,
MVT::i32,
245 SDValue Sub1 = CurDAG->getTargetExtractSubreg(SP::sub_odd, dl,
MVT::i32,
247 SDValue T0 = CurDAG->getCopyToReg(Sub0, dl, Reg0, Sub0,
254 CurDAG->UpdateNodeOperands(GU, Ops);
267 CurDAG->getMachineNode(
270 CurDAG->getTargetConstant(SP::IntPairRegClassID, dl,
273 CurDAG->getTargetConstant(SP::sub_even, dl, MVT::i32),
275 CurDAG->getTargetConstant(SP::sub_odd, dl, MVT::i32),
282 PairedReg = CurDAG->getRegister(GPVR,
MVT::v2i32);
283 Chain = CurDAG->getCopyToReg(T1, dl, GPVR, Pair, T1.
getValue(1));
292 OpChanged[OpChanged.
size() -1 ] =
true;
294 if (IsTiedToChangedOp)
299 AsmNodeOperands[AsmNodeOperands.size() -1] = CurDAG->getTargetConstant(
302 AsmNodeOperands.push_back(PairedReg);
309 AsmNodeOperands.push_back(Glue);
313 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;
385 if (!SelectADDRrr(Op, Op0, Op1))
386 SelectADDRri(Op, Op0, Op1);
390 OutOps.push_back(Op0);
391 OutOps.push_back(Op1);
399 return new SparcDAGToDAGISel(TM);
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
This class represents lattice values for constants.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
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())
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
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...
Wrapper class representing virtual and physical registers.
static unsigned getFlagWordForMatchingOp(unsigned InputFlag, unsigned MatchedOperandNo)
getFlagWordForMatchingOp - Augment an existing flag word returned by getFlagWord with information ind...