Beispiel #1
0
        /// <inheritdoc/>
        public IEnumerable <AttributeValue> GetAttributesAtIndex(FunctionAttributeIndex index)
        {
            uint count = GetAttributeCountAtIndex(index);

            if (count == 0)
            {
                return(Enumerable.Empty <AttributeValue>( ));
            }

            var buffer = new LLVMAttributeRef[count];

            LLVMGetCallSiteAttributes(ValueHandle, ( LLVMAttributeIndex )index, buffer);
            return(from attribRef in buffer
                   select AttributeValue.FromHandle(Context, attribRef));
        }
Beispiel #2
0
        // looks up an attribute by it's handle, if none is found a new manaeged wrapper is created
        // The factory as a Func<> allows for the constructor to remain private so that the only
        // way to create an AttributeValue is via the containing context. This ensures that the
        // proper ownership is maintained. (LLVM has no method of retrieving the context that owns an attribute)
        internal AttributeValue GetAttributeFor(LLVMAttributeRef handle, Func <Context, LLVMAttributeRef, AttributeValue> factory)
        {
            if (handle.Pointer.IsNull( ))
            {
                return(default(AttributeValue));
            }

            if (AttributeValueCache.TryGetValue(handle.Pointer, out AttributeValue retVal))
            {
                return(retVal);
            }

            retVal = factory(this, handle);
            AttributeValueCache.Add(handle.Pointer, retVal);
            return(retVal);
        }
Beispiel #3
0
 private AttributeValue(Context context, LLVMAttributeRef nativeValue)
 {
     context.ValidateNotNull(nameof(context));
     Context         = context;
     NativeAttribute = nativeValue;
 }
Beispiel #4
0
 internal static AttributeValue FromHandle(Context context, LLVMAttributeRef handle)
 {
     return(context.GetAttributeFor(handle));
 }
Beispiel #5
0
        /*TODO:
         * public unsigned GetMDKindId(string name) {...}
         * public IEnumerable<string> MDKindNames { get; }
         *
         * public unsigned GetOperandBundleTagId(string name) {...}
         * public IEnumerable<string> OperandBundleTagIds { get; }
         *
         * public bool ODRUniqueDebugTypes { get; set; }
         *
         * public OptBisect OptBisec { get; set; }
         */

        // looks up an attribute by it's handle, if none is found a new managed wrapper is created
        // The factory as a Func<> allows for the constructor to remain private so that the only
        // way to create an AttributeValue is via the containing context. This ensures that the
        // proper ownership is maintained. (LLVM has no method of retrieving the context that owns an attribute)
        // TODO: move this to an attribute interning factory bound to the context
        internal AttributeValue GetAttributeFor(LLVMAttributeRef handle, Func <Context, LLVMAttributeRef, AttributeValue> factory)
        {
            factory.ValidateNotNull(nameof(factory));
            if (handle == default)
            {
                return(default);
 private AttributeValue(Context context, LLVMAttributeRef nativeValue)
 {
     this.Context         = context;
     this.NativeAttribute = nativeValue;
 }
Beispiel #7
0
 private AttributeValue(Context context, LLVMAttributeRef nativeValue)
 {
     context.VerifyAsArg(nameof(context));
     Context         = context;
     NativeAttribute = nativeValue;
 }