NaplesPU Tools

From NaplesPU Documentation
Jump to: navigation, search

NaplesPU is provided with a set of additional tools in order to fully support the compilation process of an application.

elf2hex

elf2hex is the tool required for elf code transformation. It works on an input ELF code to produce a hex output file as the memory image to be written on device memory. NaplesPU relies on its own implementation of the elf2hex tool, located in elf2hex.cpp. In our purposes, the tool produces two different outputs:

  • MANGO compliant memory image, a 512-bit little-endian aligned image ready to be flashed on the MANGO platform;
  • Standalone compliant memory image, a 512-bit little-endian aligned image to be used in a standalone environment.

Disassembler

A disassembler attempts to revert back the assembly code from the binary one. In order to be able to support NaplesPU code disassembly, LLVM requires to implement a Disassembler class. The implementation is provided in NaplesPUDisassembler.cpp. Disassembly methods rely on auto-generated decoder tables from TableGen files. TableGen also offers a way to force a specific decoder method to be called, specifying the DecoderMethod field on instructions.

def V16MEMri : Operand<v16i32> {
  let EncoderMethod = "encodeMemoryOpValue";
  let DecoderMethod = "decodeVectorWMemoryOpValue";
...
}

static DecodeStatus decodeVectorWMemoryOpValue(...) 
{
  return decodeMemoryOpValue(Inst, Insn, Address, Decoder,
         NaplesPU::VR512WRegClassID);
}

Object File Dumper

LLVM provides a custom tool to work as an object file dumper, that is a utility that prints the contents of object files and of the final linked image. For this reason, it is primarily used to debug the generated machine code. In the LLVM implementation, the llvm-objdump binary relies on the Disassembler classes, in order to revert the binary code into the assembly back.