xref: /freebsd/contrib/llvm-project/llvm/lib/Target/CSKY/CSKYISelLowering.h (revision 5e801ac66d24704442eba426ed13c3effb8a34e7)
1 //===-- CSKYISelLowering.cpp - CSKY DAG Lowering Implementation  ----------===//
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 CSKY uses to lower LLVM code into a
10 // selection DAG.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_CSKY_CSKYISELLOWERING_H
15 #define LLVM_LIB_TARGET_CSKY_CSKYISELLOWERING_H
16 
17 #include "MCTargetDesc/CSKYBaseInfo.h"
18 #include "llvm/CodeGen/CallingConvLower.h"
19 #include "llvm/CodeGen/TargetLowering.h"
20 
21 namespace llvm {
22 class CSKYSubtarget;
23 
24 namespace CSKYISD {
25 enum NodeType : unsigned {
26   FIRST_NUMBER = ISD::BUILTIN_OP_END,
27   NIE,
28   NIR,
29   RET,
30   BITCAST_TO_LOHI
31 };
32 }
33 
34 class CSKYTargetLowering : public TargetLowering {
35   const CSKYSubtarget &Subtarget;
36 
37 public:
38   explicit CSKYTargetLowering(const TargetMachine &TM,
39                               const CSKYSubtarget &STI);
40 
41   EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
42                          EVT VT) const override;
43 
44 private:
45   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
46                                bool IsVarArg,
47                                const SmallVectorImpl<ISD::InputArg> &Ins,
48                                const SDLoc &DL, SelectionDAG &DAG,
49                                SmallVectorImpl<SDValue> &InVals) const override;
50 
51   bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
52                       bool IsVarArg,
53                       const SmallVectorImpl<ISD::OutputArg> &Outs,
54                       LLVMContext &Context) const override;
55 
56   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
57                       const SmallVectorImpl<ISD::OutputArg> &Outs,
58                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
59                       SelectionDAG &DAG) const override;
60 
61   const char *getTargetNodeName(unsigned Opcode) const override;
62 
63   CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const;
64   CCAssignFn *CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg) const;
65 };
66 
67 } // namespace llvm
68 
69 #endif // LLVM_LIB_TARGET_CSKY_CSKYISELLOWERING_H
70