[llvm-commits] [llvm] r48326 - in /llvm/trunk: include/llvm/Function.h include/llvm/Instructions.h lib/VMCore/Function.cpp lib/VMCore/Instructions.cpp

Chris Lattner sabre at nondot.org
Wed Mar 12 22:00:21 PDT 2008


Author: lattner
Date: Thu Mar 13 00:00:21 2008
New Revision: 48326

URL: http://llvm.org/viewvc/llvm-project?rev=48326&view=rev
Log:
move a bunch of trivial methods to be inline.

Modified:
    llvm/trunk/include/llvm/Function.h
    llvm/trunk/include/llvm/Instructions.h
    llvm/trunk/lib/VMCore/Function.cpp
    llvm/trunk/lib/VMCore/Instructions.cpp

Modified: llvm/trunk/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=48326&r1=48325&r2=48326&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Thu Mar 13 00:00:21 2008
@@ -160,26 +160,38 @@
   void clearCollector();
 
   /// @brief Determine whether the function has the given attribute.
-  bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+  bool paramHasAttr(unsigned i, ParameterAttributes attr) const {
+    return ParamAttrs.paramHasAttr(i, attr);
+  }
   
   /// @brief Extract the alignment for a call or parameter (0=unknown).
-  uint16_t getParamAlignment(uint16_t i) const;
+  unsigned getParamAlignment(unsigned i) const {
+    return ParamAttrs.getParamAlignment(i);
+  }
 
   /// @brief Determine if the function cannot return.
-  bool doesNotReturn() const;
+  bool doesNotReturn() const { return paramHasAttr(0, ParamAttr::NoReturn); }
 
   /// @brief Determine if the function cannot unwind.
-  bool doesNotThrow() const;
+  bool doesNotThrow() const {
+    return paramHasAttr(0, ParamAttr::NoUnwind);
+  }
 
   /// @brief Determine if the function does not access memory.
-  bool doesNotAccessMemory() const;
+  bool doesNotAccessMemory() const {
+    return paramHasAttr(0, ParamAttr::ReadNone);
+  }
 
   /// @brief Determine if the function does not access or only reads memory.
-  bool onlyReadsMemory() const;
+  bool onlyReadsMemory() const {
+    return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+  }
 
   /// @brief Determine if the function returns a structure through first 
   /// pointer argument.
-  bool hasStructRetAttr() const;
+  bool hasStructRetAttr() const {
+    return paramHasAttr(1, ParamAttr::StructRet);
+  }
 
   /// deleteBody - This method deletes the body of the function, and converts
   /// the linkage to external.

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=48326&r1=48325&r2=48326&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Thu Mar 13 00:00:21 2008
@@ -934,30 +934,45 @@
   void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
 
   /// @brief Determine whether the call or the callee has the given attribute.
-  bool paramHasAttr(uint16_t i, unsigned attr) const;
+  bool paramHasAttr(unsigned i, unsigned attr) const;
 
   /// @brief Extract the alignment for a call or parameter (0=unknown).
-  uint16_t getParamAlignment(uint16_t i) const;
+  unsigned getParamAlignment(unsigned i) const {
+    return ParamAttrs.getParamAlignment(i);
+  }
 
   /// @brief Determine if the call does not access memory.
-  bool doesNotAccessMemory() const;
+  bool doesNotAccessMemory() const {
+    return paramHasAttr(0, ParamAttr::ReadNone);
+  }
   
   /// @brief Determine if the call does not access or only reads memory.
-  bool onlyReadsMemory() const;
+  bool onlyReadsMemory() const {
+    return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+  }
   
   /// @brief Determine if the call cannot return.
-  bool doesNotReturn() const;
+  bool doesNotReturn() const {
+    return paramHasAttr(0, ParamAttr::NoReturn);
+  }
 
   /// @brief Determine if the call cannot unwind.
-  bool doesNotThrow() const;
+  bool doesNotThrow() const {
+    return paramHasAttr(0, ParamAttr::NoUnwind);
+  }
   void setDoesNotThrow(bool doesNotThrow = true);
 
   /// @brief Determine if the call returns a structure through first 
   /// pointer argument.
