MSP430: Add defaulting to the insn length attribute
authorJozef Lawrynowicz <jozef.l@mittosystems.com>
Fri, 13 Nov 2020 15:35:47 +0000 (15:35 +0000)
committerJozef Lawrynowicz <jozef.l@mittosystems.com>
Fri, 13 Nov 2020 15:36:30 +0000 (15:36 +0000)
commit546c8f955804ad74b0382b012f64e621a02eebde
tree53ade7d1dd5544885a644fe2a30923907e8baafc
parentf62dd3982398d031bc26c853522c5f4e20ef08fc
MSP430: Add defaulting to the insn length attribute

The length of MSP430 instructions is mostly just a function of the type
and number of operands. Setting the "type" attribute on all insns
describes the number of operands, and the position of the source and
destination operands.

In most cases, defaulting in the "length" and "extension" attribute
definitions can then be used to calculate the total length of the
instruction by using the value of the "type" attribute to examine the
operands.

gcc/ChangeLog:

* config/msp430/msp430-protos.h (msp430x_extendhisi): Return int
instead of char *.
(msp430_output_asm_shift_insns): Likewise.
Add new return_length argument.
(msp430x_insn_required): Add prototype.
* config/msp430/msp430.c (msp430_output_asm_shift_insns): Return the
total length, in bytes, of the emitted instructions.
(msp430x_insn_required): New function.
(msp430x_extendhisi): Return the total length, in bytes, of the
emitted instructions.
* config/msp430/msp430.h (ADJUST_INSN_LENGTH): Define.
* config/msp430/msp430.md: New define_attr "type".
New define_attr "extension".
New define_attr "length_multiplier".
New define_attr "extra_length".
Rewrite define_attr "length".
Set type, extension, length, length_multiplier or extra_length insn
attributes on all insns, as appropriate.
(andneghi3): Rewrite using constraints instead of C code to decide
output insns.
* config/msp430/predicates.md (msp430_cheap_operand): New predicate.
(msp430_high_memory_operand): New predicate.
gcc/config/msp430/msp430-protos.h
gcc/config/msp430/msp430.c
gcc/config/msp430/msp430.h
gcc/config/msp430/msp430.md
gcc/config/msp430/predicates.md