scalus.compiler.sir.lowering.simple
Members list
Type members
Classlikes
Base class for simple lowering from Scalus Intermediate Representation SIR to UPLC Term.
Base class for simple lowering from Scalus Intermediate Representation SIR to UPLC Term.
This class contains common functionality shared between different lowering strategies. Subclasses must implement the encoding-specific methods for constructors, pattern matching, and field selection.
Value parameters
- generateErrorTraces
-
whether to generate error traces
- sir
-
the Scalus Intermediate Representation to lower
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class ScottEncodingLoweringclass SumOfProductsLowering
Let-floating transformation that moves lazy let bindings closer to their usage points.
Let-floating transformation that moves lazy let bindings closer to their usage points.
This transformation implements "floating inward" as described in: Simon Peyton Jones, Will Partain, and André Santos. 1996. Let-floating: moving bindings to give faster programs.
The algorithm works in three phases:
- Enrichment pass (down-traversal): Build enriched SIR with node indices, track variable usage, lambda context, and dependencies
- Analysis pass: Find dominating nodes for each lazy let binding using tracked usage information and transitive dependency propagation
- Output generation pass (down-traversal): Reconstruct SIR, moving lazy lets to their computed dominating nodes
Lambda barrier: Non-effortless bindings (computations) are prevented from crossing lambda boundaries to avoid duplicating work when the lambda is called multiple times. Effortless bindings (constants, variables, lambdas) can cross freely.
TODO: optimization can introduce expressions like App((lambda x, x),y) which can be eliminated. Maybe add a beta-reduction pass after let-floating, or just handle it here.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
LetFloating.type
Scott encoding-based lowering from Scalus Intermediate Representation SIR to UPLC Term.
Scott encoding-based lowering from Scalus Intermediate Representation SIR to UPLC Term.
This implementation uses Scott encoding for data types:
Nilis represented as\Nil Cons -> force NilCons h tlis represented as(\head tail Nil Cons -> Cons head tail) h tl
Value parameters
- generateErrorTraces
-
whether to generate error traces
- sir
-
the Scalus Intermediate Representation to lower
Attributes
- Supertypes
UPLC 1.1.0-based lowering from Scalus Intermediate Representation SIR to UPLC Term.
UPLC 1.1.0-based lowering from Scalus Intermediate Representation SIR to UPLC Term.
We use UPLC version 1.1.0 and generate Sums of Products (SoP) constructors case and constr to represent data types. Also we optimize newtype kind of constructors to be represented as just values.
Value parameters
- generateErrorTraces
-
whether to generate error traces
- sir
-
the Scalus Intermediate Representation to lower
Attributes
- Example
-
case class Wrapper(a: BigInt) val x = Wrapper(1) // lowers to just (const integer 1) - Supertypes
Deprecated types
Attributes
- Deprecated
-
[Since version 0.13.0]Use ScottEncodingLowering instead
Attributes
- Deprecated
-
[Since version 0.13.0]Use SumOfProductsLowering instead