LLVM 24.0.0git
XCoreISelLowering.h
Go to the documentation of this file.
1//===-- XCoreISelLowering.h - XCore DAG Lowering Interface ------*- C++ -*-===//
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 XCore uses to lower LLVM code into a
10// selection DAG.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_XCORE_XCOREISELLOWERING_H
15#define LLVM_LIB_TARGET_XCORE_XCOREISELLOWERING_H
16
17#include "XCore.h"
20
21namespace llvm {
22
23 // Forward delcarations
24 class XCoreSubtarget;
25
26 //===--------------------------------------------------------------------===//
27 // TargetLowering Implementation
28 //===--------------------------------------------------------------------===//
30 {
31 public:
32 explicit XCoreTargetLowering(const TargetMachine &TM,
33 const XCoreSubtarget &Subtarget);
34
36 bool isZExtFree(SDValue Val, EVT VT2) const override;
37
38
39 unsigned getJumpTableEncoding() const override;
40 MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override {
41 return MVT::i32;
42 }
43
44 /// LowerOperation - Provide custom lowering hooks for some operations.
45 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
46
47 /// ReplaceNodeResults - Replace the results of node with an illegal result
48 /// type with new values built out of custom code.
49 ///
51 SelectionDAG &DAG) const override;
52
55 MachineBasicBlock *MBB) const override;
56
57 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
58 Type *Ty, unsigned AS,
59 Instruction *I = nullptr) const override;
60
61 /// If a physical register, this returns the register that receives the
62 /// exception address on entry to an EH pad.
65 const Constant *PersonalityFn) const override {
66 return XCore::R0;
67 }
68
69 /// If a physical register, this returns the register that receives the
70 /// exception typeid on entry to a landing pad.
73 const Constant *PersonalityFn) const override {
74 return XCore::R1;
75 }
76
77 private:
79
80 // Lower Operand helpers
81 SDValue LowerCCCArguments(SDValue Chain, CallingConv::ID CallConv,
82 bool isVarArg,
84 const SDLoc &dl, SelectionDAG &DAG,
85 SmallVectorImpl<SDValue> &InVals) const;
86 SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
87 CallingConv::ID CallConv, bool isVarArg,
88 bool isTailCall,
90 const SmallVectorImpl<SDValue> &OutVals,
92 const SDLoc &dl, SelectionDAG &DAG,
93 SmallVectorImpl<SDValue> &InVals) const;
94 SDValue getGlobalAddressWrapper(SDValue GA, const GlobalValue *GV,
95 SelectionDAG &DAG) const;
96 SDValue lowerLoadWordFromAlignedBasePlusOffset(const SDLoc &DL,
97 SDValue Chain, SDValue Base,
98 int64_t Offset,
99 SelectionDAG &DAG) const;
100
101 // Lower Operand specifics
104 SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
105 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
106 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
107 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
108 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
111 SDValue LowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
112 SDValue LowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
114 SDValue LowerFRAME_TO_ARGS_OFFSET(SDValue Op, SelectionDAG &DAG) const;
116 SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
118 SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
120
121 // Inline asm support
122 std::pair<unsigned, const TargetRegisterClass *>
123 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
124 StringRef Constraint, MVT VT) const override;
125
126 // Expand specifics
127 SDValue TryExpandADDWithMul(SDNode *Op, SelectionDAG &DAG) const;
128 SDValue ExpandADDSUB(SDNode *Op, SelectionDAG &DAG) const;
129
130 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
131
132 void computeKnownBitsForTargetNode(const SDValue Op,
134 const APInt &DemandedElts,
135 const SelectionDAG &DAG,
136 unsigned Depth = 0) const override;
137
138 SDValue
139 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
141 const SDLoc &dl, SelectionDAG &DAG,
142 SmallVectorImpl<SDValue> &InVals) const override;
143
144 SDValue
146 SmallVectorImpl<SDValue> &InVals) const override;
147
148 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
150 const SmallVectorImpl<SDValue> &OutVals,
151 const SDLoc &dl, SelectionDAG &DAG) const override;
152
153 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
154 bool isVarArg,
155 const SmallVectorImpl<ISD::OutputArg> &ArgsFlags,
156 LLVMContext &Context, const Type *RetTy) const override;
157 };
158}
159
160#endif
const AArch64Subtarget & Subtarget
static SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG)
static SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG, const ARMSubtarget *Subtarget)
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
static SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG)
static SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
static SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG)
static SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, const SparcSubtarget *Subtarget)
static SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG)
This file describes how to lower LLVM code to machine code.
static SDValue LowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG)
Class for arbitrary precision integers.
Definition APInt.h:78
This is an important base class in LLVM.
Definition Constant.h:44
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
Machine Value Type.
Representation of each machine instruction.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
TargetLowering(const TargetLowering &)=delete
Primary interface to the complete machine description for the target machine.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override
Return the type to use for a scalar shift opcode, given the shifted amount type.
bool isZExtFree(SDValue Val, EVT VT2) const override
Return true if zero-extending the specific node Val to type VT2 is free (either because it's implicit...
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
isLegalAddressingMode - Return true if the addressing mode represented by AM is legal for this target...
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
LowerOperation - Provide custom lowering hooks for some operations.
Register getExceptionPointerRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
ReplaceNodeResults - Replace the results of node with an illegal result type with new values built ou...
Register getExceptionSelectorRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
unsigned getJumpTableEncoding() const override
Return the entry encoding for a jump table in the current function.
XCoreTargetLowering(const TargetMachine &TM, const XCoreSubtarget &Subtarget)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
@ Known
Known to have no common set bits.
DWARFExpression::Operation Op
ExceptionHandling
Definition CodeGen.h:54
#define N
Extended Value Type.
Definition ValueTypes.h:35
This structure contains all information that is necessary for lowering calls.