Next: , Up: Submodel Options


3.17.1 Altera Nios II Options

These are the `-m' options defined for the Altera Nios II processor.

-msmallc
Link with a limited version of the C library, -lsmallc. For more information see the C Library Documentation.
-mbypass-cache
-mno-bypass-cache
Force all load and store instructions to always bypass cache by using io variants of the instructions. The default is to not bypass the cache.
-mno-cache-volatile
-mcache-volatile
Volatile memory access bypass the cache using the io variants of the ld and st instructions. The default is to cache volatile accesses.

-mno-cache-volatile is deprecated and will be deleted in a future GCC release.

-mno-inline-memcpy
-minline-memcpy
Do not inline memcpy. The default is to inline when -O is on.
-mno-fast-sw-div
-mfast-sw-div
Do no use table based fast divide for small numbers. The default is to use the fast divide at -O3 and above.
-mno-hw-mul
-mhw-mul
-mno-hw-mulx
-mhw-mulx
-mno-hw-div
-mhw-div
Enable or disable emitting mul, mulx and div family of instructions by the compiler. The default is to emit mul and not emit div and mulx.

The different combinations of mul and mulx instructions generate a different multilib options.

-mno-stack-check
-mstack-check
Enables or disables the checking for sufficient memory when items are pushed onto the stack. A checked and non-checked version of each of the multilibs is provided.
-msys-crt0=startfile
startfile is the file name of the startfile (crt0) to use when linking. The default is crt0.o that comes with libgloss and is only suitable for use with the instruction set simulator.
-msys-lib=systemlib
-msys-lib=nosys
systemlib is the library name of the library which provides the system calls required by the C library, e.g. read, write etc. The default is to use nosys, this library provides stub implementations of the calls and is part of libgloss.
-mno-reverse-bitfields
-mreverse-bitfields
When enabled, bitfields within a struct are allocated in reverse order. This is useful with legacy code that depends on the (inherently non-portable) ordering of bitfields via a union. Given:
          struct inner
          {
            unsigned int a:1;
            unsigned int b:31;
          };
          
          union outer
          {
            struct inner inner;
            unsigned int val;
          };
          
          unsigned int f()
          {
            union outer o;
            o.inner.a = 1;
            o.inner.b = 0;
            return o.val;
          }
     

a call to f will return 1 when compiled with -mno-reverse-bitfields (the default), or 2147483648 when compiled with -mreverse-bitfields.

For structures that are a multiple of 32 bits wide, the reversal is done 32 bits at a time. For structures that are an odd multiple of 16 bits wide, the reversal is done 16 bits at a time. For structures that are an odd multiple of 8 bits wide, the reversal is done 8 bits at a time. The size of a structure (as measured by the sizeof operator) never changes between -mno-reverse-bitfields and -mreverse-bitfields. Nonetheless, there can be some confusing corner cases with structs where the compiler has to add additional padding to meet alignment restrictions. Consider:

          struct inner
          {
            unsigned int a:1;
            unsigned int b:15;
          };
          
          union outer
          {
            struct inner inner;
            unsigned int val;
          };
          
          unsigned int f()
          {
            union outer o;
            o.val = 0;
            o.inner.b = 1;
            return o.val;
          }
     

a call to f will return 2 when compiled with -mno-reverse-bitfields (the default), or 65536 when compiled with -mreverse-bitfields. This is because sizeof (inner) is 4 in both cases. In the -mno-reverse-bitfields case, the compiler pads the struct at the end to be 4 bytes long, effectively doing:

          struct inner
          {
            unsigned int a:1;
            unsigned int b:15;
            unsigned int padding:16;
          };
     

In the -mreverse-bitfields case, the hidden padding is reversed along with everything else, yielding the equivalent of:

          struct inner
          {
            unsigned int padding:16;
            unsigned int b:15;
            unsigned int a:1;
          };
     

Of course, if we would rather that sizeof (inner) was 2, we could write the struct as:

          struct inner
          {
            unsigned short a:1;
            unsigned short b:15;
          };
     

and the padding would go away.

In some cases, especially when using the __packed__ attribute, there is no well-defined bit reversal that is possible: the compiler will issue an error message in this case. Consider:

          struct invalid
          {
            unsigned int f1:1;
            unsigned int f2:15;
            unsigned int f3:4;
            unsigned int f4:4;
          } __attribute__ ((__packed__));
     

Since sizeof (invalid) is 3, we are forced to try reversing individual bytes in the struct. But f2 is more than a byte wide, so we can't reverse it and still have it be contiguous. Similar cases occur when dealing with arrays or other large contiguous objects:

          struct invalid2
          {
            unsigned char f1[5];
            unsigned char f2[3];
          };
     

You'll have to rewrite the affected structs to say exactly what you mean in odd cases like that.

Finally, note that individual fields are sized as a whole. The structs

          struct array1
          {
            unsigned char f1[3];
            unsigned char f2;
          }
     

and:

          struct array2
          {
            unsigned char f1a;
            unsigned char f1b;
            unsigned char f1c;
            unsigned char f2;
          }
     

are not equivalent. When compiled with -mreverse-bitfields, they behave the same as:

          struct array1r
          {
            unsigned char f2;
            unsigned char f1[3];
          }
     

and:

          struct array2r
          {
            unsigned char f2;
            unsigned char f1c;
            unsigned char f1b;
            unsigned char f1a;
          }
     

would, respectively, when compiled with -mno-reverse-bitfields. In particular, f1 is treated as a single contiguous 24-bit object for purposes of reversal, while f1a, f1b, and f1c are treated as individual 8-bit objects that need not (and do not) remain contiguous. Use caution.