Skip to content

Instantly share code, notes, and snippets.

@CensoredUsername
Created May 8, 2019 23:08
Show Gist options
  • Save CensoredUsername/befd0cdc8536a478f3ec6c1f23c2a7a5 to your computer and use it in GitHub Desktop.
Save CensoredUsername/befd0cdc8536a478f3ec6c1f23c2a7a5 to your computer and use it in GitHub Desktop.
Aarch64 backend time estimations

Aarch64 backend work distribution

References:

Complete implementation

  • Plugin

    • Implementation of a parser for Aarch64 implementing the standard ARM assembly dialect, mixed with dynasm dynamic register, immediate and label specification.
    • Creation of a database of ARM instruction encoding data.
    • Implementation of a compiler that combines the parse and instruction data to emit code targetting the runtime ARM backend.
    • Add support for relocations in directives.
  • Runtime

    • Addition of a new backend, based on the x64 backend as both architectures feature PIC and relative jumps smaller than the total address space.
    • Implementation of a relocation model for Aarch64.
    • Runtime helpers needed to assist in compiling the different kind of immediates Aarch64 assembly supports.
  • Tests

    • Generation of a test suite that uses the ARM instruction encoding data to generate a large suite of expectedly passing and failing test cases. These will be ran by both dynasm-aarch64 and a reference assembler to ensure compliance of the instruction encoding data.
    • A set of custom-written test cases and targeting the relocation infrastructure of the dynasm aarch64 backend which can be tested on an actual aarch64 machine.
    • Porting of several of the current x64 examples to aarch64 to demonstrate the readyness of the backend.
  • Documentation

    • Generating a listing of supported instructions
    • Documenting the syntax and functionality of the Aarch64 backend.

Time distribution

Time estimations include the time spent debugging the features after their initial implementation.

Parser: 8 hours

This is expected to be quite straightforward, as Aarch64 assembly is significantly simpler than x64 assembly. Some complexity is present due to the presence of operand modifiers, different addressing modes and vector register lane notation.

Instruction listing: 24 hours

While the instruction count of ARM is lower and the instructions are fixed width, the encodings themselves feature large amounts of small bitfields. To simplify the process and ensure correctness this instruction listing will be generated by processing the data provided by ARM in their Machine-Readable Architecture specification. This specification is however quite complex, and extracting the needed data in an easy format for the compiler will require all features of the instruction encoding and assembly specification to be processed.

Compiler: 16 hours

The compiler will validate the parsed assembly data with the data provided by the instruction listing. As Aarch64 assembly has a very rigid encoding format, this is expected to be mostly straightforward validation of the assembly to the instruction listing, and encoding the required data in their bitfields. The major complication here will be handling PC-relative bitfields and emitting their respective relocations.

Relocations in directives: 4 hours

To support Aarch64 literal pools which are necessary for efficient absolute jumps, support needs to be added for emitting relocations into data directives.

Runtime additions: 8 hours

Most of the runtime backend can be ported over directly from the x64 backend. Relocation handling will need to be adjusted to match the output of the compiler, and several runtime helpers need to be added to support fallible conversions for encoding several Aarch64 features (logical immediates, shifted immediates)

Static instruction encoding tests: 12 hours

A tool to generate a large amount of test cases is needed, as well as integration of another Aarch64 assembler toolchain to validate the results.

Custom test cases: 4 hours

These will be written early on while engineering the parser and compiler to ensure all features are operational in their basic forms.

Porting of examples: 4 hours

I have a decent amount of experience with ARM assembly (although mostly ARMv7/Thumb) so I do not expect to encounter significant issues during this step.

Documentation: 8 hours

Based on how long writing documentation for the x64 backend took.

Total: 88 hours

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment