mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +00:00
Pass into the AttributeWithIndex::get method an ArrayRef of attribute
enums. These are then created via the correct Attributes creation method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165607 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
82d46aec62
commit
11d00420e4
@ -97,18 +97,6 @@ DECLARE_LLVM_ATTRIBUTE(AddressSafety,1ULL<<32) ///< Address safety checking is o
|
||||
|
||||
#undef DECLARE_LLVM_ATTRIBUTE
|
||||
|
||||
/// Note that uwtable is about the ABI or the user mandating an entry in the
|
||||
/// unwind table. The nounwind attribute is about an exception passing by the
|
||||
/// function.
|
||||
/// In a theoretical system that uses tables for profiling and sjlj for
|
||||
/// exceptions, they would be fully independent. In a normal system that
|
||||
/// uses tables for both, the semantics are:
|
||||
/// nil = Needs an entry because an exception might pass by.
|
||||
/// nounwind = No need for an entry
|
||||
/// uwtable = Needs an entry because the ABI says so and because
|
||||
/// an exception might pass by.
|
||||
/// uwtable + nounwind = Needs an entry because the ABI says so.
|
||||
|
||||
} // namespace Attribute
|
||||
|
||||
/// AttributeImpl - The internal representation of the Attributes class. This is
|
||||
@ -118,6 +106,20 @@ class AttributesImpl;
|
||||
/// Attributes - A bitset of attributes.
|
||||
class Attributes {
|
||||
public:
|
||||
/// Note that uwtable is about the ABI or the user mandating an entry in the
|
||||
/// unwind table. The nounwind attribute is about an exception passing by the
|
||||
/// function.
|
||||
///
|
||||
/// In a theoretical system that uses tables for profiling and sjlj for
|
||||
/// exceptions, they would be fully independent. In a normal system that uses
|
||||
/// tables for both, the semantics are:
|
||||
///
|
||||
/// nil = Needs an entry because an exception might pass by.
|
||||
/// nounwind = No need for an entry
|
||||
/// uwtable = Needs an entry because the ABI says so and because
|
||||
/// an exception might pass by.
|
||||
/// uwtable + nounwind = Needs an entry because the ABI says so.
|
||||
|
||||
enum AttrVal {
|
||||
None = 0, ///< No attributes have been set
|
||||
AddressSafety = 1, ///< Address safety checking is on.
|
||||
@ -375,6 +377,19 @@ struct AttributeWithIndex {
|
||||
///< Index 0 is used for return value attributes.
|
||||
///< Index ~0U is used for function attributes.
|
||||
|
||||
static AttributeWithIndex get(unsigned Idx,
|
||||
ArrayRef<Attributes::AttrVal> Attrs) {
|
||||
Attributes::Builder B;
|
||||
|
||||
for (ArrayRef<Attributes::AttrVal>::iterator I = Attrs.begin(),
|
||||
E = Attrs.end(); I != E; ++I)
|
||||
B.addAttribute(*I);
|
||||
|
||||
AttributeWithIndex P;
|
||||
P.Index = Idx;
|
||||
P.Attrs = Attributes::get(B);
|
||||
return P;
|
||||
}
|
||||
static AttributeWithIndex get(unsigned Idx, Attributes Attrs) {
|
||||
AttributeWithIndex P;
|
||||
P.Index = Idx;
|
||||
|
@ -277,9 +277,10 @@ public:
|
||||
bool doesNotAlias(unsigned n) const {
|
||||
return getParamAttributes(n).hasAttribute(Attributes::NoAlias);
|
||||
}
|
||||
void setDoesNotAlias(unsigned n, bool DoesNotAlias = true) {
|
||||
if (DoesNotAlias) addAttribute(n, Attribute::NoAlias);
|
||||
else removeAttribute(n, Attribute::NoAlias);
|
||||
void setDoesNotAlias(unsigned n) {
|
||||
Attributes::Builder B;
|
||||
B.addAttribute(Attributes::NoAlias);
|
||||
addAttribute(n, Attributes::get(B));
|
||||
}
|
||||
|
||||
/// @brief Determine if the parameter can be captured.
|
||||
@ -287,9 +288,10 @@ public:
|
||||
bool doesNotCapture(unsigned n) const {
|
||||
return getParamAttributes(n).hasAttribute(Attributes::NoCapture);
|
||||
}
|
||||
void setDoesNotCapture(unsigned n, bool DoesNotCapture = true) {
|
||||
if (DoesNotCapture) addAttribute(n, Attribute::NoCapture);
|
||||
else removeAttribute(n, Attribute::NoCapture);
|
||||
void setDoesNotCapture(unsigned n) {
|
||||
Attributes::Builder B;
|
||||
B.addAttribute(Attributes::NoCapture);
|
||||
addAttribute(n, Attributes::get(B));
|
||||
}
|
||||
|
||||
/// copyAttributesFrom - copy all additional attributes (those not needed to
|
||||
|
@ -41,9 +41,9 @@ Value *llvm::EmitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout *TD,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[2];
|
||||
AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::ReadOnly |
|
||||
Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||
AWI[1] = AttributeWithIndex::get(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Constant *StrLen = M->getOrInsertFunction("strlen", AttrListPtr::get(AWI),
|
||||
@ -67,9 +67,9 @@ Value *llvm::EmitStrNLen(Value *Ptr, Value *MaxLen, IRBuilder<> &B,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[2];
|
||||
AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::ReadOnly |
|
||||
Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||
AWI[1] = AttributeWithIndex::get(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Constant *StrNLen = M->getOrInsertFunction("strnlen", AttrListPtr::get(AWI),
|
||||
@ -93,8 +93,9 @@ Value *llvm::EmitStrChr(Value *Ptr, char C, IRBuilder<> &B,
|
||||
return 0;
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||
AttributeWithIndex AWI =
|
||||
AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind);
|
||||
AttributeWithIndex::get(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||
|
||||
Type *I8Ptr = B.getInt8PtrTy();
|
||||
Type *I32Ty = B.getInt32Ty();
|
||||
@ -116,10 +117,10 @@ Value *llvm::EmitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[3];
|
||||
AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(2, Attribute::NoCapture);
|
||||
AWI[2] = AttributeWithIndex::get(~0u, Attribute::ReadOnly |
|
||||
Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(2, Attributes::NoCapture);
|
||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||
AWI[2] = AttributeWithIndex::get(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Value *StrNCmp = M->getOrInsertFunction("strncmp", AttrListPtr::get(AWI),
|
||||
@ -146,8 +147,8 @@ Value *llvm::EmitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[2];
|
||||
AWI[0] = AttributeWithIndex::get(2, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(2, Attributes::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
||||
Type *I8Ptr = B.getInt8PtrTy();
|
||||
Value *StrCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
||||
I8Ptr, I8Ptr, I8Ptr, NULL);
|
||||
@ -168,8 +169,8 @@ Value *llvm::EmitStrNCpy(Value *Dst, Value *Src, Value *Len,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[2];
|
||||
AWI[0] = AttributeWithIndex::get(2, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(2, Attributes::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
||||
Type *I8Ptr = B.getInt8PtrTy();
|
||||
Value *StrNCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
||||
I8Ptr, I8Ptr, I8Ptr,
|
||||
@ -192,7 +193,7 @@ Value *llvm::EmitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI;
|
||||
AWI = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
AWI = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Value *MemCpy = M->getOrInsertFunction("__memcpy_chk",
|
||||
AttrListPtr::get(AWI),
|
||||
@ -219,7 +220,8 @@ Value *llvm::EmitMemChr(Value *Ptr, Value *Val,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI;
|
||||
AWI = AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind);
|
||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||
AWI = AttributeWithIndex::get(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(AWI),
|
||||
B.getInt8PtrTy(),
|
||||
@ -244,10 +246,10 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[3];
|
||||
AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(2, Attribute::NoCapture);
|
||||
AWI[2] = AttributeWithIndex::get(~0u, Attribute::ReadOnly |
|
||||
Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(2, Attributes::NoCapture);
|
||||
Attributes::AttrVal AVs[2] = { Attributes::ReadOnly, Attributes::NoUnwind };
|
||||
AWI[2] = AttributeWithIndex::get(~0u, ArrayRef<Attributes::AttrVal>(AVs, 2));
|
||||
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI),
|
||||
@ -323,8 +325,8 @@ Value *llvm::EmitPutS(Value *Str, IRBuilder<> &B, const DataLayout *TD,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[2];
|
||||
AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
||||
|
||||
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI),
|
||||
B.getInt32Ty(),
|
||||
@ -345,8 +347,8 @@ Value *llvm::EmitFPutC(Value *Char, Value *File, IRBuilder<> &B,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[2];
|
||||
AWI[0] = AttributeWithIndex::get(2, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(2, Attributes::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
||||
Constant *F;
|
||||
if (File->getType()->isPointerTy())
|
||||
F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI),
|
||||
@ -376,9 +378,9 @@ Value *llvm::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[3];
|
||||
AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(2, Attribute::NoCapture);
|
||||
AWI[2] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(2, Attributes::NoCapture);
|
||||
AWI[2] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
||||
StringRef FPutsName = TLI->getName(LibFunc::fputs);
|
||||
Constant *F;
|
||||
if (File->getType()->isPointerTy())
|
||||
@ -407,9 +409,9 @@ Value *llvm::EmitFWrite(Value *Ptr, Value *Size, Value *File,
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
AttributeWithIndex AWI[3];
|
||||
AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(4, Attribute::NoCapture);
|
||||
AWI[2] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
AWI[0] = AttributeWithIndex::get(1, Attributes::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(4, Attributes::NoCapture);
|
||||
AWI[2] = AttributeWithIndex::get(~0u, Attributes::NoUnwind);
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
StringRef FWriteName = TLI->getName(LibFunc::fwrite);
|
||||
Constant *F;
|
||||
|
@ -547,6 +547,7 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
|
||||
OS << " AttributeWithIndex AWI[" << maxArgAttrs+1 << "];\n";
|
||||
OS << " unsigned NumAttrs = 0;\n";
|
||||
OS << " if (id != 0) {\n";
|
||||
OS << " SmallVector<Attributes::AttrVal, 8> AttrVec;\n";
|
||||
OS << " switch(IntrinsicsToAttributesMap[id - ";
|
||||
if (TargetOnly)
|
||||
OS << "Intrinsic::num_intrinsics";
|
||||
@ -564,58 +565,49 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
|
||||
unsigned numAttrs = 0;
|
||||
|
||||
// The argument attributes are alreadys sorted by argument index.
|
||||
for (unsigned ai = 0, ae = intrinsic.ArgumentAttributes.size(); ai != ae;) {
|
||||
unsigned argNo = intrinsic.ArgumentAttributes[ai].first;
|
||||
unsigned ai = 0, ae = intrinsic.ArgumentAttributes.size();
|
||||
if (ae) {
|
||||
while (ai != ae) {
|
||||
unsigned argNo = intrinsic.ArgumentAttributes[ai].first;
|
||||
|
||||
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get("
|
||||
<< argNo+1 << ", ";
|
||||
OS << " AttrVec.clear();\n";
|
||||
|
||||
bool moreThanOne = false;
|
||||
do {
|
||||
switch (intrinsic.ArgumentAttributes[ai].second) {
|
||||
case CodeGenIntrinsic::NoCapture:
|
||||
OS << " AttrVec.push_back(Attributes::NoCapture);\n";
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
if (moreThanOne) OS << '|';
|
||||
++ai;
|
||||
} while (ai != ae && intrinsic.ArgumentAttributes[ai].first == argNo);
|
||||
|
||||
switch (intrinsic.ArgumentAttributes[ai].second) {
|
||||
case CodeGenIntrinsic::NoCapture:
|
||||
OS << "Attribute::NoCapture";
|
||||
break;
|
||||
}
|
||||
|
||||
++ai;
|
||||
moreThanOne = true;
|
||||
} while (ai != ae && intrinsic.ArgumentAttributes[ai].first == argNo);
|
||||
|
||||
OS << ");\n";
|
||||
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get("
|
||||
<< argNo+1 << ", AttrVec);\n";
|
||||
}
|
||||
}
|
||||
|
||||
ModRefKind modRef = getModRefKind(intrinsic);
|
||||
|
||||
if (!intrinsic.canThrow || modRef || intrinsic.isNoReturn) {
|
||||
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(~0, ";
|
||||
bool Emitted = false;
|
||||
if (!intrinsic.canThrow) {
|
||||
OS << "Attribute::NoUnwind";
|
||||
Emitted = true;
|
||||
}
|
||||
|
||||
if (intrinsic.isNoReturn) {
|
||||
if (Emitted) OS << '|';
|
||||
OS << "Attribute::NoReturn";
|
||||
Emitted = true;
|
||||
}
|
||||
OS << " AttrVec.clear();\n";
|
||||
|
||||
if (!intrinsic.canThrow)
|
||||
OS << " AttrVec.push_back(Attributes::NoUnwind);\n";
|
||||
if (intrinsic.isNoReturn)
|
||||
OS << " AttrVec.push_back(Attributes::NoReturn);\n";
|
||||
|
||||
switch (modRef) {
|
||||
case MRK_none: break;
|
||||
case MRK_readonly:
|
||||
if (Emitted) OS << '|';
|
||||
OS << "Attribute::ReadOnly";
|
||||
OS << " AttrVec.push_back(Attributes::ReadOnly);\n";
|
||||
break;
|
||||
case MRK_readnone:
|
||||
if (Emitted) OS << '|';
|
||||
OS << "Attribute::ReadNone";
|
||||
OS << " AttrVec.push_back(Attributes::ReadNone);\n";
|
||||
break;
|
||||
}
|
||||
OS << ");\n";
|
||||
OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(~0, "
|
||||
<< "AttrVec);\n";
|
||||
}
|
||||
|
||||
if (numAttrs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user