[llvm-commits] [llvm] r47352 - in /llvm/trunk: include/llvm/ParameterAttributes.h lib/VMCore/ParameterAttributes.cpp
Dale Johannesen
dalej at apple.com
Tue Feb 19 15:51:49 PST 2008
Author: johannes
Date: Tue Feb 19 17:51:49 2008
New Revision: 47352
URL: http://llvm.org/viewvc/llvm-project?rev=47352&view=rev
Log:
Add Alignment field to ParameterAttributes and
treat more or less rationally in interface
functions, subject to change. No functional change.
Modified:
llvm/trunk/include/llvm/ParameterAttributes.h
llvm/trunk/lib/VMCore/ParameterAttributes.cpp
Modified: llvm/trunk/include/llvm/ParameterAttributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ParameterAttributes.h?rev=47352&r1=47351&r2=47352&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ParameterAttributes.h (original)
+++ llvm/trunk/include/llvm/ParameterAttributes.h Tue Feb 19 17:51:49 2008
@@ -47,6 +47,8 @@
const Attributes Nest = 1<<8; ///< Nested function static chain
const Attributes ReadNone = 1<<9; ///< Function does not access memory
const Attributes ReadOnly = 1<<10; ///< Function only reads from memory
+const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter (16 bits)
+ // 0 = unknown, else in clear (not log)
/// @brief Attributes that only apply to function parameters.
const Attributes ParameterOnly = ByVal | InReg | Nest | StructRet;
Modified: llvm/trunk/lib/VMCore/ParameterAttributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ParameterAttributes.cpp?rev=47352&r1=47351&r2=47352&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ParameterAttributes.cpp (original)
+++ llvm/trunk/lib/VMCore/ParameterAttributes.cpp Tue Feb 19 17:51:49 2008
@@ -14,6 +14,7 @@
#include "llvm/ParameterAttributes.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Support/ManagedStatic.h"
+#include <sstream>
using namespace llvm;
@@ -68,13 +69,20 @@
Result += "readnone ";
if (Attrs & ParamAttr::ReadOnly)
Result += "readonly ";
+ if (Attrs & ParamAttr::Alignment) {
+ std::stringstream s;
+ s << ((Attrs & ParamAttr::Alignment) >> 16);
+ Result += "align ";
+ Result += s.str();
+ Result += " ";
+ }
return Result;
}
void ParamAttrsList::Profile(FoldingSetNodeID &ID,
const ParamAttrsVector &Attrs) {
for (unsigned i = 0; i < Attrs.size(); ++i)
- ID.AddInteger(unsigned(Attrs[i].attrs) << 16 | unsigned(Attrs[i].index));
+ ID.AddInteger(uint64_t(Attrs[i].attrs) << 16 | unsigned(Attrs[i].index));
}
const ParamAttrsList *
@@ -173,6 +181,15 @@
uint16_t idx, ParameterAttributes attrs) {
ParameterAttributes OldAttrs = PAL ? PAL->getParamAttrs(idx) :
ParamAttr::None;
+#ifndef NDEBUG
+ // FIXME it is not obvious how this should work for alignment.
+ // For now, say we can't change a known alignment.
+ ParameterAttributes OldAlign = OldAttrs & ParamAttr::Alignment;
+ ParameterAttributes NewAlign = attrs & ParamAttr::Alignment;
+ assert(!OldAlign || !NewAlign || OldAlign == NewAlign &&
+ "Attempt to change alignment!");
+#endif
+
ParameterAttributes NewAttrs = OldAttrs | attrs;
if (NewAttrs == OldAttrs)
return PAL;
@@ -185,6 +202,11 @@
const ParamAttrsList *
ParamAttrsList::excludeAttrs(const ParamAttrsList *PAL,
uint16_t idx, ParameterAttributes attrs) {
+#ifndef NDEBUG
+ // FIXME it is not obvious how this should work for alignment.
+ // For now, say we can't pass in alignment, which no current use does.
+ assert(!(attrs & ParamAttr::Alignment) && "Attempt to exclude alignment!");
+#endif
ParameterAttributes OldAttrs = PAL ? PAL->getParamAttrs(idx) :
ParamAttr::None;
ParameterAttributes NewAttrs = OldAttrs & ~attrs;
More information about the llvm-commits
mailing list