15 #define DEBUG_TYPE "function-lowering-info"
47 if (isa<PHINode>(I))
return true;
52 if (cast<Instruction>(U)->getParent() != BB || isa<PHINode>(U))
78 if (
const ConstantInt *CUI = dyn_cast<ConstantInt>(AI->getArraySize())) {
79 Type *Ty = AI->getAllocatedType();
85 TySize *= CUI->getZExtValue();
86 if (TySize == 0) TySize = 1;
92 (AI->isArrayAllocation() ||
93 (TySize >= 8 && isa<ArrayType>(Ty) &&
94 cast<ArrayType>(Ty)->getElementType()->isIntegerTy(8)));
100 for (; BB != EB; ++BB)
106 if (!isa<AllocaInst>(
I) ||
116 assert((!DIVar || DIVar.isVariable()) &&
117 "Variable in DbgDeclareInst should be either null or a DIVariable.");
120 !DI->getDebugLoc().isUnknown()) {
124 const Value *Address = DI->getAddress();
126 if (
const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
127 Address = BCI->getOperand(0);
128 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(Address)) {
134 FI, DI->getDebugLoc());
145 for (BB =
Fn->
begin(); BB != EB; ++BB) {
153 if (BB->hasAddressTaken())
168 assert(PHIReg &&
"PHI node does not have an assigned virtual register!");
172 for (
unsigned vti = 0, vte = ValueVTs.
size(); vti != vte; ++vti) {
173 EVT VT = ValueVTs[vti];
176 for (
unsigned i = 0; i != NumRegisters; ++i)
178 PHIReg += NumRegisters;
184 for (BB =
Fn->
begin(); BB != EB; ++BB)
185 if (
const InvokeInst *Invoke = dyn_cast<InvokeInst>(BB->getTerminator()))
186 MBBMap[Invoke->getSuccessor(1)]->setIsLandingPad();
194 "Not all catch info was assigned to a landing pad!");
203 LiveOutRegInfo.clear();
213 createVirtualRegister(
TM.getTargetLowering()->getRegClassFor(VT));
229 unsigned FirstReg = 0;
235 for (
unsigned i = 0; i != NumRegs; ++i) {
237 if (!FirstReg) FirstReg = R;
250 if (!LiveOutRegInfo.inBounds(Reg))
277 assert(ValueVTs.
size() == 1 &&
278 "PHIs with non-vector integer types should have a single VT.");
279 EVT IntVT = ValueVTs[0];
289 LiveOutRegInfo.grow(DestReg);
293 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
295 APInt Zero(BitWidth, 0);
307 assert(
ValueMap.
count(V) &&
"V should have been placed in ValueMap when its"
308 "CopyToReg node was created.");
324 "Masks should have the same bit width as the type.");
328 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) {
330 APInt Zero(BitWidth, 0);
344 assert(
ValueMap.
count(V) &&
"V should have been placed in ValueMap when "
345 "its CopyToReg node was created.");
378 DEBUG(
dbgs() <<
"Argument does not have assigned frame index!\n");
397 if (i->isFloatingPointTy()) {
412 assert(CE->
getOpcode() == Instruction::BitCast &&
414 "Personality should be a function");
419 std::vector<const GlobalVariable *> TyInfo;
422 for (
unsigned i = N - 1; i > 1; --i) {
424 unsigned FilterLength = CI->getZExtValue();
425 unsigned FirstCatch = i + FilterLength + !FilterLength;
426 assert(FirstCatch <= N &&
"Invalid filter length");
428 if (FirstCatch < N) {
429 TyInfo.reserve(N - FirstCatch);
430 for (
unsigned j = FirstCatch; j <
N; ++j)
441 TyInfo.reserve(FilterLength - 1);
442 for (
unsigned j = i + 1; j < FirstCatch; ++j)
453 TyInfo.reserve(N - 2);
454 for (
unsigned j = 2; j <
N; ++j)
480 Constant *CVal = cast<Constant>(Val);
484 FilterList.
push_back(cast<GlobalVariable>((*II)->stripPointerCasts()));
const Value * getCalledValue() const
void push_back(const T &Elt)
void ComputeValueVTs(const TargetLowering &TLI, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=0, uint64_t StartingOffset=0)
LLVMContext & getContext() const
LLVM Argument representation.
GlobalVariable * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
unsigned getNumRegisters(LLVMContext &Context, EVT VT) const
SmallPtrSet< const Instruction *, 8 > CatchInfoFound
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getPrefTypeAlignment(Type *Ty) const
static bool isVirtualRegister(unsigned Reg)
Type * getReturnType() const
unsigned getNumSignBits() const
Value * getPersonalityFn() const
APInt LLVM_ATTRIBUTE_UNUSED_RESULT zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
unsigned getOpcode() const
getOpcode - Return the opcode at the root of this constant expression
CallingConv::ID getCallingConv() const
static bool isUsedOutsideOfDefiningBlock(const Instruction *I)
const HexagonInstrInfo * TII
unsigned getNumArgOperands() const
po_iterator< T > po_begin(T G)
bool hasDebugInfo() const
bool usesVAFloatArgument() const
int getArgumentFrameIndex(const Argument *A)
getArgumentFrameIndex - Get frame index for the byval argument.
bool count(const KeyT &Val) const
count - Return true if the specified key is in the map.
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
const LiveOutInfo * GetLiveOutRegInfo(unsigned Reg)
This class represents a no-op cast from one type to another.
unsigned getNumClauses() const
getNumClauses - Get the number of clauses for this landing pad.
void addPersonality(MachineBasicBlock *LandingPad, const Function *Personality)
void AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI, MachineBasicBlock *MBB)
unsigned getNumIncomingValues() const
void GetReturnInfo(Type *ReturnType, AttributeSet attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI)
Value * getClause(unsigned Idx) const
SmallPtrSet< const Instruction *, 8 > CatchInfoLost
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=0)
LLVM Basic Block Representation.
Type * getContainedType(unsigned i) const
LLVM Constant Representation.
const DebugLoc & getDebugLoc() const
getDebugLoc - Return the debug location for this node as a DebugLoc.
const DataLayout * getDataLayout() const
unsigned getBitWidth() const
Return the number of bits in the APInt.
Value * getOperand(unsigned i) const
MVT getRegisterType(MVT VT) const
Return the type of registers that this ValueType will eventually require.
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
SmallPtrSet< const BasicBlock *, 4 > VisitedBBs
LLVMContext & getContext() const
All values hold a context through their type.
void ComputePHILiveOutRegInfo(const PHINode *)
const MCInstrDesc & get(unsigned Opcode) const
MachineBasicBlock * MBB
MBB - The current block.
virtual const TargetInstrInfo * getInstrInfo() const
Class for constant integers.
Value * getIncomingValue(unsigned i) const
uint64_t getTypeAllocSize(Type *Ty) const
DenseMap< unsigned, unsigned > RegFixups
RegFixups - Registers which need to be replaced after isel is done.
SmallVector< MachineInstr *, 8 > ArgDbgValues
void addCatchTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalVariable * > TyInfo)
void addCleanup(MachineBasicBlock *LandingPad)
Value * stripPointerCasts()
Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value...
MachineFrameInfo * getFrameInfo()
unsigned CreateRegs(Type *Ty)
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
AttributeSet getAttributes() const
Return the attribute list for this Function.
Value * getArgOperand(unsigned i) const
Class for arbitrary precision integers.
void setHasAddressTaken()
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
virtual bool CanLowerReturn(CallingConv::ID, MachineFunction &, bool, const SmallVectorImpl< ISD::OutputArg > &, LLVMContext &) const
void set(const Function &Fn, MachineFunction &MF)
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, bool MayNeedSP=false, const AllocaInst *Alloca=0)
MachineRegisterInfo * RegInfo
MachineRegisterInfo & getRegInfo()
po_iterator< T > po_end(T G)
DenseMap< const Argument *, int > ByValArgFrameIndexMap
ByValArgFrameIndexMap - Keep track of frame indices for byval arguments.
unsigned getSizeInBits() const
getSizeInBits - Return the size of the specified value type in bits.
bool isCatch(unsigned Idx) const
isCatch - Return 'true' if the clause and index Idx is a catch clause.
void setUsesVAFloatArgument(bool b)
const TargetMachine & getTarget() const
unsigned CreateReg(MVT VT)
CreateReg - Allocate a single virtual register for the given type.
DenseMap< const AllocaInst *, int > StaticAllocaMap
void setVariableDbgInfo(MDNode *N, unsigned Slot, DebugLoc Loc)
void addFilterTypeInfo(MachineBasicBlock *LandingPad, ArrayRef< const GlobalVariable * > TyInfo)
EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
LLVM Value Representation.
void push_back(MachineBasicBlock *MBB)
void AddCatchInfo(const CallInst &I, MachineModuleInfo *MMI, MachineBasicBlock *MBB)
DenseMap< const BasicBlock *, MachineBasicBlock * > MBBMap
MBBMap - A mapping from LLVM basic blocks to their machine code entry.
MachineModuleInfo & getMMI() const
void setArgumentFrameIndex(const Argument *A, int FI)
void ComputeUsesVAFloatArgument(const CallInst &I, MachineModuleInfo *MMI)
const BasicBlock * getParent() const
unsigned InitializeRegForValue(const Value *V)