Giter Site home page Giter Site logo

despiller's Introduction

despiller

A proof of concept of a code-optimisation technique, hereby referred to as de-spilling of registers, in a fake ISA.

This is a work in progress, far from feature-complete status. Once the project reaches sufficient maturity this message will be removed.

overview

De-spilling is a codegen optimisaiton technique, which addresses post-factum excessive spilling or registers. The latter can come from two sources:

  • prior suboptimal codegen stages
  • function prologues/epilogues not taking into account the inherent register pressure at function call sites

De-spilling works by tracking register occupancy across the control-flow graph (CFG) of a program. One can think of de-spilling as a whole-program-optimisaion technique, but it can be applied to any well-isolated (i.e. singular entry edge) subgraph in the CFG. Characteristic of de-spilling is that it does not try to re-arrange basic blocks like inlining does, but instead re-arranges individual instructions' register operands with the goal of picking vacant registers as instruction destinations. This enables the elimination (e.g. op -> nop) of spill/restore sequences, which constitutes the actual optimisation. Please note, that a routine that has undergone such optimisation may no longer comply with the standard calling conventions, and hence invoking it outside the original program context for which de-spilling was carried is effectively undefined behavior.

As de-spilling is a very conservative optimisation technique, it could be applied to program binaries post compile.

ISA

A fictional, non-Turing-complete ISA of little-endian 31-bit machine word is used. The ISA is 3-argument and has an unspecified-size GPR file { R0..Rn }. The ISA also has access to an unlimited storage space 'storage' where regs can be spilled -- i.e. stored to and eventually restored from, in a LIFO manner. The ISA employs the following ops:

  • nop -- no-op
  • li Rn, imm -- load immediate to register
  • push Rn -- store a single register to 'storage'
  • pop Rn -- restore a single register from 'storage'
  • br Rt -- unconditional branch to register
  • cbr Rt, Rn, Rm -- conditional branch to register; branch to Rt if unspecified comparison between Rn and Rm is true
  • op Rn, Rm -- unspecified op which is not any of the above, taking 2 operands: one destination and one source
  • op Rn, Rm, Rk -- unspecified op which is not any of the above, taking 3 operands: one destination and two sources

limitations

This proof of concept does not handle branch targets which cannot be computed via simple static analysis, e.g. targets of virtual or dispatch calls.

despiller's People

Contributors

blu avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar Angel Angelov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.