@@ -4,10 +4,107 @@ import Stg.Syntax
44
55data StgPoint
66 -- expression locations
7- = SP_CaseScrutineeExpr { spScrutineeResultName :: Name }
7+ = SP_CaseScrutineeExpr { spScrutineeResultName :: Id }
88 | SP_LetExpr { spParent :: StgPoint }
99 | SP_LetNoEscapeExpr { spParent :: StgPoint }
10- | SP_RhsClosureExpr { spRhsBinderName :: Name }
11- | SP_AltExpr { spScrutineeResultName :: Name , spAltIndex :: Int }
12- | SP_RhsCon { spRhsBinderName :: Name }
10+ | SP_RhsClosureExpr { spRhsBinderName :: Id }
11+ | SP_AltExpr { spScrutineeResultName :: Id , spAltIndex :: Int }
12+ | SP_RhsCon { spRhsBinderName :: Id }
1313 deriving (Eq , Ord , Show )
14+
15+ {-
16+ breakpoint types:
17+ - program point: IRPath
18+ - primop name
19+ - foreign symbol name
20+ -}
21+
22+ {-
23+ unitid - name
24+ Module - name
25+ topbinding - name
26+ binding - name
27+ rhs
28+ arg
29+ expr
30+ arg
31+ expr
32+ binding
33+ alt
34+ expr
35+ -}
36+ {-
37+ identification methods:
38+ - unique name
39+ - index (this means the parent's children index, e.g. Case's Alt chidren)
40+ -}
41+ {-
42+ StgPoint location root:
43+ - top IR data structure: [Module]
44+ - uniqueNamed
45+ TopBinding
46+ Binding (StgNonRec binding)
47+ Rhs (StgRec binding)
48+ Expr (StgCase)
49+ -}
50+ {-
51+ IR elements with unique names:
52+ - StgCase
53+ - StgNonRec
54+ - any Rhs ; from StgRec
55+ - StgTopStringLit
56+ -}
57+
58+ -- can select any type that StgIR can represent
59+ data FieldSelector
60+ -- generic
61+ = FS_UniqueName Name -- selects uniquely named IR element
62+ | FS_Binder Id -- selects uniquely named IR element
63+
64+ -- Module
65+ | FS_Module_moduleTopBindings Int -- selects: Module -> TopBinding
66+ -- TopBinding
67+ | FS_StgTopLifted_arg0 -- selects: TopBinding -> Binding
68+ -- Binding
69+ | FS_StgNonRec_arg0 -- selects: Binding -> Rhs
70+ | FS_StgRec_arg0 Int -- selects: Binding -> Rhs
71+ -- Rhs
72+ | FS_StgRhsClosure_arg0 Int -- selects: Rhs -> Binder
73+ | FS_StgRhsClosure_arg2 Int -- selects: Rhs -> Binder
74+ | FS_StgRhsClosure_arg3 -- selects: Rhs -> Expr
75+ | FS_StgRhsCon_arg1 Int -- selects: Rhs -> Arg
76+ -- Arg
77+ | FS_StgVarArg_arg0 -- selects: Arg -> Binder
78+ -- Expr
79+ | FS_StgApp_arg0 -- selects: Expr -> Binder
80+ | FS_StgApp_arg1 Int -- selects: Expr -> Arg
81+ | FS_StgConApp_arg1 Int -- selects: Expr -> Arg
82+ | FS_StgOpApp_arg1 Int -- selects: Expr -> Arg
83+ | FS_StgCase_arg0 -- selects: Expr -> Expr
84+ | FS_StgCase_arg1 -- selects: Expr -> Binder
85+ | FS_StgCase_arg3 Int -- selects: Expr -> Alt
86+ | FS_StgLet_arg0 -- selects: Expr -> Binding
87+ | FS_StgLet_arg1 -- selects: Expr -> Expr
88+ | FS_StgLetNoEscape_arg0 -- selects: Expr -> Binding
89+ | FS_StgLetNoEscape_arg1 -- selects: Expr -> Expr
90+ | FS_StgTick_arg0 -- selects: Expr -> Expr
91+ -- Alt
92+ | FS_Alt_altBinders Int -- selects: Alt -> Binder
93+ | FS_Alt_altRHS -- selects: Alt -> Expr
94+ deriving (Eq , Ord , Show )
95+
96+ type IRPath = [FieldSelector ]
97+
98+ data IR
99+ = IR_Module Module
100+ | IR_TopBinding TopBinding
101+ | IR_Binding Binding
102+ | IR_Rhs Rhs
103+ | IR_Arg Arg
104+ | IR_Expr Expr
105+ | IR_Alt Alt
106+ | IR_Binder Binder
107+ deriving (Eq , Ord , Show )
108+
109+ lookupIR :: IR -> IRPath -> IR
110+ lookupIR = undefined
0 commit comments