Write a program to perform constant propagation
|
1. For all 4-tuples do 1.1 get next 4-tuple 1.2 If the operator is
"Label" then 1.2.1
free the constant table 1.2.2
write the 4-tuple 1.3 If either or both of the operands are
in the constant table then 1.3.1
substitute the constant value(s) for the operand(s) 1.3.2
if either of the operands are intermediate results then 1.3.2.1
remove those operand(s) from the constant table. 1.4 if 4-tuple operand(s) are constant then 1.4.1 if
operator is "JPCT" then 1.4.1.1
if the operand is true then 1.4.1.1.1
replace the JPCT with JP 1.4.1.1.2
write the new 4-tuple else 1.4.1.1.3
eliminate the 4-tuple 1.4.2 if operator is "="
then 1.4.2.1
place the variable and constant in the constant table 1.4.2.2
write the 4-tuple with the constant operand 1.4.3 else 1.4.3.1
Perform the operation. 1.4.3.2
Place the intermediate result name and constant value in the constant
table.Else 1.4.4 write the 4-tuple Consider the
following sequence. |
Program for Write a program to perform constant propagation-
Enter the input :
= 3 - a
+ a b t1
+ a c t2
+ t1 t2 t3
+ 3 b t1
+ 3 c t2
+ t1 t2 t3
Comments
Post a Comment