Skip to content

Commit

Permalink
uc-crux-llvm: Prefer TypeApplications when using Proxy (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
langston-barrett authored Dec 9, 2021
1 parent c07213c commit 0d01800
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
5 changes: 5 additions & 0 deletions uc-crux-llvm/.hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
lhs: "Prettyprinter.pretty (show x)"
rhs: 'Prettyprinter.viaShow x'

- error:
name: Use TypeApplications
lhs: "Proxy :: a"
rhs: 'Proxy @Whatever'

# Ignored
# -------

Expand Down
3 changes: 2 additions & 1 deletion uc-crux-llvm/src/UCCrux/LLVM/Context/Module.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Stability : provisional
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

module UCCrux.LLVM.Context.Module
( ModuleContext,
Expand Down Expand Up @@ -204,7 +205,7 @@ findFun modCtx funcSym =
case retTy of
Nothing -> panic "findFun" ["Missing return type"]
Just (Some retTy') ->
case testCompatibility (Proxy :: Proxy arch) retTy' cRetTy of
case testCompatibility (Proxy @arch) retTy' cRetTy of
Just Refl ->
CFGWithTypes
{ cfgWithTypes = cfg,
Expand Down
5 changes: 3 additions & 2 deletions uc-crux-llvm/src/UCCrux/LLVM/FullType/Translation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Stability : provisional
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

Expand Down Expand Up @@ -208,7 +209,7 @@ translateModuleDefines llvmModule trans =
if isVarArgs
then removeVarArgsRepr crucibleTypes
else Some crucibleTypes
case testCompatibilityAssign (Proxy :: Proxy arch) fullTypes crucibleTypes' of
case testCompatibilityAssign (Proxy @arch) fullTypes crucibleTypes' of
Just Refl ->
pure $
FunctionTypes
Expand Down Expand Up @@ -252,7 +253,7 @@ translateModuleDefines llvmModule trans =
(withExceptT FullTypeTranslation . toFullTypeM)
(fdRetType liftedDecl)
SomeAssign' crucibleTypes Refl _ <-
pure $ assignmentToCrucibleType (Proxy :: Proxy arch) fullTypes
pure $ assignmentToCrucibleType (Proxy @arch) fullTypes
pure $
FunctionTypes
{ ftArgTypes = MatchingAssign fullTypes crucibleTypes,
Expand Down
3 changes: 2 additions & 1 deletion uc-crux-llvm/src/UCCrux/LLVM/Overrides/Skip.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Stability : provisional
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

module UCCrux.LLVM.Overrides.Skip
( SkipOverrideName (..),
Expand Down Expand Up @@ -475,7 +476,7 @@ createSkipOverride modCtx sym usedRef annotationRef clobbers postcondition funcS
"createSkipOverride"
["Mismatched return types - CFG was non-void"]
(_, Just (Some retFullType)) ->
case testEquality (toCrucibleType (Proxy :: Proxy arch) retFullType) ret of
case testEquality (toCrucibleType (Proxy @arch) retFullType) ret of
Nothing ->
panic
"createSkipOverride"
Expand Down
5 changes: 3 additions & 2 deletions uc-crux-llvm/src/UCCrux/LLVM/PP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Stability : provisional
-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

module UCCrux.LLVM.PP
( ppRegValue,
Expand Down Expand Up @@ -82,13 +83,13 @@ ppRegMap _proxy funCtx sym mem (Crucible.RegMap regmap) =
toListFC getConst
<$> Ctx.traverseWithIndex
( \index (Const storageType) ->
case translateIndex (Proxy :: Proxy arch) (Ctx.size (funCtx ^. argumentStorageTypes)) index of
case translateIndex (Proxy @arch) (Ctx.size (funCtx ^. argumentStorageTypes)) index of
SomeIndex idx Refl ->
do
let regEntry = regmap Ctx.! idx
arg <-
liftIO $
ppRegValue (Proxy :: Proxy arch) sym mem storageType regEntry
ppRegValue (Proxy @arch) sym mem storageType regEntry
pure $
Const $
PP.hsep
Expand Down
11 changes: 6 additions & 5 deletions uc-crux-llvm/src/UCCrux/LLVM/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Stability : provisional
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

Expand Down Expand Up @@ -107,7 +108,7 @@ constrainHere ::
Crucible.RegEntry sym (ToCrucibleType arch atTy) ->
Setup m arch sym argTypes (Crucible.RegEntry sym (ToCrucibleType arch atTy))
constrainHere sym _selector constraint fullTypeRepr regEntry@(Crucible.RegEntry _typeRepr regValue) =
liftIO (constraintToPred (Proxy :: Proxy arch) sym constraint fullTypeRepr regValue) >>=
liftIO (constraintToPred (Proxy @arch) sym constraint fullTypeRepr regValue) >>=
assume constraint >>
return regEntry

Expand Down Expand Up @@ -163,7 +164,7 @@ generateM' h1 gen =
( \(n :: NatRepr n) ->
case NatRepr.leqAdd2
(LeqProof :: LeqProof n h)
(NatRepr.leqRefl (Proxy :: Proxy 1) :: LeqProof 1 1) ::
(NatRepr.leqRefl (Proxy @1) :: LeqProof 1 1) ::
LeqProof (n + 1) (h + 1) of
LeqProof -> gen n
)
Expand Down Expand Up @@ -306,11 +307,11 @@ generate sym modCtx ftRepr selector (ConstrainedShape shape) =
(selector & selectorCursor %~ deepenStruct idx)
(ConstrainedShape (fields ^. ixF' idx))
let fieldVals =
FTCT.generate (Proxy :: Proxy arch) (Ctx.size fields) $
FTCT.generate proxy (Ctx.size fields) $
\idx _ Refl -> fields' ^. ixF' idx . Shape.tag . to getSymValue . to Crucible.RV
pure $ Shape.ShapeStruct (SymValue fieldVals) fields'
where
proxy = Proxy :: Proxy arch
proxy = Proxy @arch
constrain ::
Compose [] (Constraint m) atTy ->
Shape m (SymValue sym arch) atTy ->
Expand Down Expand Up @@ -360,7 +361,7 @@ generateArgs _appCtx modCtx funCtx sym argSpecs =
( shapes,
Crucible.RegMap $
FTCT.generate
(Proxy :: Proxy arch)
(Proxy @arch)
(Ctx.size (funCtx ^. argumentFullTypes))
( \index index' Refl ->
Crucible.RegEntry
Expand Down
6 changes: 3 additions & 3 deletions uc-crux-llvm/src/UCCrux/LLVM/Setup/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Stability : provisional
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}

Expand Down Expand Up @@ -347,8 +348,7 @@ store sym mts ptrRepr selector ptr regValue =
\mem ->
do
ptr' <- annotatePointer sym selector ptrRepr ptr
let proxy = Proxy :: Proxy arch
mem' <- liftIO $ Mem.store' proxy sym mem mts ptrRepr ptr' regValue
mem' <- liftIO $ Mem.store' (Proxy @arch) sym mem mts ptrRepr ptr' regValue
pure (ptr', mem')

storeGlobal ::
Expand All @@ -373,5 +373,5 @@ storeGlobal sym ftRepr selector symb regValue =
\mem' ->
do
mem'' <-
liftIO $ Mem.store (Proxy :: Proxy arch) sym mem' ftRepr ptr' regValue
liftIO $ Mem.store (Proxy @arch) sym mem' ftRepr ptr' regValue
pure (ptr', mem'')

0 comments on commit 0d01800

Please sign in to comment.