Add methods which query for the specific attribute instead of using the
authorBill Wendling <isanbard@gmail.com>
Wed, 3 Oct 2012 17:54:26 +0000 (17:54 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 3 Oct 2012 17:54:26 +0000 (17:54 +0000)
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

include/llvm/Instructions.h
include/llvm/Support/CallSite.h
lib/Target/ARM/ARMFastISel.cpp
lib/Target/X86/X86FastISel.cpp
lib/VMCore/Instructions.cpp

index 7a0379e371bd61bcac4dd84cbb581c4d6aaa9ad8..a607c84c5bc96db6e3c1d382aa8bc6a5001e7c74 100644 (file)
@@ -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;
 
index 8905e1e33b7b32bf4ce1691c386f2ad834d6460f..3e1a2f582274167916c1051e0b7e468194670a0e 100644 (file)
@@ -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));
index 8933a02701c61c433c969be931a121be2fc6a28a..ecd48452e365f33f316c7f82511892c9811db3ee 100644 (file)
@@ -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();
index fd279a169cfbe209e4cac030584afac07370c48c..cf14fe05212afff6ed2bacc98ba27588d5050d87 100644 (file)
@@ -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<PointerType>(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);
     }
index d5b756dac09bf44df96f3e83c30979dd8a1ef07b..b3acbc42410f73770fa506200de0d4e60debad58 100644 (file)
@@ -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;