-  bool hasStructRetAttr() const;
+  bool hasStructRetAttr() const {
+    // Be friendly and also check the callee.
+    return paramHasAttr(1, ParamAttr::StructRet);
+  }
 
   /// @brief Determine if any call argument is an aggregate passed by value.
-  bool hasByValArgument() const;
+  bool hasByValArgument() const {
+    return ParamAttrs.hasAttrSomewhere(ParamAttr::ByVal);
+  }
 
   /// getCalledFunction - Return the function being called by this instruction
   /// if it is a direct call.  If it is a call through a function pointer,
@@ -1749,27 +1764,40 @@
   void setParamAttrs(const PAListPtr &Attrs) { ParamAttrs = Attrs; }
 
   /// @brief Determine whether the call or the callee has the given attribute.
-  bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+  bool paramHasAttr(unsigned i, ParameterAttributes attr) const;
 
   /// @brief Extract the alignment for a call or parameter (0=unknown).
-  uint16_t getParamAlignment(uint16_t i) const;
+  unsigned getParamAlignment(unsigned i) const {
+    return ParamAttrs.getParamAlignment(i);
+  }
 
   /// @brief Determine if the call does not access memory.
-  bool doesNotAccessMemory() const;
+  bool doesNotAccessMemory() const {
+    return paramHasAttr(0, ParamAttr::ReadNone);
+  }
 
   /// @brief Determine if the call does not access or only reads memory.
-  bool onlyReadsMemory() const;
+  bool onlyReadsMemory() const {
+    return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+  }
 
   /// @brief Determine if the call cannot return.
-  bool doesNotReturn() const;
+  bool doesNotReturn() const {
+    return paramHasAttr(0, ParamAttr::NoReturn);
+  }
 
   /// @brief Determine if the call cannot unwind.
-  bool doesNotThrow() const;
+  bool doesNotThrow() const {
+    return paramHasAttr(0, ParamAttr::NoUnwind);
+  }
   void setDoesNotThrow(bool doesNotThrow = true);
 
   /// @brief Determine if the call returns a structure through first 
   /// pointer argument.
-  bool hasStructRetAttr() const;
+  bool hasStructRetAttr() const {
+    // Be friendly and also check the callee.
+    return paramHasAttr(1, ParamAttr::StructRet);
+  }
 
   /// getCalledFunction - Return the function called, or null if this is an
   /// indirect function invocation.

Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=48326&r1=48325&r2=48326&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Thu Mar 13 00:00:21 2008
@@ -137,42 +137,6 @@
   getParent()->getFunctionList().erase(this);
 }
 
-/// @brief Determine whether the function has the given attribute.
-bool Function::paramHasAttr(uint16_t i, ParameterAttributes attr) const {
-  return ParamAttrs.paramHasAttr(i, attr);
-}
-
-/// @brief Extract the alignment for a call or parameter (0=unknown).
-uint16_t Function::getParamAlignment(uint16_t i) const {
-  return ParamAttrs.getParamAlignment(i);
-}
-
-/// @brief Determine if the function cannot return.
-bool Function::doesNotReturn() const {
-  return paramHasAttr(0, ParamAttr::NoReturn);
-}
-
-/// @brief Determine if the function cannot unwind.
-bool Function::doesNotThrow() const {
-  return paramHasAttr(0, ParamAttr::NoUnwind);
-}
-
-/// @brief Determine if the function does not access memory.
-bool Function::doesNotAccessMemory() const {
-  return paramHasAttr(0, ParamAttr::ReadNone);
-}
-
-/// @brief Determine if the function does not access or only reads memory.
-bool Function::onlyReadsMemory() const {
-  return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
-}
-
-/// @brief Determine if the function returns a structure through first 
-/// pointer argument.
-bool Function::hasStructRetAttr() const {
-  return paramHasAttr(1, ParamAttr::StructRet);
-}
-
 //===----------------------------------------------------------------------===//
 // Function Implementation
 //===----------------------------------------------------------------------===//

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=48326&r1=48325&r2=48326&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Thu Mar 13 00:00:21 2008
@@ -362,7 +362,7 @@
     OL[i].init(InOL[i], this);
 }
 
