Skip to content

Reorder ARM disassembler decode functions to eliminate forward declarations #156560

@jurahul

Description

@jurahul

In #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 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions