[llvm-commits] [llvm] r165550 - in /llvm/trunk: include/llvm/Attributes.h include/llvm/Instructions.h include/llvm/Support/CallSite.h include/llvm/Target/TargetLowering.h lib/Analysis/AliasAnalysis.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp lib/Target/ARM/ARMFastISel.cpp lib/Target/X86/X86FastISel.cpp lib/Transforms/IPO/FunctionAttrs.cpp lib/VMCore/Instructions.cpp
Bill Wendling
isanbard at gmail.com
Tue Oct 9 14:38:15 PDT 2012
Author: void
Date: Tue Oct 9 16:38:14 2012
New Revision: 165550
URL: http://llvm.org/viewvc/llvm-project?rev=165550&view=rev
Log:
Use the attribute enums to query if a parameter has an attribute.
Modified:
llvm/trunk/include/llvm/Attributes.h
llvm/trunk/include/llvm/Instructions.h
llvm/trunk/include/llvm/Support/CallSite.h
llvm/trunk/include/llvm/Target/TargetLowering.h
llvm/trunk/lib/Analysis/AliasAnalysis.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
llvm/trunk/lib/Target/X86/X86FastISel.cpp
llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/trunk/lib/VMCore/Instructions.cpp
Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Tue Oct 9 16:38:14 2012
@@ -295,7 +295,7 @@
static Attributes constructAlignmentFromInt(unsigned i) {
// Default alignment, allow the target to define how to align it.
if (i == 0)
- return Attribute::None;
+ return Attributes();
assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
assert(i <= 0x40000000 && "Alignment too large.");
@@ -307,7 +307,7 @@
static Attributes constructStackAlignmentFromInt(unsigned i) {
// Default alignment, allow the target to define how to align it.
if (i == 0)
- return Attribute::None;
+ return Attributes();
assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
assert(i <= 0x100 && "Alignment too large.");
Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Tue Oct 9 16:38:14 2012
@@ -1277,14 +1277,7 @@
bool fnHasReturnsTwiceAttr() const;
/// @brief Determine whether the call or the callee has the given attributes.
- bool paramHasByValAttr(unsigned i) const;
- bool paramHasInRegAttr(unsigned i) const;
- bool paramHasNestAttr(unsigned i) const;
- bool paramHasNoAliasAttr(unsigned i) const;
- bool paramHasNoCaptureAttr(unsigned i) const;
- bool paramHasSExtAttr(unsigned i) const;
- bool paramHasStructRetAttr(unsigned i) const;
- bool paramHasZExtAttr(unsigned i) const;
+ bool paramHasAttr(unsigned i, Attributes::AttrVal A) const;
/// @brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
@@ -1343,7 +1336,7 @@
/// pointer argument.
bool hasStructRetAttr() const {
// Be friendly and also check the callee.
- return paramHasStructRetAttr(1);
+ return paramHasAttr(1, Attributes::StructRet);
}
/// @brief Determine if any call argument is an aggregate passed by value.
@@ -3053,14 +3046,7 @@
bool fnHasReturnsTwiceAttr() const;
/// @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;
- bool paramHasNoAliasAttr(unsigned i) const;
- bool paramHasNoCaptureAttr(unsigned i) const;
+ bool paramHasAttr(unsigned i, Attributes::AttrVal A) const;
/// @brief Extract the alignment for a call or parameter (0=unknown).
unsigned getParamAlignment(unsigned i) const {
@@ -3110,7 +3096,7 @@
/// pointer argument.
bool hasStructRetAttr() const {
// Be friendly and also check the callee.
- return paramHasStructRetAttr(1);
+ return paramHasAttr(1, Attributes::StructRet);
}
/// @brief Determine if any call argument is an aggregate passed by value.
Modified: llvm/trunk/include/llvm/Support/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CallSite.h (original)
+++ llvm/trunk/include/llvm/Support/CallSite.h Tue Oct 9 16:38:14 2012
@@ -210,35 +210,9 @@
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));
- }
- bool paramHasNoAliasAttr(unsigned i) const {
- CALLSITE_DELEGATE_GETTER(paramHasNoAliasAttr(i));
- }
- bool paramHasNoCaptureAttr(unsigned i) const {
- CALLSITE_DELEGATE_GETTER(paramHasNoCaptureAttr(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));
+ /// \brief Return true if the call or the callee has the given attribute.
+ bool paramHasAttr(unsigned i, Attributes::AttrVal A) const {
+ CALLSITE_DELEGATE_GETTER(paramHasAttr(i, A));
}
/// @brief Extract the alignment for a call or parameter (0=unknown).
@@ -291,12 +265,12 @@
/// @brief Determine whether this argument is not captured.
bool doesNotCapture(unsigned ArgNo) const {
- return paramHasNoCaptureAttr(ArgNo + 1);
+ return paramHasAttr(ArgNo + 1, Attributes::NoCapture);
}
/// @brief Determine whether this argument is passed by value.
bool isByValArgument(unsigned ArgNo) const {
- return paramHasByValAttr(ArgNo + 1);
+ return paramHasAttr(ArgNo + 1, Attributes::ByVal);
}
/// hasArgument - Returns true if this CallSite passes the given Value* as an
Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Tue Oct 9 16:38:14 2012
@@ -1323,9 +1323,9 @@
FunctionType *FTy, bool isTailCall, SDValue callee,
ArgListTy &args, SelectionDAG &dag, DebugLoc dl,
ImmutableCallSite &cs)
- : Chain(chain), RetTy(retTy), RetSExt(cs.paramHasSExtAttr(0)),
- RetZExt(cs.paramHasZExtAttr(0)), IsVarArg(FTy->isVarArg()),
- IsInReg(cs.paramHasInRegAttr(0)),
+ : Chain(chain), RetTy(retTy), RetSExt(cs.paramHasAttr(0, Attributes::SExt)),
+ RetZExt(cs.paramHasAttr(0, Attributes::ZExt)), IsVarArg(FTy->isVarArg()),
+ IsInReg(cs.paramHasAttr(0, Attributes::InReg)),
DoesNotReturn(cs.doesNotReturn()),
IsReturnValueUsed(!cs.getInstruction()->use_empty()),
IsTailCall(isTailCall), NumFixedArgs(FTy->getNumParams()),
Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Tue Oct 9 16:38:14 2012
@@ -503,7 +503,7 @@
bool llvm::isNoAliasCall(const Value *V) {
if (isa<CallInst>(V) || isa<InvokeInst>(V))
return ImmutableCallSite(cast<Instruction>(V))
- .paramHasNoAliasAttr(0);
+ .paramHasAttr(0, Attributes::NoAlias);
return false;
}
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Oct 9 16:38:14 2012
@@ -5342,12 +5342,12 @@
Entry.Node = ArgNode; Entry.Ty = V->getType();
unsigned attrInd = i - CS.arg_begin() + 1;
- Entry.isSExt = CS.paramHasSExtAttr(attrInd);
- Entry.isZExt = CS.paramHasZExtAttr(attrInd);
- Entry.isInReg = CS.paramHasInRegAttr(attrInd);
- Entry.isSRet = CS.paramHasStructRetAttr(attrInd);
- Entry.isNest = CS.paramHasNestAttr(attrInd);
- Entry.isByVal = CS.paramHasByValAttr(attrInd);
+ Entry.isSExt = CS.paramHasAttr(attrInd, Attributes::SExt);
+ Entry.isZExt = CS.paramHasAttr(attrInd, Attributes::ZExt);
+ Entry.isInReg = CS.paramHasAttr(attrInd, Attributes::InReg);
+ Entry.isSRet = CS.paramHasAttr(attrInd, Attributes::StructRet);
+ Entry.isNest = CS.paramHasAttr(attrInd, Attributes::Nest);
+ Entry.isByVal = CS.paramHasAttr(attrInd, Attributes::ByVal);
Entry.Alignment = CS.getParamAlignment(attrInd);
Args.push_back(Entry);
}
Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Tue Oct 9 16:38:14 2012
@@ -2320,16 +2320,16 @@
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
- if (CS.paramHasSExtAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::SExt))
Flags.setSExt();
- if (CS.paramHasZExtAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::ZExt))
Flags.setZExt();
// FIXME: Only handle *easy* calls for now.
- if (CS.paramHasInRegAttr(AttrInd) ||
- CS.paramHasStructRetAttr(AttrInd) ||
- CS.paramHasNestAttr(AttrInd) ||
- CS.paramHasByValAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::InReg) ||
+ CS.paramHasAttr(AttrInd, Attributes::StructRet) ||
+ CS.paramHasAttr(AttrInd, Attributes::Nest) ||
+ CS.paramHasAttr(AttrInd, Attributes::ByVal))
return false;
Type *ArgTy = (*i)->getType();
Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Oct 9 16:38:14 2012
@@ -1541,9 +1541,9 @@
CallingConv::ID CC = CS.getCallingConv();
if (CC == CallingConv::Fast || CC == CallingConv::GHC)
return 0;
- if (!CS.paramHasStructRetAttr(1))
+ if (!CS.paramHasAttr(1, Attributes::StructRet))
return 0;
- if (CS.paramHasInRegAttr(1))
+ if (CS.paramHasAttr(1, Attributes::InReg))
return 0;
return 4;
}
@@ -1622,12 +1622,12 @@
Value *ArgVal = *i;
ISD::ArgFlagsTy Flags;
unsigned AttrInd = i - CS.arg_begin() + 1;
- if (CS.paramHasSExtAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::SExt))
Flags.setSExt();
- if (CS.paramHasZExtAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::ZExt))
Flags.setZExt();
- if (CS.paramHasByValAttr(AttrInd)) {
+ if (CS.paramHasAttr(AttrInd, Attributes::ByVal)) {
PointerType *Ty = cast<PointerType>(ArgVal->getType());
Type *ElementTy = Ty->getElementType();
unsigned FrameSize = TD.getTypeAllocSize(ElementTy);
@@ -1641,9 +1641,9 @@
return false;
}
- if (CS.paramHasInRegAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::InReg))
Flags.setInReg();
- if (CS.paramHasNestAttr(AttrInd))
+ if (CS.paramHasAttr(AttrInd, Attributes::Nest))
Flags.setNest();
// If this is an i1/i8/i16 argument, promote to i32 to avoid an extra
@@ -1911,11 +1911,11 @@
ISD::InputArg MyFlags;
MyFlags.VT = RegisterVT.getSimpleVT();
MyFlags.Used = !CS.getInstruction()->use_empty();
- if (CS.paramHasSExtAttr(0))
+ if (CS.paramHasAttr(0, Attributes::SExt))
MyFlags.Flags.setSExt();
- if (CS.paramHasZExtAttr(0))
+ if (CS.paramHasAttr(0, Attributes::ZExt))
MyFlags.Flags.setZExt();
- if (CS.paramHasInRegAttr(0))
+ if (CS.paramHasAttr(0, Attributes::InReg))
MyFlags.Flags.setInReg();
Ins.push_back(MyFlags);
}
Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Tue Oct 9 16:38:14 2012
@@ -518,7 +518,7 @@
case Instruction::Call:
case Instruction::Invoke: {
CallSite CS(RVI);
- if (CS.paramHasNoAliasAttr(0))
+ if (CS.paramHasAttr(0, Attributes::NoAlias))
break;
if (CS.getCalledFunction() &&
SCCNodes.count(CS.getCalledFunction()))
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=165550&r1=165549&r2=165550&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Oct 9 16:38:14 2012
@@ -393,67 +393,11 @@
return false;
}
-bool CallInst::paramHasSExtAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::SExt))
+bool CallInst::paramHasAttr(unsigned i, Attributes::AttrVal A) const {
+ if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::SExt);
- return false;
-}
-
-bool CallInst::paramHasZExtAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::ZExt))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::ZExt);
- return false;
-}
-
-bool CallInst::paramHasInRegAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::InReg))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::InReg);
- return false;
-}
-
-bool CallInst::paramHasStructRetAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::StructRet))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::StructRet);
- return false;
-}
-
-bool CallInst::paramHasNestAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::Nest))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::Nest);
- return false;
-}
-
-bool CallInst::paramHasByValAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::ByVal))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::ByVal);
- return false;
-}
-
-bool CallInst::paramHasNoAliasAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::NoAlias))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::NoAlias);
- return false;
-}
-
-bool CallInst::paramHasNoCaptureAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::NoCapture))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::NoCapture);
+ return F->getParamAttributes(i).hasAttribute(A);
return false;
}
@@ -720,67 +664,11 @@
return false;
}
-bool InvokeInst::paramHasSExtAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::SExt))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::SExt);
- return false;
-}
-
-bool InvokeInst::paramHasZExtAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::ZExt))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::ZExt);
- return false;
-}
-
-bool InvokeInst::paramHasInRegAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::InReg))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::InReg);
- return false;
-}
-
-bool InvokeInst::paramHasStructRetAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::StructRet))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::StructRet);
- return false;
-}
-
-bool InvokeInst::paramHasNestAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::Nest))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::Nest);
- return false;
-}
-
-bool InvokeInst::paramHasByValAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::ByVal))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::ByVal);
- return false;
-}
-
-bool InvokeInst::paramHasNoAliasAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::NoAlias))
- return true;
- if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::NoAlias);
- return false;
-}
-
-bool InvokeInst::paramHasNoCaptureAttr(unsigned i) const {
- if (AttributeList.getParamAttributes(i).hasAttribute(Attributes::NoCapture))
+bool InvokeInst::paramHasAttr(unsigned i, Attributes::AttrVal A) const {
+ if (AttributeList.getParamAttributes(i).hasAttribute(A))
return true;
if (const Function *F = getCalledFunction())
- return F->getParamAttributes(i).hasAttribute(Attributes::NoCapture);
+ return F->getParamAttributes(i).hasAttribute(A);
return false;
}
More information about the llvm-commits
mailing list