Compilation as a Typed EDSL-to-EDSL Transformation

  • 2018-04-19 17:30:56
  • Emil Axelsson
  • 0

Abstract

This article is about an implementation and compilation technique that isused in RAW-Feldspar which is a complete rewrite of the Feldspar embeddeddomain-specific language (EDSL) (Axelsson et al. 2010). Feldspar is high-levelfunctional language that generates efficient C code to run on embedded targets.The gist of the technique presented in this post is the following: ratherwriting a back end that converts pure Feldspar expressions directly to C, wetranslate them to a low-level monadic EDSL. From the low-level EDSL, C code isthen generated. This approach has several advantages: 1. The translation is simpler to write than a complete C back end. 2. The translation is between two typed EDSLs, which rules out many potentialerrors. 3. The low-level EDSL is reusable and can be shared between severalhigh-level EDSLs. Although the article contains a lot of code, most of it is in fact reusable.As mentioned in Discussion, we can write the same implementation in less than50 lines of code using generic libraries that we have developed to supportFeldspar.

 

Quick Read (beta)

loading the full paper ...