15 #ifndef LLVM_CODEGEN_FASTISEL_H 16 #define LLVM_CODEGEN_FASTISEL_H 43 class FunctionLoweringInfo;
45 class MachineConstantPool;
46 class MachineFrameInfo;
47 class MachineFunction;
49 class MachineMemOperand;
51 class MachineRegisterInfo;
55 class TargetInstrInfo;
56 class TargetLibraryInfo;
58 class TargetRegisterClass;
59 class TargetRegisterInfo;
119 Args = std::move(ArgsList);
130 unsigned FixedArgs = ~0U) {
143 Args = std::move(ArgsList);
144 NumFixedArgs = (FixedArgs == ~0U) ? FuncTy->
getNumParams() : FixedArgs;
153 unsigned FixedArgs = ~0U) {
157 Args = std::move(ArgsList);
158 NumFixedArgs = (FixedArgs == ~0U) ? Args.size() : FixedArgs;
165 unsigned FixedArgs = ~0U);
169 unsigned FixedArgs = ~0U) {
173 Args = std::move(ArgsList);
174 NumFixedArgs = (FixedArgs == ~0U) ? Args.size() : FixedArgs;
333 bool SkipTargetIndependentISel =
false);
359 virtual unsigned fastEmit_r(
MVT VT,
MVT RetVT,
unsigned Opcode,
unsigned Op0,
365 bool Op0IsKill,
unsigned Op1,
bool Op1IsKill);
371 bool Op0IsKill, uint64_t Imm);
378 unsigned fastEmit_ri_(
MVT VT,
unsigned Opcode,
unsigned Op0,
bool Op0IsKill,
379 uint64_t Imm,
MVT ImmType);
383 virtual unsigned fastEmit_i(
MVT VT,
MVT RetVT,
unsigned Opcode, uint64_t Imm);
406 bool Op0IsKill,
unsigned Op1,
bool Op1IsKill);
412 bool Op0IsKill,
unsigned Op1,
bool Op1IsKill,
413 unsigned Op2,
bool Op2IsKill);
419 bool Op0IsKill, uint64_t Imm);
425 bool Op0IsKill, uint64_t Imm1, uint64_t Imm2);
437 bool Op0IsKill,
unsigned Op1,
bool Op1IsKill,
552 bool handlePHINodesInSuccessorBlocks(
const BasicBlock *LLVMBB);
556 unsigned materializeConstant(
const Value *V,
MVT VT);
561 unsigned materializeRegForValue(
const Value *V,
MVT VT);
566 void flushLocalValueMap();
569 void removeDeadLocalValueCode(
MachineInstr *SavedLastLocalValue);
571 struct InstOrderMap {
582 void sinkLocalValueMaterialization(
MachineInstr &LocalMI,
unsigned DefReg,
583 InstOrderMap &OrderMap);
591 const CallInst *CI,
unsigned StartIdx);
592 bool lowerCallOperands(
const CallInst *CI,
unsigned ArgIdx,
unsigned NumArgs,
599 #endif // LLVM_CODEGEN_FASTISEL_H
unsigned fastEmitInst_rrr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill, unsigned Op2, bool Op2IsKill)
Emit a MachineInstr with three register operands and a result register in the given register class...
A parsed version of the target data layout string in and methods for querying it. ...
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
This class is the base class for the comparison instructions.
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
unsigned fastEmitZExtFromI1(MVT VT, unsigned Op0, bool Op0IsKill)
Emit MachineInstrs to compute the value of Op with all but the least significant bit set to zero...
C - The default llvm calling convention, compatible with C.
MachineConstantPool & MCP
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
bool lowerCall(const CallInst *I)
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
This class represents lattice values for constants.
virtual unsigned fastMaterializeConstant(const Constant *C)
Emit a constant in a register using target-specific logic, such as constant pool loads.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool selectXRayTypedEvent(const CallInst *II)
bool selectGetElementPtr(const User *I)
void leaveLocalValueArea(SavePoint Old)
Reset InsertPt to the given old insert position.
Describe properties that are true of each instruction in the target description file.
bool selectStackmap(const CallInst *I)
This class represents a function call, abstracting a target machine's calling convention.
virtual bool tryToFoldLoadIntoMI(MachineInstr *, unsigned, const LoadInst *)
The specified machine instr operand is a vreg, and that vreg is being provided by the specified load ...
MachineMemOperand * createMachineMemOperandFor(const Instruction *I) const
Create a machine mem operand from the given instruction.
virtual unsigned fastEmit_(MVT VT, MVT RetVT, unsigned Opcode)
This method is called by target-independent code to request that an instruction with the given type a...
SmallVector< unsigned, 4 > InRegs
block Block Frequency true
An instruction for reading from memory.
virtual unsigned fastEmit_i(MVT VT, MVT RetVT, unsigned Opcode, uint64_t Imm)
This method is called by target-independent code to request that an instruction with the given type...
virtual unsigned fastMaterializeFloatZero(const ConstantFP *CF)
Emit the floating-point constant +0.0 in a register using target- specific logic. ...
virtual bool fastLowerCall(CallLoweringInfo &CLI)
This method is called by target-independent code to do target- specific call lowering.
bool selectInstruction(const Instruction *I)
Do "fast" instruction selection for the given LLVM IR instruction and append the generated machine in...
unsigned fastEmitInst_rii(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, uint64_t Imm1, uint64_t Imm2)
Emit a MachineInstr with one register operand and two immediate operands.
DenseMap< const Value *, unsigned > LocalValueMap
unsigned fastEmitInst_ri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, uint64_t Imm)
Emit a MachineInstr with a register operand, an immediate, and a result register in the given registe...
void setLastLocalValue(MachineInstr *I)
Update the position of the last instruction emitted for materializing constants for use in the curren...
unsigned fastEmitInst_rri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill, uint64_t Imm)
Emit a MachineInstr with two register operands, an immediate, and a result register in the given regi...
CmpInst::Predicate optimizeCmpPredicate(const CmpInst *CI) const
A description of a memory reference used in the backend.
bool doesNotReturn() const
Determine if the call cannot return.
CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultTy, const Value *Target, ArgListTy &&ArgsList, unsigned FixedArgs=~0U)
TargetLoweringBase::ArgListTy ArgListTy
bool canFoldAddIntoGEP(const User *GEP, const Value *Add)
Check if Add is an add that can be safely folded into GEP.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
unsigned fastEmitInst_r(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill)
Emit a MachineInstr with one register operand and a result register in the given register class...
MachineInstr * EmitStartPt
The top most instruction in the current block that is allowed for emitting local variables.
This file contains the simple types necessary to represent the attributes associated with functions a...
InstrTy * getInstruction() const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
MachineBasicBlock::iterator LastFlushPoint
Last local value flush point.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool selectIntrinsicCall(const IntrinsicInst *II)
bool selectCast(const User *I, unsigned Opcode)
Context object for machine code objects.
ValTy * getCalledValue() const
Return the pointer to function that is being called.
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Class to represent function types.
SmallVector< ISD::InputArg, 4 > Ins
unsigned constrainOperandRegClass(const MCInstrDesc &II, unsigned Op, unsigned OpNum)
Try to constrain Op so that it is usable by argument OpNum of the provided MCInstrDesc.
bool selectOperator(const User *I, unsigned Opcode)
Do "fast" instruction selection for the given LLVM IR operator (Instruction or ConstantExpr), and append generated machine instructions to the current block.
DebugLoc getCurDebugLoc() const
Return current debug location information.
bool selectExtractValue(const User *U)
unsigned getRegForValue(const Value *V)
Create a virtual register and arrange for it to be assigned the value for the given LLVM value...
unsigned fastEmitInst_(unsigned MachineInstOpcode, const TargetRegisterClass *RC)
Emit a MachineInstr with no operands and a result register in the given register class.
bool hasTrivialKill(const Value *V)
Test whether the given value has exactly one use.
MachineInstr * getLastLocalValue()
Return the position of the last instruction emitted for materializing constants for use in the curren...
unsigned lookUpRegForValue(const Value *V)
Look up the value to see if its value is already cached in a register.
void finishBasicBlock()
Flush the local value map and sink local values if possible.
TargetInstrInfo - Interface to description of machine instruction set.
bool selectInsertValue(const User *I)
CallLoweringInfo & setCallee(Type *ResultTy, FunctionType *FuncTy, const Value *Target, ArgListTy &&ArgsList, ImmutableCallSite &Call)
LLVM Basic Block Representation.
CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultTy, MCSymbol *Target, ArgListTy &&ArgsList, unsigned FixedArgs=~0U)
The instances of the Type class are immutable: once they are created, they are never changed...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
void removeDeadCode(MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)
Remove all dead instructions between the I and E.
SmallVector< ISD::ArgFlagsTy, 16 > OutFlags
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
ConstantFP - Floating Point Values [float, double].
virtual unsigned fastEmit_r(MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill)
This method is called by target-independent code to request that an instruction with the given type...
bool SkipTargetIndependentISel
bool tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst)
We're checking to see if we can fold LI into FoldInst.
bool lowerArguments()
Do "fast" instruction selection for function arguments and append the machine instructions to the cur...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
std::pair< unsigned, bool > getRegForGEPIndex(const Value *Idx)
This is a wrapper around getRegForValue that also takes care of truncating or sign-extending the give...
bool selectXRayCustomEvent(const CallInst *II)
const TargetRegisterInfo & TRI
std::vector< ArgListEntry > ArgListTy
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool selectFNeg(const User *I)
Emit an FNeg operation.
CallLoweringInfo & setTailCall(bool Value=true)
SmallVector< Value *, 16 > OutVals
const TargetInstrInfo & TII
MachineInstr * LastLocalValue
The position of the last instruction for materializing constants for use in the current block...
void recomputeInsertPt()
Reset InsertPt to prepare for inserting instructions into the current block.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
virtual unsigned fastEmit_rr(MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill)
This method is called by target-independent code to request that an instruction with the given type...
bool isCommutativeIntrinsic(IntrinsicInst const *II)
virtual unsigned fastEmit_ri(MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0, bool Op0IsKill, uint64_t Imm)
This method is called by target-independent code to request that an instruction with the given type...
CallLoweringInfo & setCallee(Type *ResultTy, FunctionType *FuncTy, MCSymbol *Target, ArgListTy &&ArgsList, ImmutableCallSite &Call, unsigned FixedArgs=~0U)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool selectCall(const User *I)
Provides information about what library functions are available for the current target.
void finishCondBranch(const BasicBlock *BranchBB, MachineBasicBlock *TrueMBB, MachineBasicBlock *FalseMBB)
Emit an unconditional branch to FalseMBB, obtains the branch weight and adds TrueMBB and FalseMBB to ...
const TargetLibraryInfo * LibInfo
unsigned fastEmitInst_rr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill)
Emit a MachineInstr with two register operands and a result register in the given register class...
void updateValueMap(const Value *I, unsigned Reg, unsigned NumRegs=1)
Update the value map to include the new mapping for this instruction, or insert an extra copy to get ...
void startNewBlock()
Set the current block to which generated machine instructions will be appended.
bool selectBitCast(const User *I)
Target - Wrapper for Target specific information.
virtual unsigned fastEmit_f(MVT VT, MVT RetVT, unsigned Opcode, const ConstantFP *FPImm)
This method is called by target-independent code to request that an instruction with the given type...
SmallVector< unsigned, 16 > OutRegs
bool selectBinaryOp(const User *I, unsigned ISDOpcode)
Select and emit code for a binary operator instruction, which has an opcode which directly correspond...
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringRef > StandardNames)
Initialize the set of available library functions based on the specified target triple.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
SavePoint enterLocalValueArea()
Prepare InsertPt to begin inserting instructions into the local value area and return the old insert ...
Representation of each machine instruction.
virtual bool fastLowerIntrinsicCall(const IntrinsicInst *II)
This method is called by target-independent code to do target- specific intrinsic lowering...
bool selectPatchpoint(const CallInst *I)
MachineRegisterInfo & MRI
bool lowerCallTo(const CallInst *CI, MCSymbol *Symbol, unsigned NumArgs)
Establish a view to a call site for examination.
unsigned fastEmitInst_i(unsigned MachineInstOpcode, const TargetRegisterClass *RC, uint64_t Imm)
Emit a MachineInstr with a single immediate operand, and a result register in the given register clas...
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
virtual unsigned fastMaterializeAlloca(const AllocaInst *C)
Emit an alloca address in a register using target-specific logic.
const TargetLowering & TLI
unsigned createResultReg(const TargetRegisterClass *RC)
CallLoweringInfo & setIsPatchPoint(bool Value=true)
unsigned fastEmit_ri_(MVT VT, unsigned Opcode, unsigned Op0, bool Op0IsKill, uint64_t Imm, MVT ImmType)
This method is a wrapper of fastEmit_ri.
unsigned fastEmitInst_extractsubreg(MVT RetVT, unsigned Op0, bool Op0IsKill, uint32_t Idx)
Emit a MachineInstr for an extract_subreg from a specified index of a superregister to a specified ty...
MachineBasicBlock::iterator InsertPt
FastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo, bool SkipTargetIndependentISel=false)
virtual bool fastLowerArguments()
This method is called by target-independent code to do target- specific argument lowering.
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if this return value has the given attribute.
LLVM Value Representation.
Primary interface to the complete machine description for the target machine.
void fastEmitBranch(MachineBasicBlock *MSucc, const DebugLoc &DbgLoc)
Emit an unconditional branch to the given block, unless it is the immediate (fall-through) successor...
StringRef - Represent a constant reference to a string, i.e.
virtual bool fastSelectInstruction(const Instruction *I)=0
This method is called by target-independent code when the normal FastISel process fails to select an ...
unsigned fastEmitInst_f(unsigned MachineInstOpcode, const TargetRegisterClass *RC, const ConstantFP *FPImm)
Emit a MachineInstr with a floating point immediate, and a result register in the given register clas...
FunctionLoweringInfo & FuncInfo
A wrapper class for inspecting calls to intrinsic functions.
This file describes how to lower LLVM code to machine code.
an instruction to allocate memory on the stack