mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
Initial commit for the AttributesImpl class.
This opaque class will contain all of the attributes. All attribute queries will go through this object. This object will also be uniqued in the LLVMContext. Currently not used, so no implementation change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164722 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Attributes.h"
|
||||
#include "AttributesImpl.h"
|
||||
#include "LLVMContextImpl.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
@@ -109,6 +111,36 @@ Attributes Attributes::typeIncompatible(Type *Ty) {
|
||||
return Incompatible;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// AttributeImpl Definition
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Attributes::Attributes(AttributesImpl *A) : Bits(0) {}
|
||||
|
||||
Attributes Attributes::get(LLVMContext &Context, Attributes::Builder &B) {
|
||||
// If there are no attributes, return an empty Attributes class.
|
||||
if (B.Bits == 0)
|
||||
return Attributes();
|
||||
|
||||
// Otherwise, build a key to look up the existing attributes.
|
||||
LLVMContextImpl *pImpl = Context.pImpl;
|
||||
FoldingSetNodeID ID;
|
||||
ID.AddInteger(B.Bits);
|
||||
|
||||
void *InsertPoint;
|
||||
AttributesImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
|
||||
|
||||
if (!PA) {
|
||||
// If we didn't find any existing attributes of the same shape then create a
|
||||
// new one and insert it.
|
||||
PA = new AttributesImpl(B.Bits);
|
||||
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
|
||||
}
|
||||
|
||||
// Return the AttributesList that we found or created.
|
||||
return Attributes(PA);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// AttributeListImpl Definition
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Reference in New Issue
Block a user