LLVM  7.0.0
RISCVISelLowering.h
Go to the documentation of this file.
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"
21 
22 namespace llvm {
23 class RISCVSubtarget;
24 namespace RISCVISD {
25 enum NodeType : unsigned {
36 };
37 }
38 
40  const RISCVSubtarget &Subtarget;
41 
42 public:
43  explicit RISCVTargetLowering(const TargetMachine &TM,
44  const RISCVSubtarget &STI);
45 
46  bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
47  unsigned AS,
48  Instruction *I = nullptr) const override;
49  bool isLegalICmpImmediate(int64_t Imm) const override;
50  bool isLegalAddImmediate(int64_t Imm) const override;
51  bool isTruncateFree(Type *SrcTy, Type *DstTy) const override;
52  bool isTruncateFree(EVT SrcVT, EVT DstVT) const override;
53  bool isZExtFree(SDValue Val, EVT VT2) const override;
54 
55  // Provide custom lowering hooks for some operations.
56  SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
57 
58  // This method returns the name of a target specific DAG node.
59  const char *getTargetNodeName(unsigned Opcode) const override;
60 
61  std::pair<unsigned, const TargetRegisterClass *>
62  getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
63  StringRef Constraint, MVT VT) const override;
64 
66  EmitInstrWithCustomInserter(MachineInstr &MI,
67  MachineBasicBlock *BB) const override;
68 
69  EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
70  EVT VT) const override;
71 
72  bool shouldInsertFencesForAtomic(const Instruction *I) const override {
73  return isa<LoadInst>(I) || isa<StoreInst>(I);
74  }
75  Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst,
76  AtomicOrdering Ord) const override;
77  Instruction *emitTrailingFence(IRBuilder<> &Builder, Instruction *Inst,
78  AtomicOrdering Ord) const override;
79 
80 private:
81  void analyzeInputArgs(MachineFunction &MF, CCState &CCInfo,
83  bool IsRet) const;
84  void analyzeOutputArgs(MachineFunction &MF, CCState &CCInfo,
86  bool IsRet, CallLoweringInfo *CLI) const;
87  // Lower incoming arguments, copy physregs into vregs
88  SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
89  bool IsVarArg,
91  const SDLoc &DL, SelectionDAG &DAG,
92  SmallVectorImpl<SDValue> &InVals) const override;
93  bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
94  bool IsVarArg,
96  LLVMContext &Context) const override;
97  SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
99  const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
100  SelectionDAG &DAG) const override;
102  SmallVectorImpl<SDValue> &InVals) const override;
103  bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
104  Type *Ty) const override {
105  return true;
106  }
107  SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
108  SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
109  SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
110  SDValue lowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
111  SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const;
112  SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
113  SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
115 
116  bool IsEligibleForTailCallOptimization(CCState &CCInfo,
118  const SmallVector<CCValAssign, 16> &ArgLocs) const;
119 };
120 }
121 
122 #endif
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:831
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
LLVMContext & Context
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
unsigned const TargetRegisterInfo * TRI
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:731
static SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, const SparcSubtarget *Subtarget)
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
AtomicOrdering
Atomic ordering for LLVM&#39;s memory model.
bool shouldInsertFencesForAtomic(const Instruction *I) const override
Whether AtomicExpandPass should automatically insert fences and reduce ordering for this atomic...
Machine Value Type.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:69
static SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
Extended Value Type.
Definition: ValueTypes.h:34
const AMDGPUAS & AS
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This structure contains all information that is necessary for lowering calls.
CCState - This class holds information needed while lowering arguments and return values...
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:222
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Class for arbitrary precision integers.
Definition: APInt.h:69
Representation of each machine instruction.
Definition: MachineInstr.h:60
#define I(x, y, z)
Definition: MD5.cpp:58
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:59
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
This file describes how to lower LLVM code to machine code.