5 const uint32 regmask_localvars
[NUM_REGMASK
] = { 0x43FFFFFE, 0x00000000 };
8 void mark_ssavar (struct ssavar
*var
, enum ssavartype type
, int num
)
15 useel
= list_head (var
->uses
);
17 struct operation
*use
= element_getvalue (useel
);
18 if (use
->type
== OP_PHI
) {
19 phiel
= list_head (use
->operands
);
21 struct value
*val
= element_getvalue (phiel
);
22 if (val
->val
.variable
->type
== SSAVAR_UNK
) {
23 mark_ssavar (val
->val
.variable
, type
, num
);
25 phiel
= element_next (phiel
);
27 val
= list_headvalue (use
->results
);
28 if (val
->val
.variable
->type
== SSAVAR_UNK
)
29 mark_ssavar (val
->val
.variable
, type
, num
);
31 useel
= element_next (useel
);
34 if (var
->def
->type
== OP_PHI
) {
35 phiel
= list_head (var
->def
->operands
);
37 struct value
*val
= element_getvalue (phiel
);
38 if (val
->val
.variable
->type
== SSAVAR_UNK
) {
39 mark_ssavar (val
->val
.variable
, type
, num
);
41 phiel
= element_next (phiel
);
46 void extract_variables (struct subroutine
*sub
)
51 varel
= list_head (sub
->ssavars
);
53 struct ssavar
*var
= element_getvalue (varel
);
54 if (var
->type
== SSAVAR_UNK
) {
55 if (IS_BIT_SET (regmask_localvars
, var
->name
.val
.intval
)) {
56 if (var
->def
->type
== OP_START
) {
57 mark_ssavar (var
, SSAVAR_ARGUMENT
, var
->name
.val
.intval
);
58 } else if (var
->def
->type
== OP_CALL
&& var
->name
.val
.intval
!= REGISTER_GPR_V0
&&
59 var
->name
.val
.intval
!= REGISTER_GPR_V1
) {
60 var
->type
= SSAVAR_INVALID
;
64 if (list_size (var
->uses
) <= 1) {
65 struct operation
*op
= list_headvalue (var
->uses
);
67 if (op
->type
!= OP_PHI
)
74 if (var
->def
->type
== OP_MOVE
|| var
->def
->type
== OP_INSTRUCTION
) {
75 if (var
->def
->type
== OP_INSTRUCTION
) {
76 if (var
->def
->info
.iop
.loc
->insn
->flags
& (INSN_LOAD
| INSN_STORE
| INSN_BRANCH
))
84 var
->def
->status
|= OPERATION_DEFERRED
;
85 var
->type
= SSAVAR_TEMP
;
88 mark_ssavar (var
, SSAVAR_LOCAL
, ++count
);
92 var
->type
= SSAVAR_ARGUMENT
;
95 varel
= element_next (varel
);