[llvm-commits] [llvm] r165132 - in /llvm/trunk: include/llvm/Instructions.h include/llvm/Support/CallSite.h lib/Target/ARM/ARMFastISel.cpp lib/Target/X86/X86FastISel.cpp lib/VMCore/Instructions.cpp

Bill Wendling isanbard at gmail.com
Wed Oct 3 10:54:26 PDT 2012


Author: void
Date: Wed Oct  3 12:54:26 2012
New Revision: 165132

URL: http://llvm.org/viewvc/llvm-project?rev=165132&view=rev
Log:
Add methods which query for the specific attribute instead of using the
enums. This allows for better encapsulation of the Attributes class.

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

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=165132&r1=165131&r2=165132&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Wed Oct  3 12:54:26 2012
@@ -1272,6 +1272,14 @@
     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 @@
     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;
 

Modified: llvm/trunk/include/llvm/Support/CallSite.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=165132&r1=165131&r2=165132&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CallSite.h (original)
+++ llvm/trunk/include/llvm/Support/CallSite.h Wed Oct  3 12:54:26 2012
@@ -189,6 +189,26 @@
     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));

Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=165132&r1=165131&r2=165132&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Wed Oct  3 12:54:26 2012
@@ -2320,16 +2320,16 @@
 
     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();

Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=165132&r1=165131&r2=165132&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Wed Oct  3 12:54:26 2012
@@ -1541,9 +1541,9 @@
   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 @@
     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 @@
         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 @@
       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);
     }

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=165132&r1=165131&r2=165132&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Wed Oct  3 12:54:26 2012
@@ -342,6 +342,54 @@
   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 @@
   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;





More information about the llvm-commits mailing list