[M3devel] completing M3CG_Binary.Op?

Jay K jay.krell at cornell.edu
Thu Oct 11 08:23:34 CEST 2012


Here is a more heavily commented diff.Again, notice that the existing code does a small translation in writing files. My desire is to represent M3CG call sequence more directly. Granted, it might be reasonable, really, to change one or the other -- either make M3CG.T more closely resemble M3CG_Wr, or the other way around -- remove the transform and adjust one backend(s) or other.I'd also be putting in more newlines, either to separate every enum element here, or to separate all the newly-commented ones, and put the comment on each one.
Index: m3-sys/m3cggen/src/Main.m3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3cggen/src/Main.m3,vretrieving revision 1.6diff -u -r1.6 Main.m3--- m3-sys/m3cggen/src/Main.m3	1 Nov 2010 09:59:44 -0000	1.6+++ m3-sys/m3cggen/src/Main.m3	11 Oct 2012 06:18:42 -0000@@ -9,7 +9,7 @@   Desc = RECORD name: TEXT;  op: Op;  END;  CONST-  Map = ARRAY Op OF Desc {+  Map = ARRAY [Op.begin_unit..Op.fetch_and_xor] OF Desc {     Desc { "begin_unit", Op.begin_unit },      Desc { "end_unit", Op.end_unit },      Desc { "import_unit", Op.import_unit }, Index: m3-sys/m3middle/src/M3CG_BinRd.m3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- m3-sys/m3middle/src/M3CG_BinRd.m3	4 Sep 2012 14:29:54 -0000	1.19+++ m3-sys/m3middle/src/M3CG_BinRd.m3	11 Oct 2012 06:18:42 -0000@@ -37,7 +37,7 @@   END;  CONST-  CmdMap = ARRAY Bop OF Cmd {+  CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd {     Cmd {Bop.begin_unit, begin_unit},     Cmd {Bop.end_unit, end_unit},     Cmd {Bop.import_unit, import_unit},Index: m3-sys/m3middle/src/M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- m3-sys/m3middle/src/M3CG_Binary.i3	1 Nov 2010 09:59:44 -0000	1.6+++ m3-sys/m3middle/src/M3CG_Binary.i3	11 Oct 2012 06:18:42 -0000@@ -21,14 +21,19 @@     end_init, init_int, init_proc, init_label, init_var, init_offset,     init_chars, init_float, import_procedure, declare_procedure,     begin_procedure, end_procedure, begin_block, end_block,-    note_procedure_origin, set_label, jump, if_true, if_false, if_eq,-    if_ne, if_gt, if_ge, if_lt, if_le, case_jump, exit_proc, load,+    note_procedure_origin, set_label, jump, if_true, if_false,+    if_eq, if_ne, if_gt, if_ge, if_lt, if_le,       (* file only; in-memory uses if_compare *)+    case_jump, exit_proc, load,     load_address, load_indirect, store, store_indirect,-    load_nil, load_integer, load_float, eq, ne,-    gt, ge, lt, le, add, subtract, multiply, divide, negate, abs, max,-    min, round, trunc, floor, ceiling, cvt_float, div, mod, set_union,+    load_nil, load_integer, load_float,+    eq, ne, gt, ge, lt,  le,                        (* file only; in-memory uses compare *)+    add, subtract, multiply, divide, negate, abs, max,+    min,+    round, trunc, floor, ceiling,                   (* file only; in-memory uses cvt_int *)+    cvt_float, div, mod, set_union,     set_difference, set_intersection, set_sym_difference, set_member,-    set_eq, set_ne, set_lt, set_le, set_gt, set_ge, set_range,+    set_eq, set_ne, set_lt, set_le, set_gt, set_ge, (* file only; in-memory uses set_compare *)+    set_range,     set_singleton, not, and, or, xor, shift, shift_left, shift_right,     rotate, rotate_left, rotate_right, widen, chop, extract, extract_n,     extract_mn, insert, insert_n, insert_mn, swap, pop, copy_n, copy,@@ -38,7 +43,17 @@     call_indirect, pop_param, pop_struct, pop_static_link,     load_procedure, load_static_link, comment,     store_ordered, load_ordered, exchange, compare_exchange, fence,-    fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+    fetch_and_add,      (* file only; in-memory uses fetch_and_op *)+    fetch_and_sub,      (* file only; in-memory uses fetch_and_op *)+    fetch_and_or,       (* file only; in-memory uses fetch_and_op *)+    fetch_and_and,      (* file only; in-memory uses fetch_and_op *)+    fetch_and_xor,      (* file only; in-memory uses fetch_and_op *)+    set_error_handler,  (* in-memory only; contains a pointer, so silently skipped in files *)+    compare,            (* in-memory only; file converts to eq/ne/etc. *)+    cvt_int,            (* in-memory only; file converts to trunc/ceiling/etc. *)+    fetch_and_op,       (* in-memory only; file converts to fetch_and_add/fetch_and_sub/etc. *)+    if_compare,         (* in-memory only; file converts to if_eq/if_ne/etc. *)+    set_compare         (* in-memory only; file converts to set_eq/set_ne/etc. *)   };  (* Integers are encoded as sequences of unsigned bytes, [0..255].

 - Jay

From: jay.krell at cornell.edu
To: hosking at cs.purdue.edu
Date: Thu, 11 Oct 2012 05:46:07 +0000
CC: m3devel at elegosoft.com
Subject: Re: [M3devel] completing M3CG_Binary.Op?




Tony, I think you might not understand, or have it backwards.

In my code I do use cvt_int.It is the existing M3CG_Wr and M3CG_BinWr that don't.It seems like a pretty pointless transformation there, and I'd rathernot make it in my code.The comments in the change describe what we already currently do for "files", that I do not want to do for in-memory.

For example, M3CG_Wr.m3:
PROCEDURE set_compare  (u: U;  s: ByteSize;  op: CompareOp;  t: IType) =  (* s1.t := (s1.B  op  s0.B)  ; pop *)  CONST OpName = ARRAY CompareOp OF TEXT {                   "set_eq", "set_ne", "set_gt", "set_ge", "set_lt", "set_le" };  BEGIN    Cmd   (u, OpName [op]);    Int   (u, s);    TName (u, t);    NL    (u);  END set_compare;

but in my M3CG_MultiPass.m3 (not necessarily the commited version!)
PROCEDURE set_compare(self: T; byte_size: ByteSize; op: CompareOp; type: IType) =BEGINself.Add(NEW(set_compare_t, op := Op.set_compare, byte_size := byte_size, compare_op := op, type := type));END set_compare;

so -- ok with my change?
Thank you, - Jay


From: jay.krell at cornell.edu
Date: Wed, 10 Oct 2012 20:08:41 -0700
To: hosking at cs.purdue.edu
CC: m3devel at elegosoft.com; jay.krell at cornell.edu
Subject: Re: [M3devel] completing M3CG_Binary.Op?

I agree I could do the transforms that M3CG_Wr does but I'd rather leave things untranformed. You understand? It is the existing code that changes to "different" "instructions" instead of channeling the interface a bit more directly. I want a more direct form.

 - Jay (briefly/pocket-sized-computer-aka-phone)
On Oct 10, 2012, at 5:18 PM, Antony Hosking <hosking at cs.purdue.edu> wrote:

Why not simply capture the state of the existing ops?  e.g,, cvt_int.


On Oct 10, 2012, at 7:33 PM, Jay K <jay.krell at cornell.edu> wrote:
Look at M3CG_MultiPass.

For each function, it creates a record to hold the parameters.
    So they can be later be looped over in a different order and/or multiple times.
The record includes an enum.
I need an enum that looks almost exactly like M3CG_Binary.Op,
except that I need those few missing elements.
 
 M3CG_MultiPass already has most of this, except 
   1) I somehow forgot got to handle a bunch of them  
   2) I need the below diff for it to be complete, or some other nearly identical enum instead.  
 
 - Jay
 
Subject: Re: [M3devel] completing M3CG_Binary.Op?
From: hosking at cs.purdue.edu
Date: Wed, 10 Oct 2012 12:13:51 -0400
CC: m3devel at elegosoft.com
To: jay.krell at cornell.edu

I still don’t understand why the change is needed.

On Oct 10, 2012, at 11:53 AM, Jay K <jay.krell at cornell.edu> wrote:M3CG.T, M3CG_Ops.T also same thing, I use them interchangably in email and checkin comments. My code is more careful.
 - Jay
From: hosking at cs.purdue.edu
Date: Wed, 10 Oct 2012 02:33:13 -0400
To: jay.krell at cornell.edu
CC: m3devel at elegosoft.com
Subject: Re: [M3devel] completing M3CG_Binary.Op?

Hmm.  But the M3CG calls don’t include those operations.  e.g., cvt_int is defined in M3CG_Ops.  Why wouldn’t you just have a record for that?
On Oct 10, 2012, at 1:59 AM, Jay <jay.krell at cornell.edu> wrote:
I have an array of records, one per M3CG.T call. See M3CG_MultiPass -- which I guess is where I'd put the enum, if I can't reuse the existing one.

 - Jay (briefly/pocket-sized-computer-aka-phone)
On Oct 9, 2012, at 10:35 PM, Antony Hosking <hosking at cs.purdue.edu> wrote:

Why?
On Oct 10, 2012, at 12:52 AM, Jay <jay.krell at cornell.edu> wrote:I need an enumeration with a member per M3CG.T method. M3CG_Binary.Op is very nearly it.

 - Jay (briefly/pocket-sized-computer-aka-phone)
On Oct 9, 2012, at 9:36 PM, Antony Hosking <hosking at cs.purdue.edu> wrote:

Forgive me, but I don’t understand the purpose of this change.

On Oct 10, 2012, at 12:08 AM, Jay K <jay.krell at cornell.edu> wrote:M3CG_Binary.Op currently representswhat we write to ".mc" files for the gccbackend to read in. This is very very closeto what you'd want to fully represent M3CG.T.

It missing an operation that takes a function pointer -- can'tbe stored in a file. It is missing operations that get convertedto different operations by M3CG_Wr. There is no realvalue in the transform but it doesn't hurt either.

I'd like to add the missing operations.It seems like a very sensible reasonable change to me.


===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,vretrieving revision 1.19diff -u -r1.19 M3CG_BinRd.m3--- M3CG_BinRd.m3	4 Sep 2012 14:29:54 -0000	1.19+++ M3CG_BinRd.m3	10 Oct 2012 04:04:19 -0000@@ -37,7 +37,7 @@   END;  CONST-  CmdMap = ARRAY Bop OF Cmd {+  CmdMap = ARRAY [Bop.begin_unit..Bop.fetch_and_xor] OF Cmd {     Cmd {Bop.begin_unit, begin_unit},     Cmd {Bop.end_unit, end_unit},     Cmd {Bop.import_unit, import_unit},Index: M3CG_Binary.i3===================================================================RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_Binary.i3,vretrieving revision 1.6diff -u -r1.6 M3CG_Binary.i3--- M3CG_Binary.i3	1 Nov 2010 09:59:44 -0000	1.6+++ M3CG_Binary.i3	10 Oct 2012 04:04:19 -0000@@ -38,7 +38,17 @@     call_indirect, pop_param, pop_struct, pop_static_link,     load_procedure, load_static_link, comment,     store_ordered, load_ordered, exchange, compare_exchange, fence,-    fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor+    fetch_and_add, fetch_and_sub, fetch_and_or, fetch_and_and, fetch_and_xor,++    (* These only occur in memory, not in files.+       Conversely, what they are converted to only occur in files,+       not in memory. *)+    set_error_handler,  (* disk: contains a pointer, silently skipped *)+    compare             (* converted to eq/ne/etc. *)+    cvt_int,            (* converted to trunc/ceiling/etc. *)+    fetch_and_op,       (* converted to fetch_and_add/fetch_and_sub/etc. *)+    if_compare,         (* converted to if_eq/if_ne/etc. *)+    set_compare,        (* converted to set_eq/set_ne/etc. *)   };
 		 	   		   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20121011/21088d23/attachment-0002.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 1.txt
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20121011/21088d23/attachment-0002.txt>


More information about the M3devel mailing list