<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/156560>156560</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Reorder ARM disassembler decode functions to eliminate forward declarations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:ARM
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jurahul
</td>
</tr>
</table>
<pre>
In https://github.com/llvm/llvm-project/pull/154802, we refactored the decoder emitter to move the common functions generated by the decoder emitter into a new header file: MCDecoder.h. This includes the function `fieldFromInstruction`.
Prior to that, decoder functions that called `fieldFromInstruction` had to be declared before including the generated GenDisassembler.inc file (as the generated code references them) and then defined after that so that they can find use the `fieldFromInstruction` function which is in the generated code:
```
static DecodeStatus DecodeXYX(...);
#include "GenDisassembler.inc"
static DecodeStatus DecodeXYZ(...) {
Z = fieldFromInstruction()
}
```
Now that `fieldFromInstruction` is in a common header, we can do away with the need to forward declare these functions:
```
#include "MCDecoder.h"
static DecodeStatus DecodeXYZ(...) {
Z = fieldFromInstruction()
}
#include "GenDisassembler.inc"
```
For most other targets, doing this generates a diff that looks just like this (include AArch64). For some other targets, this requires a little more rearrangement to get rid of all forward declarations, and then the diff becomes too complex. This includes the ARM disassembler. Hence, for ARM, we need to this in N steps so that in each step the diff is a simple code motion and looks like that. This issue is to track that.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0lc1u4zYQx5-Gvgwq0JQlSwcdtDHc7mEXxbaHbW4jcWQxoUiXpOLm7QtSdpy6RtoeCgQIrCGH__nNF3qvDoaoYcUnVuxWOIfRuuZpdjjOetVZ-dp8NjCGcPQsb5nYM7E_qDDOXdbbiYm91i-Xfz8cnX2iPjCxP85aM7FfF5uKCyYe4ETgaMA-WEcSwkggqbeSHNCkQiAHwcJkXyjZejtN1sAwmz4oazwcyJDDQBK617u3lQkWEAydYCSMlkFpYnkLXx52y9lszODXUXlQ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