Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ollef committed Jun 21, 2024
1 parent 59c2cf5 commit ef09465
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
16 changes: 11 additions & 5 deletions src/Low/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ import Protolude

data Term v
= Operand !(Operand v)
| Let !PassBy !Name !(Term v) !(Scope Term v)
| Seq !(Term v) !(Term v)
| Let !PassBy !Name !(LetOperation v) !(Scope Term v)
| Seq !(SeqOperation v) !(Term v)
| Case !(Operand v) [Branch v] (Maybe (Term v))
| Call !Name.Lowered [Operand v]
deriving (Eq, Show, Generic, Hashable)

data LetOperation v
= Call !Name.Lowered [Operand v]
| StackAllocate !(Operand v)
| HeapAllocate !Name.QualifiedConstructor !(Operand v)
| HeapPayload !(Operand v)
| PointerTag !(Operand v)
| Offset !(Operand v) !(Operand v)
| Copy !(Operand v) !(Operand v) !(Operand v)
| Store !(Operand v) !(Operand v) !Representation
| Load !(Operand v) !Representation
deriving (Eq, Show, Generic, Hashable)

data SeqOperation v
= Store !(Operand v) !(Operand v) !Representation
| Copy !(Operand v) !(Operand v) !(Operand v)
| IncreaseReferenceCount !(Operand v) !Representation
| DecreaseReferenceCount !(Operand v) !Representation
deriving (Eq, Show, Generic, Hashable)
Expand Down
18 changes: 13 additions & 5 deletions src/Lower.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,28 @@ import Var (Var)

data Value
= Operand !Operand
| Let !PassBy !Name !Var !Value !Value
| Seq !Value !Value
| Let !PassBy !Name !Var !LetOperation !Value
| Seq !SeqOperation !Value
| Case !Operand [Branch] (Maybe Value)
| Call !Name.Lowered [Operand]
deriving (Show)

data LetOperation
= Call !Name.Lowered [Operand ]
| StackAllocate !Operand
| HeapAllocate !Name.QualifiedConstructor !Operand
| HeapPayload !Operand
| PointerTag !Operand
| Offset !Operand !Operand
| Copy !Operand !Operand !Operand
| Store !Operand !Operand !Representation
| Load !Operand !Representation
deriving (Show)

data SeqOperation
= Store !Operand !Operand !Representation
| Copy !Operand !Operand !Operand
| IncreaseReferenceCount !Operand !Representation
| DecreaseReferenceCount !Operand !Representation
deriving (Show)

data Operand
= Var !Var
| Global !Representation !Name.Lowered
Expand Down

0 comments on commit ef09465

Please sign in to comment.