1*9880d681SAndroid Build Coastguard Worker //===-- AVRISelLowering.h - AVR DAG Lowering Interface ----------*- C++ -*-===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file defines the interfaces that AVR uses to lower LLVM code into a 11*9880d681SAndroid Build Coastguard Worker // selection DAG. 12*9880d681SAndroid Build Coastguard Worker // 13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_AVR_ISEL_LOWERING_H 16*9880d681SAndroid Build Coastguard Worker #define LLVM_AVR_ISEL_LOWERING_H 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLowering.h" 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Worker namespace llvm { 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Worker namespace AVRISD { 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Worker /// AVR Specific DAG Nodes 25*9880d681SAndroid Build Coastguard Worker enum NodeType { 26*9880d681SAndroid Build Coastguard Worker /// Start the numbering where the builtin ops leave off. 27*9880d681SAndroid Build Coastguard Worker FIRST_NUMBER = ISD::BUILTIN_OP_END, 28*9880d681SAndroid Build Coastguard Worker /// Return from subroutine. 29*9880d681SAndroid Build Coastguard Worker RET_FLAG, 30*9880d681SAndroid Build Coastguard Worker /// Return from ISR. 31*9880d681SAndroid Build Coastguard Worker RETI_FLAG, 32*9880d681SAndroid Build Coastguard Worker /// Represents an abstract call instruction, 33*9880d681SAndroid Build Coastguard Worker /// which includes a bunch of information. 34*9880d681SAndroid Build Coastguard Worker CALL, 35*9880d681SAndroid Build Coastguard Worker /// A wrapper node for TargetConstantPool, 36*9880d681SAndroid Build Coastguard Worker /// TargetExternalSymbol, and TargetGlobalAddress. 37*9880d681SAndroid Build Coastguard Worker WRAPPER, 38*9880d681SAndroid Build Coastguard Worker LSL, ///< Logical shift left. 39*9880d681SAndroid Build Coastguard Worker LSR, ///< Logical shift right. 40*9880d681SAndroid Build Coastguard Worker ASR, ///< Arithmetic shift right. 41*9880d681SAndroid Build Coastguard Worker ROR, ///< Bit rotate right. 42*9880d681SAndroid Build Coastguard Worker ROL, ///< Bit rotate left. 43*9880d681SAndroid Build Coastguard Worker LSLLOOP, ///< A loop of single logical shift left instructions. 44*9880d681SAndroid Build Coastguard Worker LSRLOOP, ///< A loop of single logical shift right instructions. 45*9880d681SAndroid Build Coastguard Worker ASRLOOP, ///< A loop of single arithmetic shift right instructions. 46*9880d681SAndroid Build Coastguard Worker /// AVR conditional branches. Operand 0 is the chain operand, operand 1 47*9880d681SAndroid Build Coastguard Worker /// is the block to branch if condition is true, operand 2 is the 48*9880d681SAndroid Build Coastguard Worker /// condition code, and operand 3 is the flag operand produced by a CMP 49*9880d681SAndroid Build Coastguard Worker /// or TEST instruction. 50*9880d681SAndroid Build Coastguard Worker BRCOND, 51*9880d681SAndroid Build Coastguard Worker /// Compare instruction. 52*9880d681SAndroid Build Coastguard Worker CMP, 53*9880d681SAndroid Build Coastguard Worker /// Compare with carry instruction. 54*9880d681SAndroid Build Coastguard Worker CMPC, 55*9880d681SAndroid Build Coastguard Worker /// Test for zero or minus instruction. 56*9880d681SAndroid Build Coastguard Worker TST, 57*9880d681SAndroid Build Coastguard Worker /// Operand 0 and operand 1 are selection variable, operand 2 58*9880d681SAndroid Build Coastguard Worker /// is condition code and operand 3 is flag operand. 59*9880d681SAndroid Build Coastguard Worker SELECT_CC 60*9880d681SAndroid Build Coastguard Worker }; 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Worker } // end of namespace AVRISD 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Worker class AVRTargetMachine; 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Worker /// Performs target lowering for the AVR. 67*9880d681SAndroid Build Coastguard Worker class AVRTargetLowering : public TargetLowering { 68*9880d681SAndroid Build Coastguard Worker public: 69*9880d681SAndroid Build Coastguard Worker explicit AVRTargetLowering(AVRTargetMachine &TM); 70*9880d681SAndroid Build Coastguard Worker 71*9880d681SAndroid Build Coastguard Worker public: getScalarShiftAmountTy(const DataLayout &,EVT LHSTy)72*9880d681SAndroid Build Coastguard Worker MVT getScalarShiftAmountTy(const DataLayout &, EVT LHSTy) const override { 73*9880d681SAndroid Build Coastguard Worker return MVT::i8; 74*9880d681SAndroid Build Coastguard Worker } 75*9880d681SAndroid Build Coastguard Worker const char *getTargetNodeName(unsigned Opcode) const override; 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Worker SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; 78*9880d681SAndroid Build Coastguard Worker 79*9880d681SAndroid Build Coastguard Worker void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results, 80*9880d681SAndroid Build Coastguard Worker SelectionDAG &DAG) const override; 81*9880d681SAndroid Build Coastguard Worker 82*9880d681SAndroid Build Coastguard Worker bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, 83*9880d681SAndroid Build Coastguard Worker unsigned AS) const override; 84*9880d681SAndroid Build Coastguard Worker 85*9880d681SAndroid Build Coastguard Worker bool getPreIndexedAddressParts(SDNode *N, SDValue &Base, SDValue &Offset, 86*9880d681SAndroid Build Coastguard Worker ISD::MemIndexedMode &AM, 87*9880d681SAndroid Build Coastguard Worker SelectionDAG &DAG) const override; 88*9880d681SAndroid Build Coastguard Worker 89*9880d681SAndroid Build Coastguard Worker bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base, 90*9880d681SAndroid Build Coastguard Worker SDValue &Offset, ISD::MemIndexedMode &AM, 91*9880d681SAndroid Build Coastguard Worker SelectionDAG &DAG) const override; 92*9880d681SAndroid Build Coastguard Worker 93*9880d681SAndroid Build Coastguard Worker bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override; 94*9880d681SAndroid Build Coastguard Worker 95*9880d681SAndroid Build Coastguard Worker MachineBasicBlock * 96*9880d681SAndroid Build Coastguard Worker EmitInstrWithCustomInserter(MachineInstr &MI, 97*9880d681SAndroid Build Coastguard Worker MachineBasicBlock *MBB) const override; 98*9880d681SAndroid Build Coastguard Worker 99*9880d681SAndroid Build Coastguard Worker ConstraintType getConstraintType(StringRef Constraint) const override; 100*9880d681SAndroid Build Coastguard Worker 101*9880d681SAndroid Build Coastguard Worker ConstraintWeight 102*9880d681SAndroid Build Coastguard Worker getSingleConstraintMatchWeight(AsmOperandInfo &info, 103*9880d681SAndroid Build Coastguard Worker const char *constraint) const override; 104*9880d681SAndroid Build Coastguard Worker 105*9880d681SAndroid Build Coastguard Worker std::pair<unsigned, const TargetRegisterClass *> 106*9880d681SAndroid Build Coastguard Worker getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, 107*9880d681SAndroid Build Coastguard Worker StringRef Constraint, MVT VT) const override; 108*9880d681SAndroid Build Coastguard Worker 109*9880d681SAndroid Build Coastguard Worker unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override; 110*9880d681SAndroid Build Coastguard Worker 111*9880d681SAndroid Build Coastguard Worker void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint, 112*9880d681SAndroid Build Coastguard Worker std::vector<SDValue> &Ops, 113*9880d681SAndroid Build Coastguard Worker SelectionDAG &DAG) const override; 114*9880d681SAndroid Build Coastguard Worker 115*9880d681SAndroid Build Coastguard Worker private: 116*9880d681SAndroid Build Coastguard Worker SDValue getAVRCmp(SDValue LHS, SDValue RHS, ISD::CondCode CC, SDValue &AVRcc, 117*9880d681SAndroid Build Coastguard Worker SelectionDAG &DAG, SDLoc dl) const; 118*9880d681SAndroid Build Coastguard Worker SDValue LowerShifts(SDValue Op, SelectionDAG &DAG) const; 119*9880d681SAndroid Build Coastguard Worker SDValue LowerDivRem(SDValue Op, SelectionDAG &DAG) const; 120*9880d681SAndroid Build Coastguard Worker SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; 121*9880d681SAndroid Build Coastguard Worker SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; 122*9880d681SAndroid Build Coastguard Worker SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const; 123*9880d681SAndroid Build Coastguard Worker SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const; 124*9880d681SAndroid Build Coastguard Worker SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; 125*9880d681SAndroid Build Coastguard Worker SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const; 126*9880d681SAndroid Build Coastguard Worker SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const; 127*9880d681SAndroid Build Coastguard Worker 128*9880d681SAndroid Build Coastguard Worker SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, 129*9880d681SAndroid Build Coastguard Worker const SmallVectorImpl<ISD::OutputArg> &Outs, 130*9880d681SAndroid Build Coastguard Worker const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl, 131*9880d681SAndroid Build Coastguard Worker SelectionDAG &DAG) const override; 132*9880d681SAndroid Build Coastguard Worker SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, 133*9880d681SAndroid Build Coastguard Worker bool isVarArg, 134*9880d681SAndroid Build Coastguard Worker const SmallVectorImpl<ISD::InputArg> &Ins, 135*9880d681SAndroid Build Coastguard Worker const SDLoc &dl, SelectionDAG &DAG, 136*9880d681SAndroid Build Coastguard Worker SmallVectorImpl<SDValue> &InVals) const override; 137*9880d681SAndroid Build Coastguard Worker SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, 138*9880d681SAndroid Build Coastguard Worker SmallVectorImpl<SDValue> &InVals) const override; 139*9880d681SAndroid Build Coastguard Worker SDValue LowerCallResult(SDValue Chain, SDValue InFlag, 140*9880d681SAndroid Build Coastguard Worker CallingConv::ID CallConv, bool isVarArg, 141*9880d681SAndroid Build Coastguard Worker const SmallVectorImpl<ISD::InputArg> &Ins, 142*9880d681SAndroid Build Coastguard Worker const SDLoc &dl, SelectionDAG &DAG, 143*9880d681SAndroid Build Coastguard Worker SmallVectorImpl<SDValue> &InVals) const; 144*9880d681SAndroid Build Coastguard Worker 145*9880d681SAndroid Build Coastguard Worker private: 146*9880d681SAndroid Build Coastguard Worker MachineBasicBlock *insertShift(MachineInstr *MI, MachineBasicBlock *BB) const; 147*9880d681SAndroid Build Coastguard Worker MachineBasicBlock *insertMul(MachineInstr *MI, MachineBasicBlock *BB) const; 148*9880d681SAndroid Build Coastguard Worker }; 149*9880d681SAndroid Build Coastguard Worker 150*9880d681SAndroid Build Coastguard Worker } // end namespace llvm 151*9880d681SAndroid Build Coastguard Worker 152*9880d681SAndroid Build Coastguard Worker #endif // LLVM_AVR_ISEL_LOWERING_H 153