? m3-sys/m3cggen/SPARC32_SOLARIS ? m3-sys/m3middle/1.c ? m3-sys/m3middle/1.txt ? m3-sys/m3middle/2.c ? m3-sys/m3middle/3.c ? m3-sys/m3middle/SPARC32_SOLARIS ? m3-sys/m3middle/src/1 ? m3-sys/m3middle/src/1.c ? m3-sys/m3middle/src/1.s ? m3-sys/m3middle/src/1.tt ? m3-sys/m3middle/src/1.txt ? m3-sys/m3middle/src/121 ? m3-sys/m3middle/src/2.c ? m3-sys/m3middle/src/2.txt ? m3-sys/m3middle/src/2.tzt ? m3-sys/m3middle/src/3.txt ? m3-sys/m3middle/src/M3CG_Filter.m3 ? m3-sys/m3middle/src/a.out ? m3-sys/m3middle/src/m.cpp ? m3-sys/m3middle/src/m3cg-def.h ? m3-sys/m3middle/src/m3cg.h ? m3-sys/m3middle/src/make-binrd.cpp ? m3-sys/m3middle/src/make-binwr.cpp Index: m3-sys/m3cggen/src/Main.m3 =================================================================== RCS file: /usr/cvs/cm3/m3-sys/m3cggen/src/Main.m3,v retrieving revision 1.6 diff -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/m3cggen/src/m3makefile =================================================================== RCS file: /usr/cvs/cm3/m3-sys/m3cggen/src/m3makefile,v retrieving revision 1.3 diff -u -r1.3 m3makefile --- m3-sys/m3cggen/src/m3makefile 26 Jun 2009 12:34:57 -0000 1.3 +++ m3-sys/m3cggen/src/m3makefile 11 Oct 2012 06:18:42 -0000 @@ -1,5 +1,6 @@ import ("m3middle") +%import ("m3back") implementation ("Main") Index: m3-sys/m3middle/src/M3CG_BinRd.m3 =================================================================== RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_BinRd.m3,v retrieving revision 1.19 diff -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,v retrieving revision 1.6 diff -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]. Index: m3-sys/m3middle/src/M3CG_MultiPass.i3 =================================================================== RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_MultiPass.i3,v retrieving revision 1.8 diff -u -r1.8 M3CG_MultiPass.i3 --- m3-sys/m3middle/src/M3CG_MultiPass.i3 30 Sep 2012 06:40:21 -0000 1.8 +++ m3-sys/m3middle/src/M3CG_MultiPass.i3 11 Oct 2012 06:18:42 -0000 @@ -8,7 +8,7 @@ * I expect to use #3. *) -IMPORT M3CG, Target; +IMPORT M3CG, Target, M3CG_AssertFalse; FROM M3CG IMPORT Type, MType, IType, RType, AType, ZType, Sign; FROM M3CG IMPORT Name, Alignment, Label; FROM M3CG IMPORT Frequency, CallingConvention, CompareOp, ConvertOp, AtomicOp; @@ -21,7 +21,7 @@ TYPE T <: Public; -TYPE Public = M3CG.T OBJECT +TYPE Public = M3CG_AssertFalse.T OBJECT data: REF ARRAY OF op_t; op_data: ARRAY Op OF REF ARRAY OF op_t; Index: m3-sys/m3middle/src/M3CG_MultiPass.m3 =================================================================== RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/M3CG_MultiPass.m3,v retrieving revision 1.11 diff -u -r1.11 M3CG_MultiPass.m3 --- m3-sys/m3middle/src/M3CG_MultiPass.m3 5 Oct 2012 07:25:50 -0000 1.11 +++ m3-sys/m3middle/src/M3CG_MultiPass.m3 11 Oct 2012 06:18:42 -0000 @@ -56,7 +56,7 @@ REVEAL T = Public BRANDED "M3CG_MultiPass.T" OBJECT refs: GrowableRefs_t := NIL; - next_label_id := 100; + next_label_id := 1; op_counts := ARRAY Op OF INTEGER{0, ..}; total_ops: INTEGER := 0; private_data: RefSeq.T := NIL; @@ -390,7 +390,7 @@ PROCEDURE set_error_handler(self: T; proc: PROCEDURE(msg: TEXT)) = BEGIN -self.Add(NEW(set_error_handler_t, (*op := Op.set_error_handler,*) proc := proc)); +self.Add(NEW(set_error_handler_t, op := Op.set_error_handler, proc := proc)); END set_error_handler; PROCEDURE begin_procedure(self: T; proc: Proc) = @@ -619,7 +619,7 @@ END if_false; PROCEDURE if_compare(self: T; type: ZType; op: CompareOp; label: Label; frequency: Frequency) = BEGIN -self.Add(NEW(if_compare_t, (*op := Op.if_compare,*) type := type, compare_op := op, label := label, frequency := frequency)); +self.Add(NEW(if_compare_t, op := Op.if_compare, type := type, compare_op := op, label := label, frequency := frequency)); END if_compare; PROCEDURE case_jump(self: T; type: IType; READONLY labels: ARRAY OF Label) = @@ -666,7 +666,7 @@ END load_float; PROCEDURE compare(self: T; ztype: ZType; itype: IType; op: CompareOp) = BEGIN -self.Add(NEW(compare_t, (*op := Op.compare,*) ztype := ztype, itype := itype, compare_op := op)); +self.Add(NEW(compare_t, op := Op.compare, ztype := ztype, itype := itype, compare_op := op)); END compare; PROCEDURE add(self: T; type: AType) = BEGIN @@ -716,302 +716,302 @@ PROCEDURE cvt_int(self: T; rtype: RType; itype: IType; op: ConvertOp) = BEGIN -self.Add(NEW(cvt_int_t, rtype := rtype, itype := itype, convert_op := op)); +self.Add(NEW(cvt_int_t, op := Op.cvt_int, rtype := rtype, itype := itype, convert_op := op)); END cvt_int; PROCEDURE cvt_float(self: T; atype: AType; rtype: RType) = BEGIN -self.Add(NEW(cvt_float_t, atype := atype, rtype := rtype)); +self.Add(NEW(cvt_float_t, op := Op.cvt_float, atype := atype, rtype := rtype)); END cvt_float; PROCEDURE set_union(self: T; byte_size: ByteSize) = BEGIN -self.Add(NEW(set_union_t, byte_size := byte_size)); +self.Add(NEW(set_union_t, op := Op.set_union, byte_size := byte_size)); END set_union; PROCEDURE set_difference(self: T; byte_size: ByteSize) = BEGIN -self.Add(NEW(set_difference_t, byte_size := byte_size)); +self.Add(NEW(set_difference_t, op := Op.set_difference, byte_size := byte_size)); END set_difference; PROCEDURE set_intersection(self: T; byte_size: ByteSize) = BEGIN -self.Add(NEW(set_intersection_t, byte_size := byte_size)); +self.Add(NEW(set_intersection_t, op := Op.set_intersection, byte_size := byte_size)); END set_intersection; PROCEDURE set_sym_difference(self: T; byte_size: ByteSize) = BEGIN -self.Add(NEW(set_sym_difference_t, byte_size := byte_size)); +self.Add(NEW(set_sym_difference_t, op := Op.set_sym_difference, byte_size := byte_size)); END set_sym_difference; PROCEDURE set_member(self: T; byte_size: ByteSize; type: IType) = BEGIN -self.Add(NEW(set_member_t, byte_size := byte_size, type := type)); +self.Add(NEW(set_member_t, op := Op.set_member, byte_size := byte_size, type := type)); END set_member; PROCEDURE set_compare(self: T; byte_size: ByteSize; op: CompareOp; type: IType) = BEGIN -self.Add(NEW(set_compare_t, byte_size := byte_size, compare_op := op, type := type)); +self.Add(NEW(set_compare_t, op := Op.set_compare, byte_size := byte_size, compare_op := op, type := type)); END set_compare; PROCEDURE set_range(self: T; byte_size: ByteSize; type: IType) = BEGIN -self.Add(NEW(set_range_t, byte_size := byte_size, type := type)); +self.Add(NEW(set_range_t, op := Op.set_range, byte_size := byte_size, type := type)); END set_range; PROCEDURE set_singleton(self: T; byte_size: ByteSize; type: IType) = BEGIN -self.Add(NEW(set_singleton_t, byte_size := byte_size, type := type)); +self.Add(NEW(set_singleton_t, op := Op.set_singleton, byte_size := byte_size, type := type)); END set_singleton; PROCEDURE not(self: T; type: IType) = BEGIN -self.Add(NEW(not_t, type := type)); +self.Add(NEW(not_t, op := Op.not, type := type)); END not; PROCEDURE and(self: T; type: IType) = BEGIN -self.Add(NEW(and_t, type := type)); +self.Add(NEW(and_t, op := Op.and, type := type)); END and; PROCEDURE or(self: T; type: IType) = BEGIN -self.Add(NEW(or_t, type := type)); +self.Add(NEW(or_t, op := Op.or, type := type)); END or; PROCEDURE xor(self: T; type: IType) = BEGIN -self.Add(NEW(xor_t, type := type)); +self.Add(NEW(xor_t, op := Op.xor, type := type)); END xor; PROCEDURE shift(self: T; type: IType) = BEGIN -self.Add(NEW(shift_t, type := type)); +self.Add(NEW(shift_t, op := Op.shift, type := type)); END shift; PROCEDURE shift_left(self: T; type: IType) = BEGIN -self.Add(NEW(shift_left_t, type := type)); +self.Add(NEW(shift_left_t, op := Op.shift_left, type := type)); END shift_left; PROCEDURE shift_right(self: T; type: IType) = BEGIN -self.Add(NEW(shift_right_t, type := type)); +self.Add(NEW(shift_right_t, op := Op.shift_right, type := type)); END shift_right; PROCEDURE rotate(self: T; type: IType) = BEGIN -self.Add(NEW(rotate_t, type := type)); +self.Add(NEW(rotate_t, op := Op.rotate, type := type)); END rotate; PROCEDURE rotate_left(self: T; type: IType) = BEGIN -self.Add(NEW(rotate_left_t, type := type)); +self.Add(NEW(rotate_left_t, op := Op.rotate_left, type := type)); END rotate_left; PROCEDURE rotate_right(self: T; type: IType) = BEGIN -self.Add(NEW(rotate_right_t, type := type)); +self.Add(NEW(rotate_right_t, op := Op.rotate_right, type := type)); END rotate_right; PROCEDURE widen(self: T; sign: BOOLEAN) = BEGIN -self.Add(NEW(widen_t, sign := sign)); +self.Add(NEW(widen_t, op := Op.widen, sign := sign)); END widen; PROCEDURE chop(self: T) = BEGIN -self.Add(NEW(chop_t)); +self.Add(NEW(chop_t, op := Op.chop)); END chop; PROCEDURE extract(self: T; type: IType; sign_extend: BOOLEAN) = BEGIN -self.Add(NEW(extract_t, type := type, sign_extend := sign_extend)); +self.Add(NEW(extract_t, op := Op.extract, type := type, sign_extend := sign_extend)); END extract; PROCEDURE extract_n(self: T; type: IType; sign_extend: BOOLEAN; count: CARDINAL) = BEGIN -self.Add(NEW(extract_n_t, type := type, sign_extend := sign_extend, count := count)); +self.Add(NEW(extract_n_t, op := Op.extract_n, type := type, sign_extend := sign_extend, count := count)); END extract_n; PROCEDURE extract_mn(self: T; type: IType; sign_extend: BOOLEAN; offset, count: CARDINAL) = BEGIN -self.Add(NEW(extract_mn_t, type := type, sign_extend := sign_extend, offset := offset, count := count)); +self.Add(NEW(extract_mn_t, op := Op.extract_mn, type := type, sign_extend := sign_extend, offset := offset, count := count)); END extract_mn; PROCEDURE insert(self: T; type: IType) = BEGIN -self.Add(NEW(insert_t, type := type)); +self.Add(NEW(insert_t, op := Op.insert, type := type)); END insert; PROCEDURE insert_n(self: T; type: IType; count: CARDINAL) = BEGIN -self.Add(NEW(insert_n_t, type := type, count := count)); +self.Add(NEW(insert_n_t, op := Op.insert_n, type := type, count := count)); END insert_n; PROCEDURE insert_mn(self: T; type: IType; offset, count: CARDINAL) = BEGIN -self.Add(NEW(insert_mn_t, type := type, offset := offset, count := count)); +self.Add(NEW(insert_mn_t, op := Op.insert_mn, type := type, offset := offset, count := count)); END insert_mn; PROCEDURE swap(self: T; a, b: Type) = BEGIN -self.Add(NEW(swap_t, a := a, b := b)); +self.Add(NEW(swap_t, op := Op.swap, a := a, b := b)); END swap; PROCEDURE pop(self: T; type: Type) = BEGIN -self.Add(NEW(pop_t, type := type)); +self.Add(NEW(pop_t, op := Op.pop, type := type)); END pop; PROCEDURE copy_n(self: T; itype: IType; mtype: MType; overlap: BOOLEAN) = BEGIN -self.Add(NEW(copy_n_t, itype := itype, mtype := mtype, overlap := overlap)); +self.Add(NEW(copy_n_t, op := Op.copy_n, itype := itype, mtype := mtype, overlap := overlap)); END copy_n; PROCEDURE copy(self: T; n: INTEGER; mtype: MType; overlap: BOOLEAN) = BEGIN -self.Add(NEW(copy_t, n := n, mtype := mtype, overlap := overlap)); +self.Add(NEW(copy_t, op := Op.copy, n := n, mtype := mtype, overlap := overlap)); END copy; PROCEDURE zero_n(self: T; itype: IType; mtype: MType) = BEGIN -self.Add(NEW(zero_n_t, itype := itype, mtype := mtype)); +self.Add(NEW(zero_n_t, op := Op.zero_n, itype := itype, mtype := mtype)); END zero_n; PROCEDURE zero(self: T; n: INTEGER; type: MType) = BEGIN -self.Add(NEW(zero_t, n := n, type := type)); +self.Add(NEW(zero_t, op := Op.zero, n := n, type := type)); END zero; PROCEDURE loophole(self: T; from, to: ZType) = BEGIN -self.Add(NEW(loophole_t, from := from, to := to)); +self.Add(NEW(loophole_t, op := Op.loophole, from := from, to := to)); END loophole; PROCEDURE abort(self: T; code: RuntimeError) = BEGIN -self.Add(NEW(abort_t, code := code)); +self.Add(NEW(abort_t, op := Op.abort, code := code)); END abort; PROCEDURE check_nil(self: T; code: RuntimeError) = BEGIN -self.Add(NEW(check_nil_t, code := code)); +self.Add(NEW(check_nil_t, op := Op.check_nil, code := code)); END check_nil; PROCEDURE check_lo(self: T; type: IType; READONLY i: Target.Int; code: RuntimeError) = BEGIN -self.Add(NEW(check_lo_t, type := type, i := i, code := code)); +self.Add(NEW(check_lo_t, op := Op.check_lo, type := type, i := i, code := code)); END check_lo; PROCEDURE check_hi(self: T; type: IType; READONLY i: Target.Int; code: RuntimeError) = BEGIN -self.Add(NEW(check_hi_t, type := type, i := i, code := code)); +self.Add(NEW(check_hi_t, op := Op.check_hi, type := type, i := i, code := code)); END check_hi; PROCEDURE check_range(self: T; type: IType; READONLY a, b: Target.Int; code: RuntimeError) = BEGIN -self.Add(NEW(check_range_t, type := type, a := a, b := b, code := code)); +self.Add(NEW(check_range_t, op := Op.check_range, type := type, a := a, b := b, code := code)); END check_range; PROCEDURE check_index(self: T; type: IType; code: RuntimeError) = BEGIN -self.Add(NEW(check_index_t, type := type, code := code)); +self.Add(NEW(check_index_t, op := Op.check_index, type := type, code := code)); END check_index; PROCEDURE check_eq(self: T; type: IType; code: RuntimeError) = BEGIN -self.Add(NEW(check_eq_t, type := type, code := code)); +self.Add(NEW(check_eq_t, op := Op.check_eq, type := type, code := code)); END check_eq; PROCEDURE add_offset(self: T; i: INTEGER) = BEGIN -self.Add(NEW(add_offset_t, i := i)); +self.Add(NEW(add_offset_t, op := Op.add_offset, i := i)); END add_offset; PROCEDURE index_address(self: T; type: IType; size: INTEGER) = BEGIN -self.Add(NEW(index_address_t, type := type, size := size)); +self.Add(NEW(index_address_t, op := Op.index_address, type := type, size := size)); END index_address; PROCEDURE start_call_direct(self: T; proc: Proc; level: INTEGER; type: Type) = BEGIN -self.Add(NEW(start_call_direct_t, proc := NARROW(proc, proc_t).tag, level := level, type := type)); +self.Add(NEW(start_call_direct_t, op := Op.start_call_direct, proc := NARROW(proc, proc_t).tag, level := level, type := type)); END start_call_direct; PROCEDURE start_call_indirect(self: T; type: Type; callingConvention: CallingConvention) = BEGIN -self.Add(NEW(start_call_indirect_t, type := type, callingConvention := callingConvention)); +self.Add(NEW(start_call_indirect_t, op := Op.start_call_indirect, type := type, callingConvention := callingConvention)); END start_call_indirect; PROCEDURE pop_param(self: T; type: MType) = BEGIN -self.Add(NEW(pop_param_t, type := type)); +self.Add(NEW(pop_param_t, op := Op.pop_param, type := type)); END pop_param; PROCEDURE pop_struct(self: T; typeid: TypeUID; byte_size: ByteSize; alignment: Alignment) = BEGIN -self.Add(NEW(pop_struct_t, typeid := typeid, byte_size := byte_size, alignment := alignment)); +self.Add(NEW(pop_struct_t, op := Op.pop_struct, typeid := typeid, byte_size := byte_size, alignment := alignment)); END pop_struct; PROCEDURE pop_static_link(self: T) = BEGIN -self.Add(NEW(pop_static_link_t)); +self.Add(NEW(pop_static_link_t, op := Op.pop_static_link)); END pop_static_link; PROCEDURE call_direct(self: T; proc: Proc; type: Type) = BEGIN -self.Add(NEW(call_direct_t, proc := NARROW(proc, proc_t).tag, type := type)); +self.Add(NEW(call_direct_t, op := Op.call_direct, proc := NARROW(proc, proc_t).tag, type := type)); END call_direct; PROCEDURE call_indirect(self: T; type: Type; callingConvention: CallingConvention) = BEGIN -self.Add(NEW(call_indirect_t, type := type, callingConvention := callingConvention)); +self.Add(NEW(call_indirect_t, op := Op.call_indirect, type := type, callingConvention := callingConvention)); END call_indirect; PROCEDURE load_procedure(self: T; proc: Proc) = BEGIN -self.Add(NEW(load_procedure_t, proc := NARROW(proc, proc_t).tag)); +self.Add(NEW(load_procedure_t, op := Op.load_procedure, proc := NARROW(proc, proc_t).tag)); END load_procedure; PROCEDURE load_static_link(self: T; proc: Proc) = BEGIN -self.Add(NEW(load_static_link_t, proc := NARROW(proc, proc_t).tag)); +self.Add(NEW(load_static_link_t, op := Op.load_static_link, proc := NARROW(proc, proc_t).tag)); END load_static_link; PROCEDURE comment(self: T; a, b, c, d: TEXT := NIL) = BEGIN -self.Add(NEW(comment_t, a := a, b := b, c := c, d := d)); +self.Add(NEW(comment_t, op := Op.comment, a := a, b := b, c := c, d := d)); END comment; PROCEDURE store_ordered(self: T; ztype: ZType; mtype: MType; order: MemoryOrder) = BEGIN -self.Add(NEW(store_ordered_t, mtype := mtype, ztype := ztype, order := order)); +self.Add(NEW(store_ordered_t, op := Op.store_ordered, mtype := mtype, ztype := ztype, order := order)); END store_ordered; PROCEDURE load_ordered(self: T; mtype: MType; ztype: ZType; order: MemoryOrder) = BEGIN -self.Add(NEW(load_ordered_t, mtype := mtype, ztype := ztype, order := order)); +self.Add(NEW(load_ordered_t, op := Op.load_ordered, mtype := mtype, ztype := ztype, order := order)); END load_ordered; PROCEDURE exchange(self: T; mtype: MType; ztype: ZType; order: MemoryOrder) = BEGIN -self.Add(NEW(exchange_t, mtype := mtype, ztype := ztype, order := order)); +self.Add(NEW(exchange_t, op := Op.exchange, mtype := mtype, ztype := ztype, order := order)); END exchange; PROCEDURE compare_exchange(self: T; mtype: MType; ztype: ZType; r: IType; success, failure: MemoryOrder) = BEGIN -self.Add(NEW(compare_exchange_t, mtype := mtype, ztype := ztype, r := r, success := success, failure := failure)); +self.Add(NEW(compare_exchange_t, op := Op.compare_exchange, mtype := mtype, ztype := ztype, r := r, success := success, failure := failure)); END compare_exchange; PROCEDURE fence(self: T; order: MemoryOrder) = BEGIN -self.Add(NEW(fence_t, order := order)); +self.Add(NEW(fence_t, op := Op.fence, order := order)); END fence; PROCEDURE fetch_and_op(self: T; op: AtomicOp; mtype: MType; ztype: ZType; order: MemoryOrder) = BEGIN -self.Add(NEW(fetch_and_op_t, atomic_op := op, mtype := mtype, ztype := ztype, order := order)); +self.Add(NEW(fetch_and_op_t, op := Op.fetch_and_op, atomic_op := op, mtype := mtype, ztype := ztype, order := order)); END fetch_and_op; PROCEDURE Replay_Init(self: Replay_t; refcount: INTEGER): Replay_t = Index: m3-sys/m3middle/src/Target.i3 =================================================================== RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/Target.i3,v retrieving revision 1.70 diff -u -r1.70 Target.i3 --- m3-sys/m3middle/src/Target.i3 4 Sep 2012 15:11:09 -0000 1.70 +++ m3-sys/m3middle/src/Target.i3 11 Oct 2012 06:18:42 -0000 @@ -136,7 +136,8 @@ IntegratedObject, (* "0" -- don't call m3_backend, M3CG produces object code *) IntegratedAssembly, (* "1" -- don't call m3_backend, M3CG produces assembly code *) ExternalObject, (* "2" -- call m3_backend, it produces object code *) - ExternalAssembly (* "3" -- call m3_backend, it produces assembly code *) + ExternalAssembly, (* "3" -- call m3_backend, it produces assembly code *) + C (* -- don't call m3_backend, call compile_c, M3CG produces C *) }; CONST @@ -144,10 +145,11 @@ { "IntegratedObject", "IntegratedAssembly", "ExternalObject", - "ExternalAssembly" }; + "ExternalAssembly", + "C" }; - BackendIntegrated = ARRAY M3BackendMode_t OF BOOLEAN { TRUE, TRUE, FALSE, FALSE }; - BackendAssembly = ARRAY M3BackendMode_t OF BOOLEAN { FALSE, TRUE, FALSE, TRUE }; + BackendIntegrated = ARRAY M3BackendMode_t OF BOOLEAN { TRUE, TRUE, FALSE, FALSE, TRUE }; + BackendAssembly = ARRAY M3BackendMode_t OF BOOLEAN { FALSE, TRUE, FALSE, TRUE, FALSE }; (*-------------------------------------------------------- initialization ---*) Index: m3-sys/m3middle/src/Target.m3 =================================================================== RCS file: /usr/cvs/cm3/m3-sys/m3middle/src/Target.m3,v retrieving revision 1.126 diff -u -r1.126 Target.m3 --- m3-sys/m3middle/src/Target.m3 4 Sep 2012 15:11:09 -0000 1.126 +++ m3-sys/m3middle/src/Target.m3 11 Oct 2012 06:18:42 -0000 @@ -402,10 +402,10 @@ InitCallingConventions (backend_mode, System IN SET OF Systems{Systems.I386_INTERIX, - Systems.NT386, - Systems.I386_NT, - Systems.I386_CYGWIN, - Systems.I386_MINGW}); + Systems.NT386, + Systems.I386_NT, + Systems.I386_CYGWIN, + Systems.I386_MINGW}); (* fill in the "bytes" and "pack" fields *) FixI (Address, max_align); @@ -440,20 +440,25 @@ END Init; PROCEDURE InitCallingConventions(backend_mode: M3BackendMode_t; - calling_conventions: BOOLEAN) = + target_has_calling_conventions: BOOLEAN) = PROCEDURE New(name: TEXT; id: [0..1]): CallingConvention = VAR cc := NEW(CallingConvention, name := name); BEGIN - (* The external backend handles more calling convention details than the - integrated backend -- reversing parameter order and knowing how to - return structs. *) - IF calling_conventions THEN + (* This stuff seems messed up. *) + IF backend_mode = M3BackendMode_t.C OR target_has_calling_conventions THEN cc.m3cg_id := id; - cc.args_left_to_right := NOT integrated; - cc.results_on_left := TRUE; - cc.standard_structs := NOT integrated; ELSE cc.m3cg_id := 0; + END; + IF backend_mode = M3BackendMode_t.C THEN + cc.args_left_to_right := TRUE; + cc.results_on_left := FALSE; (* FUTURE: a) this is wrong, b) should be left to C compiler *) + cc.standard_structs := TRUE; (* FUTURE: fix this -- need to know the size! *) + ELSIF integrated THEN + cc.args_left_to_right := FALSE; + cc.results_on_left := TRUE; + cc.standard_structs := FALSE; + ELSE cc.args_left_to_right := TRUE; cc.results_on_left := FALSE; cc.standard_structs := TRUE;