Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!rochester!cornell!uw-beaver!uw-june!uw-entropy!dataio!bright From: bright@dataio.Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c Subject: Re: re-using registers Message-ID: <1334@dataio.Data-IO.COM> Date: Mon, 27-Jul-87 13:43:59 EDT Article-I.D.: dataio.1334 Posted: Mon Jul 27 13:43:59 1987 Date-Received: Tue, 28-Jul-87 05:35:14 EDT References: <2803@phri.UUCP> <1331@dataio.Data-IO.COM> <1668@sfsup.UUCP> <358@rufus.molly.UUCP> Reply-To: bright@dataio.UUCP (Walter Bright) Organization: Data I/O - FutureNet Corp., Redmond, WA Lines: 22 In article <358@rufus.molly.UUCP> john@rufus.molly.UUCP (John Franks) writes: >In article <1668@sfsup.UUCP>, grk@sfsup.UUCP (G.R.Kuntz) writes: >> On my master's thesis compiler I too did register allocation by graph coloring >Anybody want to explain what is register allocation by coloring? For register AX, you color in the top part of the A... :-) But seriously, Imagine an x-y graph. The each point on the horizontal axis corresponds to one statement in the program. Each point on the vertical axis corresponds to a variable that could be allocated to a register. Now graph with a pencil each x-y point where the value of variable y is required at point x. (This is called the 'live range' of each variable.) Now aquire a crayon for each register you have, a different color for each crayon. Find a way of assigning a crayon to each variable such that when the graph is redrawn with the crayons, at no statement x do any two variables have the same color. In other words, you can never have two variables assigned to the same register at the same time, and two variable can occupy the same register if their usages do not overlap.