2017-10-20 05:37:38 +08:00
|
|
|
//===-- RISCVISelLowering.h - RISCV DAG Lowering Interface ------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interfaces that RISCV uses to lower LLVM code into a
|
|
|
|
// selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_RISCV_RISCVISELLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_RISCV_RISCVISELLOWERING_H
|
|
|
|
|
|
|
|
#include "RISCV.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
2017-10-20 05:37:38 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class RISCVSubtarget;
|
|
|
|
namespace RISCVISD {
|
|
|
|
enum NodeType : unsigned {
|
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
2017-11-08 21:41:21 +08:00
|
|
|
RET_FLAG,
|
2017-11-21 15:51:32 +08:00
|
|
|
CALL,
|
2018-04-12 13:34:25 +08:00
|
|
|
SELECT_CC,
|
|
|
|
BuildPairF64,
|
|
|
|
SplitF64
|
2017-10-20 05:37:38 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
class RISCVTargetLowering : public TargetLowering {
|
|
|
|
const RISCVSubtarget &Subtarget;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit RISCVTargetLowering(const TargetMachine &TM,
|
|
|
|
const RISCVSubtarget &STI);
|
|
|
|
|
2018-04-26 20:13:48 +08:00
|
|
|
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
|
|
|
|
unsigned AS,
|
|
|
|
Instruction *I = nullptr) const override;
|
2018-04-26 21:15:17 +08:00
|
|
|
bool isLegalICmpImmediate(int64_t Imm) const override;
|
2018-04-26 21:00:37 +08:00
|
|
|
bool isLegalAddImmediate(int64_t Imm) const override;
|
2018-04-26 21:37:00 +08:00
|
|
|
bool isTruncateFree(Type *SrcTy, Type *DstTy) const override;
|
|
|
|
bool isTruncateFree(EVT SrcVT, EVT DstVT) const override;
|
2018-04-26 20:13:48 +08:00
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
// Provide custom lowering hooks for some operations.
|
|
|
|
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
|
|
|
|
|
|
|
// This method returns the name of a target specific DAG node.
|
|
|
|
const char *getTargetNodeName(unsigned Opcode) const override;
|
2018-01-11 04:05:09 +08:00
|
|
|
|
|
|
|
std::pair<unsigned, const TargetRegisterClass *>
|
|
|
|
getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
|
|
|
|
StringRef Constraint, MVT VT) const override;
|
2017-10-20 05:37:38 +08:00
|
|
|
|
2017-11-21 15:51:32 +08:00
|
|
|
MachineBasicBlock *
|
|
|
|
EmitInstrWithCustomInserter(MachineInstr &MI,
|
|
|
|
MachineBasicBlock *BB) const override;
|
2018-02-02 10:43:18 +08:00
|
|
|
|
|
|
|
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
|
|
|
|
EVT VT) const override;
|
2017-11-21 15:51:32 +08:00
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
private:
|
2017-12-11 20:49:02 +08:00
|
|
|
void analyzeInputArgs(MachineFunction &MF, CCState &CCInfo,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
bool IsRet) const;
|
|
|
|
void analyzeOutputArgs(MachineFunction &MF, CCState &CCInfo,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
2018-01-11 03:41:03 +08:00
|
|
|
bool IsRet, CallLoweringInfo *CLI) const;
|
2017-10-20 05:37:38 +08:00
|
|
|
// Lower incoming arguments, copy physregs into vregs
|
|
|
|
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
|
|
|
|
bool IsVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
const SDLoc &DL, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
2017-12-11 20:49:02 +08:00
|
|
|
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
|
|
|
|
bool IsVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
LLVMContext &Context) const override;
|
2017-10-20 05:37:38 +08:00
|
|
|
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
|
|
|
|
SelectionDAG &DAG) const override;
|
2017-11-08 21:41:21 +08:00
|
|
|
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
2017-10-20 05:37:38 +08:00
|
|
|
bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
|
|
|
|
Type *Ty) const override {
|
|
|
|
return true;
|
|
|
|
}
|
2017-11-08 21:24:21 +08:00
|
|
|
SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
|
2018-03-20 21:26:12 +08:00
|
|
|
SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
SDValue lowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
|
2017-11-21 15:51:32 +08:00
|
|
|
SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const;
|
2018-01-11 03:41:03 +08:00
|
|
|
SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
|
2018-01-11 04:12:00 +08:00
|
|
|
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
|
2017-10-20 05:37:38 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|