Path: blob/main/contrib/llvm-project/llvm/lib/Target/MSP430/MSP430ISelLowering.h
35269 views
//===-- MSP430ISelLowering.h - MSP430 DAG Lowering Interface ----*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines the interfaces that MSP430 uses to lower LLVM code into a9// selection DAG.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_LIB_TARGET_MSP430_MSP430ISELLOWERING_H14#define LLVM_LIB_TARGET_MSP430_MSP430ISELLOWERING_H1516#include "MSP430.h"17#include "llvm/CodeGen/SelectionDAG.h"18#include "llvm/CodeGen/TargetLowering.h"1920namespace llvm {21namespace MSP430ISD {22enum NodeType : unsigned {23FIRST_NUMBER = ISD::BUILTIN_OP_END,2425/// Return with a glue operand. Operand 0 is the chain operand.26RET_GLUE,2728/// Same as RET_GLUE, but used for returning from ISRs.29RETI_GLUE,3031/// Y = R{R,L}A X, rotate right (left) arithmetically32RRA, RLA,3334/// Y = RRC X, rotate right via carry35RRC,3637/// Rotate right via carry, carry gets cleared beforehand by clrc38RRCL,3940/// CALL - These operations represent an abstract call41/// instruction, which includes a bunch of information.42CALL,4344/// Wrapper - A wrapper node for TargetConstantPool, TargetExternalSymbol,45/// and TargetGlobalAddress.46Wrapper,4748/// CMP - Compare instruction.49CMP,5051/// SetCC - Operand 0 is condition code, and operand 1 is the flag52/// operand produced by a CMP instruction.53SETCC,5455/// MSP430 conditional branches. Operand 0 is the chain operand, operand 156/// is the block to branch if condition is true, operand 2 is the57/// condition code, and operand 3 is the flag operand produced by a CMP58/// instruction.59BR_CC,6061/// SELECT_CC - Operand 0 and operand 1 are selection variable, operand 362/// is condition code and operand 4 is flag operand.63SELECT_CC,6465/// DADD - Decimal addition with carry66/// TODO Nothing generates a node of this type yet.67DADD,68};69}7071class MSP430Subtarget;72class MSP430TargetLowering : public TargetLowering {73public:74explicit MSP430TargetLowering(const TargetMachine &TM,75const MSP430Subtarget &STI);7677MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {78return MVT::i8;79}8081MVT::SimpleValueType getCmpLibcallReturnType() const override {82return MVT::i16;83}8485/// LowerOperation - Provide custom lowering hooks for some operations.86SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;8788/// getTargetNodeName - This method returns the name of a target specific89/// DAG node.90const char *getTargetNodeName(unsigned Opcode) const override;9192SDValue LowerShifts(SDValue Op, SelectionDAG &DAG) const;93SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;94SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;95SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;96SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;97SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;98SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;99SDValue LowerSIGN_EXTEND(SDValue Op, SelectionDAG &DAG) const;100SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;101SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;102SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;103SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;104SDValue getReturnAddressFrameIndex(SelectionDAG &DAG) const;105106TargetLowering::ConstraintType107getConstraintType(StringRef Constraint) const override;108std::pair<unsigned, const TargetRegisterClass *>109getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,110StringRef Constraint, MVT VT) const override;111112/// isTruncateFree - Return true if it's free to truncate a value of type113/// Ty1 to type Ty2. e.g. On msp430 it's free to truncate a i16 value in114/// register R15W to i8 by referencing its sub-register R15B.115bool isTruncateFree(Type *Ty1, Type *Ty2) const override;116bool isTruncateFree(EVT VT1, EVT VT2) const override;117118/// isZExtFree - Return true if any actual instruction that defines a value119/// of type Ty1 implicit zero-extends the value to Ty2 in the result120/// register. This does not necessarily include registers defined in unknown121/// ways, such as incoming arguments, or copies from unknown virtual122/// registers. Also, if isTruncateFree(Ty2, Ty1) is true, this does not123/// necessarily apply to truncate instructions. e.g. on msp430, all124/// instructions that define 8-bit values implicit zero-extend the result125/// out to 16 bits.126bool isZExtFree(Type *Ty1, Type *Ty2) const override;127bool isZExtFree(EVT VT1, EVT VT2) const override;128129bool isLegalICmpImmediate(int64_t) const override;130bool shouldAvoidTransformToShift(EVT VT, unsigned Amount) const override;131132MachineBasicBlock *133EmitInstrWithCustomInserter(MachineInstr &MI,134MachineBasicBlock *BB) const override;135MachineBasicBlock *EmitShiftInstr(MachineInstr &MI,136MachineBasicBlock *BB) const;137138private:139SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,140CallingConv::ID CallConv, bool isVarArg,141bool isTailCall,142const SmallVectorImpl<ISD::OutputArg> &Outs,143const SmallVectorImpl<SDValue> &OutVals,144const SmallVectorImpl<ISD::InputArg> &Ins,145const SDLoc &dl, SelectionDAG &DAG,146SmallVectorImpl<SDValue> &InVals) const;147148SDValue LowerCCCArguments(SDValue Chain, CallingConv::ID CallConv,149bool isVarArg,150const SmallVectorImpl<ISD::InputArg> &Ins,151const SDLoc &dl, SelectionDAG &DAG,152SmallVectorImpl<SDValue> &InVals) const;153154SDValue LowerCallResult(SDValue Chain, SDValue InGlue,155CallingConv::ID CallConv, bool isVarArg,156const SmallVectorImpl<ISD::InputArg> &Ins,157const SDLoc &dl, SelectionDAG &DAG,158SmallVectorImpl<SDValue> &InVals) const;159160SDValue161LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,162const SmallVectorImpl<ISD::InputArg> &Ins,163const SDLoc &dl, SelectionDAG &DAG,164SmallVectorImpl<SDValue> &InVals) const override;165SDValue166LowerCall(TargetLowering::CallLoweringInfo &CLI,167SmallVectorImpl<SDValue> &InVals) const override;168169bool CanLowerReturn(CallingConv::ID CallConv,170MachineFunction &MF,171bool IsVarArg,172const SmallVectorImpl<ISD::OutputArg> &Outs,173LLVMContext &Context) const override;174175SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,176const SmallVectorImpl<ISD::OutputArg> &Outs,177const SmallVectorImpl<SDValue> &OutVals,178const SDLoc &dl, SelectionDAG &DAG) const override;179180bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,181SDValue &Base,182SDValue &Offset,183ISD::MemIndexedMode &AM,184SelectionDAG &DAG) const override;185};186} // namespace llvm187188#endif189190191