Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Optimization The machine-independent code-optimization phase attempts to improve the intermediate code so that better target code will result

Optimization The machine-independent code-optimization phase attempts to improve the intermediate code so that better target code will result

Computer Science

Optimization
The machine-independent code-optimization phase attempts to improve the
intermediate code so that better target code will result. Usually better means
faster, but other ob jectives may be desired, such as shorter code, or target code
that consumes less power. For example, a straightforward algorithm generates
the intermediate code (1.3), using an instruction for each operator in the tree
representation that comes from the semantic analyzer.
A simple intermediate code generation algorithm followed by code optimiza-
tion is a reasonable way to generate good target code. The optimizer can deduce
that the conversion of 60 from integer to  oating point can be done once and for
all at compile time, so the intto oat operation can be eliminated by replacing
the integer 60 by the  oating-point number 60.0. Moreover, t3 is used only
once to transmit its value to id1 so the optimizer can transform (1.3) into the
shorter sequence
t1 = id3 * 60.0
id1 = id2 + t1 (1.4)
There is a great variation in the amount of code optimization dierent com-
pilers perform. In those that do the most, the so-called optimizing compilers,"
a signicant amount of time is spent on this phase. There are simple opti-
mizations that signicantly improve the running time of the target program
without slowing down compilation too much. The chapters from 8 on discuss
machine-independent and machine-dependent optimizations in detail.
1.2.6 Code Generation
The code generator takes as input an intermediate representation of the source
program and maps it into the target language. If the target language is machine
code, registers or memory locations are selected for each of the variables used by
the program. Then, the intermediate instructions are translated into sequences
of machine instructions that perform the same task. A crucial aspect of code
generation is the judicious assignment of registers to hold variables.
For example, using registers R1 and R2, the intermediate code in (1.4) might
get translated into the machine code
LDF R2, id3
MULF R2, R2, #60.0
LDF R1, id2
ADDF R1, R1, R2
STF id1, R1
(1.5)
The  rst operand of each instruction species a destination. The F in each
instruction tells us that it deals with  oating-point numbers.

A 6-node network with the following list of distances between various pairs of nodes: From To Node Node Distance 2 90 3 70 MJ 4 70 5 20 40 un 60 30 60 5 6 90 10a (10 points) Formulate finding the shortest route from node 1 to node 6 as a linear programming problem. 10b (10 points) Solve the problem on a linear programming software and show the total distance and the connections from node 1 to node 6 for the shortest route.

C# P-9 Programming PLO-2 Measured: Design, implement, and evaluate computer solutions utilizing structured and object-oriented programming methodologies. Design a class named Contractor. The class should keep the following information: Contractor name Contractor number . Contractor start date Write one or more constructors, and the appropriate accessor and mutator functions for the class. For this assignment and P-10 you will have to include an algorithm for you program. This will be a word document attached to the dropbox. Submit your REPL.it link to the written submission section of the assignment dropbox. This code will be used in P-10

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE