1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===-- AlphaISelLowering.h - Alpha DAG Lowering Interface ------*- C++ -*-===// 2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// The LLVM Compiler Infrastructure 4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source 6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details. 7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===// 9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file defines the interfaces that Alpha uses to lower LLVM code into a 11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// selection DAG. 12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===// 14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H 16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H 17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/ADT/VectorExtras.h" 19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Target/TargetLowering.h" 20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/CodeGen/SelectionDAG.h" 21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "Alpha.h" 22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm { 24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman namespace AlphaISD { 26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman enum NodeType { 27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Start the numbering where the builting ops and target ops leave off. 28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman FIRST_NUMBER = ISD::BUILTIN_OP_END, 29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman //These corrospond to the identical Instruction 30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CVTQT_, CVTQS_, CVTTQ_, 31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// GPRelHi/GPRelLo - These represent the high and low 16-bit 33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// parts of a global address respectively. 3419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman GPRelHi, GPRelLo, 35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// RetLit - Literal Relocation of a Global 37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RelLit, 38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// GlobalRetAddr - used to restore the return address 40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman GlobalRetAddr, 4119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// CALL - Normal call. 43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CALL, 44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// DIVCALL - used for special library calls for div and rem 46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman DivCall, 4719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// return flag operand 49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman RET_FLAG, 50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// CHAIN = COND_BRANCH CHAIN, OPC, (G|F)PRC, DESTBB [, INFLAG] - This 5219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman /// corresponds to the COND_BRANCH pseudo instruction. 53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// *PRC is the input register to compare to zero, 54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// OPC is the branch opcode to use (e.g. Alpha::BEQ), 55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// DESTBB is the destination block to branch to, and INFLAG is 56894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// an optional input flag argument. 57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman COND_BRANCH_I, COND_BRANCH_F 58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman }; 60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman class AlphaTargetLowering : public TargetLowering { 63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman public: 64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman explicit AlphaTargetLowering(TargetMachine &TM); 6519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 6619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman virtual MVT getShiftAmountTy(EVT LHSTy) const { return MVT::i64; } 6719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// getSetCCResultType - Get the SETCC result ValueType 6919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman virtual EVT getSetCCResultType(EVT VT) const; 70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// LowerOperation - Provide custom lowering hooks for some operations. 72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// 73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; 74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// ReplaceNodeResults - Replace the results of node with an illegal result 76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// type with new values built out of custom code. 77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// 78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, 79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SelectionDAG &DAG) const; 80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Friendly names for dumps 82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const char *getTargetNodeName(unsigned Opcode) const; 83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SDValue LowerCallResult(SDValue Chain, SDValue InFlag, 85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CallingConv::ID CallConv, bool isVarArg, 86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const SmallVectorImpl<ISD::InputArg> &Ins, 87894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman DebugLoc dl, SelectionDAG &DAG, 88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SmallVectorImpl<SDValue> &InVals) const; 89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ConstraintType getConstraintType(const std::string &Constraint) const; 91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 9219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman /// Examine constraint string and operand type and determine a weight value. 9319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman /// The operand object must already have been set up with the operand type. 9419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman ConstraintWeight getSingleConstraintMatchWeight( 9519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman AsmOperandInfo &info, const char *constraint) const; 9619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 9719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman std::pair<unsigned, const TargetRegisterClass*> 9819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman getRegForInlineAsmConstraint(const std::string &Constraint, 9919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman EVT VT) const; 100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MachineBasicBlock * 102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman EmitInstrWithCustomInserter(MachineInstr *MI, 103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman MachineBasicBlock *BB) const; 104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; 106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// isFPImmLegal - Returns true if the target can instruction select the 108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// specified FP immediate natively. If false, the legalizer will 109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// materialize the FP immediate as a load from a constant pool. 110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const; 111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 112894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman private: 113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Helpers for custom lowering. 114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void LowerVAARG(SDNode *N, SDValue &Chain, SDValue &DataPtr, 115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SelectionDAG &DAG) const; 116894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 117894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual SDValue 118894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman LowerFormalArguments(SDValue Chain, 119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CallingConv::ID CallConv, bool isVarArg, 120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const SmallVectorImpl<ISD::InputArg> &Ins, 121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman DebugLoc dl, SelectionDAG &DAG, 122894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SmallVectorImpl<SDValue> &InVals) const; 123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual SDValue 125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman LowerCall(SDValue Chain, SDValue Callee, 126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CallingConv::ID CallConv, bool isVarArg, bool &isTailCall, 127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const SmallVectorImpl<ISD::OutputArg> &Outs, 128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const SmallVectorImpl<SDValue> &OutVals, 129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const SmallVectorImpl<ISD::InputArg> &Ins, 130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman DebugLoc dl, SelectionDAG &DAG, 131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman SmallVectorImpl<SDValue> &InVals) const; 132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 133894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman virtual SDValue 134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman LowerReturn(SDValue Chain, 135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman CallingConv::ID CallConv, bool isVarArg, 136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const SmallVectorImpl<ISD::OutputArg> &Outs, 137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman const SmallVectorImpl<SDValue> &OutVals, 138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman DebugLoc dl, SelectionDAG &DAG) const; 139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman }; 140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 141894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 142894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif // LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H 143