-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschedutils.h
More file actions
133 lines (91 loc) · 3.12 KB
/
Copy pathschedutils.h
File metadata and controls
133 lines (91 loc) · 3.12 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
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
#ifndef SCHEDUTILS
#define SCHEDUTILS
#include <stdlib.h>
// The different possible instructions
typedef enum { NOP=1, ADDI, ADD, SUBI, SUB, MULT, DIV, LOAD, LOADI, LOADAO, LOADAI, STORE, STOREAO, STOREAI, OUTPUT } CodeType;
struct Values {
int isRegister; // tells whether if register or not
int value; // if it is a register, tells the register number. It may also tell the number value
int dependencyType; // 0 if RAW (true), 1 if WAR (anti)
};
typedef struct Values* Register;
struct Restriction {
struct Command* restricts;
int isAnti; // set to 1 if it's anti. Set to 50 if it's a memory, default to 0
int bothTrueMem; //set to 1 if the memory link is a true one
int depAntiDone;//set to 1 if the restriction is done processing (dependency dead)
int depMemDone;//set to 1 if the restriction is done proceessing (dependency mem dead)
};
typedef struct Restriction* Dependency;
struct Command {
CodeType opcode; // What type of instruction this holds
int latency;
struct Command* next;
struct Command* prev;
int ismem; // Flag to determine whether this instruction is movable or not
int ismemread;
int ismemwrite;
Register firstReg; // Will always have something
Register secondReg; // May be null
Register outputReg1; // May be null
Register outputReg2; // May be null
Dependency depends[5];// 0 is for mem Read, 1 through 4 are same
struct Command** memoryDepends;
int numdepends;
struct Command** successors; // successors allocate index = # of instructions
int numInstructions;
int priority;
int cycle;
int delay;
int isDone;
int hasAnti;
int isReady;
int isActive;
int isLeaves;
int hasMemTrue;
int found;
};
typedef struct Command* Instruction;
typedef struct Node {
Instruction pointer;
struct Node* next;
} Node;
typedef struct Queue {
Node* head;
Node* tail;
void (*push) (struct Queue*, Instruction);
Instruction (*pop) (struct Queue*);
Instruction (*peek) (struct Queue*);
Instruction (*removeNode) (struct Queue*, Instruction);
int size;
} Queue;
int notreadyMemCheck(Instruction node);
void addReady(Queue* ready, Instruction* active, Instruction node, int index);
void push(Queue* queue, Instruction instr);
Instruction pop (Queue* queue);
Instruction peek(Queue* queue);
Instruction removeNode(Queue* queue, Instruction instr);
Queue createQueue();
void chooseOp(Instruction head, char* token);
void init(Instruction* head);
void destroy(Instruction node);
void createReg(Instruction head, char* token, int index);
void create(Instruction* head);
void destroyRep(Instruction head);
void buildDeps(Instruction head);
void longlatency(Instruction head);
void highlatency(Instruction head);
void choice(Instruction head);
void memory_deps(Instruction head, int index);
void deps(Instruction head);
void sort(Instruction head);
void helperLL(Instruction head, int extra, int isAnti);
void print(Instruction head);
void printDeps(Instruction head);
void printAllDeps(Instruction head);
void schedule(Instruction head);
void addIn(Instruction temp, Instruction head, int index);
int readyCheck(Instruction node);
void debugPrint(Instruction head);
void printNode(Instruction head);
#endif