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

Remove packing for bools. #5449

Merged
merged 7 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion unison-runtime/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ flags:
stackchecks:
manual: true
default: false
dumpcore:
manual: true
default: false

when:
- condition: flag(arraychecks)
cpp-options: -DARRAY_CHECK
- condition: flag(stackchecks)
cpp-options: -DSTACK_CHECK

- condition: flag(dumpcore)
ghc-options: -ddump-simpl -ddump-stg-final -ddump-to-file -dsuppress-coercions -dsuppress-idinfo -dsuppress-module-prefixes # -dsuppress-type-applications -dsuppress-type-signatures

library:
source-dirs: src
Expand Down
28 changes: 23 additions & 5 deletions unison-runtime/src/Unison/Runtime/ANF.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Unison.Runtime.ANF
pattern TApv,
pattern TCom,
pattern TCon,
pattern UFalse,
pattern UTrue,
pattern TKon,
pattern TReq,
pattern TPrm,
Expand Down Expand Up @@ -1290,7 +1292,9 @@ data POp
| INCI -- inc
| DECI -- dec
| LEQI -- <=
| LESI -- <
| EQLI -- ==
| NEQI -- !=
| TRNC -- truncate0
-- Nat
| ADDN -- +
Expand All @@ -1312,7 +1316,9 @@ data POp
| INCN -- inc
| DECN -- dec
| LEQN -- <=
| LESN -- <
| EQLN -- ==
| NEQN -- !=
-- Float
| ADDF -- +
| SUBF -- -
Expand All @@ -1321,7 +1327,9 @@ data POp
| MINF -- min
| MAXF -- max
| LEQF -- <=
| LESF -- <
| EQLF -- ==
| NEQF -- !=
| POWF -- pow
| EXPF -- exp
| SQRT -- sqrt
Expand Down Expand Up @@ -1396,6 +1404,8 @@ data POp
| -- Universal operations
EQLU -- ==
| CMPU -- compare
| LEQU -- <=
| LESU -- <
| EROR -- error
| -- Code
MISS -- isMissing
Expand Down Expand Up @@ -1423,6 +1433,10 @@ data POp
| RCAS -- Ref.cas
| RRFC -- Ref.readForCas
| TIKR -- Ref.Ticket.read
-- Bools
| NOTB -- not
| ANDB -- and
| IORB -- or
deriving (Show, Eq, Ord, Enum, Bounded)

type ANormal = ABTN.Term ANormalF
Expand Down Expand Up @@ -1742,9 +1756,13 @@ anfHandled body =
cc = case l of T {} -> BX; LM {} -> BX; LY {} -> BX; _ -> UN
p -> pure p

fls, tru :: (Var v) => ANormal v
fls = TCon Ty.booleanRef 0 []
tru = TCon Ty.booleanRef 1 []
pattern UFalse <- TCon ((== Ty.booleanRef) -> True) 0 []
where
UFalse = TCon Ty.booleanRef 0 []

pattern UTrue <- TCon ((== Ty.booleanRef) -> True) 1 []
where
UTrue = TCon Ty.booleanRef 1 []

-- Helper function for renaming a variable arising from a
-- let v = u
Expand Down Expand Up @@ -1882,7 +1900,7 @@ anfBlock (And' l r) = do
let tree =
TMatch vl . MatchDataCover Ty.booleanRef $
mapFromList
[ (0, ([], fls)),
[ (0, ([], UFalse)),
(1, ([], tmr))
]
pure (lctx, (Indirect () <> d, tree))
Expand All @@ -1892,7 +1910,7 @@ anfBlock (Or' l r) = do
let tree =
TMatch vl . MatchDataCover Ty.booleanRef $
mapFromList
[ (1, ([], tru)),
[ (1, ([], UTrue)),
(0, ([], tmr))
]
pure (lctx, (Indirect () <> d, tree))
Expand Down
11 changes: 11 additions & 0 deletions unison-runtime/src/Unison/Runtime/ANF/Serialize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,17 @@ pOpCode op = case op of
RCAS -> 134
RRFC -> 135
TIKR -> 136
LESI -> 137
NEQI -> 138
LESN -> 139
NEQN -> 140
LESF -> 141
NEQF -> 142
LEQU -> 143
LESU -> 144
NOTB -> 145
ANDB -> 146
IORB -> 147

pOpAssoc :: [(POp, Word16)]
pOpAssoc = map (\op -> (op, pOpCode op)) [minBound .. maxBound]
Expand Down
Loading
Loading