search
Log In
0 votes
275 views
a x b x c + d - a + e x f - g + h
order of precedence : x>+>- ; with x is left associative and +, - as right.
Min number of variables required in TAC?
Should'nt the expression be expressed as :

((a x b) x c) + d - a + (e x f) - g + h
(((a x b) x c) + (d - (a + (e x f)) - (g + h)))
in Compiler Design
edited by
275 views
0
Minimum number of variables required in Three address code?Is it your question
0
((((a x b) x c) + d) - ((a +( e x f) )- (g + h)))
0
Yes @manas please explain wht's wrong in what I am doing.

@shivam yes
1
@manisha11 while paranthising you forgot that + has higher precedence over - and you treated as if both have same precedence and are right to left associative.
0
yeah
THANKS!
0
We have different types of 3address code representations like triple, quadruple ,indirect in which does the result wanted to be in?

Indirect doesn't use any extra variables I guess.
0
@hemanth i think in gate they ask to represent in general form of 3 address code
0
Will someone tell me how many minimum number of variables will be used in this question? @hemanth

@manisha11

@manas mishra
0

Shivam Kasat

Got 15 as below.

manisha11 what is the answer they have provided?

 

 

0
8 temperory variables + a-h(8)

16 ! Isn't it?
0
no its 15--> 7 temp + a-h(8)
0
t1-t8(8)+a-h(8)=16
According to your comment solution.
0
Yes sorry :P
0
:)
0

@Hemanth_13 The question is minimum number of variables required in three address code, does that mean SSA?

1
No SSA explicitly mention if they ask

see previous years 2015,16,17 questions
0
SSA is not mentioned..so 3 variables

2 Answers

0 votes
It must be 16 temporary variable.

(T1 to T8) and (a to h )
0 votes

Make sure it is 3 address code not SSA

so we can reuse temporary variable after using * > + > - precedence

* Left to right associative rest Right to Left

 

Related questions

1 vote
1 answer
1
373 views
Consider the intermediate code given below: The number of nodes and edges in the control-flow graph constructed for the above code, respectively are X and Y. The value of X + Y is ________.
asked Jan 24, 2018 in Compiler Design rahul sharma 5 373 views
4 votes
2 answers
2
455 views
The following program uses six temporary variables p, q, r, s, t and u. The code is : Assuming that all operations take their operands from registers. The minimum number of registers needed to execute this program without spilling are __________. The answer given is 5, but ... lines except the first three lines and the last line are dead code. So the answer should be 2. Please correct me if wrong.
asked Jan 22, 2018 in Compiler Design Saikat Dutta 455 views
1 vote
1 answer
4
201 views
someone please share detailed rules for this along with solution- would be of great help. and we usually dont take start and end state- arent they extra here? coz count comes different
asked Jan 8, 2019 in Compiler Design Markzuck 201 views
...