Skip to content

Commit

Permalink
edits
Browse files Browse the repository at this point in the history
  • Loading branch information
vidsinghal committed Dec 4, 2024
1 parent c38e6c1 commit 947bdc4
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 136 deletions.
110 changes: 55 additions & 55 deletions gibbon-compiler/src/Gibbon/L2/Examples.hs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gibbon-compiler/src/Gibbon/L2/Interp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ interpExt sizeEnv rc env ddefs fenv ext =
Just _ ->
go (M.insert (unwrapLocVar loc) (VLoc (regionToVar reg) 0) env) sizeEnv bod

AfterConstantLE i loc2 -> do
AfterConstantLE i _ loc2 -> do
case M.lookup (unwrapLocVar loc2) env of
Nothing -> error $ "L2.Interp: Unbound location: " ++ sdoc loc2
Just (VLoc reg offset) ->
go (M.insert (unwrapLocVar loc) (VLoc reg (offset + i)) env) sizeEnv bod
Just val ->
error $ "L2.Interp: Unexpected value for " ++ sdoc loc2 ++ ":" ++ sdoc val

AfterVariableLE v loc2 _ -> do
AfterVariableLE v _ loc2 _ -> do
case M.lookup (unwrapLocVar loc2) env of
Nothing -> error $ "L2.Interp: Unbound location: " ++ sdoc loc2
Just (VLoc reg offset) ->
Expand Down
5 changes: 3 additions & 2 deletions gibbon-compiler/src/Gibbon/L2/Typecheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -780,14 +780,15 @@ tcExp ddfs env funs constrs regs tstatein exp =
(ty,tstate2) <- tcExp ddfs env' funs constrs1 regs tstate1 e
tstate3 <- removeLoc exp tstate2 (Single loc)
return (ty,tstate3)
AfterConstantLE i l1 ->
{-TODO handle what needs to happen with the wildcard argument, list of offsets in case of soa -}
AfterConstantLE i _ l1 ->
do r <- getRegion exp constrs l1
let tstate1 = extendTS (Single loc) (Output,True) $ setAfter l1 tstatein
let constrs1 = extendConstrs (InRegionC (Single loc) r) $ extendConstrs (AfterConstantC i l1 (Single loc)) constrs
(ty,tstate2) <- tcExp ddfs env' funs constrs1 regs tstate1 e
tstate3 <- removeLoc exp tstate2 (Single loc)
return (ty,tstate3)
AfterVariableLE x l1 _ ->
AfterVariableLE x _ l1 _ ->
do r <- getRegion exp constrs l1
(_xty,tstate1) <- tcExp ddfs env funs constrs regs tstatein $ VarE x
-- NOTE: We now allow aliases (offsets) from scalar vars too. So we can leave out this check
Expand Down
4 changes: 2 additions & 2 deletions gibbon-compiler/src/Gibbon/NewL2/FromOldL2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ fromOldL2Exp ddefs fundefs locenv env2 ex =
toLocArg loc locexp locenv0 =
case locexp of
StartOfRegionLE reg -> New.Loc (New.LREM loc (regionToVar reg) (toEndV (regionToVar reg)) Output)
AfterConstantLE _ loc2 ->
AfterConstantLE _ _ loc2 ->
let (New.Loc lrem) = locenv0 # loc2
in New.Loc (New.LREM loc (New.lremReg lrem) (New.lremEndReg lrem) Output)
AfterVariableLE _ loc2 _ ->
AfterVariableLE _ _ loc2 _ ->
let (New.Loc lrem) = locenv0 # loc2
in New.Loc (New.LREM loc (New.lremReg lrem) (New.lremEndReg lrem) Output)
InRegionLE reg ->
Expand Down
8 changes: 4 additions & 4 deletions gibbon-compiler/src/Gibbon/NewL2/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ toEndFromTaggedV v = (toVar "end_from_tagged_") `varAppend` v
instance FreeVars LocExp where
gFreeVars e =
case e of
Old.AfterConstantLE _ loc -> S.singleton $ unwrapLocVar (toLocVar loc)
Old.AfterVariableLE v loc _ -> S.fromList $ [v, unwrapLocVar (toLocVar loc)]
Old.AfterConstantLE _ _ loc -> S.singleton $ unwrapLocVar (toLocVar loc)
Old.AfterVariableLE v vs loc _ -> S.fromList [v, unwrapLocVar (toLocVar loc)] `S.union` S.fromList vs
_ -> S.empty


