xls
xls copied to clipboard
Define semantics for out-of-bounds array accesses in IR
Out-of-bounds ArrayIndex operations clamp the index to the highest element: https://github.com/google/xls/blob/ec980d843016e7b7257aeedc4fffd06d8198aa3b/xls/ir/ir_interpreter.cc#L256
Out-of-bounds ArrayUpdate operations are noops: https://github.com/google/xls/blob/ec980d843016e7b7257aeedc4fffd06d8198aa3b/xls/ir/ir_interpreter.cc#L268
This is not very consistent because we clamp only in the ArrayIndex case. We should think about what semantics we want here. One option is to make OOB ArrayIndex return the zero value. Alternatively OOB behavior could be configurable.
@meheff I think we've probably reached a stable state on this one, even if we've talked about alternatives -- want to summarize so we can close this out?