Next: M680x0 Options, Up: Submodel Options
These are the `-m' options defined for the Altera Nios II processor.
-msmallc
-mbypass-cache
-mno-bypass-cache
-mno-cache-volatile
-mcache-volatile
-mno-cache-volatile is deprecated and will be deleted in a
future GCC release.
-mno-inline-memcpy
-minline-memcpy
-mno-fast-sw-div
-mfast-sw-div
-mno-hw-mul
-mhw-mul
-mno-hw-mulx
-mhw-mulx
-mno-hw-div
-mhw-div
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
-msys-crt0=
startfile-msys-lib=
systemlib-msys-lib=nosys
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
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.