Skip to content

Commit

Permalink
Inline immediate values (#2842)
Browse files Browse the repository at this point in the history
* Closes #2745 
* Adds inlining of immediate values, i.e., values that don't require
computation or memory allocation.
* Non-immediate zero-argument functions / values should not be inlined,
because when not inlined they can be computed only once.
  • Loading branch information
lukaszcz authored Jun 20, 2024
1 parent a5cd3c9 commit af758cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Juvix/Compiler/Core/Transformation/Optimize/Inlining.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ convertNode inlineDepth recSyms md = dmapL go
Just InlineFullyApplied | argsNum == 0 -> def
Just (InlinePartiallyApplied 0) -> def
Just InlineAlways -> def
_ -> node
Just InlineNever -> node
_
| not (HashSet.member _identSymbol recSyms)
&& isImmediate md def ->
def
| otherwise ->
node
where
ii = lookupIdentifierInfo md _identSymbol
pi = ii ^. identifierPragmas . pragmasInline
Expand Down

0 comments on commit af758cc

Please sign in to comment.