]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/[568]g: explain the purpose of various Reg fields.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 24 Sep 2012 18:55:11 +0000 (20:55 +0200)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 24 Sep 2012 18:55:11 +0000 (20:55 +0200)
R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6554062

src/cmd/5g/opt.h
src/cmd/6g/opt.h
src/cmd/8g/opt.h

index 7a0070fc9dce2a44410f9e0443f73a9b91b1e608..0f738188dd7dca0d697637f32648477fa1c441e2 100644 (file)
 typedef        struct  Reg     Reg;
 typedef        struct  Rgn     Rgn;
 
+// A Reg is a wrapper around a single Prog (one instruction) that holds
+// register optimization information while the optimizer runs.
+// r->prog is the instruction.
+// r->prog->regp points back to r.
 struct Reg
 {
 
-       Bits    set;
-       Bits    use1;
-       Bits    use2;
+       Bits    set;            // variables written by this instruction.
+       Bits    use1;           // variables read by prog->from.
+       Bits    use2;           // variables read by prog->to.
 
        Bits    refbehind;
        Bits    refahead;
@@ -70,13 +74,13 @@ struct      Reg
        uint16  loop;           // x5 for every loop
        uchar   refset;         // diagnostic generated
 
-       Reg*    p1;
-       Reg*    p2;
+       Reg*    p1;             // predecessors of this instruction: p1,
+       Reg*    p2;             // and then p2 linked though p2link.
        Reg*    p2link;
-       Reg*    s1;
+       Reg*    s1;             // successors of this instruction (at most two: s1 and s2).
        Reg*    s2;
-       Reg*    link;
-       Prog*   prog;
+       Reg*    link;           // next instruction in function code
+       Prog*   prog;           // actual instruction
 };
 #define        R       ((Reg*)0)
 
index 9a8866b8d1492220d6daa09de50bc32859fe01c6..5fb24737e8b4ddd3281069fb95eb7b182f87310e 100644 (file)
 typedef        struct  Reg     Reg;
 typedef        struct  Rgn     Rgn;
 
+// A Reg is a wrapper around a single Prog (one instruction) that holds
+// register optimization information while the optimizer runs.
+// r->prog is the instruction.
+// r->prog->regp points back to r.
 struct Reg
 {
 
-       Bits    set;
-       Bits    use1;
-       Bits    use2;
+       Bits    set;            // variables written by this instruction.
+       Bits    use1;           // variables read by prog->from.
+       Bits    use2;           // variables read by prog->to.
 
        Bits    refbehind;
        Bits    refahead;
@@ -70,13 +74,13 @@ struct      Reg
        uint16  loop;           // x5 for every loop
        uchar   refset;         // diagnostic generated
 
-       Reg*    p1;
-       Reg*    p2;
+       Reg*    p1;             // predecessors of this instruction: p1,
+       Reg*    p2;             // and then p2 linked though p2link.
        Reg*    p2link;
-       Reg*    s1;
+       Reg*    s1;             // successors of this instruction (at most two: s1 and s2).
        Reg*    s2;
-       Reg*    link;
-       Prog*   prog;
+       Reg*    link;           // next instruction in function code
+       Prog*   prog;           // actual instruction
 };
 #define        R       ((Reg*)0)
 
index ed6eb15ab4812ed1ecf91d7dc586a6a60fa7ffac..b80043e0f1ec72dd6475c87c4f7171badeb8531e 100644 (file)
 typedef        struct  Reg     Reg;
 typedef        struct  Rgn     Rgn;
 
+// A Reg is a wrapper around a single Prog (one instruction) that holds
+// register optimization information while the optimizer runs.
+// r->prog is the instruction.
+// r->prog->regp points back to r.
 struct Reg
 {
 
-       Bits    set;
-       Bits    use1;
-       Bits    use2;
+       Bits    set;            // variables written by this instruction.
+       Bits    use1;           // variables read by prog->from.
+       Bits    use2;           // variables read by prog->to.
 
        Bits    refbehind;
        Bits    refahead;
@@ -68,13 +72,13 @@ struct      Reg
        uint16  loop;           // x5 for every loop
        uchar   refset;         // diagnostic generated
 
-       Reg*    p1;
-       Reg*    p2;
+       Reg*    p1;             // predecessors of this instruction: p1,
+       Reg*    p2;             // and then p2 linked though p2link.
        Reg*    p2link;
-       Reg*    s1;
+       Reg*    s1;             // successors of this instruction (at most two: s1 and s2).
        Reg*    s2;
-       Reg*    link;
-       Prog*   prog;
+       Reg*    link;           // next instruction in function code
+       Prog*   prog;           // actual instruction
 };
 #define        R       ((Reg*)0)