From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoann Padioleau To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Date: Tue, 14 Oct 2014 22:11:35 +0000 Message-ID: Content-Type: multipart/alternative; boundary="_000_AA00716C7B8A43A18B534454016F16B2fbcom_" MIME-Version: 1.0 Subject: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1cc332c0-ead9-11e9-9d60-3106f5b1d025 --_000_AA00716C7B8A43A18B534454016F16B2fbcom_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi, It=92s a copy paste bug here right? https://code.google.com/p/ken-cc/source/browse/src/cmd/cc/cc.y#476 | LSWITCH '(' cexpr ')' stmnt { $$ =3D new(OCONST, Z, Z); $$->vconst =3D 0; $$->type =3D types[TINT]; $3 =3D new(OSUB, $$, $3); $$ =3D new(OCONST, Z, Z); $$->vconst =3D 0; $$->type =3D types[TINT]; $3 =3D new(OSUB, $$, $3); $$ =3D new(OSWITCH, $3, $5); } --_000_AA00716C7B8A43A18B534454016F16B2fbcom_ Content-Type: text/html; charset="Windows-1252" Content-ID: <240BB476EDAD3B45A6D820419C67A221@fb.com> Content-Transfer-Encoding: quoted-printable Hi,

It=92s a copy paste bug here right?
https://code.google.com/p/ken-cc/source/browse/src/cmd/cc/cc.y#476=


|       LSWITCH '(' cexpr ')' stmnt
        {
               = $$ =3D new(OCONST, Z, Z);
               = $$->vconst =3D 0;
               = $$->type =3D types[TINT];
               = $3 =3D new(OSUB, $$, $3);<= span class=3D"pln">

               = $$ =3D new(OCONST, Z, Z);
               = $$->vconst =3D 0;
               = $$->type =3D types[TINT];
               = $3 =3D new(OSUB, $$, $3);<= span class=3D"pln">

               = $$ =3D new(OSWITCH, $3, $5);<= span class=3D"pln">
        }


--_000_AA00716C7B8A43A18B534454016F16B2fbcom_-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: From: Rob Pike Date: Tue, 14 Oct 2014 15:45:48 -0700 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=089e0158be220fb091050569c886 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1cd31fd2-ead9-11e9-9d60-3106f5b1d025 --089e0158be220fb091050569c886 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Looks like it. -rob On Tue, Oct 14, 2014 at 3:11 PM, Yoann Padioleau wrote: > Hi, > > It=E2=80=99s a copy paste bug here right? > https://code.google.com/p/ken-cc/source/browse/src/cmd/cc/cc.y#476 > > > | LSWITCH '(' cexpr ')' stmnt > { > $$ =3D new(OCONST, Z, Z); > $$->vconst =3D 0; > $$->type =3D types[TINT]; > $3 =3D new(OSUB, $$, $3); > > $$ =3D new(OCONST, Z, Z); > $$->vconst =3D 0; > $$->type =3D types[TINT]; > $3 =3D new(OSUB, $$, $3); > > $$ =3D new(OSWITCH, $3, $5); > } > > > --089e0158be220fb091050569c886 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Looks like it.

-rob


On Tue, Oc= t 14, 2014 at 3:11 PM, Yoann Padioleau <pad@fb.com> wrote:
Hi,

It=E2=80=99s a copy paste bug here right?


| =C2=A0 =C2=A0 =C2=A0 LS= WITCH '(' cexpr ')' stmnt
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$ =3D new(OCONST, Z, Z);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$->vconst =3D 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$->type =3D types[TINT];
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $3 =3D new(OSUB, $$, $3);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$ =3D new(OCONST, Z, Z);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$->vconst =3D 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$->type =3D types[TINT];
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $3 =3D new(OSUB, $$, $3);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$ =3D new(OSWITCH, $3, $5);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }



