Skip to content

Commit

Permalink
edits
Browse files Browse the repository at this point in the history
  • Loading branch information
vidsinghal committed Feb 14, 2024
1 parent e913977 commit cf620df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gibbon-compiler/src/Gibbon/L2/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ mapPacked fn t =
SymSetTy -> SymSetTy
SymHashTy-> SymHashTy
IntHashTy-> IntHashTy
MutableCursorTy -> MutableCursorTy

constPacked :: UrTy a1 -> UrTy a2 -> UrTy a1
constPacked c t =
Expand All @@ -840,6 +841,7 @@ constPacked c t =
SymSetTy -> SymSetTy
SymHashTy-> SymHashTy
IntHashTy-> IntHashTy
MutableCursorTy -> MutableCursorTy

-- | Build a dependency list which can be later converted to a graph
depList :: Exp2 -> [(Var, Var, [Var])]
Expand Down
1 change: 1 addition & 0 deletions gibbon-compiler/src/Gibbon/Language.hs
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ stripTyLocs ty =
SymHashTy -> SymHashTy
IntHashTy -> IntHashTy
ArenaTy -> ArenaTy
MutableCursorTy -> MutableCursorTy

-- | Get the data constructor type from a type, failing if it's not packed
tyToDataCon :: Show a => UrTy a -> DataCon
Expand Down
4 changes: 4 additions & 0 deletions gibbon-compiler/src/Gibbon/Language/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,10 @@ data UrTy loc
-- to an unkwown type or to a fraction of a complete value.
-- It is a machine pointer that can point to any byte.

| MutableCursorTy -- ^ A cursor for writing to an output location.
-- It is a mutable cursor, the address that the
-- cursor points to changes.

deriving (Show, Read, Ord, Eq, Generic, NFData, Functor, Foldable, Traversable, Out)


Expand Down
8 changes: 5 additions & 3 deletions gibbon-compiler/src/Gibbon/Passes/Cursorize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ cursorizeFunDef ddefs fundefs FunDef{funName,funTy,funArgs,funBody,funMeta} = do
-- intuitive and can be improved.

-- Input & output regions are always inserted before all other arguments.
regBinds = map toEndV (inRegs ++ outRegs)
regBinds = dbgTraceIt (sdoc funName) dbgTraceIt (sdoc funTy') dbgTraceIt ("\n") map toEndV (inRegs ++ outRegs)

-- Output cursors after that.
outCurBinds = outLocs
Expand Down Expand Up @@ -224,14 +224,16 @@ This is used to create bindings for input location variables.
-- Adding additional input arguments for the destination cursors to which outputs
-- are written.
outCurs = filter (\(LRM _ _ m) -> m == Output) locVars
outCurTys = map (\_ -> CursorTy) outCurs
outCurTys = map (\_ -> CursorTy) outCurs --MutableCursorTy, in case of tail recursive functions.
inRegs = map (\_ -> CursorTy) (inRegVars ty)
in_tys = inRegs ++ outRegs ++ outCurTys ++ (map unTy2 arrIns)

-- Packed types in the input now become (read-only) cursors.
newIns = map (constPacked CursorTy) in_tys

in (map stripTyLocs newIns, stripTyLocs newOut')
ty' = dbgTraceIt (sdoc (in_tys, outRegs, outCurTys, arrIns, ty, outLocVars ty)) (map stripTyLocs newIns, stripTyLocs newOut')

in ty'


-- | Cursorize expressions NOT producing `Packed` values
Expand Down

0 comments on commit cf620df

Please sign in to comment.