]> Cypherpunks repositories - gostls13.git/commit
cmd/6g: move opt instruction decode into common function
authorRuss Cox <rsc@golang.org>
Mon, 12 Aug 2013 01:46:38 +0000 (21:46 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 12 Aug 2013 01:46:38 +0000 (21:46 -0400)
commit24c8035fbe113dfe644f4419eadcb826e08788ee
tree756badb61ff255151905836a4a697b95e6c21a5c
parent9baac2bf157b61e47a4ab446bf1960f98f9847b5
cmd/6g: move opt instruction decode into common function

Add new proginfo function that returns information about a
Prog*. The information includes various instruction
description bits as well as a list of required registers set
and used and indexing registers used.

Convert the large instruction switches to use proginfo.

This information was formerly duplicated in multiple
optimization passes, inconsistently. For example, the
information about which registers an instruction requires
appeared three times for most instructions.

Most of the switches were incomplete or incorrect in some way.
For example, the switch in copyu did not list cases for INCB,
JPS, MOVAPD, MOVBWSX, MOVBWZX, PCDATA, POPQ, PUSHQ, STD,
TESTB, TESTQ, and XCHGL. Those were all falling into the
"unknown instruction" default case and stopping the rewrite,
perhaps unnecessarily. Similarly, the switch in needc only
listed a handful of the instructions that use or set the carry bit.

We still need to decide whether to use proginfo to generalize
a few of the remaining smaller switches in peep.c.

If this goes well, we'll make similar changes in 8g and 5g.

R=ken2
CC=golang-dev
https://golang.org/cl/12637051
src/cmd/6g/opt.h
src/cmd/6g/peep.c
src/cmd/6g/prog.c [new file with mode: 0644]
src/cmd/6g/reg.c