Expand Down Expand Up @@ -510,8 +510,8 @@ depList = L.map (\(a,b) -> (a,a,b)) . M.toList . go M.empty
dep ex =
case ex of
Old.StartOfRegionLE r -> [Old.regionToVar r]
Old.AfterConstantLE _ loc -> [unwrapLocVar $ toLocVar loc]
Old.AfterVariableLE v loc _ -> [v, unwrapLocVar $ toLocVar loc]
Old.AfterConstantLE _ _ loc -> [unwrapLocVar $ toLocVar loc]
Old.AfterVariableLE v vs loc _ -> [v, unwrapLocVar $ toLocVar loc] ++ vs
Old.InRegionLE r -> [Old.regionToVar r]
Old.FromEndLE loc -> [unwrapLocVar $ toLocVar loc]
Old.FreeLE -> []
Expand Down
4 changes: 2 additions & 2 deletions gibbon-compiler/src/Gibbon/Passes/AddRAN.hs
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ we need random access for that type.
let reg = case rhs of
StartOfRegionLE r -> regionToVar r
InRegionLE r -> regionToVar r
AfterConstantLE _ lc -> renv # lc
AfterVariableLE _ lc _ -> renv # lc
AfterConstantLE _ _ lc -> renv # lc
AfterVariableLE _ _ lc _ -> renv # lc
FromEndLE lc -> renv # lc -- TODO: This needs to be fixed
in needsRANExp ddefs fundefs env2 (M.insert loc reg renv) tcenv parlocss bod
_ -> S.empty
Expand Down
4 changes: 2 additions & 2 deletions gibbon-compiler/src/Gibbon/Passes/AddTraversals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ addTraversalsExp ddefs fundefs env2 renv context ex =
let reg = case locexp of
StartOfRegionLE r -> regionToVar r
InRegionLE r -> regionToVar r
AfterConstantLE _ lc -> renv # lc
AfterVariableLE _ lc _ -> renv # lc
AfterConstantLE _ _ lc -> renv # lc
AfterVariableLE _ _ lc _ -> renv # lc
FromEndLE lc -> renv # lc -- TODO: This needs to be fixed
in Ext <$> LetLocE loc locexp <$>
addTraversalsExp ddefs fundefs env2 (M.insert loc reg renv) context bod
Expand Down
6 changes: 4 additions & 2 deletions gibbon-compiler/src/Gibbon/Passes/CalculateBounds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ calculateBoundsExp ddefs env2 varSzEnv varLocEnv locRegEnv locOffEnv regSzEnv re
else do
let (re, off) = case locExp of
(StartOfRegionLE r ) -> (regionToVar r, BoundedSize 0)
(AfterConstantLE n l ) -> (locRegEnv # l, locOffEnv # l <> BoundedSize n)
-- [2024.12.04] VS: currently discarding offsets for SoA representation
(AfterConstantLE n _ l ) -> (locRegEnv # l, locOffEnv # l <> BoundedSize n)
-- [2022.12.26] CSK: the lookup in varSzEnv always fails since the
-- pass never inserts anything into it. Disabling it for now.
(AfterVariableLE v l _) -> (locRegEnv # l, locOffEnv # (varLocEnv # v)) -- <> varSzEnv # v
-- [2024.12.04] VS: currently discarding offsets for SoA representation
(AfterVariableLE v _ l _) -> (locRegEnv # l, locOffEnv # (varLocEnv # v)) -- <> varSzEnv # v
(InRegionLE r ) -> (regionToVar r, Undefined)
(FromEndLE l ) -> (locRegEnv # l, Undefined)
FreeLE -> undefined
Expand Down
7 changes: 5 additions & 2 deletions gibbon-compiler/src/Gibbon/Passes/Cursorize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,12 @@ cursorizeReadPackedFile ddfs fundefs denv tenv senv isPackedContext v path tyc r
cursorizeLocExp :: DepEnv -> TyEnv Var Ty2 -> SyncEnv -> LocVar -> LocExp -> Either DepEnv (Exp3, [Binds Exp3], TyEnv Var Ty2, SyncEnv)
cursorizeLocExp denv tenv senv lvar locExp =
case locExp of
AfterConstantLE i loc ->
AfterConstantLE i [] loc ->
let rhs = Ext $ AddCursor ((unwrapLocVar . toLocVar) loc) (LitE i)
in if isBound ((toLocVar) loc) tenv
then Right (rhs, [], tenv, senv)
else Left$ M.insertWith (++) ((toLocVar) loc) [((unwrapLocVar lvar),[],CursorTy,rhs)] denv
AfterConstantLE i irst loc -> error "cursorizeLocExp :: AfterConstantLE Bounds for SoA not implemented."
-- TODO: handle product types here

{- [2018.03.07]:
Expand All @@ -711,7 +712,7 @@ For BigInfinite regions, this is simple:
But Infinite regions do not support sizes yet. Re-enable this later.
-}
AfterVariableLE v locarg was_stolen -> do
AfterVariableLE v [] locarg was_stolen -> do
let vty = case M.lookup v tenv of
Just ty -> ty
Nothing -> case M.lookup v senv of
Expand Down Expand Up @@ -763,6 +764,8 @@ But Infinite regions do not support sizes yet. Re-enable this later.
Right (bod, bnds, tenv', M.delete v senv)
else Left $ M.insertWith (++) loc [((unwrapLocVar lvar),[],CursorTy,bod)] denv

AfterVariableLE v vrst locarg was_stolen -> error "TODO: cursorizeLocExp: AfterVariableLE offsets for SoA not implemented yet."

FromEndLE locarg ->
let loc = toLocVar locarg in
if isBound loc tenv
Expand Down
8 changes: 4 additions & 4 deletions gibbon-compiler/src/Gibbon/Passes/FindWitnesses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ findWitnesses p@Prog{fundefs} = mapMExprs fn p
then Ext $ LetLocE loc locexp $ goE (Set.insert loc bound) mp bod
else
case locexp of
AfterVariableLE v loc2 b ->
(go (Map.insert loc (DelayLoc (loc, (AfterVariableLE v loc2 b))) mp) bod)
AfterConstantLE i loc2 ->
go (Map.insert loc (DelayLoc (loc, (AfterConstantLE i loc2))) mp) bod
AfterVariableLE v vs loc2 b ->
(go (Map.insert loc (DelayLoc (loc, (AfterVariableLE v vs loc2 b))) mp) bod)
AfterConstantLE i irst loc2 ->
go (Map.insert loc (DelayLoc (loc, (AfterConstantLE i irst loc2))) mp) bod
_ -> Ext $ LetLocE loc locexp $ goE (Set.insert loc bound) mp bod
LetRegionE r sz ty bod -> Ext $ LetRegionE r sz ty $ go mp bod
LetParRegionE r sz ty bod -> Ext $ LetParRegionE r sz ty $ go mp bod
Expand Down
2 changes: 1 addition & 1 deletion gibbon-compiler/src/Gibbon/Passes/FollowPtrs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ followPtrs (Prog ddefs fundefs mainExp) = do
let in_locs = foldr (\loc acc -> if loc == scrt_loc then ((Single indir_ptrv) : acc) else (loc : acc)) [] (inLocVars funTy)
let out_locs = outLocVars funTy
wc <- gensym "wildcard"
let indir_bod = Ext $ LetLocE (Single jump) (AfterConstantLE 8 (Single indir_ptrloc)) $
let indir_bod = Ext $ LetLocE (Single jump) (AfterConstantLE 8 [] (Single indir_ptrloc)) $
(if isPrinterName funName then LetE (wc,[],ProdTy[],PrimAppE PrintSym [LitSymE (toVar " ->i ")]) else id) $
LetE (callv,endofs',out_ty,AppE funName (in_locs ++ out_locs) args) $
Ext (RetE ret_endofs callv)
Expand Down
Loading

0 comments on commit 947bdc4

Please sign in to comment.