gcc: MIPS Function Attributes
1
1 6.31.18 MIPS Function Attributes
1 --------------------------------
1
1 These function attributes are supported by the MIPS back end:
1
1 'interrupt'
1 Use this attribute to indicate that the specified function is an
1 interrupt handler. The compiler generates function entry and exit
1 sequences suitable for use in an interrupt handler when this
1 attribute is present. An optional argument is supported for the
1 interrupt attribute which allows the interrupt mode to be
1 described. By default GCC assumes the external interrupt
1 controller (EIC) mode is in use, this can be explicitly set using
1 'eic'. When interrupts are non-masked then the requested Interrupt
1 Priority Level (IPL) is copied to the current IPL which has the
1 effect of only enabling higher priority interrupts. To use
1 vectored interrupt mode use the argument
1 'vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]', this will change the
1 behavior of the non-masked interrupt support and GCC will arrange
1 to mask all interrupts from sw0 up to and including the specified
1 interrupt vector.
1
1 You can use the following attributes to modify the behavior of an
1 interrupt handler:
1 'use_shadow_register_set'
1 Assume that the handler uses a shadow register set, instead of
1 the main general-purpose registers. An optional argument
1 'intstack' is supported to indicate that the shadow register
1 set contains a valid stack pointer.
1
1 'keep_interrupts_masked'
1 Keep interrupts masked for the whole function. Without this
1 attribute, GCC tries to reenable interrupts for as much of the
1 function as it can.
1
1 'use_debug_exception_return'
1 Return using the 'deret' instruction. Interrupt handlers that
1 don't have this attribute return using 'eret' instead.
1
1 You can use any combination of these attributes, as shown below:
1 void __attribute__ ((interrupt)) v0 ();
1 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
1 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
1 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
1 void __attribute__ ((interrupt, use_shadow_register_set,
1 keep_interrupts_masked)) v4 ();
1 void __attribute__ ((interrupt, use_shadow_register_set,
1 use_debug_exception_return)) v5 ();
1 void __attribute__ ((interrupt, keep_interrupts_masked,
1 use_debug_exception_return)) v6 ();
1 void __attribute__ ((interrupt, use_shadow_register_set,
1 keep_interrupts_masked,
1 use_debug_exception_return)) v7 ();
1 void __attribute__ ((interrupt("eic"))) v8 ();
1 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
1
1 'long_call'
1 'short_call'
1 'near'
1 'far'
1 These attributes specify how a particular function is called on
11 MIPS. The attributes override the '-mlong-calls' (⇒MIPS
Options) command-line switch. The 'long_call' and 'far'
1 attributes are synonyms, and cause the compiler to always call the
1 function by first loading its address into a register, and then
1 using the contents of that register. The 'short_call' and 'near'
1 attributes are synonyms, and have the opposite effect; they specify
1 that non-PIC calls should be made using the more efficient 'jal'
1 instruction.
1
1 'mips16'
1 'nomips16'
1
1 On MIPS targets, you can use the 'mips16' and 'nomips16' function
1 attributes to locally select or turn off MIPS16 code generation. A
1 function with the 'mips16' attribute is emitted as MIPS16 code,
1 while MIPS16 code generation is disabled for functions with the
1 'nomips16' attribute. These attributes override the '-mips16' and
1 '-mno-mips16' options on the command line (⇒MIPS Options).
1
1 When compiling files containing mixed MIPS16 and non-MIPS16 code,
1 the preprocessor symbol '__mips16' reflects the setting on the
1 command line, not that within individual functions. Mixed MIPS16
1 and non-MIPS16 code may interact badly with some GCC extensions
1 such as '__builtin_apply' (⇒Constructing Calls).
1
1 'micromips, MIPS'
1 'nomicromips, MIPS'
1
1 On MIPS targets, you can use the 'micromips' and 'nomicromips'
1 function attributes to locally select or turn off microMIPS code
1 generation. A function with the 'micromips' attribute is emitted
1 as microMIPS code, while microMIPS code generation is disabled for
1 functions with the 'nomicromips' attribute. These attributes
1 override the '-mmicromips' and '-mno-micromips' options on the
1 command line (⇒MIPS Options).
1
1 When compiling files containing mixed microMIPS and non-microMIPS
1 code, the preprocessor symbol '__mips_micromips' reflects the
1 setting on the command line, not that within individual functions.
1 Mixed microMIPS and non-microMIPS code may interact badly with some
11 GCC extensions such as '__builtin_apply' (⇒Constructing
Calls).
1
1 'nocompression'
1 On MIPS targets, you can use the 'nocompression' function attribute
1 to locally turn off MIPS16 and microMIPS code generation. This
1 attribute overrides the '-mips16' and '-mmicromips' options on the
1 command line (⇒MIPS Options).
1