[28e18d]: Backend / If1opt / cascade.c  Maximize  Restore  History

Download this file

96 lines (80 with data), 3.1 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
/**************************************************************************/
/* FILE ************** cascade.c ************************/
/**************************************************************************/
/* Author: Dave Cann */
/* Update: Patrick Miller -- Ansi support (Dec 2000) */
/* Copyright (C) University of California Regents */
/**************************************************************************/
/*
* $Log:
*/
/**************************************************************************/
#include "world.h"
static void
TestCascade(G)
PNODE G;
{
PNODE SubG,N,Test,TrueSide,FalseSide;
PEDGE TestEdge,E,ENext;
int TestPort;
for(N=G->G_NODES; N; N = N->nsucc) {
if ( IsCompound(N) ) {
/* ------------------------------------------------------------ */
/* Recursively apply */
/* ------------------------------------------------------------ */
for(SubG = N->C_SUBS; SubG; SubG = SubG->gsucc) TestCascade(SubG);
if ( !IsBranch(N) )
continue;
switch (N->type) {
case IFSelect:
Test = N->S_TEST;
FalseSide = N->S_ALT;
TrueSide = N->S_CONS;
/* ------------------------------------------------------------ */
/* Find the test edge -- It must be an imported value */
/* ------------------------------------------------------------ */
TestEdge = FindImport(Test,1);
if ( TestEdge->src != Test ) break;
TestPort = TestEdge->eport;
/* ------------------------------------------------------------ */
/* If the test edge is used internally, set to true or false */
/* ------------------------------------------------------------ */
for(E=FalseSide->exp; E; E = ENext ) {
ENext = E->esucc;
if ( E->eport == TestPort ) {
UnlinkExport(E);
E->src = (PNODE)NULL;
E->eport = CONST_PORT;
E->CoNsT = "FALSE";
}
}
for(E=TrueSide->exp; E; E = ENext ) {
ENext = E->esucc;
if ( E->eport == TestPort ) {
UnlinkExport(E);
E->src = (PNODE)NULL;
E->eport = CONST_PORT;
E->CoNsT = "TRUE";
}
}
break;
default:
UNEXPECTED("Unknown branch");
}
}
}
}
/**************************************************************************/
/* GLOBAL ************** If1ITestCascade ************************/
/**************************************************************************/
/* PURPOSE: APPLY TEST CASCADE TO ALL THE NODES IN THE PROGRAM. */
/**************************************************************************/
void
If1TestCascade()
{
register PNODE f;
for ( f = glstop->gsucc; f != NULL; f = f->gsucc ) {
TestCascade( f );
FastCleanGraph( f );
}
}