--089e0158be220fb091050569c886-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: From: Rob Pike Date: Tue, 14 Oct 2014 17:50:36 -0700 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=089e01634a4058994c05056b8627 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1ce89a4c-ead9-11e9-9d60-3106f5b1d025 --089e01634a4058994c05056b8627 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable It's not dead code. It's prepping the switch somehow. -rob On Tue, Oct 14, 2014 at 3:45 PM, Rob Pike wrote: > Looks like it. > > -rob > > > On Tue, Oct 14, 2014 at 3:11 PM, Yoann Padioleau wrote: > >> Hi, >> >> It=E2=80=99s a copy paste bug here right? >> https://code.google.com/p/ken-cc/source/browse/src/cmd/cc/cc.y#476 >> >> >> | LSWITCH '(' cexpr ')' stmnt >> { >> $$ =3D new(OCONST, Z, Z); >> $$->vconst =3D 0; >> $$->type =3D types[TINT]; >> $3 =3D new(OSUB, $$, $3); >> >> $$ =3D new(OCONST, Z, Z); >> $$->vconst =3D 0; >> $$->type =3D types[TINT]; >> $3 =3D new(OSUB, $$, $3); >> >> $$ =3D new(OSWITCH, $3, $5); >> } >> >> >> > --089e01634a4058994c05056b8627 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
It's not dead code. It's prepping the switch someh= ow.

-rob


On Tue, Oct 14, 2014 at 3:45 PM, Rob P= ike <robpike@gmail.com> wrote:
Looks like it.

-rob


On Tue, Oct 14, 2014 at 3:11 PM, Yoann Padioleau <pad@fb.com= > wrote:
Hi,

It=E2=80=99s a copy paste bug here right?


| =C2=A0 =C2=A0 =C2=A0 LS= WITCH '(' cexpr ')' stmnt
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$ =3D new(OCONST, Z, Z);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$->vconst =3D 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$->type =3D types[TINT];
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $3 =3D new(OSUB, $$, $3);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$ =3D new(OCONST, Z, Z);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$->vconst =3D 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$->type =3D types[TINT];
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $3 =3D new(OSUB, $$, $3);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $$ =3D new(OSWITCH, $3, $5);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }




--089e01634a4058994c05056b8627-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoann Padioleau To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Date: Fri, 17 Oct 2014 17:48:46 +0000 Message-ID: References: In-Reply-To: Content-Type: multipart/alternative; boundary="_000_F8114E49B8EF4D748BDB15B99BEB97E9fbcom_" MIME-Version: 1.0 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1d6c4eb4-ead9-11e9-9d60-3106f5b1d025 --_000_F8114E49B8EF4D748BDB15B99BEB97E9fbcom_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Somehow? Would be nice to have a comment explaining this =93somehow" then because it looks tricky. Also is there a place explaining the naming conventions? I have a hard time understanding what is the difference between tcom(), acom(), xcom(), and then there=92s complex() =85 On Oct 14, 2014, at 5:50 PM, Rob Pike > wrote: It's not dead code. It's prepping the switch somehow. -rob On Tue, Oct 14, 2014 at 3:45 PM, Rob Pike > wrote: Looks like it. -rob On Tue, Oct 14, 2014 at 3:11 PM, Yoann Padioleau > wrote: Hi, It=92s a copy paste bug here right? https://code.google.com/p/ken-cc/source/browse/src/cmd/cc/cc.y#476 | LSWITCH '(' cexpr ')' stmnt { $$ =3D new(OCONST, Z, Z); $$->vconst =3D 0; $$->type =3D types[TINT]; $3 =3D new(OSUB, $$, $3); $$ =3D new(OCONST, Z, Z); $$->vconst =3D 0; $$->type =3D types[TINT]; $3 =3D new(OSUB, $$, $3); $$ =3D new(OSWITCH, $3, $5); } --_000_F8114E49B8EF4D748BDB15B99BEB97E9fbcom_ Content-Type: text/html; charset="Windows-1252" Content-ID: Content-Transfer-Encoding: quoted-printable Somehow?

Would be nice to have a comment explaining this =93somehow" then<= /div>
because it looks tricky.

Also is there a place explaining the naming conventions?
I have a hard time understanding what is the difference
between tcom(), acom(), xcom(), and then there=92s  complex() =85=


On Oct 14, 2014, at 5:50 PM, Rob Pike <robpike@gmail.com> wrote:

It's not dead code. It's prepping the switch somehow.

-rob


On Tue, Oct 14, 2014 at 3:45 PM, Rob Pike <robpike@gmail.co= m> wrote:
Looks like it.

-rob


On Tue, Oct 14, 2014 at 3:11 PM, Yoann Padioleau= <pad@fb.com> wrote:
Hi,

It=92s a copy paste bug here right?


|       LS= WITCH '(' cexpr ')' stmnt
        {
                $$ =3D new(OCONST, Z, Z);
                $$->vconst =3D 0= ;
                $$->type =3D types[TINT];
                $3 =3D new(OSUB, $$, $3);

                $$ =3D new(OCONST, Z, Z);
                $$->vconst =3D 0= ;
                $$->type =3D types[TINT];
                $3 =3D new(OSUB, $$, $3);

                $$ =3D new(OSWITCH, $3, $5);
        }





