@@ -9,7 +9,10 @@ signature module InputSig {
9
9
* A basic block, that is, a maximal straight-line sequence of control flow nodes
10
10
* without branches or joins.
11
11
*/
12
- class BasicBlock ;
12
+ class BasicBlock {
13
+ /** Gets a textual representation of this basic block. */
14
+ string toString ( ) ;
15
+ }
13
16
14
17
/**
15
18
* Gets the basic block that immediately dominates basic block `bb`, if any.
@@ -43,7 +46,10 @@ signature module InputSig {
43
46
class ExitBasicBlock extends BasicBlock ;
44
47
45
48
/** A variable that can be SSA converted. */
46
- class SourceVariable ;
49
+ class SourceVariable {
50
+ /** Gets a textual representation of this variable. */
51
+ string toString ( ) ;
52
+ }
47
53
48
54
/**
49
55
* Holds if the `i`th node of basic block `bb` is a (potential) write to source
@@ -844,8 +850,6 @@ module Make<InputSig Input> {
844
850
}
845
851
846
852
/** Provides a set of consistency queries. */
847
- // TODO: Make these `query` predicates once class signatures are supported
848
- // (`SourceVariable` and `BasicBlock` must have `toString`)
849
853
module Consistency {
850
854
/** A definition that is relevant for the consistency queries. */
851
855
abstract class RelevantDefinition extends Definition {
@@ -856,27 +860,27 @@ module Make<InputSig Input> {
856
860
}
857
861
858
862
/** Holds if a read can be reached from multiple definitions. */
859
- predicate nonUniqueDef ( RelevantDefinition def , SourceVariable v , BasicBlock bb , int i ) {
863
+ query predicate nonUniqueDef ( RelevantDefinition def , SourceVariable v , BasicBlock bb , int i ) {
860
864
ssaDefReachesRead ( v , def , bb , i ) and
861
865
not exists ( unique( Definition def0 | ssaDefReachesRead ( v , def0 , bb , i ) ) )
862
866
}
863
867
864
868
/** Holds if a read cannot be reached from a definition. */
865
- predicate readWithoutDef ( SourceVariable v , BasicBlock bb , int i ) {
869
+ query predicate readWithoutDef ( SourceVariable v , BasicBlock bb , int i ) {
866
870
variableRead ( bb , i , v , _) and
867
871
not ssaDefReachesRead ( v , _, bb , i )
868
872
}
869
873
870
874
/** Holds if a definition cannot reach a read. */
871
- predicate deadDef ( RelevantDefinition def , SourceVariable v ) {
875
+ query predicate deadDef ( RelevantDefinition def , SourceVariable v ) {
872
876
v = def .getSourceVariable ( ) and
873
877
not ssaDefReachesRead ( _, def , _, _) and
874
878
not phiHasInputFromBlock ( _, def , _) and
875
879
not uncertainWriteDefinitionInput ( _, def )
876
880
}
877
881
878
882
/** Holds if a read is not dominated by a definition. */
879
- predicate notDominatedByDef ( RelevantDefinition def , SourceVariable v , BasicBlock bb , int i ) {
883
+ query predicate notDominatedByDef ( RelevantDefinition def , SourceVariable v , BasicBlock bb , int i ) {
880
884
exists ( BasicBlock bbDef , int iDef | def .definesAt ( v , bbDef , iDef ) |
881
885
ssaDefReachesReadWithinBlock ( v , def , bb , i ) and
882
886
( bb != bbDef or i < iDef )
0 commit comments