[llvm-commits] [dragonegg] r165612 - in /dragonegg/trunk/src: Convert.cpp DefaultABI.cpp TypeConversion.cpp
Bill Wendling
isanbard at gmail.com
Wed Oct 10 00:55:26 PDT 2012
Author: void
Date: Wed Oct 10 02:55:26 2012
New Revision: 165612
URL: http://llvm.org/viewvc/llvm-project?rev=165612&view=rev
Log:
Attempt to convert dragonegg to the new Attributes syntax.
Modified:
dragonegg/trunk/src/Convert.cpp
dragonegg/trunk/src/DefaultABI.cpp
dragonegg/trunk/src/TypeConversion.cpp
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=165612&r1=165611&r2=165612&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed Oct 10 02:55:26 2012
@@ -3242,11 +3242,14 @@
PAL = cast<Function>(Callee)->getAttributes();
// Work out whether to use an invoke or an ordinary call.
- if (!stmt_could_throw_p(stmt))
+ if (!stmt_could_throw_p(stmt)) {
// This call does not throw - mark it 'nounwind'.
- PAL = PAL.addAttr(~0, Attribute::NoUnwind);
+ Attributes::Builder B;
+ B.addAttribute(Attributes::NoUnwind);
+ PAL = PAL.addAttr(~0, Attributes::get(B));
+ }
- if (!PAL.paramHasAttr(~0, Attribute::NoUnwind)) {
+ if (!PAL.getFnAttributes(~0).hasAttribute(Attributes::NoUnwind)) {
// This call may throw. Determine if we need to generate
// an invoke rather than a simple call.
LPadNo = lookup_stmt_eh_lp(stmt);
@@ -3333,13 +3336,13 @@
}
}
- Attributes Attrs = Attribute::None;
+ Attributes Attrs;
unsigned OldSize = CallOperands.size();
ABIConverter.HandleArgument(type, ScalarArgs, &Attrs);
- if (Attrs != Attribute::None) {
+ if (Attrs.hasAttributes()) {
// If the argument is split into multiple scalars, assign the
// attributes to all scalars of the aggregate.
for (unsigned j = OldSize + 1; j <= CallOperands.size(); ++j) {
@@ -5264,10 +5267,10 @@
PassedInMemory = true;
}
- Attributes Attrs = Attribute::None;
+ Attributes Attrs;
std::vector<Type*> ScalarArgs;
ABIConverter.HandleArgument(cplx_type, ScalarArgs, &Attrs);
- assert(Attrs == Attribute::None && "Got attributes but none given!");
+ assert(!Attrs.hasAttributes() && "Got attributes but none given!");
Client.clear();
// Create the call.
Modified: dragonegg/trunk/src/DefaultABI.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/DefaultABI.cpp?rev=165612&r1=165611&r2=165612&view=diff
==============================================================================
--- dragonegg/trunk/src/DefaultABI.cpp (original)
+++ dragonegg/trunk/src/DefaultABI.cpp Wed Oct 10 02:55:26 2012
@@ -214,9 +214,10 @@
} else if (LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(type)) {
C.HandleByValArgument(Ty, type);
if (Attributes) {
- *Attributes |= Attribute::ByVal;
- *Attributes |=
- Attributes::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type));
+ Attributes::Builder B;
+ B.addAttribute(Attributes::ByVal);
+ B.addAlignmentAttr(LLVM_BYVAL_ALIGNMENT(type));
+ *Attributes |= Attributes::get(B);
}
} else {
C.HandleScalarArgument(Ty, type);
@@ -240,17 +241,19 @@
else {
C.HandleByValArgument(Ty, type);
if (Attributes) {
- *Attributes |= Attribute::ByVal;
- *Attributes |=
- Attributes::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type));
+ Attributes::Builder B;
+ B.addAttribute(Attributes::ByVal);
+ B.addAlignmentAttr(LLVM_BYVAL_ALIGNMENT(type));
+ *Attributes |= Attributes::get(B);
}
}
} else if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) {
C.HandleByValArgument(Ty, type);
if (Attributes) {
- *Attributes |= Attribute::ByVal;
- *Attributes |=
- Attributes::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type));
+ Attributes::Builder B;
+ B.addAttribute(Attributes::ByVal);
+ B.addAlignmentAttr(LLVM_BYVAL_ALIGNMENT(type));
+ *Attributes |= Attributes::get(B);
}
} else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type, &Size,
&DontCheckAlignment)) {
Modified: dragonegg/trunk/src/TypeConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/TypeConversion.cpp?rev=165612&r1=165611&r2=165612&view=diff
==============================================================================
--- dragonegg/trunk/src/TypeConversion.cpp (original)
+++ dragonegg/trunk/src/TypeConversion.cpp Wed Oct 10 02:55:26 2012
@@ -643,16 +643,16 @@
static Attributes HandleArgumentExtension(tree ArgTy) {
if (isa<BOOLEAN_TYPE>(ArgTy)) {
if (TREE_INT_CST_LOW(TYPE_SIZE(ArgTy)) < INT_TYPE_SIZE)
- return Attribute::ZExt;
+ return Attributes::get(Attributes::Builder(Attributes::ZExt));
} else if (isa<INTEGER_TYPE>(ArgTy) &&
TREE_INT_CST_LOW(TYPE_SIZE(ArgTy)) < INT_TYPE_SIZE) {
if (TYPE_UNSIGNED(ArgTy))
- return Attribute::ZExt;
+ return Attributes::get(Attributes::Builder(Attributes::ZExt));
else
- return Attribute::SExt;
+ return Attributes::get(Attributes::Builder(Attributes::SExt));
}
- return Attribute::None;
+ return Attribute();
}
/// ConvertParamListToLLVMSignature - This method is used to build the argument
@@ -689,29 +689,35 @@
TARGET_ADJUST_LLVM_RETATTR(RAttributes, type);
#endif
- if (RAttributes != Attribute::None)
+ if (RAttributes.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(0, RAttributes));
// If this function returns via a shadow argument, the dest loc is passed
// in as a pointer. Mark that pointer as struct-ret and noalias.
- if (ABIConverter.isShadowReturn())
+ if (ABIConverter.isShadowReturn()) {
+ Attributes::Builder B;
+ B.addAttribute(Attributes::StructRet)
+ .addAttribute(Attributes::NoAlias);
Attrs.push_back(AttributeWithIndex::get(ArgTys.size(),
- Attribute::StructRet | Attribute::NoAlias));
+ Attributes::get(B)));
+ }
std::vector<Type*> ScalarArgs;
if (static_chain) {
// Pass the static chain as the first parameter.
ABIConverter.HandleArgument(TREE_TYPE(static_chain), ScalarArgs);
// Mark it as the chain argument.
+ Attributes::Builder B;
+ B.addAttribute(Attributes::Nest);
Attrs.push_back(AttributeWithIndex::get(ArgTys.size(),
- Attribute::Nest));
+ Attributes::get(B)));
}
for (ArrayRef<tree>::iterator I = Args.begin(), E = Args.end(); I != E; ++I) {
tree ArgTy = TREE_TYPE(*I);
// Determine if there are any attributes for this param.
- Attributes PAttributes = Attribute::None;
+ Attributes PAttributes;
ABIConverter.HandleArgument(ArgTy, ScalarArgs, &PAttributes);
@@ -719,10 +725,12 @@
PAttributes |= HandleArgumentExtension(ArgTy);
// Compute noalias attributes.
+ Attributes::Builder B;
if (isa<ACCESS_TYPE>(ArgTy) && TYPE_RESTRICT(ArgTy))
- PAttributes |= Attribute::NoAlias;
+ B.addAttribute(Attributes::NoAlias);
- if (PAttributes != Attribute::None)
+ PAttributes |= Attributes::get(B);
+ if (PAttributes.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(ArgTys.size(), PAttributes));
}
@@ -748,44 +756,46 @@
// Compute attributes for return type (and function attributes).
SmallVector<AttributeWithIndex, 8> Attrs;
- Attributes FnAttributes = Attribute::None;
+ Attributes::Builder FnAttributes;
int flags = flags_from_decl_or_type(decl ? decl : type);
// Check for 'readnone' and 'readonly' function attributes.
if (flags & ECF_CONST)
- FnAttributes |= Attribute::ReadNone;
+ FnAttributes.addAttribute(Attributes::ReadNone);
else if (flags & ECF_PURE)
- FnAttributes |= Attribute::ReadOnly;
+ FnAttributes.addAttribute(Attributes::ReadOnly);
// TODO: Handle ECF_LOOPING_CONST_OR_PURE
// Check for 'noreturn' function attribute.
if (flags & ECF_NORETURN)
- FnAttributes |= Attribute::NoReturn;
+ FnAttributes.addAttribute(Attributes::NoReturn);
// Check for 'nounwind' function attribute.
if (flags & ECF_NOTHROW)
- FnAttributes |= Attribute::NoUnwind;
+ FnAttributes.addAttribute(Attributes::NoUnwind);
// Check for 'returnstwice' function attribute.
if (flags & ECF_RETURNS_TWICE)
- FnAttributes |= Attribute::ReturnsTwice;
+ FnAttributes.addAttribute(Attributes::ReturnsTwice);
// Since they write the return value through a pointer,
// 'sret' functions cannot be 'readnone' or 'readonly'.
- if (ABIConverter.isShadowReturn())
- FnAttributes &= ~(Attribute::ReadNone|Attribute::ReadOnly);
+ if (ABIConverter.isShadowReturn()) {
+ FnAttributes.removeAttribute(Attributes::ReadNone)
+ .removeAttribute(Attributes::ReadOnly);
+ }
// Demote 'readnone' nested functions to 'readonly' since
// they may need to read through the static chain.
- if (static_chain && (FnAttributes & Attribute::ReadNone)) {
- FnAttributes &= ~Attribute::ReadNone;
- FnAttributes |= Attribute::ReadOnly;
+ if (static_chain && FnAttributes.hasAttribute(Attributes::ReadNone)) {
+ FnAttributes.removeAttribute(Attributes::ReadNone);
+ FnAttributes.addAttribute(Attributes::ReadOnly);
}
// Compute whether the result needs to be zext or sext'd.
- Attributes RAttributes = Attribute::None;
+ Attributes RAttributes;
RAttributes |= HandleArgumentExtension(TREE_TYPE(type));
// Allow the target to change the attributes.
@@ -795,24 +805,30 @@
// The value returned by a 'malloc' function does not alias anything.
if (flags & ECF_MALLOC)
- RAttributes |= Attribute::NoAlias;
+ RAttributes |= Attributes::get(Attributes::Builder(Attribute::NoAlias));
- if (RAttributes != Attribute::None)
+ if (RAttributes.hasAttributes())
Attrs.push_back(AttributeWithIndex::get(0, RAttributes));
// If this function returns via a shadow argument, the dest loc is passed
// in as a pointer. Mark that pointer as struct-ret and noalias.
- if (ABIConverter.isShadowReturn())
+ if (ABIConverter.isShadowReturn()) {
+ Attributes::Builder B;
+ B.addAttribute(Attributes::StructRet)
+ .addAttribute(Attributes::NoAlias);
Attrs.push_back(AttributeWithIndex::get(ArgTypes.size(),
- Attribute::StructRet | Attribute::NoAlias));
+ Attributes::get(B)));
+ }
std::vector<Type*> ScalarArgs;
if (static_chain) {
// Pass the static chain as the first parameter.
ABIConverter.HandleArgument(TREE_TYPE(static_chain), ScalarArgs);
// Mark it as the chain argument.
+ Attributes::Builder B;
+ B.addAttribute(Attributes::Nest);
Attrs.push_back(AttributeWithIndex::get(ArgTypes.size(),
- Attribute::Nest));
+ Attributes::get(B)));
}
#ifdef LLVM_TARGET_ENABLE_REGPARM
@@ -848,7 +864,7 @@
}
// Determine if there are any attributes for this param.
- Attributes PAttributes = Attribute::None;
+ Attributes PAttributes;
unsigned OldSize = ArgTypes.size();
@@ -862,7 +878,7 @@
// types.
tree RestrictArgTy = (DeclArgs) ? TREE_TYPE(DeclArgs) : ArgTy;
if (isa<ACCESS_TYPE>(RestrictArgTy) && TYPE_RESTRICT(RestrictArgTy))
- PAttributes |= Attribute::NoAlias;
+ PAttributes |= Attributes::get(Attributes::Builder(Attributes::NoAlias));
#ifdef LLVM_TARGET_ENABLE_REGPARM
// Allow the target to mark this as inreg.
@@ -873,8 +889,8 @@
local_regparam, local_fp_regparam);
#endif // LLVM_TARGET_ENABLE_REGPARM
- if (PAttributes != Attribute::None) {
- HasByVal |= (PAttributes & Attribute::ByVal) != Attribute::None;
+ if (PAttributes.hasAttributes()) {
+ HasByVal |= PAttributes.hasAttribute(Attributes::ByVal);
// If the argument is split into multiple scalars, assign the
// attributes to all scalars of the aggregate.
@@ -892,13 +908,14 @@
// write to struct arguments passed by value, but in LLVM this becomes a
// write through the byval pointer argument, which LLVM does not allow for
// readonly/readnone functions.
- if (HasByVal)
- FnAttributes &= ~(Attribute::ReadNone | Attribute::ReadOnly);
+ if (HasByVal) {
+ FnAttributes.removeAttribute(Attributes::ReadNone)
+ .removeAttribute(Attributes::ReadOnly);
assert(RetTy && "Return type not specified!");
- if (FnAttributes != Attribute::None)
- Attrs.push_back(AttributeWithIndex::get(~0, FnAttributes));
+ if (FnAttributes.hasAttribute())
+ Attrs.push_back(AttributeWithIndex::get(~0, Attributes::get(FnAttributes)));
// Finally, make the function type and result attributes.
PAL = AttrListPtr::get(Attrs);
More information about the llvm-commits
mailing list