1 //===- XtensaISelLowering.h - Xtensa DAG Lowering Interface -----*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the interfaces that Xtensa uses to lower LLVM code into a
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H
15 #define LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H
17 #include "llvm/CodeGen/CallingConvLower.h"
18 #include "llvm/CodeGen/SelectionDAG.h"
19 #include "llvm/CodeGen/TargetLowering.h"
25 FIRST_NUMBER
= ISD::BUILTIN_OP_END
,
28 // Calls a function. Operand 0 is the chain operand and operand 1
29 // is the target address. The arguments start at operand 2.
30 // There is an optional glue operand at the end.
33 // Wraps a TargetGlobalAddress that should be loaded using PC-relative
34 // accesses. Operand 0 is the address.
38 // Select with condition operator - This selects between a true value and
39 // a false value (ops #2 and #3) based on the boolean result of comparing
40 // the lhs and rhs (ops #0 and #1) of a conditional expression with the
41 // condition code in op #4
46 class XtensaSubtarget
;
48 class XtensaTargetLowering
: public TargetLowering
{
50 explicit XtensaTargetLowering(const TargetMachine
&TM
,
51 const XtensaSubtarget
&STI
);
53 EVT
getSetCCResultType(const DataLayout
&, LLVMContext
&,
54 EVT VT
) const override
{
57 return VT
.changeVectorElementTypeToInteger();
60 bool isOffsetFoldingLegal(const GlobalAddressSDNode
*GA
) const override
;
62 const char *getTargetNodeName(unsigned Opcode
) const override
;
64 SDValue
LowerOperation(SDValue Op
, SelectionDAG
&DAG
) const override
;
66 SDValue
LowerFormalArguments(SDValue Chain
, CallingConv::ID CallConv
,
68 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
69 const SDLoc
&DL
, SelectionDAG
&DAG
,
70 SmallVectorImpl
<SDValue
> &InVals
) const override
;
72 SDValue
LowerCall(CallLoweringInfo
&CLI
,
73 SmallVectorImpl
<SDValue
> &InVals
) const override
;
75 bool CanLowerReturn(CallingConv::ID CallConv
, MachineFunction
&MF
,
77 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
78 LLVMContext
&Context
) const override
;
80 SDValue
LowerReturn(SDValue Chain
, CallingConv::ID CallConv
, bool IsVarArg
,
81 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
82 const SmallVectorImpl
<SDValue
> &OutVals
, const SDLoc
&DL
,
83 SelectionDAG
&DAG
) const override
;
85 const XtensaSubtarget
&getSubtarget() const { return Subtarget
; }
88 EmitInstrWithCustomInserter(MachineInstr
&MI
,
89 MachineBasicBlock
*BB
) const override
;
92 const XtensaSubtarget
&Subtarget
;
94 SDValue
LowerBR_JT(SDValue Op
, SelectionDAG
&DAG
) const;
96 SDValue
LowerImmediate(SDValue Op
, SelectionDAG
&DAG
) const;
98 SDValue
LowerGlobalAddress(SDValue Op
, SelectionDAG
&DAG
) const;
100 SDValue
LowerBlockAddress(SDValue Op
, SelectionDAG
&DAG
) const;
102 SDValue
LowerJumpTable(SDValue Op
, SelectionDAG
&DAG
) const;
104 SDValue
LowerConstantPool(ConstantPoolSDNode
*CP
, SelectionDAG
&DAG
) const;
106 SDValue
LowerSELECT_CC(SDValue Op
, SelectionDAG
&DAG
) const;
108 SDValue
LowerDYNAMIC_STACKALLOC(SDValue Op
, SelectionDAG
&DAG
) const;
110 SDValue
LowerSTACKSAVE(SDValue Op
, SelectionDAG
&DAG
) const;
112 SDValue
LowerSTACKRESTORE(SDValue Op
, SelectionDAG
&DAG
) const;
114 SDValue
getAddrPCRel(SDValue Op
, SelectionDAG
&DAG
) const;
116 CCAssignFn
*CCAssignFnForCall(CallingConv::ID CC
, bool IsVarArg
) const;
118 MachineBasicBlock
*emitSelectCC(MachineInstr
&MI
,
119 MachineBasicBlock
*BB
) const;
122 } // end namespace llvm
124 #endif /* LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H */