1 //===- ARCISelLowering.h - ARC 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 ARC uses to lower LLVM code into a
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_ARC_ARCISELLOWERING_H
15 #define LLVM_LIB_TARGET_ARC_ARCISELLOWERING_H
18 #include "llvm/CodeGen/SelectionDAG.h"
19 #include "llvm/CodeGen/TargetLowering.h"
23 // Forward delcarations
25 class ARCTargetMachine
;
29 enum NodeType
: unsigned {
30 // Start the numbering where the builtin ops and target ops leave off.
31 FIRST_NUMBER
= ISD::BUILTIN_OP_END
,
33 // Branch and link (call)
36 // Jump and link (indirect call)
48 // Global Address Wrapper
51 // return, (j_s [blink])
55 } // end namespace ARCISD
57 //===--------------------------------------------------------------------===//
58 // TargetLowering Implementation
59 //===--------------------------------------------------------------------===//
60 class ARCTargetLowering
: public TargetLowering
{
62 explicit ARCTargetLowering(const TargetMachine
&TM
,
63 const ARCSubtarget
&Subtarget
);
65 /// Provide custom lowering hooks for some operations.
66 SDValue
LowerOperation(SDValue Op
, SelectionDAG
&DAG
) const override
;
68 /// This method returns the name of a target specific DAG node.
69 const char *getTargetNodeName(unsigned Opcode
) const override
;
71 /// Return true if the addressing mode represented by AM is legal for this
72 /// target, for a load/store of the specified type.
73 bool isLegalAddressingMode(const DataLayout
&DL
, const AddrMode
&AM
, Type
*Ty
,
75 Instruction
*I
= nullptr) const override
;
78 const ARCSubtarget
&Subtarget
;
80 void ReplaceNodeResults(SDNode
*N
, SmallVectorImpl
<SDValue
> &Results
,
81 SelectionDAG
&DAG
) const override
;
83 // Lower Operand helpers
84 SDValue
LowerCallArguments(SDValue Chain
, CallingConv::ID CallConv
,
86 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
87 SDLoc dl
, SelectionDAG
&DAG
,
88 SmallVectorImpl
<SDValue
> &InVals
) const;
89 // Lower Operand specifics
90 SDValue
LowerJumpTable(SDValue Op
, SelectionDAG
&DAG
) const;
91 SDValue
LowerFRAMEADDR(SDValue Op
, SelectionDAG
&DAG
) const;
92 SDValue
LowerSELECT_CC(SDValue Op
, SelectionDAG
&DAG
) const;
93 SDValue
LowerBR_CC(SDValue Op
, SelectionDAG
&DAG
) const;
94 SDValue
LowerSIGN_EXTEND_INREG(SDValue Op
, SelectionDAG
&DAG
) const;
95 SDValue
LowerGlobalAddress(SDValue Op
, SelectionDAG
&DAG
) const;
96 SDValue
PerformDAGCombine(SDNode
*N
, DAGCombinerInfo
&DCI
) const override
;
98 SDValue
LowerFormalArguments(SDValue Chain
, CallingConv::ID CallConv
,
100 const SmallVectorImpl
<ISD::InputArg
> &Ins
,
101 const SDLoc
&dl
, SelectionDAG
&DAG
,
102 SmallVectorImpl
<SDValue
> &InVals
) const override
;
104 SDValue
LowerCall(TargetLowering::CallLoweringInfo
&CLI
,
105 SmallVectorImpl
<SDValue
> &InVals
) const override
;
107 SDValue
LowerReturn(SDValue Chain
, CallingConv::ID CallConv
, bool isVarArg
,
108 const SmallVectorImpl
<ISD::OutputArg
> &Outs
,
109 const SmallVectorImpl
<SDValue
> &OutVals
, const SDLoc
&dl
,
110 SelectionDAG
&DAG
) const override
;
112 bool CanLowerReturn(CallingConv::ID CallConv
, MachineFunction
&MF
,
114 const SmallVectorImpl
<ISD::OutputArg
> &ArgsFlags
,
115 LLVMContext
&Context
) const override
;
117 bool mayBeEmittedAsTailCall(const CallInst
*CI
) const override
;
120 } // end namespace llvm
122 #endif // LLVM_LIB_TARGET_ARC_ARCISELLOWERING_H