1//===- FunctionLoweringInfo.h - Lower functions from LLVM IR ---*- C++ -*--===//
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
7//===----------------------------------------------------------------------===//
9// This implements routines for translating functions from LLVM IR into
12//===----------------------------------------------------------------------===//
14#ifndef LLVM_CODEGEN_FUNCTIONLOWERINGINFO_H
15#define LLVM_CODEGEN_FUNCTIONLOWERINGINFO_H
52//===--------------------------------------------------------------------===//
53/// FunctionLoweringInfo - This contains information that is global to a
54/// function that is used when lowering a region of the function.
64 /// CanLowerReturn - true iff the function's return value can be lowered to
68 /// True if part of the CSRs will be handled via explicit copies.
71 /// DemoteRegister - if CanLowerReturn is false, DemoteRegister is a vreg
72 /// allocated to hold a pointer to the hidden sret parameter.
75 /// A mapping from LLVM basic block number to their machine block.
78 /// ValueMap - Since we emit code for the function a basic block at a time,
79 /// we must remember which virtual registers hold the values for
80 /// cross-basic-block values.
83 /// VirtReg2Value map is needed by the Divergence Analysis driven
84 /// instruction selection. It is reverted ValueMap. It is computed
85 /// in lazy style - on demand. It is used to get the Value corresponding
86 /// to the live in virtual register and is called from the
87 /// TargetLowerinInfo::isSDNodeSourceOfDivergence.
90 /// This method is called from TargetLowerinInfo::isSDNodeSourceOfDivergence
91 /// to get the Value corresponding to the live-in virtual register.
94 /// Track virtual registers created for exception pointers.
97 /// Helper object to track which of three possible relocation mechanisms are
98 /// used for a particular value being relocated over a statepoint.
101 // Value did not need to be relocated and can be used directly.
103 // Value was spilled to stack and needs filled at the gc.relocate.
105 // Value was lowered to tied def and gc.relocate should be replaced with
108 // Value was lowered to tied def and gc.relocate should be replaced with
109 // SDValue kept in StatepointLoweringInfo structure. This valid for local
113 // Payload contains either frame index of the stack slot in which the value
114 // was spilled, or virtual register which contains the re-definition.
122 /// Keep track of each value which was relocated and the strategy used to
123 /// relocate that value. This information is required when visiting
124 /// gc.relocates which may appear in following blocks.
129 /// StaticAllocaMap - Keep track of frame indices for fixed sized allocas in
130 /// the entry block. This allows the allocas to be efficiently referenced
131 /// anywhere in the function.
134 /// ByValArgFrameIndexMap - Keep track of frame indices for byval arguments.
137 /// ArgDbgValues - A list of DBG_VALUE instructions created during isel for
138 /// function arguments that are inserted after scheduling is completed.
141 /// Bitvector with a bit set if corresponding argument is described in
142 /// ArgDbgValues. Using arg numbers according to Argument numbering.
145 /// RegFixups - Registers which need to be replaced after isel is done.
150 /// StatepointStackSlots - A list of temporary stack slots (frame indices)
151 /// used to spill values at a statepoint. We store them here to enable
152 /// reuse of the same stack slots across different statepoints in different
156 /// MBB - The current block.
159 /// MBB - The current insert position inside the current block.
170 /// Record the preferred extend type (ISD::SIGN_EXTEND or ISD::ZERO_EXTEND)
174 /// The set of basic blocks visited thus far by instruction selection. Indexed
175 /// by basic block number.
178 /// PHINodesToUpdate - A list of phi instructions whose operand list will
179 /// be updated after processing the current basic block.
180 /// TODO: This isn't per-function state, it's per-basic-block state. But
181 /// there's no other convenient place for it to live right now.
185 /// If the current MBB is a landing pad, the exception pointer and exception
186 /// selector registers are copied into these virtual registers by
187 /// SelectionDAGISel::PrepareEHLandingPad().
190 /// The current call site index being processed, if any. 0 if none.
193 /// Collection of dbg_declare instructions handled after argument
194 /// lowering and before ISel proper.
197 /// set - Initialize this FunctionLoweringInfo with the given Function
198 /// and its associated MachineFunction.
202 /// clear - Clear out all the function-specific state. This returns this
203 /// FunctionLoweringInfo to an empty state, ready to be used for a
204 /// different function.
207 /// isExportedInst - Return true if the specified value is an instruction
208 /// exported from its block.
226 /// GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the
227 /// register is a PHI destination and the PHI's LiveOutInfo is not valid.
229 if (!LiveOutRegInfo.inBounds(
Reg))
239 /// GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the
240 /// register is a PHI destination and the PHI's LiveOutInfo is not valid. If
241 /// the register's LiveOutInfo is for a smaller bit width, it is extended to
242 /// the larger bit width by zero extension. The bit width must be no smaller
243 /// than the LiveOutInfo's existing bit width.
246 /// AddLiveOutRegInfo - Adds LiveOutInfo for a register.
249 // Only install this information if it tells us something.
250 if (NumSignBits == 1 && Known.
isUnknown())
253 LiveOutRegInfo.grow(
Reg);
260 /// ComputePHILiveOutRegInfo - Compute LiveOutInfo for a PHI's destination
261 /// register based on the LiveOutInfo of its operands.
264 /// InvalidatePHILiveOutRegInfo - Invalidates a PHI's LiveOutInfo, to be
265 /// called when a block is visited before all of its predecessors.
267 // PHIs with no uses have no ValueMap entry.
276 LiveOutRegInfo.grow(
Reg);
277 LiveOutRegInfo[
Reg].IsValid =
false;
280 /// setArgumentFrameIndex - Record frame index for the byval
284 /// getArgumentFrameIndex - Get frame index for the byval argument.
290 /// Set the call site currently being processed.
293 /// Get the call site currently being processed, if any. Return zero if none.
297 /// LiveOutRegInfo - Information about live out vregs.
301}
// end namespace llvm
303#endif // LLVM_CODEGEN_FUNCTIONLOWERINGINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file defines the DenseMap class.
This file implements an indexed map.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This class represents an incoming formal argument to a Function.
LLVM Basic Block Representation.
unsigned getNumber() const
Analysis providing branch probability information.
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
Implements a dense probed hash-table based set.
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
BranchProbabilityInfo * BPI
Register CreateRegs(const Value *V)
DenseMap< const Value *, StatepointRelocationRecord > StatepointSpillMapTy
Keep track of each value which was relocated and the strategy used to relocate that value.
SmallPtrSet< const DbgVariableRecord *, 8 > PreprocessedDVRDeclares
Collection of dbg_declare instructions handled after argument lowering and before ISel proper.
void clear()
clear - Clear out all the function-specific state.
MachineBasicBlock * getMBB(const BasicBlock *BB) const
DenseSet< Register > RegsWithFixups
Register DemoteRegister
DemoteRegister - if CanLowerReturn is false, DemoteRegister is a vreg allocated to hold a pointer to ...
void setArgumentFrameIndex(const Argument *A, int FI)
setArgumentFrameIndex - Record frame index for the byval argument.
unsigned OrigNumPHINodesToUpdate
SmallVector< bool > VisitedBBs
The set of basic blocks visited thus far by instruction selection.
void InvalidatePHILiveOutRegInfo(const PHINode *PN)
InvalidatePHILiveOutRegInfo - Invalidates a PHI's LiveOutInfo, to be called when a block is visited b...
BitVector DescribedArgs
Bitvector with a bit set if corresponding argument is described in ArgDbgValues.
DenseMap< const AllocaInst *, int > StaticAllocaMap
StaticAllocaMap - Keep track of frame indices for fixed sized allocas in the entry block.
const UniformityInfo * UA
DenseMap< const Instruction *, StatepointSpillMapTy > StatepointRelocationMaps
unsigned CurCallSite
The current call site index being processed, if any. 0 if none.
int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
Register ExceptionSelectorVirtReg
bool isExportedInst(const Value *V) const
isExportedInst - Return true if the specified value is an instruction exported from its block.
void AddLiveOutRegInfo(Register Reg, unsigned NumSignBits, const KnownBits &Known)
AddLiveOutRegInfo - Adds LiveOutInfo for a register.
const LiveOutInfo * GetLiveOutRegInfo(Register Reg)
GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the register is a PHI destinat...
Register InitializeRegForValue(const Value *V)
bool SplitCSR
True if part of the CSRs will be handled via explicit copies.
DenseMap< const Value *, Register > ValueMap
ValueMap - Since we emit code for the function a basic block at a time, we must remember which virtua...
Register ExceptionPointerVirtReg
If the current MBB is a landing pad, the exception pointer and exception selector registers are copie...
MachineBasicBlock::iterator InsertPt
MBB - The current insert position inside the current block.
SmallVector< unsigned, 50 > StatepointStackSlots
StatepointStackSlots - A list of temporary stack slots (frame indices) used to spill values at a stat...
void set(const Function &Fn, MachineFunction &MF, SelectionDAG *DAG)
set - Initialize this FunctionLoweringInfo with the given Function and its associated MachineFunction...
MachineBasicBlock * MBB
MBB - The current block.
DenseMap< const Argument *, int > ByValArgFrameIndexMap
ByValArgFrameIndexMap - Keep track of frame indices for byval arguments.
DenseMap< Register, Register > RegFixups
RegFixups - Registers which need to be replaced after isel is done.
SmallVector< MachineInstr *, 8 > ArgDbgValues
ArgDbgValues - A list of DBG_VALUE instructions created during isel for function arguments that are i...
std::vector< std::pair< MachineInstr *, Register > > PHINodesToUpdate
PHINodesToUpdate - A list of phi instructions whose operand list will be updated after processing the...
unsigned getCurrentCallSite()
Get the call site currently being processed, if any. Return zero if none.
void ComputePHILiveOutRegInfo(const PHINode *)
ComputePHILiveOutRegInfo - Compute LiveOutInfo for a PHI's destination register based on the LiveOutI...
SmallVector< MachineBasicBlock * > MBBMap
A mapping from LLVM basic block number to their machine block.
const TargetLowering * TLI
const Value * getValueFromVirtualReg(Register Vreg)
This method is called from TargetLowerinInfo::isSDNodeSourceOfDivergence to get the Value correspondi...
void setCurrentCallSite(unsigned Site)
Set the call site currently being processed.
DenseMap< Register, const Value * > VirtReg2Value
VirtReg2Value map is needed by the Divergence Analysis driven instruction selection.
MachineRegisterInfo * RegInfo
Register CreateReg(MVT VT, bool isDivergent=false)
CreateReg - Allocate a single virtual register for the given type.
bool CanLowerReturn
CanLowerReturn - true iff the function's return value can be lowered to registers.
DenseMap< const Value *, ISD::NodeType > PreferredExtendType
Record the preferred extend type (ISD::SIGN_EXTEND or ISD::ZERO_EXTEND) for a value.
Register getCatchPadExceptionPointerVReg(const Value *CPI, const TargetRegisterClass *RC)
DenseMap< const Value *, Register > CatchPadExceptionPointers
Track virtual registers created for exception pointers.
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
GenericUniformityInfo< SSAContext > UniformityInfo
GenericSSAContext< Function > SSAContext
constexpr unsigned BitWidth
Helper object to track which of three possible relocation mechanisms are used for a particular value ...
union llvm::FunctionLoweringInfo::StatepointRelocationRecord::payload_t payload
enum llvm::FunctionLoweringInfo::StatepointRelocationRecord::RelocType type
bool isUnknown() const
Returns true if we don't know any bits.