Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touch up Imp.hs in a couple places as I read through it #931

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/lib/Imp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Name
import Builder
import Syntax
import CheckType (CheckableE (..))
import Simplify
import Simplify (buildBlockSimplified, dceApproxBlock, emitSimplified, simplifyBlockToBlock)
import LabeledItems
import QueryType
import Util (enumerate)
Expand Down Expand Up @@ -294,7 +294,7 @@ translateTopLevel cc maybeDest (Abs bs body) = do
ab <- buildImpNaryAbs argTys \vs ->
extendSubst (bs @@> map Rename vs) do
outDest <- case maybeDest of
Nothing -> makeAllocDest Unmanaged =<< getType =<< substM body
Nothing -> makeAllocDest Unmanaged =<< getTypeSubst body
Just dest -> sinkM dest
void $ translateBlock (Just outDest) body
destToAtom outDest
Expand Down Expand Up @@ -411,7 +411,7 @@ toImpOp maybeDest op = case op of
liftMonoidCombine (sink xTy) (sink combine) (sink refVal) (sink x)
copyAtom refDest result
returnVal UnitVal
MPut x -> copyAtom refDest x >> returnVal UnitVal
MPut x -> copyAtom refDest x >> returnVal UnitVal
MGet -> do
resultTy <- resultTyM
dest <- allocDest maybeDest resultTy
Expand Down Expand Up @@ -526,9 +526,7 @@ toImpOp maybeDest op = case op of

toImpHof :: Emits o => Maybe (Dest o) -> PrimHof (Atom i) -> SubstImpM i o (Atom o)
toImpHof maybeDest hof = do
-- TODO: it's a shame to have to substitute the whole expression just to get its type.
-- Laziness *might* save us, but we should check.
resultTy <- getType =<< substM (Hof hof)
resultTy <- getTypeSubst (Hof hof)
case hof of
For (RegularFor d) (IxTy ixTy) (Lam (LamExpr b body)) -> do
ixTy' <- substM ixTy
Expand Down Expand Up @@ -889,13 +887,12 @@ type NaryLamDest = Abs (Nest (BinderP AtomNameC Dest)) Dest
makeNaryLamDest :: NaryPiType n -> SubstImpM i n (AbsPtrs NaryLamDest n)
makeNaryLamDest piTy = do
let allocInfo = (LLVM, CPU, Unmanaged) -- TODO! This is just a placeholder
result <- liftDestM allocInfo $ buildLocalDest do
liftDestM allocInfo $ buildLocalDest do
Abs decls dest <- buildDeclsDest $
makeNaryLamDestRec (Abs Empty UnitE, []) [] (sink piTy)
case decls of
Empty -> return dest
_ -> error "shouldn't have decls if we have empty indices"
return result

makeNaryLamDestRec :: forall n. Emits n => DestIdxs n -> DepVars n
-> NaryPiType n -> DestM n (NaryLamDest n)
Expand Down