10.07.2015 Views

An ARM Backend for PyPyls Tracing JIT - STUPS Group

An ARM Backend for PyPyls Tracing JIT - STUPS Group

An ARM Backend for PyPyls Tracing JIT - STUPS Group

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

24 6 A BACKEND FOR PYPY’S <strong>JIT</strong>which is a fixed-width 32-bit instruction set.The <strong>ARM</strong> Architecture Reference Manual [<strong>ARM</strong>10] defines different instruction groupsand <strong>for</strong> each of these instruction groups it describes how the arguments to the instructionare encoded in the bits that actually build the instruction. In this section we are going touse the group of Data-processing (immediate) instructions as an example. These instructionstake one register and one immediate value as their arguments. Instructions suchas AND, CMP are defined in this group. The bit encoding <strong>for</strong> instructions defined there isshown in Figure 11. The empty part in the lowest bits of the encoding is defined on aper instruction basis. As explained in Section 2.2.5 almost every instruction can take aconditional execution flag, this flag is stored in the upper 4 bits of the instruction.Figure 11: Bit encoding <strong>for</strong> the data processing instructions with immediate values[<strong>ARM</strong>10]To encode the instructions <strong>for</strong> the backend all instructions <strong>for</strong> one group are stored in aPython hashmap. This grouping is possible, because most of the instructions in a grouphave a common interface. For each instruction the hashmap contains the name of theoperation, its arguments and a description of the variable parts of the encoding. Figure12 shows how some of the instruction of our example group are stored. For exampleAND_ri instruction has the operation number 0 and it has a result and a register argument.This instruction per<strong>for</strong>ms a bitwise AND between the register and the immediatevalue arguments storing the result in a result register.data_proc_imm = {’AND_ri’: {’op’: 0, ’result’:True, ’base’:True},’EOR_ri’: {’op’: 0x2, ’result’:True, ’base’:True},’SUB_ri’: {’op’: 0x4, ’result’:True, ’base’:True},’RSB_ri’: {’op’: 0x6, ’result’:True, ’base’:True},’CMN_ri’: {’op’: 0x17, ’result’:False, ’base’:True},’ADD_ri’: {’op’: 0x8, ’result’:True, ’base’:True},’ORR_ri’: {’op’: 0x18, ’result’:True, ’base’:True},’MVN_ri’: {’op’: 0x1E, ’result’:True, ’base’:False},#snip}Figure 12: Encoding of the group of data processing instructions with immediate valuesas arguments as a Python hashmapAt load time, when the modules defining the backend are loaded into memory theseinstruction encodings are trans<strong>for</strong>med into RPython functions and attached to theCodeBuilder class. When the codebuilder is translated all required functions arealready in place and translated with the class, thus available at runtime to provide a highlevel interface to the machine instructions. In Figure 13 the function used to generate thefunctions <strong>for</strong> data processing instructions with immediate values is shown. It checks if

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!