vezba12 sppurv
-
Upload
branislav-vukovic -
Category
Documents
-
view
27 -
download
11
description
Transcript of vezba12 sppurv
-
I - 2015/ 12
1
. (
: , A
R R).
.
.
. 1
.
1.
, 2.
A := 0
B := A + 1
C := C + B
A := B * 2
A < N
B := A
1
USE DEF
I II III
OUT IN OUT IN OUT IN
6 a b a a a
5 a c ac ac ac ac ac
4 b a ac bc ac bc ac bc
3 bc c bc bc bc bc bc bc
2 a b bc ac bc ac bc ac
1 a ac c ac c ac c
1
A B C
A X
B X
C X X
2
,
:
1. , MOVE,
Bi : (A,
B1)(A,Bn)
2. MOVE =C,
Bi , C:(A, B1)(A,Bn); Bi
C
( ) .
: . Mips - 32 .
MOVE
. , , A
:= B.
-
I - 2015/ 12
2
R0, B R0. A := B
R0 := R0 .
.
, (
) . ,
. ,
, . ,
(),
( 32).
,
( ).
:
, ,
.
:
1. (build):
.
2. (simplify): :
G . G`
, G` = G {M}. G` G,
G`,
-1 , .
,
.
, . :
? ?
4
, 4 (). .
. , F
4 (3), .
().
E 3, 4,
(). .
.
-
I - 2015/ 12
3
F
E
B MKJ
D
C
GH
)
FE
B MKJ
D
C
GH
)
FB MKJ
D
C
GH
E
)
FMKJ
D
C
GH
E
B
)
FMJ
D
C
GH
E
B
K
)
FM
D
C
GH
E
B
K
J
)
2
3. (spill):
, .
.
, , ,
. ,
.
,
, .
, .
4. (select): .
. ,
.
.
.
Types.h. Instruction.
: (type), , (dst, src1,
src2). Instructions.
typedef struct InstructionStruct
{
InstructionType type;
Variable* dst;
Variable* src1;
Variable* src2;
} Instruction;
typedef list Instructions;
-
I - 2015/ 12
4
Variable : (name),
(pos), (assigment).
Variables.
struct Variable
{
char name;
int pos;
Regs assigment;
};
typedef list Variables;
InstructionType,
: _MOVE, T_EQU, T_SUB, T_ADD, T_MUL, T_COND, T_RE T_OTHER.
Regs reg0, reg1, reg2 reg3.
InterferenceGraph.
(variables), (values)
(size). __INTERFERENCE__
__EMPTY__ .
typedef struct
{
Variables* variables;
char** values;
int size;
} InterferenceGraph;
2. 3 , B C.
0, B 1 C 2. (pos Variable)
. variables,
InterferenceGraph, . .
C, A B, (values) , B C.
: Lib.lib
LivnessAnalisysLib.lib.
Instructions.h.
.
, .
void printInstruction(Instruction* instr);
void printInstructions(Instructions* instrs);
Variable.h.
.
, .
void printVariables(Variables* variables);
void printVariable(Variable* variable);
-
I - 2015/ 12
5
LivnessAnalissysLib
LivnessAnalissysLib.h. doLivenessAnalysis
. debug __DEBUG__
.
Instructions* doLivenessAnalysis(int debug);
InterferenceGraph.h.
doInterferenceGraph , .
InterferenceGraph ( ).
( )
freeInterferenceGraph.
printInterferenceGraph.
InterferenceGraph* doInterferenceGraph(Instructions* instructions);
void freeInterferenceGraph(InterferenceGraph* ig);
void printInterferenceGraph(InterferenceGraph* ig);
( ) Lib.lib,
Simplification.h, doSimplification.
. ( 2).
, .
( ).
stack* doSimplification(InterferenceGraph* ig, int degree);
-
I - 2015/ 12
6
1. . doResourceAllocation
ResourceAllocation.h
.
.
bool doResourceAllocation(stack* simplificationStack,
InterferenceGraph* ig);