Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5538926
Eliminate ArgChar PrimArg constructor
pschachte Oct 22, 2024
9feb282
Move optimisation of constant casts to more appropriate place
pschachte Oct 23, 2024
759866d
Partially working. Infers const structs.
pschachte Nov 19, 2024
e9132fb
Add XXX comment to BodyBuilder.hs
pschachte Nov 19, 2024
7ca965a
Treat constant structs as aliased
pschachte Nov 20, 2024
0b9d5fe
Convert constant closures into constant structures
pschachte Nov 20, 2024
c880711
Extract GlobalFlows from const structures
pschachte Nov 29, 2024
f7c79ea
Optimise access of constant struct; allow conversion CPointer -> Signed
pschachte Nov 29, 2024
ef17b21
cleanup
pschachte Nov 29, 2024
8b5df6b
allow mutate of constant struct to produce another constant struct; tidy
pschachte Nov 29, 2024
801dd6c
Mark some expected output changes correct
pschachte Nov 29, 2024
e123125
Improve doc of BodyBuilder.hs
pschachte Dec 3, 2024
ab59b0f
Rebuild src/README.md
pschachte Dec 3, 2024
098e788
Some changed expected outputs
pschachte Dec 4, 2024
0ca80ad
Accept more test case outputs
pschachte Dec 5, 2024
15209e0
Fix problem with LLVM aligning undef ints for fill
pschachte Dec 5, 2024
e977fd0
Fix oversight scanning GenericStructMembers
pschachte Dec 5, 2024
76e37e3
Improve dumping and logging of string constants
pschachte Dec 10, 2024
5da5be3
Retain cast information when flattening
pschachte Dec 11, 2024
2670859
Fix regression in handling explicit typing
pschachte Dec 11, 2024
6cc278f
Fix bugs in flattening code with explicit types
pschachte Dec 12, 2024
65c77d9
Optimising constant closures already handled by bodybuilder
pschachte Dec 12, 2024
76d92f8
Add XXX comment about specialisation of specialisations.
pschachte Dec 15, 2024
27494a8
small doc change
pschachte Dec 18, 2024
e6f3d76
Fix test case expectation message
pschachte Feb 12, 2025
9d6b24c
First batch of update following code review.
pschachte Feb 12, 2025
cbd738b
Merge branch 'master' into const_structs
pschachte Apr 24, 2025
72defdf
Merge branch 'master' into const_structs
pschachte Sep 4, 2025
ec562ad
Address some review feedback
pschachte Sep 4, 2025
f19b08d
Move interning of WybeStrings to avoid extranous unreachable warnings…
jimbxb Nov 26, 2025
fb2cfb4
Merge branch 'master' of github.com:pschachte/wybe into const_structs
jimbxb Nov 26, 2025
04b434c
Merge branch 'master' of github.com:pschachte/wybe into const_structs
jimbxb Feb 10, 2026
e45e2a2
fix: remove unneeded args from constant closures
jimbxb Feb 10, 2026
56a5f5f
feat: show table values in merged forks
jimbxb Feb 10, 2026
9ae8629
fix: dont cast closed vars in constants to i64
jimbxb Feb 10, 2026
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
484 changes: 389 additions & 95 deletions src/AST.hs

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions src/ASTShow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ instance Show Module where
bracketList "(" ", " ")" (show <$> modParams mod) ++
(if typeMods == defaultTypeModifiers
then ""
else "\n modifiers : " ++ (show $ typeModifiers int)) ++
else "\n modifiers : " ++ show (typeModifiers int)) ++
"\n representation : " ++
(if modIsType mod
then maybe "(not yet known)" show (modTypeRep mod)
Expand All @@ -46,6 +46,9 @@ instance Show Module where
intercalate "\n "
(List.map show $ Set.toList $ Set.unions $
List.map Map.keysSet $ Map.elems $ pubProcs int) ++
"\n constants : "
++ showMap "" "\n " ""
((++":: ") . show) show (modStructs mod) ++
if isNothing maybeimpl then "\n implementation not available"
else let impl = fromJust maybeimpl
in
Expand All @@ -65,8 +68,7 @@ instance Show Module where
(modSubmods impl)) ++
"\n procs : " ++ "\n" ++
showMap "" "\n\n" "" (const "") (showProcDefs 0)
(modProcs impl) ++
""
(modProcs impl)


-- |How to show a map, one line per item.
Expand Down
22 changes: 11 additions & 11 deletions src/AliasAnalysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Flow ((|>))
import Options (LogSelection (Analysis))
import Util
import Config (specialName2)
import Data.Maybe.HT (toMaybe)


-- This "AliasMapLocal" is used during analysis and it will be converted to
Expand All @@ -41,7 +42,7 @@ import Config (specialName2)
data AliasMapLocalItem
= LiveVar PrimVarName
| AliasByGlobal GlobalInfo
| AliasByConstant PrimArg
| AliasByConst StructID
| AliasByParam PrimVarName
| MaybeAliasByParam PrimVarName
deriving (Eq, Ord, Show)
Expand Down Expand Up @@ -198,7 +199,8 @@ aliasedByFork caller body analysisInfo = do
return $ mergeAnalysisInfo analysisInfos
MergedFork{} -> do
logAlias ">>> Merged fork:"
aliasedByFork caller body{bodyFork=unMergeFork fork} analysisInfo
fork' <- unMergeFork fork
aliasedByFork caller body{bodyFork=fork'} analysisInfo
NoFork -> do
logAlias ">>> No fork."
-- drop "deadCells", we don't need it after fork
Expand Down Expand Up @@ -342,16 +344,14 @@ _maybeAliasPrimArgs args = do
let escapedVars = catMaybes args'
return escapedVars
where
filterArg arg@ArgVar{argVarName=var, argVarType=ty} = maybeAddressAlias arg ty $ LiveVar var
filterArg arg@(ArgGlobal global ty) = maybeAddressAlias arg ty $ AliasByGlobal global
filterArg arg@ArgClosure{} | argIsConst arg = return $ Just $ AliasByConstant arg
filterArg arg@ArgString{} = return $ Just $ AliasByConstant arg
filterArg _ = return Nothing
maybeAddressAlias arg ty item = do
filterArg arg = case arg of
ArgVar{argVarName=var, argVarType=ty} -> maybeAddressAlias ty $ LiveVar var
ArgGlobal global ty -> maybeAddressAlias ty $ AliasByGlobal global
ArgConstRef ref ty -> maybeAddressAlias ty $ AliasByConst ref
_ -> return Nothing
maybeAddressAlias ty item = do
rep <- lookupTypeRepresentation ty
if maybe False aliasedRep rep
then return $ Just item
else return Nothing
return $ toMaybe (maybe False aliasedRep rep) item
aliasedRep CPointer = True
aliasedRep Pointer = True
aliasedRep Func{} = True
Expand Down
3 changes: 3 additions & 0 deletions src/BinaryFactory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ instance Binary ProcFunctor
instance Binary ParamInfo
instance Binary Prim
instance Binary PrimVarName
instance Binary ConstValue
instance Binary StructInfo
instance Binary PrimArg
instance Binary ProcAnalysis
instance Binary GlobalFlows
Expand Down Expand Up @@ -72,6 +74,7 @@ instance Binary Module
instance Binary PubProcInfo
instance Binary ModuleInterface
instance Binary Pragma
instance Binary StructID

instance Binary ProcModifiers
instance Binary Inlining
Expand Down
Loading