SPARC Assembly Language Reference Manual

Exit Print View

Updated: July 2014
 
 

7.1.2 Layout of Code in Inline Templates

A single inline template file can define more than one inline templates. Each template definition starts with a declaration, and ends with an end statement:

.inline identifier
  ...assembler code...
.end

identifier is the name of the template function. Multiple template definitions with the same name can appear in the file, but the compiler will use only the first definition.

Since the template code will be inlined directly, without a call, into the code generated by the compiler, there is no need for a return instruction.

The template requires a prototype declaration in C/C++ source code to ensure that the compiler assigns correct types for all the parameters and recognizes the template name as a function.

For example, the following prototype declaration defines the template function:

void do_nothing();

And the associated template definition of this function might look like the following:

/* The do_nothing() template does nothing*/
.inline do_nothing,0
  nop
end

The inline template definition would appear in a separate .il file and would be compiled along with the source code file containing the call.