1 //===-- RISCVISelLowering.h - RISCV DAG Lowering Interface ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interfaces that RISCV uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_RISCV_RISCVISELLOWERING_H
16 #define LLVM_LIB_TARGET_RISCV_RISCVISELLOWERING_H
17 
18 #include "RISCV.h"
19 #include "llvm/CodeGen/SelectionDAG.h"
20 #include "llvm/Target/TargetLowering.h"
21 
22 namespace llvm {
23 class RISCVSubtarget;
24 namespace RISCVISD {
25 enum NodeType : unsigned {
26   FIRST_NUMBER = ISD::BUILTIN_OP_END,
27   RET_FLAG,
28   CALL
29 };
30 }
31 
32 class RISCVTargetLowering : public TargetLowering {
33   const RISCVSubtarget &Subtarget;
34 
35 public:
36   explicit RISCVTargetLowering(const TargetMachine &TM,
37                                const RISCVSubtarget &STI);
38 
39   // Provide custom lowering hooks for some operations.
40   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
41 
42   // This method returns the name of a target specific DAG node.
43   const char *getTargetNodeName(unsigned Opcode) const override;
44 
45 private:
46   // Lower incoming arguments, copy physregs into vregs
47   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
48                                bool IsVarArg,
49                                const SmallVectorImpl<ISD::InputArg> &Ins,
50                                const SDLoc &DL, SelectionDAG &DAG,
51                                SmallVectorImpl<SDValue> &InVals) const override;
52   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
53                       const SmallVectorImpl<ISD::OutputArg> &Outs,
54                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
55                       SelectionDAG &DAG) const override;
56   SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
57                     SmallVectorImpl<SDValue> &InVals) const override;
58   bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
59                                          Type *Ty) const override {
60     return true;
61   }
62   SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
63 };
64 }
65 
66 #endif
67