LLVM API Documentation

HexagonISelLowering.h
Go to the documentation of this file.
00001 //===-- HexagonISelLowering.h - Hexagon DAG Lowering Interface --*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the interfaces that Hexagon uses to lower LLVM code into a
00011 // selection DAG.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
00016 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
00017 
00018 #include "Hexagon.h"
00019 #include "llvm/CodeGen/CallingConvLower.h"
00020 #include "llvm/IR/CallingConv.h"
00021 #include "llvm/Target/TargetLowering.h"
00022 
00023 namespace llvm {
00024   namespace HexagonISD {
00025     enum {
00026       FIRST_NUMBER = ISD::BUILTIN_OP_END,
00027 
00028       CONST32,
00029       CONST32_GP,  // For marking data present in GP.
00030       CONST32_Int_Real,
00031       FCONST32,
00032       SETCC,
00033       ADJDYNALLOC,
00034       ARGEXTEND,
00035 
00036       CMPICC,      // Compare two GPR operands, set icc.
00037       CMPFCC,      // Compare two FP operands, set fcc.
00038       BRICC,       // Branch to dest on icc condition
00039       BRFCC,       // Branch to dest on fcc condition
00040       SELECT_ICC,  // Select between two values using the current ICC flags.
00041       SELECT_FCC,  // Select between two values using the current FCC flags.
00042 
00043       Hi, Lo,      // Hi/Lo operations, typically on a global address.
00044 
00045       FTOI,        // FP to Int within a FP register.
00046       ITOF,        // Int to FP within a FP register.
00047 
00048       CALL,        // A call instruction.
00049       RET_FLAG,    // Return with a flag operand.
00050       BR_JT,       // Jump table.
00051       BARRIER,     // Memory barrier.
00052       WrapperJT,
00053       WrapperCP,
00054       WrapperCombineII,
00055       WrapperCombineRR,
00056       WrapperCombineRI_V4,
00057       WrapperCombineIR_V4,
00058       WrapperPackhl,
00059       WrapperSplatB,
00060       WrapperSplatH,
00061       WrapperShuffEB,
00062       WrapperShuffEH,
00063       WrapperShuffOB,
00064       WrapperShuffOH,
00065       TC_RETURN,
00066       EH_RETURN
00067     };
00068   }
00069 
00070   class HexagonTargetLowering : public TargetLowering {
00071     int VarArgsFrameOffset;   // Frame offset to start of varargs area.
00072 
00073     bool CanReturnSmallStruct(const Function* CalleeFn,
00074                               unsigned& RetSize) const;
00075 
00076   public:
00077     const TargetMachine &TM;
00078     explicit HexagonTargetLowering(const TargetMachine &targetmachine);
00079 
00080     /// IsEligibleForTailCallOptimization - Check whether the call is eligible
00081     /// for tail call optimization. Targets which want to do tail call
00082     /// optimization should implement this function.
00083     bool
00084     IsEligibleForTailCallOptimization(SDValue Callee,
00085                                       CallingConv::ID CalleeCC,
00086                                       bool isVarArg,
00087                                       bool isCalleeStructRet,
00088                                       bool isCallerStructRet,
00089                                       const
00090                                       SmallVectorImpl<ISD::OutputArg> &Outs,
00091                                       const SmallVectorImpl<SDValue> &OutVals,
00092                                       const SmallVectorImpl<ISD::InputArg> &Ins,
00093                                       SelectionDAG& DAG) const;
00094 
00095     bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
00096     bool isTruncateFree(EVT VT1, EVT VT2) const override;
00097 
00098     bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
00099 
00100     SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
00101 
00102     const char *getTargetNodeName(unsigned Opcode) const override;
00103     SDValue  LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
00104     SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
00105     SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
00106     SDValue LowerEH_LABEL(SDValue Op, SelectionDAG &DAG) const;
00107     SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
00108     SDValue LowerFormalArguments(SDValue Chain,
00109                                  CallingConv::ID CallConv, bool isVarArg,
00110                                  const SmallVectorImpl<ISD::InputArg> &Ins,
00111                                  SDLoc dl, SelectionDAG &DAG,
00112                                  SmallVectorImpl<SDValue> &InVals) const override;
00113     SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const;
00114     SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
00115 
00116     SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
00117                       SmallVectorImpl<SDValue> &InVals) const override;
00118 
00119     SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
00120                             CallingConv::ID CallConv, bool isVarArg,
00121                             const SmallVectorImpl<ISD::InputArg> &Ins,
00122                             SDLoc dl, SelectionDAG &DAG,
00123                             SmallVectorImpl<SDValue> &InVals,
00124                             const SmallVectorImpl<SDValue> &OutVals,
00125                             SDValue Callee) const;
00126 
00127     SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
00128     SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG& DAG) const;
00129     SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
00130 
00131     SDValue LowerReturn(SDValue Chain,
00132                         CallingConv::ID CallConv, bool isVarArg,
00133                         const SmallVectorImpl<ISD::OutputArg> &Outs,
00134                         const SmallVectorImpl<SDValue> &OutVals,
00135                         SDLoc dl, SelectionDAG &DAG) const override;
00136 
00137     MachineBasicBlock *
00138     EmitInstrWithCustomInserter(MachineInstr *MI,
00139                                 MachineBasicBlock *BB) const override;
00140 
00141     SDValue  LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
00142     SDValue  LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
00143     EVT getSetCCResultType(LLVMContext &C, EVT VT) const override {
00144       if (!VT.isVector())
00145         return MVT::i1;
00146       else
00147         return EVT::getVectorVT(C, MVT::i1, VT.getVectorNumElements());
00148     }
00149 
00150     bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
00151                                     SDValue &Base, SDValue &Offset,
00152                                     ISD::MemIndexedMode &AM,
00153                                     SelectionDAG &DAG) const override;
00154 
00155     std::pair<unsigned, const TargetRegisterClass*>
00156     getRegForInlineAsmConstraint(const std::string &Constraint,
00157                                  MVT VT) const override;
00158 
00159     // Intrinsics
00160     SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
00161     /// isLegalAddressingMode - Return true if the addressing mode represented
00162     /// by AM is legal for this target, for a load/store of the specified type.
00163     /// The type may be VoidTy, in which case only return true if the addressing
00164     /// mode is legal for a load/store of any legal type.
00165     /// TODO: Handle pre/postinc as well.
00166     bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const override;
00167     bool isFPImmLegal(const APFloat &Imm, EVT VT) const override;
00168 
00169     /// isLegalICmpImmediate - Return true if the specified immediate is legal
00170     /// icmp immediate, that is the target has icmp instructions which can
00171     /// compare a register against the immediate without having to materialize
00172     /// the immediate into a register.
00173     bool isLegalICmpImmediate(int64_t Imm) const override;
00174   };
00175 } // end namespace llvm
00176 
00177 #endif    // Hexagon_ISELLOWERING_H