poly_int
s ¶poly_int
provides various routines for aligning values and for querying
misalignments. In each case the alignment must be a power of 2.
Return true if we can align value up or down to the nearest multiple of align at compile time. The answer is the same for both directions.
Return true if can_align_p
; if so, set aligned to the greatest
aligned value that is less than or equal to value.
Return true if can_align_p
; if so, set aligned to the lowest
aligned value that is greater than or equal to value.
Return true if we can align a and b down to the nearest align boundary at compile time and if the two results are equal.
Return true if we can align a and b up to the nearest align boundary at compile time and if the two results are equal.
Return a result that is no greater than value and that is aligned to align. The result will the closest aligned value for some indeterminate values but not necessarily for all.
For example, suppose we are allocating an object of size bytes in a downward-growing stack whose current limit is given by limit. If the object requires align bytes of alignment, the new stack limit is given by:
aligned_lower_bound (limit - size, align)
Likewise return a result that is no less than value and that is aligned to align. This is the routine that would be used for upward-growing stacks in the scenario just described.
Return true if we can calculate the misalignment of value with respect to align at compile time, storing the result in misalign if so.
Return the minimum alignment that value is known to have (in other words, the largest alignment that can be guaranteed whatever the values of the indeterminates turn out to be). Return 0 if value is known to be 0.
Assert that value can be aligned down to align at compile time and return the result. When using this routine, please add a comment explaining why the assertion is known to hold.
Likewise, but aligning up.
Divide the result of force_align_down
by align. Again,
please add a comment explaining why the assertion in force_align_down
is known to hold.
Likewise for force_align_up
.
Assert that we can calculate the misalignment of value with respect to align at compile time and return the misalignment. When using this function, please add a comment explaining why the assertion is known to hold.