how many temp registers do we have?

32 views
Skip to first unread message

Peter Chen

unread,
Dec 1, 2012, 8:04:20 PM12/1/12
to uoft_csc...@googlegroups.com

Peter Goodman

unread,
Dec 1, 2012, 10:15:03 PM12/1/12
to uoft_csc...@googlegroups.com
That is hardware dependent, so there is no "right" answer. See this for more details: http://www.eecg.toronto.edu/~jzhu/csc467/readings/ARB_Fragment_Program.pdf

I suggest coming up with a strategy that allows you to re-use temp registers.

Best Regards,

Peter Goodman,
http://www.petergoodman.me
65 High Park Ave.,
Toronto, Ontario
M6P 2R7


On Sat, Dec 1, 2012 at 8:04 PM, Peter Chen <peter.fe...@gmail.com> wrote:

--
 
 

Peter Chen

unread,
Dec 1, 2012, 10:28:46 PM12/1/12
to uoft_csc...@googlegroups.com
would marks be deducted if i assume infinity? :D

Peter Goodman

unread,
Dec 1, 2012, 10:34:17 PM12/1/12
to uoft_csc...@googlegroups.com
No, marks will not be deducted.

I think the way I will test things is to make an interpreter for ARB fragment assembly. Test cases would then depend on the values in the result variables at the end of interpretation. I would run all programs through that interpreter, which itself would not have any bounds on temp registers.

I do think it would be a good exercise for you to figure out how to re-use registers though ;-)

Best Regards,

Peter Goodman,
http://www.petergoodman.me
65 High Park Ave.,
Toronto, Ontario
M6P 2R7


--
 
 

Peter Chen

unread,
Dec 1, 2012, 10:51:10 PM12/1/12
to uoft_csc...@googlegroups.com
sure....can i have another week of extensions....

Peter Goodman

unread,
Dec 1, 2012, 11:06:20 PM12/1/12
to uoft_csc...@googlegroups.com
No. Re-using temp registers should not take you one week. Here is a simple example of an approach that might work:

  1. For each non-constant variable type t, maintain two counters: allocated_t and needed_t.
  2. Create an AST visitor that, for each top-level expression in a statement, does the following:
    1. Set allocated_t = 0 for all t before visiting any expressions in the statement.
    2. For each sub-expression of type t, increment allocated_t. If allocated_t > needed_t then increment needed_t.
  3. For each type t, initialize needed_t temporary registers at the beginning of your program.
  4. When doing codegen, use allocated_t in a similar way to decide which temporary register to use to store an intermediate result of type t.

Best Regards,

Peter Goodman,
http://www.petergoodman.me
65 High Park Ave.,
Toronto, Ontario
M6P 2R7


--
 
 

Reply all
Reply to author
Forward
0 new messages