paramter attributes and function types

everyone--

I'm confused about what I'm seeing in LLVM 2.6, and I have a series of related questions.

I can see how to apply attributes to function parameters and return values when defining and declaring functions, but I don't see how to do it for function type definitions. It's certainly absent from the OCaml bindings. I'm also not seeing it in the C-langauge bindings over which the OCaml bindings are a thin veneer. I'm not seeing obvious signs of it in the C++ headers.

Nevertheless, the LLVM Language Reference document suggests, in the examples for the Function Types section, that parameter attributes are part of function types.

q1. Am I missing something? Is there a way to apply attributes to parameters in function types?

q2. If not in LLVM 2.6, is this something already sorted out in the forthcoming LLVM 2.7 release?

q3. If not, is it something that *could* be sorted out in the forthcoming LLVM 2.7 release?

Hi James,

I can see how to apply attributes to function parameters and return values when defining and declaring functions, but I don't see how to do it for function type definitions.

you can't. It used to be the case long ago that attributes went on types, but
now they go only on calls and function declarations.

Nevertheless, the LLVM Language Reference document suggests, in the examples for the Function Types section, that parameter attributes are part of function types.

Where exactly? I don't see it in the online version.

q1. Am I missing something? Is there a way to apply attributes to parameters in function types?

No, there is no way.

q2. If not in LLVM 2.6, is this something already sorted out in the forthcoming LLVM 2.7 release?
q3. If not, is it something that *could* be sorted out in the forthcoming LLVM 2.7 release?

Not sure what you are asking here. If you are asking if parameter attributes
could be added back to function types, then the answer is no, they will not be
added back to function types. Maybe you should explain why you want that?

Ciao,

Duncan.

See <http://llvm.org/docs/LangRef.html#t_function&gt; and look at the second example:

  float (i16 signext, i32 *) *

  Pointer to a function that takes an i16 that should be sign extended
  and a pointer to i32, returning float.

Hence, my confusion over the issue. If parameter attributes aren't included in function types, then I'd like to know how to call a function through a pointer of the type in the example above. I must be failing still to comprehend an important concept in the language.

I'm sorry to pester about this, but I was really hoping somebody could straighten me out about this. The Language Reference really does seem to be ambiguous about this, and I'm willing to compose a patch to fix it, but I need to know what the document should actually say to match the code.

Should the reference document not be showing parameter attributes in function types? If that's the case, then how does one call a function through a pointer where, for example, one of the parameters is declared with the 'inreg' parameter attribute? I suppose the parameter attributes could be applied in the <function args> part of the 'call' instruction, but if that's the case, then *that* isn't clear from the documentation.

So, what is the correct form? Are parameter attributes part of function types, or are they just qualifiers to the function arguments at call sites and function declarations? Thanks for any help you guys can provide.

Where exactly? I don't see it in the online version.

See <LLVM Language Reference Manual — LLVM 18.0.0git documentation; and look at the second example:

  float \(i16 signext, i32 \*\) \*

  Pointer to a function that takes an i16 that should be sign extended
  and a pointer to i32, returning float\.

Hence, my confusion over the issue. If parameter attributes aren't included in function types, then I'd like to know how to call a function through a pointer of the type in the example above. I must be failing still to comprehend an important concept in the language.

I'm sorry to pester about this, but I was really hoping somebody could straighten me out about this. The Language Reference really does seem to be ambiguous about this, and I'm willing to compose a patch to fix it, but I need to know what the document should actually say to match the code.

Attributes, including signext, are not part of the type.

Should the reference document not be showing parameter attributes in function types? If that's the case, then how does one call a function through a pointer where, for example, one of the parameters is declared with the 'inreg' parameter attribute? I suppose the parameter attributes could be applied in the <function args> part of the 'call' instruction, but if that's the case, then *that* isn't clear from the documentation.

Attributes can be attached to function declarations and to calls. For
attributes like signext, the attribute needs to be attached to both to
work properly.

-Eli

Okay then. Here's a patch to trunk/docs/LangRef.html (revision 97549) that should help keep the next poor sod from getting confused.

llvm.patch (2.84 KB)

Applied in r97557, thanks!

Nevertheless, the LLVM Language Reference document suggests, in the examples for the Function Types section, that parameter attributes are part of function types.

Where exactly? I don't see it in the online version.

See<LLVM Language Reference Manual — LLVM 18.0.0git documentation; and look at the second example:

  float (i16 signext, i32 *) *

This has been removed.

Ciao,

Duncan.