Laurel Implementor Guide

4.1. Translation Pipeline🔗

The Laurel to Core translation pipeline uses three IRs, held by Program:

  • Program.Unordered, holding a LaurelProgram

  • Program.Ordered (.WithLaurelTypes _), holding a CoreWithLaurelTypes

  • Program.Ordered (.Core _), holding a Core.Program

Every pass is a LaurelPass, which runs on a Program, so the pipeline is a single list of passes. Passes built only on the generic traversals (mapProgramStmtExprM, mapProgramProceduresM, mapProgramHighTypesM) run on any IR. A pass that needs one IR matches on its constructor, declares the other constructors unsupported, and reports a Strata bug if it is given any other IR.

Most passes run on Program.Unordered. The transparency pass splits a LaurelProgram's procedures into staticFunctions and staticProcedures; it creates LaurelProgram.staticFunctions.cons, which the earlier lowering passes declare unsupported, and the Pseudo shapes that the passes after it remove before the LaurelToCoreSchemaPass, which declares them unsupported. The ordering pass goes from Program.Unordered to Program.Ordered (.WithLaurelTypes _), and the LaurelToCoreSchemaPass from there to Program.Ordered (.Core _); each removes its input constructor and creates its output one, so a pass placed where its IR is not live fails the build.