I am working on AVR port and seek advice of the best way working out
what instructions patterns have been natched to RTL.
This requires adjustment of instruction length to assist branching -
when operands are finally known. Before this, worst case lengths are
used from pattern length attributes.
At present, the ADJUST_INSN_LENGTH routine looks at the instruction RTL
to figure out what pattern was matched, then calls the appropriate
routine that can do the precise length calculation. The problem with
this method is that this re-matching can easily be wrong. Great care is
taken when additional backend patterns are used - or existing ones are
re-arranged, or instruction length are calculated incorrectly.
To get around this problem, I replaced this RTL checking with a simple
lookup of the instruction name using
name = get_insn_name (INSN_CODE (insn));
Then a simple string compare can be used to determine precisely what has
been matched.
It works fine, but is this an acceptable method ?
The alternative, perhaps, would be to set each length attribute
dynamically in each pattern - if that was possible. But that looks like
way more work.