--_000_F8114E49B8EF4D748BDB15B99BEB97E9fbcom_-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 17 Oct 2014 20:07:48 +0100 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a11c24492abe48a0505a31436 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1d7229ba-ead9-11e9-9d60-3106f5b1d025 --001a11c24492abe48a0505a31436 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 17 October 2014 18:48, Yoann Padioleau wrote: > Somehow? > > Would be nice to have a comment explaining this =E2=80=9Csomehow" then > because it looks tricky. > it's building a tree for (0:int-(0:int-x)) which later transformations will simplify to x, but having done "the usual arithmetic conversions" balancing and promoting 0s and x as required, if it's char/int/long/vlong. --001a11c24492abe48a0505a31436 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 17 October 2014 18:48, Yoann Padioleau <pad@fb.com> wrote:
Somehow?

Would be nice to have a comment explaining this =E2=80=9Csomehow"= then
because it looks tricky.

it's bu= ilding a tree for (0:int-(0:int-x)) which later transformations will simpli= fy to x, but having done "the usual arithmetic conversions"
=
balancing and promoting 0s and x as required, if= it's char/int/long/vlong.
--001a11c24492abe48a0505a31436-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoann Padioleau To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Date: Fri, 17 Oct 2014 20:00:21 +0000 Message-ID: <6160479F-3E4D-44BF-A366-1B597655F2F8@fb.com> References: In-Reply-To: Content-Type: multipart/alternative; boundary="_000_6160479F3E4D44BFA3661B597655F2F8fbcom_" MIME-Version: 1.0 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1d7ea4a6-ead9-11e9-9d60-3106f5b1d025 --_000_6160479F3E4D44BFA3661B597655F2F8fbcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 0:int - x was not enough for those balancing(?) and promoting thing? On Oct 17, 2014, at 12:07 PM, Charles Forsyth > wrote: it's building a tree for (0:int-(0:int-x)) which later transformations will= simplify to x, but having done "the usual arithmetic conversions" balancing and promoting 0s and x as required, if it's char/int/long/vlong. --_000_6160479F3E4D44BFA3661B597655F2F8fbcom_ Content-Type: text/html; charset="us-ascii" Content-ID: <22AB477CCFC0D4498C51998C66AA3724@fb.com> Content-Transfer-Encoding: quoted-printable

0:int - x   was not enough for those balancing(?) and promoting thing?


On Oct 17, 2014, at 12:07 PM, Charles Forsyth <charles.forsyth@gmail.com> wrote:

it's building a tree for (0:int-(0:int-x)) which later transformations will= simplify to x, but having done "the usual arithmetic conversions"= ;
balancing and promoting 0s and x as required, if it's char/int/long/vlong.<= /div>

--_000_6160479F3E4D44BFA3661B597655F2F8fbcom_-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <6160479F-3E4D-44BF-A366-1B597655F2F8@fb.com> References: <6160479F-3E4D-44BF-A366-1B597655F2F8@fb.com> From: minux Date: Fri, 17 Oct 2014 16:04:30 -0400 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a11339beaadd41e0505a3e075 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1d842f02-ead9-11e9-9d60-3106f5b1d025 --001a11339beaadd41e0505a3e075 Content-Type: text/plain; charset=UTF-8 On Fri, Oct 17, 2014 at 4:00 PM, Yoann Padioleau wrote: > > 0:int - x was not enough for those balancing(?) and promoting thing? > It's enough for type promotion, but you changed the semantics of the program. --001a11339beaadd41e0505a3e075 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On Fri, Oct 17, 2014 at 4:00 PM, Yoann Padioleau <pad@fb.com> wrote= :
0:int - x =C2=A0 was not enough for those balancing(?) and promoting thing?=
It's enough for type promotion, but you changed= the semantics of the program.
--001a11339beaadd41e0505a3e075-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoann Padioleau To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Date: Fri, 17 Oct 2014 20:32:52 +0000 Message-ID: <2C0F0B93-AFEA-46EA-8D10-F4108280E17D@fb.com> References: <6160479F-3E4D-44BF-A366-1B597655F2F8@fb.com> In-Reply-To: Content-Type: multipart/alternative; boundary="_000_2C0F0B93AFEA46EA8D10F4108280E17Dfbcom_" MIME-Version: 1.0 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1d8a0a58-ead9-11e9-9d60-3106f5b1d025 --_000_2C0F0B93AFEA46EA8D10F4108280E17Dfbcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable :) Got it :) On Oct 17, 2014, at 1:04 PM, minux > wrote: On Fri, Oct 17, 2014 at 4:00 PM, Yoann Padioleau > wrote: 0:int - x was not enough for those balancing(?) and promoting thing? It's enough for type promotion, but you changed the semantics of the progra= m. --_000_2C0F0B93AFEA46EA8D10F4108280E17Dfbcom_ Content-Type: text/html; charset="us-ascii" Content-ID: <2C3F46929C49AD41A118FEE5ACEDA2E0@fb.com> Content-Transfer-Encoding: quoted-printable :) Got it :)

