-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayInfo.java
More file actions
63 lines (55 loc) · 1.9 KB
/
Copy pathArrayInfo.java
File metadata and controls
63 lines (55 loc) · 1.9 KB
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
import java.util.*;
import static java.util.stream.Collectors.*;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import org.antlr.v4.runtime.tree.ParseTreeProperty;
import org.antlr.v4.runtime.tree.TerminalNode;
class ArrayInfo{
// auxilliary data-structure for mapping types to their byte-size
// size x means the actual size is 2^x bytes, again ignoring strings
final Map<Analysis.Types, Integer> typeToSize = Collections.unmodifiableMap(new HashMap<Analysis.Types, Integer>() {
private static final long serialVersionUID = 1L;
{
put(Analysis.Types.Byte, 0);
put(Analysis.Types.Short, 1);
put(Analysis.Types.Int, 2);
put(Analysis.Types.Long, 3);
put(Analysis.Types.Char, 1);
put(Analysis.Types.Float, 2);
put(Analysis.Types.Double, 3);
put(Analysis.Types.Boolean, 0);
}
});
int ArrayDims;
Analysis.Types ArrayType;
long ArrayDim[] = new long[3];
String forLoopVar[] = new String[3];
int ElSize;
boolean isFlushed;
boolean cacheFitsBlocks;
public long Misses;
public ArrayInfo(int ADs, Analysis.Types AT, long AD[]) {
Misses = 1;
isFlushed = true;
cacheFitsBlocks = true;
ArrayDims = ADs;
ArrayType = AT;
for (int i = 0; i < ArrayDims; i++){
ArrayDim[i] = AD[i];
forLoopVar[i] = "";
}
ElSize = (int)Math.pow(2, typeToSize.get(ArrayType));
}
/************* USEFUL FOR DEBUGGING *************/
@Override
public String toString() {
String ret = "{ Type: " + ArrayType + " | Dims: ";
for (int i = 0; i < ArrayDims; i++){
ret += "[" + Long.toString(ArrayDim[i]) + "] ";
}
ret += " | Element Size: " + ElSize + " }";
return ret;
}
}