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

Const structs #476

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 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
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
435 changes: 353 additions & 82 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
8 changes: 6 additions & 2 deletions src/AliasAnalysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ import Config (specialName2)
-- something outside the procedure scope ("AliasByParam" / "MaybeAliasByParam").
-- "AliasByParam" and "MaybeAliasByParam" won't be removed during the analysis,
-- but if the existence of a "MaybeAliasByParam" can change the outcome then we
-- consider the corresponding parameter as interesting.
-- consider the corresponding parameter as interesting. For variables aliased
-- to globals (resource values), we use "AliasByGlobal". For variables aliased
-- to global constant structures, we use "AliasByConst".
data AliasMapLocalItem
= LiveVar PrimVarName
| AliasByGlobal GlobalInfo
| AliasByConst
| AliasByParam PrimVarName
| MaybeAliasByParam PrimVarName
deriving (Eq, Ord, Show)
Expand Down Expand Up @@ -273,7 +276,7 @@ updateAliasedByPrim aliasMap prim =
let ProcDefPrim _ calleeProto _ analysis _ = procImpln calleeDef
let calleeParamAliases = procArgAliasMap analysis
logAlias $ "--- call " ++ show spec ++" (callee): "
logAlias $ "" ++ show calleeProto
++ show calleeProto
logAlias $ "PrimCall args: " ++ show args
let paramArgMap = mapParamToArgVar calleeProto args
-- calleeArgsAliasMap is the alias map of actual arguments passed
Expand Down Expand Up @@ -342,6 +345,7 @@ _maybeAliasPrimArgs args = do
case arg of
ArgVar{argVarName=var, argVarType=ty} -> maybeAddressAlias arg ty $ LiveVar var
ArgGlobal global ty -> maybeAddressAlias arg ty $ AliasByGlobal global
ArgConstRef global ty -> maybeAddressAlias arg ty AliasByConst
_ -> return Nothing
maybeAddressAlias arg ty item = do
rep <- lookupTypeRepresentation ty
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
Loading