-bool CallInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const {
+bool CallInst::paramHasAttr(unsigned i, ParameterAttributes attr) const {
   if (ParamAttrs.paramHasAttr(i, attr))
     return true;
   if (const Function *F = getCalledFunction())
@@ -370,47 +370,6 @@
   return false;
 }
 
-uint16_t CallInst::getParamAlignment(uint16_t i) const {
-  return ParamAttrs.getParamAlignment(i);
-}
-
-/// @brief Determine if the call does not access memory.
-bool CallInst::doesNotAccessMemory() const {
-  return paramHasAttr(0, ParamAttr::ReadNone);
-}
-
-/// @brief Determine if the call does not access or only reads memory.
-bool CallInst::onlyReadsMemory() const {
-  return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
-}
-
-/// @brief Determine if the call cannot return.
-bool CallInst::doesNotReturn() const {
-  return paramHasAttr(0, ParamAttr::NoReturn);
-}
-
-/// @brief Determine if the call cannot unwind.
-bool CallInst::doesNotThrow() const {
-  return paramHasAttr(0, ParamAttr::NoUnwind);
-}
-
-/// @brief Determine if the call returns a structure through first 
-/// pointer argument.
-bool CallInst::hasStructRetAttr() const {
-  // Be friendly and also check the callee.
-  return paramHasAttr(1, ParamAttr::StructRet);
-}
-
-/// @brief Determine if any call argument is an aggregate passed by value.
-bool CallInst::hasByValArgument() const {
-  if (ParamAttrs.hasAttrSomewhere(ParamAttr::ByVal))
-    return true;
-  // Be consistent with other methods and check the callee too.
-  if (const Function *F = getCalledFunction())
-    return F->getParamAttrs().hasAttrSomewhere(ParamAttr::ByVal);
-  return false;
-}
-
 void CallInst::setDoesNotThrow(bool doesNotThrow) {
   PAListPtr PAL = getParamAttrs();
   if (doesNotThrow)
@@ -473,7 +432,7 @@
   return setSuccessor(idx, B);
 }
 
-bool InvokeInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const {
+bool InvokeInst::paramHasAttr(unsigned i, ParameterAttributes attr) const {
   if (ParamAttrs.paramHasAttr(i, attr))
     return true;
   if (const Function *F = getCalledFunction())
@@ -481,30 +440,6 @@
   return false;
 }
 
-uint16_t InvokeInst::getParamAlignment(uint16_t i) const {
-  return ParamAttrs.getParamAlignment(i);
-}
-
-/// @brief Determine if the call does not access memory.
-bool InvokeInst::doesNotAccessMemory() const {
-  return paramHasAttr(0, ParamAttr::ReadNone);
-}
-
-/// @brief Determine if the call does not access or only reads memory.
-bool InvokeInst::onlyReadsMemory() const {
-  return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
-}
-
-/// @brief Determine if the call cannot return.
-bool InvokeInst::doesNotReturn() const {
-  return paramHasAttr(0, ParamAttr::NoReturn);
-}
-
-/// @brief Determine if the call cannot unwind.
-bool InvokeInst::doesNotThrow() const {
-  return paramHasAttr(0, ParamAttr::NoUnwind);
-}
-
 void InvokeInst::setDoesNotThrow(bool doesNotThrow) {
   PAListPtr PAL = getParamAttrs();
   if (doesNotThrow)
@@ -514,13 +449,6 @@
   setParamAttrs(PAL);
 }
 
-/// @brief Determine if the invoke returns a structure through first 
-/// pointer argument.
-bool InvokeInst::hasStructRetAttr() const {
-  // Be friendly and also check the callee.
-  return paramHasAttr(1, ParamAttr::StructRet);
-}
-
 
 //===----------------------------------------------------------------------===//
 //                        ReturnInst Implementation





More information about the llvm-commits mailing list