summaryrefslogtreecommitdiffstats
path: root/org.eclipse.ptp.pldt.mpi.analysis.cdt/src/org/eclipse/ptp/pldt/mpi/analysis/cdt/graphs/IBlock.java
blob: f61b879d4a96897c45f4f8fc0a430c3e494940c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**********************************************************************
 * Copyright (c) 2007 IBM Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ptp.pldt.mpi.analysis.cdt.graphs;

import java.util.List;

import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;

/**
 * A "Block" contains either a single statement or a predicate expression, 
 * and it can be entered only at the beginning and exited only at the end.
 * 
 * @author Yuan Zhang
 *
 */
public interface IBlock {
	/**
	 * @return the unique ID
	 */
	public int getID();

	/**
	 * @return the list of successors in the control flow graph
	 */
	public List<IBlock> getSuccs();
	
	/**
	 * @return the list of predecessors in the control flow graph
	 */
	public List<IBlock> getPreds();
	
	/**
	 * @return the next  block in CFG according to the topological 
	 * order (top-down order)
	 */
	public IBlock topNext();
	/**
	 * @return the next  block in CFG according to the topological 
	 * order (top-down order)
	 */
	public IBlock getTopNext();
	/**
	 * Set the next  block in CFG according to the topological 
	 * order (top-down order)
	 */
	public void setTopNext(IBlock b);
	
	/**
	 * Get the next block in CFG according to the reverse
	 * topological order (bottom-up order)
	 */
	public IBlock botNext();
	/**
	 * Get the next block in CFG according to the reverse
	 * topological order (bottom-up order)
	 */
	public IBlock getBotNext();
	/**
	 * Set the next block in CFG according to the reverse
	 * topological order (bottom-up order)
	 */
	public void setBotNext(IBlock b);

	/**
	 * @return the content (a predicate expression or a statement)
	 */
	public IASTNode getContent();
	
	/**
	 * Search to determine if a block contains an expression
	 * @return true if this block contains expression expr
	 * which is the predicate of statement <parent>, false otherwise.
	 */
	public boolean search(IASTExpression expr, IASTStatement parent);
	/** 
	 * Search to determine if a block contains a statement
	 * @return true if this block contains statement stmt,
	 * false otherwise.
	 */
	public boolean search(IASTStatement stmt);
	/**
	 * Search to determine if a block contains a given label
	 * @return true if this block contains label, false otherwise
	 */
	public boolean search(IASTName label);
	
	/**
	 * Get Dominators<br>
	 * Block A dominates another block B if every path from the entry that 
	 * reaches  block B has to pass through  block A.
	 * The entry block dominates all blocks.
	 * @return list of dominator IBlocks
	 */
	public List<IBlock> getDOM();
	/**
	 * Set dominators
	 * @param set list of dominators
	 */
	public void setDOM(List<IBlock> set);
	
	/**
	 * Get post-dominators<br>
	 * Block A postdominates block B if every path from B to the exit has to pass through block A.  
	 * The exit block postdominates all blocks.
	 * 
	 * @return list of post-dominator IBlocks
	 */
	public List<IBlock> getPDOM();
	/**
	 * set post-dominators
	 * @param set
	 */
	public void setPDOM(List<IBlock> set);

	/** 
	 * An attribute (identified by its name) of a block could be any 
	 * property of it.
	 * @param name
	 * @param attr
	 */
	public void setAttr(String name, Object attr);
	/**
	 * Get an attribute of a block
	 * @param name
	 * @return
	 */
	public Object getAttr(String name);
	
	/**
	 * Print IBlock information, include id, content, and successors
	 */
	public void print();
}