Hi @Luke Wagner I have a question regard to the return values in the cannon-lift. The proposal simply put a "i32" type as flat_results. I wonder if we should be more specific about it? Like it is value or pointer? I assume if the ft has single primitive type as return, it can be a value. for other situation, it is probabaly a pointer to flatten items.
MAX_FLAT_PARAMS = 16
MAX_FLAT_RESULTS = 1
def flatten_functype(ft, context):
flat_params = flatten_types(ft.param_types())
if len(flat_params) > MAX_FLAT_PARAMS:
flat_params = ['i32']
flat_results = flatten_types(ft.result_types())
if len(flat_results) > MAX_FLAT_RESULTS:
match context:
case 'lift':
flat_results = ['i32']
case 'lower':
flat_params += ['i32']
flat_results = []
return CoreFuncType(flat_params, flat_results)
@Wang Xin thanks for the question: in this case where we have more than MAX_FLAT_RESULTS (currently 1, due to lack of multi-return support in certain parts of the LLVM toolchain), the i32
is always a pointer to linear memory that will hold all the return values as a tuple. (Once multi-return support is implemented in the right places, we can increase MAX_FLAT_RESULTS or add a canonopt
to do that.)
@Luke Wagner Thanks! I got it.
Last updated: Dec 23 2024 at 12:05 UTC