• Russ Cox's avatar
    cmd/6g: move opt instruction decode into common function · 24c8035f
    Russ Cox authored
    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
    24c8035f
opt.h 5.93 KB