Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 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" |
David Blaikie | b3bde2e | 2017-11-17 01:07:10 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/TargetLowering.h" |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | class RISCVSubtarget; |
| 24 | namespace RISCVISD { |
| 25 | enum NodeType : unsigned { |
| 26 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
Alex Bradbury | a337675 | 2017-11-08 13:41:21 +0000 | [diff] [blame] | 27 | RET_FLAG, |
Alex Bradbury | 6538516 | 2017-11-21 07:51:32 +0000 | [diff] [blame] | 28 | CALL, |
| 29 | SELECT_CC |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 30 | }; |
| 31 | } |
| 32 | |
| 33 | class RISCVTargetLowering : public TargetLowering { |
| 34 | const RISCVSubtarget &Subtarget; |
| 35 | |
| 36 | public: |
| 37 | explicit RISCVTargetLowering(const TargetMachine &TM, |
| 38 | const RISCVSubtarget &STI); |
| 39 | |
| 40 | // Provide custom lowering hooks for some operations. |
| 41 | SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; |
| 42 | |
| 43 | // This method returns the name of a target specific DAG node. |
| 44 | const char *getTargetNodeName(unsigned Opcode) const override; |
| 45 | |
Alex Bradbury | 6538516 | 2017-11-21 07:51:32 +0000 | [diff] [blame] | 46 | MachineBasicBlock * |
| 47 | EmitInstrWithCustomInserter(MachineInstr &MI, |
| 48 | MachineBasicBlock *BB) const override; |
| 49 | |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 50 | private: |
| 51 | // Lower incoming arguments, copy physregs into vregs |
| 52 | SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, |
| 53 | bool IsVarArg, |
| 54 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 55 | const SDLoc &DL, SelectionDAG &DAG, |
| 56 | SmallVectorImpl<SDValue> &InVals) const override; |
| 57 | SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, |
| 58 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 59 | const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL, |
| 60 | SelectionDAG &DAG) const override; |
Alex Bradbury | a337675 | 2017-11-08 13:41:21 +0000 | [diff] [blame] | 61 | SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, |
| 62 | SmallVectorImpl<SDValue> &InVals) const override; |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 63 | bool shouldConvertConstantLoadToIntImm(const APInt &Imm, |
| 64 | Type *Ty) const override { |
| 65 | return true; |
| 66 | } |
Alex Bradbury | ec8aa91 | 2017-11-08 13:24:21 +0000 | [diff] [blame] | 67 | SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; |
Alex Bradbury | ffc435e | 2017-11-21 08:11:03 +0000 | [diff] [blame^] | 68 | SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; |
| 69 | SDValue lowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const; |
Alex Bradbury | 6538516 | 2017-11-21 07:51:32 +0000 | [diff] [blame] | 70 | SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const; |
Alex Bradbury | 8971842 | 2017-10-19 21:37:38 +0000 | [diff] [blame] | 71 | }; |
| 72 | } |
| 73 | |
| 74 | #endif |