[m-rev.] for review: add type to array_index operator
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Jul 9 02:01:17 AEST 2001
On 08-Jul-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
>
> Add type information to the array_index operator.
> This is needed for both the GCC back-end and the IL back-end.
...
The diff that I posted for mlds_to_gcc.m was wrong.
There's a corrected version below.
Also the diff that I posted for mlds_to_il.m both the diff
for this change and also the diff for my previous change.
A corrected version, which just shows the diff for this change, is below.
I've bootchecked this in grade hlc.gc, and tested it a bit in grade ilc by
manually verifying that the generated IL is what I expected.
(String switches still don't work because of problems with the array types.)
I'll bootcheck it in asm_fast.gc too, just to be safe, but after that
I plan to go ahead and commit it, without waiting for review comments.
Tyson has already agreed in principle that we need to add type information
to the array_index operator. If there are any review comments I can
address them afterwards.
Index: mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.41
diff -u -d -u -r1.41 mlds_to_gcc.m
--- mlds_to_gcc.m 2001/06/24 06:56:57 1.41
+++ mlds_to_gcc.m 2001/07/08 14:45:31
@@ -3104,7 +3104,17 @@
%
build_rval(Arg1, DefnInfo, GCC_Arg1),
build_rval(Arg2, DefnInfo, GCC_Arg2),
- { convert_binary_op(BinaryOp, GCC_BinaryOp, GCC_ResultType) },
+ ( { BinaryOp = array_index(ElemType) } ->
+ % for array index operations,
+ % we need to convert the element type into a GCC type
+ { GCC_BinaryOp = gcc__array_ref },
+ { MLDS_Type = ml_gen_array_elem_type(ElemType) },
+ build_type(MLDS_Type, DefnInfo ^ global_info,
+ GCC_ResultType)
+ ;
+ { convert_binary_op(BinaryOp, GCC_BinaryOp,
+ GCC_ResultType) }
+ ),
gcc__build_binop(GCC_BinaryOp, GCC_ResultType,
GCC_Arg1, GCC_Arg2, Expr)
).
@@ -3143,11 +3153,8 @@
convert_binary_op(eq, gcc__eq_expr, gcc__boolean_type_node).
convert_binary_op(ne, gcc__ne_expr, gcc__boolean_type_node).
convert_binary_op(body, gcc__minus_expr, 'MR_intptr_t').
-convert_binary_op(array_index, gcc__array_ref, Type) :-
- % XXX temp hack -- this is wrong.
- % We should change builtin_ops:array_index
- % so that it takes the type as an argument.
- Type = 'MR_Integer'.
+convert_binary_op(array_index(_), _, _) :-
+ unexpected(this_file, "array_index").
convert_binary_op(str_eq, _, _) :- unexpected(this_file, "str_eq").
convert_binary_op(str_ne, _, _) :- unexpected(this_file, "str_ne").
convert_binary_op(str_lt, _, _) :- unexpected(this_file, "str_lt").
Index: mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.36
diff -u -d -u -r1.36 mlds_to_il.m
--- mlds_to_il.m 2001/07/08 08:17:03 1.36
+++ mlds_to_il.m 2001/07/08 11:28:34
@@ -1557,11 +1557,11 @@
{ unexpected(this_file, "binop: body") }.
- % XXX we need to know what kind of thing is being indexed
- % from the array in general.
-binaryop_to_il(array_index, node([
- ldelem(refany) % XXX FIXME element type here is wrong
- ])) --> [].
+binaryop_to_il(array_index(ElemType), instr_node(I)) -->
+ DataRep =^ il_data_rep,
+ { MLDS_Type = ml_gen_array_elem_type(ElemType) },
+ { ILSimpleType = mlds_type_to_ilds_simple_type(DataRep, MLDS_Type) },
+ { I = ldelem(ILSimpleType) }.
% String operations.
binaryop_to_il(str_eq, node([
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list