Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ollef committed Jul 18, 2024
1 parent 55982fc commit d38065b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
26 changes: 13 additions & 13 deletions src/Low/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ prettyTerm env = \case
"case"
<+> prettyOperand env scrutinee
<+> "of"
<> line
<> indent
2
( vcat $
(prettyBranch env <$> branches)
<> [ "_" <+> "->" <+> prettyTerm env branch
| Just branch <- [defaultBranch]
]
)
<> line
<> indent
2
( vcat $
(prettyBranch env <$> branches)
<> [ "_" <+> "->" <+> prettyTerm env branch
| Just branch <- [defaultBranch]
]
)
Syntax.Call function args ->
"call"
<+> prettyLoweredGlobal env function
Expand Down Expand Up @@ -129,8 +129,8 @@ prettySeq env = \case
<+> pretty name'
<+> "="
<+> prettyTerm env term
<> line
<> prettySeq env' body
<> line
<> prettySeq env' body
Syntax.Seq term1 term2 ->
prettyTerm env term1
<> line
Expand Down Expand Up @@ -221,5 +221,5 @@ prettyFunction env = \case
"("
<> pretty passArgBy
<+> pretty name'
<> ")"
<> prettyFunction env' function'
<> ")"
<> prettyFunction env' function'
17 changes: 8 additions & 9 deletions src/Lower.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ data Value

data LetOperation
= Case !Operand [Branch] (Maybe Value)
| Call !Name.Lowered [Operand ]
| Call !Name.Lowered [Operand]
| StackAllocate !Operand
| HeapAllocate !Name.QualifiedConstructor !Operand
| HeapPayload !Operand
Expand All @@ -58,7 +58,7 @@ data LetOperation
| Load !Operand !Representation
deriving (Show)

data SeqOperation
data SeqOperation
= Store !Operand !Operand !Representation
| Copy !Operand !Operand !Operand
deriving (Show)
Expand Down Expand Up @@ -96,9 +96,9 @@ type Collect = StateT (Tsil Collectible) M

let_ :: PassBy -> Name -> LetOperation -> Collect Operand
let_ repr name operation = do
var <- lift freshVar
modify (Tsil.:> CollectibleLet repr name var operation)
pure $ Var var
var <- lift freshVar
modify (Tsil.:> CollectibleLet repr name var operation)
pure $ Var var

letReference :: Name -> LetOperation -> Collect Operand
letReference = let_ PassBy.Reference
Expand Down Expand Up @@ -384,7 +384,7 @@ storeConstrArgs context indices mdst offset = \case
[] -> pure offset
arg : args -> do
dst <- mdst
argDst <- letOffset "constr_arg_dst" dst offset
argDst <- letOffset "constr_arg_dst" dst offset
argSize <- storeTerm context indices argDst arg
offset' <- letAddRepresentation "constr_arg_offset" offset argSize
storeConstrArgs context indices (pure dst) offset' args
Expand Down Expand Up @@ -412,8 +412,8 @@ generateTypeSize
-> CC.Syntax.Type v
-> Collect Operand
generateTypeSize context indices type_ = do
size <- generateTermWithType context Nothing indices type_ $ CC.Syntax.Global $ Name.Lifted Builtin.TypeName 0
forceValue Representation.type_ size
size <- generateTermWithType context Nothing indices type_ $ CC.Syntax.Global $ Name.Lifted Builtin.TypeName 0
forceValue Representation.type_ size

generateTermWithType
:: CC.Context v
Expand Down Expand Up @@ -701,4 +701,3 @@ readbackBranch :: Index.Map v Var -> Branch -> Low.Syntax.Branch v
readbackBranch env = \case
ConstructorBranch con value -> Low.Syntax.ConstructorBranch con $ readback env value
LiteralBranch lit value -> Low.Syntax.LiteralBranch lit $ readback env value

4 changes: 2 additions & 2 deletions src/ReferenceCounting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ increase value repr
| otherwise = pure value

decreaseBefore
:: Foldable f
:: (Foldable f)
=> f (Var, Representation)
-> Value
-> Value
Expand All @@ -373,7 +373,7 @@ decreaseBefore vars value =
vars

decreaseAfter
:: Foldable f
:: (Foldable f)
=> f (Var, Representation)
-> Value
-> PassBy
Expand Down

0 comments on commit d38065b

Please sign in to comment.