On 2025-07-07 17:47, Jakub Jelinek wrote:
Even 6 arguments is IMHO too much.
/* Expand the IFN_ACCESS_WITH_SIZE function:
    ACCESS_WITH_SIZE (REF_TO_OBJ, REF_TO_SIZE, CLASS_OF_SIZE,
                      TYPE_OF_SIZE, ACCESS_MODE)
    which returns the REF_TO_OBJ same as the 1st argument;

    1st argument REF_TO_OBJ: The reference to the object;
    2nd argument REF_TO_SIZE: The reference to the size of the object,
    3rd argument CLASS_OF_SIZE: The size referenced by the REF_TO_SIZE 
represents
      0: the number of bytes.
      1: the number of the elements of the object type;
    4th argument TYPE_OF_SIZE: A constant 0 with its TYPE being the same as the 
TYPE
     of the object referenced by REF_TO_SIZE

Wouldn't this always be TREE_TYPE(TREE_TYPE(REF_TO_SIZE))?

    5th argument ACCESS_MODE:
     -1: Unknown access semantics
      0: none
      1: read_only
      2: write_only
      3: read_write
    6th argument: A constant 0 with the pointer TYPE to the original flexible
      array type.

Likewise, wouldn't this always be TREE_TYPE(TREE_TYPE(REF_TO_OBJ))? For a FAM, the frontend does array_to_pointer, so with the INDIRECT_REF at the end of build_access_with_size_for_counted_by gone, I reckon you should be able to get the type of the array element. Likewise if it was a pointer and not a FAM.

TYPE_SIZE_UNIT may not work for them like you said, but there ought to be a usable expression that we can reach from the type, no?

Thanks,
Sid

Reply via email to