Exemple #1
0
        /// <summary>Creates an attribute with an integer value parameter</summary>
        /// <param name="kind">The kind of attribute</param>
        /// <param name="value">Value for the attribute</param>
        /// <remarks>
        /// <para>Not all attributes support a value and those that do don't all support
        /// a full 64bit value. The following table provides the kinds of attributes
        /// accepting a value and the allowed size of the values.</para>
        /// <list type="table">
        /// <listheader><term><see cref="AttributeKind"/></term><term>Bit Length</term></listheader>
        /// <item><term><see cref="AttributeKind.Alignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.StackAlignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.Dereferenceable"/></term><term>64</term></item>
        /// <item><term><see cref="AttributeKind.DereferenceableOrNull"/></term><term>64</term></item>
        /// </list>
        /// </remarks>
        public AttributeValue CreateAttribute(AttributeKind kind, UInt64 value)
        {
            var handle = NativeMethods.CreateEnumAttribute(ContextHandle
                                                           , kind.GetEnumAttributeId( )
                                                           , value
                                                           );

            return(AttributeValue.FromHandle(this, handle));
        }
Exemple #2
0
        /// <summary>Creates an attribute with an integer value parameter</summary>
        /// <param name="kind">The kind of attribute</param>
        /// <param name="value">Value for the attribute</param>
        /// <remarks>
        /// <para>Not all attributes support a value and those that do don't all support
        /// a full 64bit value. The following table provides the kinds of attributes
        /// accepting a value and the allowed size of the values.</para>
        /// <list type="table">
        /// <listheader><term><see cref="AttributeKind"/></term><term>Bit Length</term></listheader>
        /// <item><term><see cref="AttributeKind.Alignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.StackAlignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.Dereferenceable"/></term><term>64</term></item>
        /// <item><term><see cref="AttributeKind.DereferenceableOrNull"/></term><term>64</term></item>
        /// </list>
        /// </remarks>
        /// <returns><see cref="AttributeValue"/> with the specified kind and value</returns>
        public AttributeValue CreateAttribute(AttributeKind kind, UInt64 value)
        {
            kind.ValidateDefined(nameof(kind));
            if (!kind.RequiresIntValue( ))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Attribute_0_does_not_support_a_value, kind), nameof(kind));
            }

            var handle = LLVMCreateEnumAttribute(ContextHandle
                                                 , kind.GetEnumAttributeId( )
                                                 , value
                                                 );

            return(AttributeValue.FromHandle(this, handle));
        }
Exemple #3
0
        /// <summary>Creates an attribute with an integer value parameter</summary>
        /// <param name="kind">The kind of attribute</param>
        /// <param name="value">Value for the attribute</param>
        /// <remarks>
        /// <para>Not all attributes support a value and those that do don't all support
        /// a full 64bit value. The following table provides the kinds of attributes
        /// accepting a value and the allowed size of the values.</para>
        /// <list type="table">
        /// <listheader><term><see cref="AttributeKind"/></term><term>Bit Length</term></listheader>
        /// <item><term><see cref="AttributeKind.Alignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.StackAlignment"/></term><term>32</term></item>
        /// <item><term><see cref="AttributeKind.Dereferenceable"/></term><term>64</term></item>
        /// <item><term><see cref="AttributeKind.DereferenceableOrNull"/></term><term>64</term></item>
        /// </list>
        /// </remarks>
        /// <returns><see cref="AttributeValue"/> with the specified kind and value</returns>
        public AttributeValue CreateAttribute(AttributeKind kind, UInt64 value)
        {
            kind.ValidateDefined(nameof(kind));
            if (!kind.RequiresIntValue( ))
            {
                throw new ArgumentException($"Attribute {kind} does not support a value", nameof(kind));
            }

            var handle = LLVMCreateEnumAttribute(ContextHandle
                                                 , kind.GetEnumAttributeId( )
                                                 , value
                                                 );

            return(AttributeValue.FromHandle(this, handle));
        }
Exemple #4
0
 /// <inheritdoc/>
 public void RemoveAttributeAtIndex(FunctionAttributeIndex index, AttributeKind kind)
 {
     LLVMRemoveCallSiteEnumAttribute(ValueHandle, ( LLVMAttributeIndex )index, kind.GetEnumAttributeId( ));
 }
Exemple #5
0
        /// <inheritdoc/>
        public AttributeValue GetAttributeAtIndex(FunctionAttributeIndex index, AttributeKind kind)
        {
            var handle = LLVMGetCallSiteEnumAttribute(ValueHandle, ( LLVMAttributeIndex )index, kind.GetEnumAttributeId( ));

            return(AttributeValue.FromHandle(Context, handle));
        }