On Oct 17, 2014, at 1:04 PM, minux <minux.ma@gmail.com> wrote:


On Fri, Oct 17, 2014 at 4:00 PM, Yoann Padioleau= <pad@fb.com> wrote:
0:int - x   was not enough for tho= se balancing(?) and promoting thing?
It's enough for type promotion, but you changed the semantics of the p= rogram.

--_000_2C0F0B93AFEA46EA8D10F4108280E17Dfbcom_-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 17 Oct 2014 22:30:21 +0100 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a11c34e107da3a10505a512df Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1d9fc992-ead9-11e9-9d60-3106f5b1d025 --001a11c34e107da3a10505a512df Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 17 October 2014 18:48, Yoann Padioleau wrote: > Also is there a place explaining the naming conventions? > I have a hard time understanding what is the difference > between tcom(), acom(), xcom(), and then there=E2=80=99s complex() =E2= =80=A6 > the compiler assumes you've know your Aho and Ullmann either by reading them or by working with them. this will be useful later. complex runs tcom, ccom, acom, xcom in that order on a node (and each of those can recurse). the compiler works by a series of tree transformations, informed by attributes attached to each node, representing types, notional costs, addressability, and other ... stuff. tcom has a comment! /* * evaluate types * evaluate lvalues (addable =3D=3D 1) */ so that's sorted. "evaluate types" means it does most of the type checking and making casts explicit. t->addable is set to 1 if t is an l-value. L-value and R-value are terms introduced by Christopher Strachey (see https://www.itu.dk/courses/BPRD/E2009/fundamental-1967.pdf): briefly, lvalues are forms legal on the left-hand side of an assignment ("address-like objects"), and r-values legal only the right-hand side ("value-like objects") where "objects" means what it used to mean before it was ruined. acom is Aho and Ullman's acommute (with all the exercises done). basically it does code improvements taking advantage of associative-commutative operations, and extends that to look for further optimisations mentioned in Thompson's paper on the compiler. Ritchie's PDP-11 C compiler did something similar (but he called it acommute and distrib). comments such as "bust terms out" and "loo= k for factorable terms c1*i + c1*c2*j -> c1*(i + c2*j) suggest what it's doing). essentially it flattens levels of an expression tree using associative and commutative operators into an array and rearranges them. xcom, which is machine-dependent, also has a comment. it assigns an index of complexity to a sub-expression, which is usually expressed as the number of registers needed to compute it (and good luck with that on an x86), but it's also a good place to look for machine-dependent aspects of machine addressing, such as indexing, double-indexing, scaling, etc and it sets values in each tree node to mark that. "balancing", "casting", "coercion" and other terms connected with languages, types and compilation were often introduced by Algol-68. "Balancing" for instance is making operand types match each other (eg, int+long =3D> long+long). --001a11c34e107da3a10505a512df Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 17 October 2014 18:48, Yoann Padioleau <pad@fb.com> wrote:
Also is there a place explaining the naming conventions= ?
I have a hard time understanding what is the difference
between tcom(), acom(), xcom(), and then there=E2=80=99s =C2=A0complex= () =E2=80=A6

the compiler assumes you= 've know your =C2=A0Aho and Ullmann =C2=A0either by reading them or by = working with them.
this will be useful later.

complex runs tcom, ccom, acom, xcom in that or= der on a node (and each of those can recurse).
the compiler works by a series of tree transformations, informed by att= ributes attached to each node,
representing= types, notional costs, addressability, and other ... stuff.

tcom has a comment!

=C2=A0 /*
= =C2=A0 =C2=A0* evaluate types
=C2=A0 =C2=A0* evaluate lvalues (ad= dable =3D=3D 1)
=C2=A0 =C2=A0*/

so that&= #39;s sorted. "evaluate types" means it does most of the type che= cking and making casts explicit.
t->addable is set to 1 if t i= s an l-value.=C2=A0 L-value and R-value are terms introduced by Christopher= Strachey (see https://www.itu.dk/courses/BPRD/E2009/fundamental-1967.pdf):= briefly, lvalues
are forms legal on the left-hand side of an ass= ignment ("address-like objects"), and r-values legal only the rig= ht-hand side ("value-like objects")
where "objects= " means what it used to mean before it was ruined.

acom is Aho and Ullman's acommute (with all the exercises done). = basically it does code improvements
taking advantage of associati= ve-commutative operations, and extends that to look for further optimisatio= ns
mentioned in Thompson's paper on the compiler. Ritchie'= ;s PDP-11 C compiler did something similar (but he
called it acom= mute and distrib). comments such as "bust terms out" and "look for factorable terms c1*i + c1*c2*j ->= ; c1*(i + c2*j)
suggest wh= at it's doing). essentially it flattens levels of an expression tree us= ing associative and commutative operators into an array
an= d rearranges them.

xcom, which is machine-dependen= t, also has a comment. it assigns an index of complexity to a sub-expressio= n, which is usually
expressed as the number of registers needed t= o compute it (and good luck with that on an x86), but it's also a good = place to look
for machine-dependent aspects of machine addressing= , such as indexing, double-indexing, scaling, etc and it sets values in eac= h
tree node to mark that.

"balancin= g", "casting", "coercion" and other terms connecte= d with languages, types and compilation were often introduced by Algol-68.<= /div>
"Balancing" for instance is making =C2=A0operand types = match each other (eg, int+long =3D> long+long).


--001a11c34e107da3a10505a512df-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoann Padioleau To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Date: Tue, 21 Oct 2014 17:34:52 +0000 Message-ID: References: In-Reply-To: Content-Type: multipart/alternative; boundary="_000_A50BE10181944F1B9EE56EFA58F22D3Cfbcom_" MIME-Version: 1.0 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1f6b7d48-ead9-11e9-9d60-3106f5b1d025 --_000_A50BE10181944F1B9EE56EFA58F22D3Cfbcom_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable but (0:int + x) would not do the same thing? What is special about using = SUB instead of ADD? On Oct 17, 2014, at 12:07 PM, Charles Forsyth > wrote: On 17 October 2014 18:48, Yoann Padioleau > w= rote: Somehow? Would be nice to have a comment explaining this =93somehow" then because it looks tricky. it's building a tree for (0:int-(0:int-x)) which later transformations will= simplify to x, but having done "the usual arithmetic conversions" balancing and promoting 0s and x as required, if it's char/int/long/vlong. --_000_A50BE10181944F1B9EE56EFA58F22D3Cfbcom_ Content-Type: text/html; charset="Windows-1252" Content-ID: Content-Transfer-Encoding: quoted-printable

but (0:int + x)   would not do the same thing? What is specia= l about using SUB instead
of ADD?


On Oct 17, 2014, at 12:07 PM, Charles Forsyth <charles.forsyth@gmail.com> wrote:


On 17 October 2014 18:48, Yoann Padioleau <pad@fb.com> wrote:
Somehow?

Would be nice to have a comment explaining this =93somehow" then<= /div>
because it looks tricky.

it's building a tree for (0:int-(0:int-x)) which later transformations will= simplify to x, but having done "the usual arithmetic conversions"= ;
balancing and promoting 0s and x as required, if= it's char/int/long/vlong.

--_000_A50BE10181944F1B9EE56EFA58F22D3Cfbcom_-- From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 21 Oct 2014 21:53:20 +0100 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=f46d04426c52775edd0505f505f3 Subject: Re: [9fans] copy paste bug in cc.y? Topicbox-Message-UUID: 1f7d47c6-ead9-11e9-9d60-3106f5b1d025 --f46d04426c52775edd0505f505f3 Content-Type: text/plain; charset=UTF-8 On 21 October 2014 18:34, Yoann Padioleau wrote: > but (0:int + x) would not do the same thing? What is special about using > SUB instead > of ADD? > you can't subtract pointers from 0 but you can add 0 to a pointer, since + is commutative --f46d04426c52775edd0505f505f3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 21 October 2014 18:34, Yoann Padioleau <pad@fb.com> wrote:
but (0:int + x) =C2=A0 would not do the s= ame thing? What is special about using SUB instead
of ADD?

you can't subtract pointers fr= om 0 but you can add 0 to a pointer, since + is commutative
--f46d04426c52775edd0505f505f3--