Difference between revisions of "NaplesPU Tools"

From NaplesPU Documentation
Jump to: navigation, search
(elf2hex)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
nu+ is provided with a set of additional tools in order to fully support the compilation process of an application.  
+
NaplesPU is provided with a set of additional tools in order to fully support the compilation process of an application.  
  
 
== elf2hex ==
 
== elf2hex ==
As the name said, ''elf2hex'' is the tool that provides the transformation of the ''elf'' file, the output of the compilation passes illustrated in the previous sections, in ''hex'' file, in order to be compliant with the required format that has to be written in the memory.
+
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:
The ''elf2hex'' source code is implemented in the [[elf2hex.cpp]] file. It is developed to print the memory image in various formats, such as the MANGO format, that is 512-bit aligned in a little-endian fashion, MANGO architecture compliant, and the ''standalone'' format, that is compliant with the standalone implementation of the device.
+
* 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 ==  
 
== Disassembler ==  
A disassembler attempts to revert the assembly code from the binary machine code. LLVM provides its own tool, that is ''llvm-is''. In order to provide to LLVM the support for the target-platform machine code disassembly, it is necessary to register a custom implementation of the [[NuPlusDisassembler.cpp]] file. It relies on the ''decoder table'' located in the ''NuPlusGenDisassemblerTables.inc'' file, that is an autogenerated file, result of the compilation of the target-specific TableGen files. For this reason, most of ''Disassembler'' code in the [[NuPlusDisassembler.cpp]] file is retrieved from the ''.td'' description. It is also possible to specify the ''DecoderMethod'' flag on an instruction in the TableGen file. Consequently, it is necessary to provide the implementation of the specified method in the [[NuPlusDisassembler.cpp]] file.  
+
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.
  
 
<syntaxhighlight>
 
<syntaxhighlight>
Line 18: Line 19:
 
{
 
{
 
   return decodeMemoryOpValue(Inst, Insn, Address, Decoder,
 
   return decodeMemoryOpValue(Inst, Insn, Address, Decoder,
         NuPlus::VR512WRegClassID);
+
         NaplesPU::VR512WRegClassID);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 16:22, 21 June 2019

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.