14 #ifndef LLVM_CODEGEN_FASTISEL_H 15 #define LLVM_CODEGEN_FASTISEL_H 42 class FunctionLoweringInfo;
44 class MachineConstantPool;
45 class MachineFrameInfo;
46 class MachineFunction;
48 class MachineMemOperand;
50 class MachineRegisterInfo;
54 class TargetInstrInfo;
55 class TargetLibraryInfo;
57 class TargetRegisterClass;
58 class TargetRegisterInfo;
118 Args = std::move(ArgsList);
129 unsigned FixedArgs = ~0U) {
142 Args = std::move(ArgsList);
143 NumFixedArgs = (FixedArgs == ~0U) ? FuncTy->
getNumParams() : FixedArgs;
152 unsigned FixedArgs = ~0U) {
156 Args = std::move(ArgsList);
157 NumFixedArgs = (FixedArgs == ~0U) ? Args.size() : FixedArgs;
164 unsigned FixedArgs = ~0U);
168 unsigned FixedArgs = ~0U) {
172 Args = std::move(ArgsList);
173 NumFixedArgs = (FixedArgs == ~0U) ? Args.size() : FixedArgs;
332 bool SkipTargetIndependentISel =
false);
358 virtual unsigned fastEmit_r(
MVT VT,
MVT RetVT,
unsigned Opcode,
unsigned Op0,
364 bool Op0IsKill,
unsigned Op1,
bool Op1IsKill);
370 bool Op0IsKill, uint64_t Imm);
377 unsigned fastEmit_ri_(
MVT VT,
unsigned Opcode,
unsigned Op0,
bool Op0IsKill,
378 uint64_t Imm,
MVT ImmType);
382 virtual unsigned fastEmit_i(
MVT VT,
MVT RetVT,
unsigned Opcode, uint64_t Imm);
405 bool Op0IsKill,
unsigned Op1,
bool Op1IsKill);
411 bool Op0IsKill,
unsigned Op1,
bool Op1IsKill,
412 unsigned Op2,
bool Op2IsKill);
418 bool Op0IsKill, uint64_t Imm);
424 bool Op0IsKill, uint64_t Imm1, uint64_t Imm2);
436 bool Op0IsKill,
unsigned Op1,
bool Op1IsKill,
516 case Intrinsic::sadd_with_overflow:
517 case Intrinsic::uadd_with_overflow:
518 case Intrinsic::smul_with_overflow:
519 case Intrinsic::umul_with_overflow:
556 bool handlePHINodesInSuccessorBlocks(
const BasicBlock *LLVMBB);
560 unsigned materializeConstant(
const Value *V,
MVT VT);
565 unsigned materializeRegForValue(
const Value *V,
MVT VT);
570 void flushLocalValueMap();
573 void removeDeadLocalValueCode(
MachineInstr *SavedLastLocalValue);
575 struct InstOrderMap {
586 void sinkLocalValueMaterialization(
MachineInstr &LocalMI,
unsigned DefReg,
587 InstOrderMap &OrderMap);
595 const CallInst *CI,
unsigned StartIdx);
596 bool lowerCallOperands(
const CallInst *CI,
unsigned ArgIdx,
unsigned NumArgs,
603 #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.
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...
MachineConstantPool & MCP
bool lowerCall(const CallInst *I)
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.
bool selectFNeg(const User *I, const Value *In)
Emit an FNeg operation.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
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.
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if this return value has the given attribute.
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...
C - The default llvm calling convention, compatible with C.
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.
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
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.
CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultTy, const Value *Target, ArgListTy &&ArgsList, unsigned FixedArgs=~0U)
TargetLoweringBase::ArgListTy ArgListTy
ValTy * getCalledValue() const
Return the pointer to function that is being called.
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...
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.
InstrTy * getInstruction() const
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.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
bool shouldOptForSize(const MachineFunction *MF) const
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.
SmallVector< Register, 16 > OutRegs
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...
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...
Align max(MaybeAlign Lhs, Align Rhs)
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 ...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
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...
bool selectBinaryOp(const User *I, unsigned ISDOpcode)
Select and emit code for a binary operator instruction, which has an opcode which directly correspond...
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.
SmallVector< Register, 4 > InRegs
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.
LLVM Value Representation.
bool doesNotReturn() const
Determine if the call cannot return.
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