10b57cec5SDimitry Andric //===-- LanaiISelLowering.h - Lanai DAG Lowering Interface -....-*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file defines the interfaces that Lanai uses to lower LLVM code into a 100b57cec5SDimitry Andric // selection DAG. 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_LANAI_LANAIISELLOWERING_H 150b57cec5SDimitry Andric #define LLVM_LIB_TARGET_LANAI_LANAIISELLOWERING_H 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric #include "Lanai.h" 180b57cec5SDimitry Andric #include "LanaiRegisterInfo.h" 190b57cec5SDimitry Andric #include "llvm/CodeGen/SelectionDAG.h" 200b57cec5SDimitry Andric #include "llvm/CodeGen/TargetLowering.h" 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric namespace llvm { 230b57cec5SDimitry Andric namespace LanaiISD { 240b57cec5SDimitry Andric enum { 250b57cec5SDimitry Andric FIRST_NUMBER = ISD::BUILTIN_OP_END, 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric ADJDYNALLOC, 280b57cec5SDimitry Andric 2906c3fb27SDimitry Andric // Return with a glue operand. Operand 0 is the chain operand. 3006c3fb27SDimitry Andric RET_GLUE, 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric // CALL - These operations represent an abstract call instruction, which 330b57cec5SDimitry Andric // includes a bunch of information. 340b57cec5SDimitry Andric CALL, 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric // SELECT_CC - Operand 0 and operand 1 are selection variable, operand 3 370b57cec5SDimitry Andric // is condition code and operand 4 is flag operand. 380b57cec5SDimitry Andric SELECT_CC, 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric // SETCC - Store the conditional code to a register. 410b57cec5SDimitry Andric SETCC, 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric // SET_FLAG - Set flag compare. 440b57cec5SDimitry Andric SET_FLAG, 450b57cec5SDimitry Andric 460b57cec5SDimitry Andric // SUBBF - Subtract with borrow that sets flags. 470b57cec5SDimitry Andric SUBBF, 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric // BR_CC - Used to glue together a conditional branch and comparison 500b57cec5SDimitry Andric BR_CC, 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric // Wrapper - A wrapper node for TargetConstantPool, TargetExternalSymbol, 530b57cec5SDimitry Andric // and TargetGlobalAddress. 540b57cec5SDimitry Andric Wrapper, 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric // Get the Higher/Lower 16 bits from a 32-bit immediate. 570b57cec5SDimitry Andric HI, 580b57cec5SDimitry Andric LO, 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric // Small 21-bit immediate in global memory. 610b57cec5SDimitry Andric SMALL 620b57cec5SDimitry Andric }; 630b57cec5SDimitry Andric } // namespace LanaiISD 640b57cec5SDimitry Andric 650b57cec5SDimitry Andric class LanaiSubtarget; 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric class LanaiTargetLowering : public TargetLowering { 680b57cec5SDimitry Andric public: 690b57cec5SDimitry Andric LanaiTargetLowering(const TargetMachine &TM, const LanaiSubtarget &STI); 700b57cec5SDimitry Andric 710b57cec5SDimitry Andric // LowerOperation - Provide custom lowering hooks for some operations. 720b57cec5SDimitry Andric SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric // getTargetNodeName - This method returns the name of a target specific 750b57cec5SDimitry Andric // DAG node. 760b57cec5SDimitry Andric const char *getTargetNodeName(unsigned Opcode) const override; 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; 790b57cec5SDimitry Andric SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const; 800b57cec5SDimitry Andric SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const; 810b57cec5SDimitry Andric SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const; 820b57cec5SDimitry Andric SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const; 830b57cec5SDimitry Andric SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; 840b57cec5SDimitry Andric SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const; 850b57cec5SDimitry Andric SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) const; 860b57cec5SDimitry Andric SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const; 870b57cec5SDimitry Andric SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; 880b57cec5SDimitry Andric SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const; 890b57cec5SDimitry Andric SDValue LowerSHL_PARTS(SDValue Op, SelectionDAG &DAG) const; 900b57cec5SDimitry Andric SDValue LowerSRL_PARTS(SDValue Op, SelectionDAG &DAG) const; 910b57cec5SDimitry Andric SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const; 920b57cec5SDimitry Andric 93349cc55cSDimitry Andric bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, 94349cc55cSDimitry Andric bool IsVarArg, 95349cc55cSDimitry Andric const SmallVectorImpl<ISD::OutputArg> &Outs, 96349cc55cSDimitry Andric LLVMContext &Context) const override; 97349cc55cSDimitry Andric 98480093f4SDimitry Andric Register getRegisterByName(const char *RegName, LLT VT, 998bcb0991SDimitry Andric const MachineFunction &MF) const override; 1000b57cec5SDimitry Andric std::pair<unsigned, const TargetRegisterClass *> 1010b57cec5SDimitry Andric getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, 1020b57cec5SDimitry Andric StringRef Constraint, MVT VT) const override; 1030b57cec5SDimitry Andric ConstraintWeight 1040b57cec5SDimitry Andric getSingleConstraintMatchWeight(AsmOperandInfo &Info, 1050b57cec5SDimitry Andric const char *Constraint) const override; 106*5f757f3fSDimitry Andric void LowerAsmOperandForConstraint(SDValue Op, StringRef Constraint, 1070b57cec5SDimitry Andric std::vector<SDValue> &Ops, 1080b57cec5SDimitry Andric SelectionDAG &DAG) const override; 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override; 1110b57cec5SDimitry Andric 1120b57cec5SDimitry Andric void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, 1130b57cec5SDimitry Andric const APInt &DemandedElts, 1140b57cec5SDimitry Andric const SelectionDAG &DAG, 1150b57cec5SDimitry Andric unsigned Depth = 0) const override; 1160b57cec5SDimitry Andric 1170b57cec5SDimitry Andric private: 1180b57cec5SDimitry Andric SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee, 1190b57cec5SDimitry Andric CallingConv::ID CallConv, bool IsVarArg, 1200b57cec5SDimitry Andric bool IsTailCall, 1210b57cec5SDimitry Andric const SmallVectorImpl<ISD::OutputArg> &Outs, 1220b57cec5SDimitry Andric const SmallVectorImpl<SDValue> &OutVals, 1230b57cec5SDimitry Andric const SmallVectorImpl<ISD::InputArg> &Ins, 1240b57cec5SDimitry Andric const SDLoc &dl, SelectionDAG &DAG, 1250b57cec5SDimitry Andric SmallVectorImpl<SDValue> &InVals) const; 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andric SDValue LowerCCCArguments(SDValue Chain, CallingConv::ID CallConv, 1280b57cec5SDimitry Andric bool IsVarArg, 1290b57cec5SDimitry Andric const SmallVectorImpl<ISD::InputArg> &Ins, 1300b57cec5SDimitry Andric const SDLoc &DL, SelectionDAG &DAG, 1310b57cec5SDimitry Andric SmallVectorImpl<SDValue> &InVals) const; 1320b57cec5SDimitry Andric 13306c3fb27SDimitry Andric SDValue LowerCallResult(SDValue Chain, SDValue InGlue, 1340b57cec5SDimitry Andric CallingConv::ID CallConv, bool IsVarArg, 1350b57cec5SDimitry Andric const SmallVectorImpl<ISD::InputArg> &Ins, 1360b57cec5SDimitry Andric const SDLoc &DL, SelectionDAG &DAG, 1370b57cec5SDimitry Andric SmallVectorImpl<SDValue> &InVals) const; 1380b57cec5SDimitry Andric 1390b57cec5SDimitry Andric SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, 1400b57cec5SDimitry Andric SmallVectorImpl<SDValue> &InVals) const override; 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andric SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, 1430b57cec5SDimitry Andric bool IsVarArg, 1440b57cec5SDimitry Andric const SmallVectorImpl<ISD::InputArg> &Ins, 1450b57cec5SDimitry Andric const SDLoc &DL, SelectionDAG &DAG, 1460b57cec5SDimitry Andric SmallVectorImpl<SDValue> &InVals) const override; 1470b57cec5SDimitry Andric 1480b57cec5SDimitry Andric SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, 1490b57cec5SDimitry Andric const SmallVectorImpl<ISD::OutputArg> &Outs, 1500b57cec5SDimitry Andric const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL, 1510b57cec5SDimitry Andric SelectionDAG &DAG) const override; 1520b57cec5SDimitry Andric 1530b57cec5SDimitry Andric const LanaiRegisterInfo *TRI; 1540b57cec5SDimitry Andric }; 1550b57cec5SDimitry Andric } // namespace llvm 1560b57cec5SDimitry Andric 1570b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_LANAI_LANAIISELLOWERING_H 158