How to understand this function declaration: void ne10_fir_float_neon(const ne10_fir_instance_f32_t

F

fl

Hi,
I am using an ARM NEON library, which has several similar function declaration:

void ne10_fir_float_neon (const ne10_fir_instance_f32_t *S, ne10_float32_t *pSrc, ne10_float32_t *pDst, ne10_uint32_t blockSize) asm("ne10_fir_float_neon")

"ne10_fir_float_neon" shows two times above. I cannot understand it. Could you explain it to me?


Thanks,
 
B

BartC

fl said:
Hi,
I am using an ARM NEON library, which has several similar function
declaration:

void ne10_fir_float_neon (const ne10_fir_instance_f32_t *S, ne10_float32_t
*pSrc, ne10_float32_t *pDst, ne10_uint32_t blockSize)
asm("ne10_fir_float_neon")

"ne10_fir_float_neon" shows two times above. I cannot understand it. Could
you explain it to me?

It's just a standard function definition that takes four parameters. The asm
bit at the end looks odd though, especially as it's not in {...} braces. The
name inside is presumably a macro or perhaps even an instruction.

But, are you using the right version of this library? The only reference I
found mentions also this other version:

void ne10_fir_float_c (const ne10_fir_instance_f32_t *S, ne10_float32_t
*pSrc, ne10_float32_t *pDst, ne10_uint32_t blockSize)

which is conventional C, and there's even a link to its definition (no asm
in sight). (http://projectne10.github.io/Ne10/doc/group__FIR.html)
 
E

Eric Sosman

Note, that while the asm keyword is reserved in the standard, and a
syntax defined for its use, what it does and how it does it is
implementation defined.

Nitpick: The Standard does not define `asm' as a keyword (see
6.4.1p1) or as a reserved identifier (7.1.3, K.3.1.2), nor does it
define any particular syntax.

The only mention of `asm' in the C11 draft I have (N1570) is
in J.5.10. Appendix J is marked as "informative" rather than as
"normative," so nothing therein is binding on any implementation.
Section J.5 is titled "Common extensions," and J.5.10 merely
describes "the most common" form an `asm' extension takes in those
(non-conforming, see 7.1.3p2 and J.5p1) implementations that provide
one; this is some ways short of defining a syntax.
[...] You would need to
read the documentation for your compiler to find out what it really means.

Right, because the C language says nothing about any meaning
it might have -- in short, it's not C.
 
K

Keith Thompson

Richard Damon said:
Note, that while the asm keyword is reserved in the standard, and a
syntax defined for its use, what it does and how it does it is
implementation defined.

No, the asm keyword is not reserved.

The only mention of it in the lastest standard is in Annex J,
"Common extensions":

The asm keyword may be used to insert assembly language directly
into the translator output (6.8). The most common implementation
is via a statement of the form:

asm (character-string-literal );

The introduction to that section says:

The following extensions are widely used in many systems, but
are not portable to all implementations. The inclusion of any
extension that may cause a strictly conforming program to become
invalid renders an implementation nonconforming. Examples of
such extensions are new keywords, [SNIP]

So a conforming implementation *cannot* treat "asm" as a keyword,
unless it does so in a carefully limited way (for example,
recognizing it only in a context where a non-reserved identifier
would not be allowed).
 
K

Keith Thompson

fl said:
I am using an ARM NEON library, which has several similar function declaration:

void ne10_fir_float_neon (const ne10_fir_instance_f32_t *S, ne10_float32_t *pSrc, ne10_float32_t *pDst, ne10_uint32_t blockSize) asm("ne10_fir_float_neon")

"ne10_fir_float_neon" shows two times above. I cannot understand it. Could you explain it to me?

It's helpful to format your posts here so the text doesn't exceed about
72 columns. I know that a lot of forums don't use explicit line breaks;
this one does.

Reformatting your code for better readability:

void ne10_fir_float_neon
(const ne10_fir_instance_f32_t *S,
ne10_float32_t *pSrc,
ne10_float32_t *pDst,
ne10_uint32_t blockSize)
asm("ne10_fir_float_neon")

The first part of that is an ordinary function declaration, possibly the
initial part of a function *definition*. (A definition would normally
have the code that implements the function enclosed in { and }.)
Presumably the types ne10_fir_instance_f32_t, ne10_float32_t, and
ne10_uint32_ are defined elsewhere.

The last line is non-standard, but it's not uncommon for C compilers to
treat "asm" as an additional keyword that specifies inline assembly
language. My best guess is that

asm("ne10_fir_float_neon")

is a directive specifying that that function is defined elsewhere in
assembly language, but you'll have to consult your compiler's
documentation to find out exactly what it means.

(Are you by any chance missing a semicolon or two?)
 
J

James Kuyper

Hi,
I am using an ARM NEON library, which has several similar function declaration:

void ne10_fir_float_neon (const ne10_fir_instance_f32_t *S, ne10_float32_t *pSrc, ne10_float32_t *pDst, ne10_uint32_t blockSize) asm("ne10_fir_float_neon")

"ne10_fir_float_neon" shows two times above. I cannot understand it. Could you explain it to me?

No one has directly addressed the main issue you were raising, the two
different occurrences of ne10_fir_float_neon in that code. The first
occurrence simply provides the name for the function being declared. If
'asm' is a macro, then the second occurrence is simply a string literal,
and you'll need to find out how asm is #defined in order to determine
what the significance of that string literal is. It's more likely,
however, that 'asm' is the keyword that implements a non-standard
extension to C; in that case, "ne10_fir_float_neon" might or might not
be a string literal - the quote marks might simply be part of the syntax
associated with the asm keyword. You'll need to find which compiler that
code was intended to be compiled by, and look at that compiler's
documentation to find out what 'asm' will do with "ne10_fir_float_neon".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top