[llvm] [NFC][ARM][MC] Rearrange decoder functions 2/N (PR #155464)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 30 07:55:59 PDT 2025


jurahul wrote:

Sure, a few weeks back I changed the DecoderEmitter to move the `fieldFromInstruction` function from the generated code into a common MCDecoder.h header. Prior to that, decoder functions that called `fieldFromInstruction` has to be declared before including the generated GenDisassembler.inc file and then defined after that so that they can find the `fieldFromInstruction` function:

```
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. So for such targets, I am doing this in N steps instead of a single change. I did the same for XCore as well, ARM seems a bit more involved (the idea is that each diff should show as simple code motion).

https://github.com/llvm/llvm-project/pull/155464


More information about the llvm-commits mailing list