From: Bill Wendling Date: Wed, 3 Oct 2012 17:54:26 +0000 (+0000) Subject: Add methods which query for the specific attribute instead of using the X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=847d165459a8d4c30b57c896c7a7e2722f800f82;p=oota-llvm.git Add methods which query for the specific attribute instead of using the enums. This allows for better encapsulation of the Attributes class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165132 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 7a0379e371b..a607c84c5bc 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1272,6 +1272,14 @@ public: return paramHasAttr(~0, N); } + /// @brief Determine whether the call or the callee has the given attributes. + bool paramHasSExtAttr(unsigned i) const; + bool paramHasZExtAttr(unsigned i) const; + bool paramHasInRegAttr(unsigned i) const; + bool paramHasStructRetAttr(unsigned i) const; + bool paramHasNestAttr(unsigned i) const; + bool paramHasByValAttr(unsigned i) const; + /// @brief Determine whether the call or the callee has the given attribute. bool paramHasAttr(unsigned i, Attributes attr) const; @@ -3034,6 +3042,14 @@ public: return paramHasAttr(~0, N); } + /// @brief Determine whether the call or the callee has the given attributes. + bool paramHasSExtAttr(unsigned i) const; + bool paramHasZExtAttr(unsigned i) const; + bool paramHasInRegAttr(unsigned i) const; + bool paramHasStructRetAttr(unsigned i) const; + bool paramHasNestAttr(unsigned i) const; + bool paramHasByValAttr(unsigned i) const; + /// @brief Determine whether the call or the callee has the given attribute. bool paramHasAttr(unsigned i, Attributes attr) const; diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index 8905e1e33b7..3e1a2f58227 100644 --- a/include/llvm/Support/CallSite.h +++ b/include/llvm/Support/CallSite.h @@ -189,6 +189,26 @@ public: CALLSITE_DELEGATE_GETTER(hasFnAttr(N)); } + /// paramHas*Attr - whether the call or the callee has the given attribute. + bool paramHasSExtAttr(unsigned i) const { + CALLSITE_DELEGATE_GETTER(paramHasSExtAttr(i)); + } + bool paramHasZExtAttr(unsigned i) const { + CALLSITE_DELEGATE_GETTER(paramHasZExtAttr(i)); + } + bool paramHasInRegAttr(unsigned i) const { + CALLSITE_DELEGATE_GETTER(paramHasInRegAttr(i)); + } + bool paramHasStructRetAttr(unsigned i) const { + CALLSITE_DELEGATE_GETTER(paramHasStructRetAttr(i)); + } + bool paramHasNestAttr(unsigned i) const { + CALLSITE_DELEGATE_GETTER(paramHasNestAttr(i)); + } + bool paramHasByValAttr(unsigned i) const { + CALLSITE_DELEGATE_GETTER(paramHasByValAttr(i)); + } + /// paramHasAttr - whether the call or the callee has the given attribute. bool paramHasAttr(uint16_t i, Attributes attr) const { CALLSITE_DELEGATE_GETTER(paramHasAttr(i, attr)); diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp index 8933a02701c..ecd48452e36 100644 --- a/lib/Target/ARM/ARMFastISel.cpp +++ b/lib/Target/ARM/ARMFastISel.cpp @@ -2320,16 +2320,16 @@ bool ARMFastISel::SelectCall(const Instruction *I, ISD::ArgFlagsTy Flags; unsigned AttrInd = i - CS.arg_begin() + 1; - if (CS.paramHasAttr(AttrInd, Attribute::SExt)) + if (CS.paramHasSExtAttr(AttrInd)) Flags.setSExt(); - if (CS.paramHasAttr(AttrInd, Attribute::ZExt)) + if (CS.paramHasZExtAttr(AttrInd)) Flags.setZExt(); // FIXME: Only handle *easy* calls for now. - if (CS.paramHasAttr(AttrInd, Attribute::InReg) || - CS.paramHasAttr(AttrInd, Attribute::StructRet) || - CS.paramHasAttr(AttrInd, Attribute::Nest) || - CS.paramHasAttr(AttrInd, Attribute::ByVal)) + if (CS.paramHasInRegAttr(AttrInd) || + CS.paramHasStructRetAttr(AttrInd) || + CS.paramHasNestAttr(AttrInd) || + CS.paramHasByValAttr(AttrInd)) return false; Type *ArgTy = (*i)->getType(); diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index fd279a169cf..cf14fe05212 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -1541,9 +1541,9 @@ static unsigned computeBytesPoppedByCallee(const X86Subtarget &Subtarget, CallingConv::ID CC = CS.getCallingConv(); if (CC == CallingConv::Fast || CC == CallingConv::GHC) return 0; - if (!CS.paramHasAttr(1, Attribute::StructRet)) + if (!CS.paramHasStructRetAttr(1)) return 0; - if (CS.paramHasAttr(1, Attribute::InReg)) + if (CS.paramHasInRegAttr(1)) return 0; return 4; } @@ -1622,12 +1622,12 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) { Value *ArgVal = *i; ISD::ArgFlagsTy Flags; unsigned AttrInd = i - CS.arg_begin() + 1; - if (CS.paramHasAttr(AttrInd, Attribute::SExt)) + if (CS.paramHasSExtAttr(AttrInd)) Flags.setSExt(); - if (CS.paramHasAttr(AttrInd, Attribute::ZExt)) + if (CS.paramHasZExtAttr(AttrInd)) Flags.setZExt(); - if (CS.paramHasAttr(AttrInd, Attribute::ByVal)) { + if (CS.paramHasByValAttr(AttrInd)) { PointerType *Ty = cast(ArgVal->getType()); Type *ElementTy = Ty->getElementType(); unsigned FrameSize = TD.getTypeAllocSize(ElementTy); @@ -1641,9 +1641,9 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) { return false; } - if (CS.paramHasAttr(AttrInd, Attribute::InReg)) + if (CS.paramHasInRegAttr(AttrInd)) Flags.setInReg(); - if (CS.paramHasAttr(AttrInd, Attribute::Nest)) + if (CS.paramHasNestAttr(AttrInd)) Flags.setNest(); // If this is an i1/i8/i16 argument, promote to i32 to avoid an extra @@ -1911,11 +1911,11 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) { ISD::InputArg MyFlags; MyFlags.VT = RegisterVT.getSimpleVT(); MyFlags.Used = !CS.getInstruction()->use_empty(); - if (CS.paramHasAttr(0, Attribute::SExt)) + if (CS.paramHasSExtAttr(0)) MyFlags.Flags.setSExt(); - if (CS.paramHasAttr(0, Attribute::ZExt)) + if (CS.paramHasZExtAttr(0)) MyFlags.Flags.setZExt(); - if (CS.paramHasAttr(0, Attribute::InReg)) + if (CS.paramHasInRegAttr(0)) MyFlags.Flags.setInReg(); Ins.push_back(MyFlags); } diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index d5b756dac09..b3acbc42410 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -342,6 +342,54 @@ void CallInst::removeAttribute(unsigned i, Attributes attr) { setAttributes(PAL); } +bool CallInst::paramHasSExtAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasSExtAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasSExtAttr(); + return false; +} + +bool CallInst::paramHasZExtAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasZExtAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasZExtAttr(); + return false; +} + +bool CallInst::paramHasInRegAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasInRegAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasInRegAttr(); + return false; +} + +bool CallInst::paramHasStructRetAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasStructRetAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasStructRetAttr(); + return false; +} + +bool CallInst::paramHasNestAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasNestAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasNestAttr(); + return false; +} + +bool CallInst::paramHasByValAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasByValAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasByValAttr(); + return false; +} + bool CallInst::paramHasAttr(unsigned i, Attributes attr) const { if (AttributeList.paramHasAttr(i, attr)) return true; @@ -562,6 +610,54 @@ void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) { return setSuccessor(idx, B); } +bool InvokeInst::paramHasSExtAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasSExtAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasSExtAttr(); + return false; +} + +bool InvokeInst::paramHasZExtAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasZExtAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasZExtAttr(); + return false; +} + +bool InvokeInst::paramHasInRegAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasInRegAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasInRegAttr(); + return false; +} + +bool InvokeInst::paramHasStructRetAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasStructRetAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasStructRetAttr(); + return false; +} + +bool InvokeInst::paramHasNestAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasNestAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasNestAttr(); + return false; +} + +bool InvokeInst::paramHasByValAttr(unsigned i) const { + if (AttributeList.getParamAttributes(i).hasByValAttr()) + return true; + if (const Function *F = getCalledFunction()) + return F->getParamAttributes(i).hasByValAttr(); + return false; +} + bool InvokeInst::paramHasAttr(unsigned i, Attributes attr) const { if (AttributeList.paramHasAttr(i, attr)) return true;