On Wed, Jun 24, 2020 at 9:05 PM Gary Oblock via Gcc <gcc@gcc.gnu.org> wrote: > > Richard, > > First off I did suspect INDIRECT_REF wasn't supported, thanks for > confirming that. > > I tried what you said in the original code before I posted > but I suspect how I went at it is the problem. I'm probably > doing something(s) in a glaringly stupid way. > > Can you spot it, because everything I'm doing makes total sense > to me?
Well, read what I wrote ... > Thanks Gary > > -- > > Snippet from the code with MEM_REF: > > tree lhs_ref = build1 ( MEM_REF, field_type, field_addr); MEM_REF has two operands, the second is a byte offset plus encodes TBAA information. > final_set = gimple_build_assign( lhs_ref, field_val_temp); > > field_type is a double * > > field_addr is an address within an malloced array of doubles. > > -- > > Snippet from the code with ARRAY_REF: > > tree rhs_ref = build4 ( ARRAY_REF, field_type, field_arry_addr, index, > NULL_TREE, NULL_TREE); you need to dereference field_arry_addr to produce an array you can reference with the ARRAY_REF. tree arr = build2 (MEM_REF, array_type, field_arry_addr, build_int_cst (ptr_type_node, 0)); rhs_ref = build4 (ARRAY_REF, field_type, arr, index, NULL, NULL); > temp_set = gimple_build_assign( field_val_temp, rhs_ref); > > field type is double > > field_arry_addr is the starting address of an array of malloced doubles. > > index is a pointer_rep (an integer) > details: > tree pointer_rep = make_node ( INTEGER_TYPE); > TYPE_PRECISION (pointer_rep) = TYPE_PRECISION (pointer_sized_int_node); >