1 | //===- XtensaISelLowering.h - Xtensa DAG Lowering Interface -----*- C++ -*-===// |
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file defines the interfaces that Xtensa uses to lower LLVM code into a |
10 | // selection DAG. |
11 | // |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #ifndef LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H |
15 | #define LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H |
16 | |
17 | #include "llvm/CodeGen/CallingConvLower.h" |
18 | #include "llvm/CodeGen/SelectionDAG.h" |
19 | #include "llvm/CodeGen/TargetLowering.h" |
20 | |
21 | namespace llvm { |
22 | |
23 | namespace XtensaISD { |
24 | enum { |
25 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
26 | |
27 | // Calls a function. Operand 0 is the chain operand and operand 1 |
28 | // is the target address. The arguments start at operand 2. |
29 | // There is an optional glue operand at the end. |
30 | CALL, |
31 | |
32 | // Wraps a TargetGlobalAddress that should be loaded using PC-relative |
33 | // accesses. Operand 0 is the address. |
34 | PCREL_WRAPPER, |
35 | RET |
36 | }; |
37 | } |
38 | |
39 | class XtensaSubtarget; |
40 | |
41 | class XtensaTargetLowering : public TargetLowering { |
42 | public: |
43 | explicit XtensaTargetLowering(const TargetMachine &TM, |
44 | const XtensaSubtarget &STI); |
45 | |
46 | const char *getTargetNodeName(unsigned Opcode) const override; |
47 | |
48 | SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; |
49 | |
50 | SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, |
51 | bool isVarArg, |
52 | const SmallVectorImpl<ISD::InputArg> &Ins, |
53 | const SDLoc &DL, SelectionDAG &DAG, |
54 | SmallVectorImpl<SDValue> &InVals) const override; |
55 | |
56 | SDValue LowerCall(CallLoweringInfo &CLI, |
57 | SmallVectorImpl<SDValue> &InVals) const override; |
58 | |
59 | bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, |
60 | bool isVarArg, |
61 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
62 | LLVMContext &Context) const override; |
63 | |
64 | SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, |
65 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
66 | const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL, |
67 | SelectionDAG &DAG) const override; |
68 | |
69 | const XtensaSubtarget &getSubtarget() const { return Subtarget; } |
70 | |
71 | private: |
72 | const XtensaSubtarget &Subtarget; |
73 | |
74 | SDValue LowerImmediate(SDValue Op, SelectionDAG &DAG) const; |
75 | |
76 | SDValue LowerConstantPool(ConstantPoolSDNode *CP, SelectionDAG &DAG) const; |
77 | |
78 | SDValue getAddrPCRel(SDValue Op, SelectionDAG &DAG) const; |
79 | |
80 | CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const; |
81 | }; |
82 | |
83 | } // end namespace llvm |
84 | |
85 | #endif /* LLVM_LIB_TARGET_XTENSA_XTENSAISELLOWERING_H */ |
86 | |