On Fri, Nov 03, 2023 at 04:20:57PM +0000, Qing Zhao wrote: > So, based on the discussion so far, We will define the .ACCESS_WITH_SIZE as > following: > > .ACCESS_WITH_SIZE (REF_TO_OBJ, REF_TO_SIZE, ACCESS_MODE) > > INTERNAL_FN (ACCESS_WITH_SIZE, ECF_LEAF | ECF_NOTHROW, NULL) > > which returns the “REF_TO_OBJ" same as the 1st argument; > > 1st argument “REF_TO_OBJ": Reference to the object; > 2nd argument “REF_TO_SIZE”: Reference to size of the object referenced by > the 1st argument, > if the object that the “REF_TO_OBJ” refered has a > * real type, the SIZE that the “REF_TO_SIZE” referred is the number of the > elements of the type; > * void type, the SIZE that the “REF_TO_SIZE” referred is number of bytes;
No, you can't do this. Conversions between pointers are mostly useless in GIMPLE, , so you can't make decisions based on TREE_TYPE (TREE_TYPE (fnarg)) as it could have some random completely unrelated type. So, the multiplication factor needs to be encoded in the arguments rather than derived from REF_TO_OBJ's type, and similarly the size of what REF_TO_SIZE points to needs to be encoded somewhere. > 3rd argument "ACCESS_MODE": > -1: Unknown access semantics > 0: none > 1: read_only > 2: write_only > 3: read_write Jakub