xref: /netbsd-src/external/gpl3/binutils.old/dist/gas/doc/c-m32r.texi (revision e992f068c547fd6e84b3f104dc2340adcc955732)
1*e992f068Schristos@c Copyright (C) 1991-2022 Free Software Foundation, Inc.
216dce513Schristos@c This is part of the GAS manual.
316dce513Schristos@c For copying conditions, see the file as.texinfo.
416dce513Schristos@ifset GENERIC
516dce513Schristos@page
616dce513Schristos@node M32R-Dependent
716dce513Schristos@chapter M32R Dependent Features
816dce513Schristos@end ifset
916dce513Schristos@ifclear GENERIC
1016dce513Schristos@node Machine Dependencies
1116dce513Schristos@chapter M32R Dependent Features
1216dce513Schristos@end ifclear
1316dce513Schristos
1416dce513Schristos@cindex M32R support
1516dce513Schristos@menu
1616dce513Schristos* M32R-Opts::                   M32R Options
1716dce513Schristos* M32R-Directives::             M32R Directives
1816dce513Schristos* M32R-Warnings::               M32R Warnings
1916dce513Schristos@end menu
2016dce513Schristos
2116dce513Schristos@node M32R-Opts
2216dce513Schristos@section M32R Options
2316dce513Schristos
2416dce513Schristos@cindex options, M32R
2516dce513Schristos@cindex M32R options
2616dce513Schristos
27ede78133SchristosThe Renesas M32R version of @code{@value{AS}} has a few machine
2816dce513Schristosdependent options:
2916dce513Schristos
3016dce513Schristos@table @code
3116dce513Schristos
3216dce513Schristos@item -m32rx
3316dce513Schristos@cindex @samp{-m32rx} option, M32RX
3416dce513Schristos@cindex architecture options, M32RX
3516dce513Schristos@cindex M32R architecture options
3616dce513Schristos@code{@value{AS}} can assemble code for several different members of the
3716dce513SchristosRenesas M32R family.  Normally the default is to assemble code for
3816dce513Schristosthe M32R microprocessor.  This option may be used to change the default
3916dce513Schristosto the M32RX microprocessor, which adds some more instructions to the
4016dce513Schristosbasic M32R instruction set, and some additional parameters to some of
4116dce513Schristosthe original instructions.
4216dce513Schristos
4316dce513Schristos@item -m32r2
4416dce513Schristos@cindex @samp{-m32rx} option, M32R2
4516dce513Schristos@cindex architecture options, M32R2
4616dce513Schristos@cindex M32R architecture options
4716dce513SchristosThis option changes the target processor to the M32R2
4816dce513Schristosmicroprocessor.
4916dce513Schristos
5016dce513Schristos@item -m32r
5116dce513Schristos@cindex @samp{-m32r} option, M32R
5216dce513Schristos@cindex architecture options, M32R
5316dce513Schristos@cindex M32R architecture options
5416dce513SchristosThis option can be used to restore the assembler's default behaviour of
5516dce513Schristosassembling for the M32R microprocessor.  This can be useful if the
56012573ebSchristosdefault has been changed by a previous command-line option.
5716dce513Schristos
5816dce513Schristos@item -little
5916dce513Schristos@cindex @code{-little} option, M32R
6016dce513SchristosThis option tells the assembler to produce little-endian code and
6116dce513Schristosdata.  The default is dependent upon how the toolchain was
6216dce513Schristosconfigured.
6316dce513Schristos
6416dce513Schristos@item -EL
6516dce513Schristos@cindex @code{-EL} option, M32R
6616dce513SchristosThis is a synonym for @emph{-little}.
6716dce513Schristos
6816dce513Schristos@item -big
6916dce513Schristos@cindex @code{-big} option, M32R
7016dce513SchristosThis option tells the assembler to produce big-endian code and
7116dce513Schristosdata.
7216dce513Schristos
7316dce513Schristos@item -EB
7416dce513Schristos@cindex @code{-EB} option, M32R
75ede78133SchristosThis is a synonym for @emph{-big}.
7616dce513Schristos
7716dce513Schristos@item -KPIC
7816dce513Schristos@cindex @code{-KPIC} option, M32R
7916dce513Schristos@cindex PIC code generation for M32R
8016dce513SchristosThis option specifies that the output of the assembler should be
8116dce513Schristosmarked as position-independent code (PIC).
8216dce513Schristos
8316dce513Schristos@item -parallel
8416dce513Schristos@cindex @code{-parallel} option, M32RX
8516dce513SchristosThis option tells the assembler to attempts to combine two sequential
8616dce513Schristosinstructions into a single, parallel instruction, where it is legal to
8716dce513Schristosdo so.
8816dce513Schristos
8916dce513Schristos@item -no-parallel
9016dce513Schristos@cindex @code{-no-parallel} option, M32RX
9116dce513SchristosThis option disables a previously enabled @emph{-parallel} option.
9216dce513Schristos
9316dce513Schristos@item -no-bitinst
9416dce513Schristos@cindex @samp{-no-bitinst}, M32R2
9516dce513SchristosThis option disables the support for the extended bit-field
9616dce513Schristosinstructions provided by the M32R2.  If this support needs to be
9716dce513Schristosre-enabled the @emph{-bitinst} switch can be used to restore it.
9816dce513Schristos
9916dce513Schristos@item -O
10016dce513Schristos@cindex @code{-O} option, M32RX
10116dce513SchristosThis option tells the assembler to attempt to optimize the
10216dce513Schristosinstructions that it produces.  This includes filling delay slots and
10316dce513Schristosconverting sequential instructions into parallel ones.  This option
10416dce513Schristosimplies @emph{-parallel}.
10516dce513Schristos
10616dce513Schristos@item -warn-explicit-parallel-conflicts
10716dce513Schristos@cindex @samp{-warn-explicit-parallel-conflicts} option, M32RX
10816dce513SchristosInstructs @code{@value{AS}} to produce warning messages when
10916dce513Schristosquestionable parallel instructions are encountered.  This option is
11016dce513Schristosenabled by default, but @code{@value{GCC}} disables it when it invokes
11116dce513Schristos@code{@value{AS}} directly.  Questionable instructions are those whose
11216dce513Schristosbehaviour would be different if they were executed sequentially.  For
11316dce513Schristosexample the code fragment @samp{mv r1, r2 || mv r3, r1} produces a
11416dce513Schristosdifferent result from @samp{mv r1, r2 \n mv r3, r1} since the former
11516dce513Schristosmoves r1 into r3 and then r2 into r1, whereas the later moves r2 into r1
11616dce513Schristosand r3.
11716dce513Schristos
11816dce513Schristos@item -Wp
11916dce513Schristos@cindex @samp{-Wp} option, M32RX
12016dce513SchristosThis is a shorter synonym for the @emph{-warn-explicit-parallel-conflicts}
12116dce513Schristosoption.
12216dce513Schristos
12316dce513Schristos@item -no-warn-explicit-parallel-conflicts
12416dce513Schristos@cindex @samp{-no-warn-explicit-parallel-conflicts} option, M32RX
12516dce513SchristosInstructs @code{@value{AS}} not to produce warning messages when
12616dce513Schristosquestionable parallel instructions are encountered.
12716dce513Schristos
12816dce513Schristos@item -Wnp
12916dce513Schristos@cindex @samp{-Wnp} option, M32RX
13016dce513SchristosThis is a shorter synonym for the @emph{-no-warn-explicit-parallel-conflicts}
13116dce513Schristosoption.
13216dce513Schristos
13316dce513Schristos@item -ignore-parallel-conflicts
13416dce513Schristos@cindex @samp{-ignore-parallel-conflicts} option, M32RX
13516dce513SchristosThis option tells the assembler's to stop checking parallel
13616dce513Schristosinstructions for constraint violations.  This ability is provided for
13716dce513Schristoshardware vendors testing chip designs and should not be used under
13816dce513Schristosnormal circumstances.
13916dce513Schristos
14016dce513Schristos@item -no-ignore-parallel-conflicts
14116dce513Schristos@cindex @samp{-no-ignore-parallel-conflicts} option, M32RX
14216dce513SchristosThis option restores the assembler's default behaviour of checking
14316dce513Schristosparallel instructions to detect constraint violations.
14416dce513Schristos
14516dce513Schristos@item -Ip
14616dce513Schristos@cindex @samp{-Ip} option, M32RX
14716dce513SchristosThis is a shorter synonym for the @emph{-ignore-parallel-conflicts}
14816dce513Schristosoption.
14916dce513Schristos
15016dce513Schristos@item -nIp
15116dce513Schristos@cindex @samp{-nIp} option, M32RX
15216dce513SchristosThis is a shorter synonym for the @emph{-no-ignore-parallel-conflicts}
15316dce513Schristosoption.
15416dce513Schristos
15516dce513Schristos@item -warn-unmatched-high
15616dce513Schristos@cindex @samp{-warn-unmatched-high} option, M32R
15716dce513SchristosThis option tells the assembler to produce a warning message if a
15816dce513Schristos@code{.high} pseudo op is encountered without a matching @code{.low}
15916dce513Schristospseudo op.  The presence of such an unmatched pseudo op usually
16016dce513Schristosindicates a programming error.
16116dce513Schristos
16216dce513Schristos@item -no-warn-unmatched-high
16316dce513Schristos@cindex @samp{-no-warn-unmatched-high} option, M32R
16416dce513SchristosDisables a previously enabled @emph{-warn-unmatched-high} option.
16516dce513Schristos
16616dce513Schristos@item -Wuh
16716dce513Schristos@cindex @samp{-Wuh} option, M32RX
16816dce513SchristosThis is a shorter synonym for the @emph{-warn-unmatched-high} option.
16916dce513Schristos
17016dce513Schristos@item -Wnuh
17116dce513Schristos@cindex @samp{-Wnuh} option, M32RX
17216dce513SchristosThis is a shorter synonym for the @emph{-no-warn-unmatched-high} option.
17316dce513Schristos
17416dce513Schristos@end table
17516dce513Schristos
17616dce513Schristos@node M32R-Directives
17716dce513Schristos@section M32R Directives
17816dce513Schristos@cindex directives, M32R
17916dce513Schristos@cindex M32R directives
18016dce513Schristos
181ede78133SchristosThe Renesas M32R version of @code{@value{AS}} has a few architecture
18216dce513Schristosspecific directives:
18316dce513Schristos
18416dce513Schristos@table @code
18516dce513Schristos
18616dce513Schristos@cindex @code{low} directive, M32R
18716dce513Schristos@item low @var{expression}
18816dce513SchristosThe @code{low} directive computes the value of its expression and
18916dce513Schristosplaces the lower 16-bits of the result into the immediate-field of the
19016dce513Schristosinstruction.  For example:
19116dce513Schristos
19216dce513Schristos@smallexample
19316dce513Schristos   or3   r0, r0, #low(0x12345678) ; compute r0 = r0 | 0x5678
19416dce513Schristos   add3, r0, r0, #low(fred)   ; compute r0 = r0 + low 16-bits of address of fred
19516dce513Schristos@end smallexample
19616dce513Schristos
19716dce513Schristos@item high @var{expression}
19816dce513Schristos@cindex @code{high} directive, M32R
19916dce513SchristosThe @code{high} directive computes the value of its expression and
20016dce513Schristosplaces the upper 16-bits of the result into the immediate-field of the
20116dce513Schristosinstruction.  For example:
20216dce513Schristos
20316dce513Schristos@smallexample
20416dce513Schristos   seth  r0, #high(0x12345678) ; compute r0 = 0x12340000
20516dce513Schristos   seth, r0, #high(fred)       ; compute r0 = upper 16-bits of address of fred
20616dce513Schristos@end smallexample
20716dce513Schristos
20816dce513Schristos@item shigh @var{expression}
20916dce513Schristos@cindex @code{shigh} directive, M32R
21016dce513SchristosThe @code{shigh} directive is very similar to the @code{high}
21116dce513Schristosdirective.  It also computes the value of its expression and places
21216dce513Schristosthe upper 16-bits of the result into the immediate-field of the
21316dce513Schristosinstruction.  The difference is that @code{shigh} also checks to see
21416dce513Schristosif the lower 16-bits could be interpreted as a signed number, and if
21516dce513Schristosso it assumes that a borrow will occur from the upper-16 bits.  To
21616dce513Schristoscompensate for this the @code{shigh} directive pre-biases the upper
21716dce513Schristos16 bit value by adding one to it.  For example:
21816dce513Schristos
21916dce513SchristosFor example:
22016dce513Schristos
22116dce513Schristos@smallexample
22216dce513Schristos   seth  r0, #shigh(0x12345678) ; compute r0 = 0x12340000
22316dce513Schristos   seth  r0, #shigh(0x00008000) ; compute r0 = 0x00010000
22416dce513Schristos@end smallexample
22516dce513Schristos
22616dce513SchristosIn the second example the lower 16-bits are 0x8000.  If these are
22716dce513Schristostreated as a signed value and sign extended to 32-bits then the value
22816dce513Schristosbecomes 0xffff8000.  If this value is then added to 0x00010000 then
22916dce513Schristosthe result is 0x00008000.
23016dce513Schristos
23116dce513SchristosThis behaviour is to allow for the different semantics of the
23216dce513Schristos@code{or3} and @code{add3} instructions.  The @code{or3} instruction
23316dce513Schristostreats its 16-bit immediate argument as unsigned whereas the
23416dce513Schristos@code{add3} treats its 16-bit immediate as a signed value.  So for
23516dce513Schristosexample:
23616dce513Schristos
23716dce513Schristos@smallexample
23816dce513Schristos   seth  r0, #shigh(0x00008000)
23916dce513Schristos   add3  r0, r0, #low(0x00008000)
24016dce513Schristos@end smallexample
24116dce513Schristos
24216dce513SchristosProduces the correct result in r0, whereas:
24316dce513Schristos
24416dce513Schristos@smallexample
24516dce513Schristos   seth  r0, #shigh(0x00008000)
24616dce513Schristos   or3   r0, r0, #low(0x00008000)
24716dce513Schristos@end smallexample
24816dce513Schristos
24916dce513SchristosStores 0xffff8000 into r0.
25016dce513Schristos
25116dce513SchristosNote - the @code{shigh} directive does not know where in the assembly
25216dce513Schristossource code the lower 16-bits of the value are going set, so it cannot
25316dce513Schristoscheck to make sure that an @code{or3} instruction is being used rather
25416dce513Schristosthan an @code{add3} instruction.  It is up to the programmer to make
25516dce513Schristossure that correct directives are used.
25616dce513Schristos
25716dce513Schristos@cindex @code{.m32r} directive, M32R
25816dce513Schristos@item .m32r
25916dce513SchristosThe directive performs a similar thing as the @emph{-m32r} command
26016dce513Schristosline option.  It tells the assembler to only accept M32R instructions
26116dce513Schristosfrom now on.  An instructions from later M32R architectures are
26216dce513Schristosrefused.
26316dce513Schristos
26416dce513Schristos@cindex @code{.m32rx} directive, M32RX
26516dce513Schristos@item .m32rx
26616dce513SchristosThe directive performs a similar thing as the @emph{-m32rx} command
26716dce513Schristosline option.  It tells the assembler to start accepting the extra
26816dce513Schristosinstructions in the M32RX ISA as well as the ordinary M32R ISA.
26916dce513Schristos
27016dce513Schristos@cindex @code{.m32r2} directive, M32R2
27116dce513Schristos@item .m32r2
27216dce513SchristosThe directive performs a similar thing as the @emph{-m32r2} command
27316dce513Schristosline option.  It tells the assembler to start accepting the extra
27416dce513Schristosinstructions in the M32R2 ISA as well as the ordinary M32R ISA.
27516dce513Schristos
27616dce513Schristos@cindex @code{.little} directive, M32RX
27716dce513Schristos@item .little
27816dce513SchristosThe directive performs a similar thing as the @emph{-little} command
27916dce513Schristosline option.  It tells the assembler to start producing little-endian
28016dce513Schristoscode and data.  This option should be used with care as producing
28116dce513Schristosmixed-endian binary files is fraught with danger.
28216dce513Schristos
28316dce513Schristos@cindex @code{.big} directive, M32RX
28416dce513Schristos@item .big
28516dce513SchristosThe directive performs a similar thing as the @emph{-big} command
28616dce513Schristosline option.  It tells the assembler to start producing big-endian
28716dce513Schristoscode and data.  This option should be used with care as producing
28816dce513Schristosmixed-endian binary files is fraught with danger.
28916dce513Schristos
29016dce513Schristos@end table
29116dce513Schristos
29216dce513Schristos@node M32R-Warnings
29316dce513Schristos@section M32R Warnings
29416dce513Schristos
29516dce513Schristos@cindex warnings, M32R
29616dce513Schristos@cindex M32R warnings
29716dce513Schristos
29816dce513SchristosThere are several warning and error messages that can be produced by
29916dce513Schristos@code{@value{AS}} which are specific to the M32R:
30016dce513Schristos
30116dce513Schristos@table @code
30216dce513Schristos
30316dce513Schristos@item output of 1st instruction is the same as an input to 2nd instruction - is this intentional ?
30416dce513SchristosThis message is only produced if warnings for explicit parallel
30516dce513Schristosconflicts have been enabled.  It indicates that the assembler has
30616dce513Schristosencountered a parallel instruction in which the destination register of
30716dce513Schristosthe left hand instruction is used as an input register in the right hand
30816dce513Schristosinstruction.  For example in this code fragment
30916dce513Schristos@samp{mv r1, r2 || neg r3, r1} register r1 is the destination of the
31016dce513Schristosmove instruction and the input to the neg instruction.
31116dce513Schristos
31216dce513Schristos@item output of 2nd instruction is the same as an input to 1st instruction - is this intentional ?
31316dce513SchristosThis message is only produced if warnings for explicit parallel
31416dce513Schristosconflicts have been enabled.  It indicates that the assembler has
31516dce513Schristosencountered a parallel instruction in which the destination register of
31616dce513Schristosthe right hand instruction is used as an input register in the left hand
31716dce513Schristosinstruction.  For example in this code fragment
31816dce513Schristos@samp{mv r1, r2 || neg r2, r3} register r2 is the destination of the
31916dce513Schristosneg instruction and the input to the move instruction.
32016dce513Schristos
32116dce513Schristos@item instruction @samp{...} is for the M32RX only
32216dce513SchristosThis message is produced when the assembler encounters an instruction
32316dce513Schristoswhich is only supported by the M32Rx processor, and the @samp{-m32rx}
324012573ebSchristoscommand-line flag has not been specified to allow assembly of such
32516dce513Schristosinstructions.
32616dce513Schristos
32716dce513Schristos@item unknown instruction @samp{...}
32816dce513SchristosThis message is produced when the assembler encounters an instruction
32916dce513Schristoswhich it does not recognize.
33016dce513Schristos
33116dce513Schristos@item only the NOP instruction can be issued in parallel on the m32r
33216dce513SchristosThis message is produced when the assembler encounters a parallel
33316dce513Schristosinstruction which does not involve a NOP instruction and the
334012573ebSchristos@samp{-m32rx} command-line flag has not been specified.  Only the M32Rx
33516dce513Schristosprocessor is able to execute two instructions in parallel.
33616dce513Schristos
33716dce513Schristos@item instruction @samp{...} cannot be executed in parallel.
33816dce513SchristosThis message is produced when the assembler encounters a parallel
33916dce513Schristosinstruction which is made up of one or two instructions which cannot be
34016dce513Schristosexecuted in parallel.
34116dce513Schristos
34216dce513Schristos@item Instructions share the same execution pipeline
34316dce513SchristosThis message is produced when the assembler encounters a parallel
344ede78133Schristosinstruction whose components both use the same execution pipeline.
34516dce513Schristos
34616dce513Schristos@item Instructions write to the same destination register.
34716dce513SchristosThis message is produced when the assembler encounters a parallel
34816dce513Schristosinstruction where both components attempt to modify the same register.
34916dce513SchristosFor example these code fragments will produce this message:
35016dce513Schristos@samp{mv r1, r2 || neg r1, r3}
35116dce513Schristos@samp{jl r0 || mv r14, r1}
35216dce513Schristos@samp{st r2, @@-r1 || mv r1, r3}
35316dce513Schristos@samp{mv r1, r2 || ld r0, @@r1+}
35416dce513Schristos@samp{cmp r1, r2 || addx r3, r4} (Both write to the condition bit)
35516dce513Schristos
35616dce513Schristos@end table
357