Movatterモバイル変換


[0]ホーム

URL:


Next:, Previous:, Up:Sizes and offsets as runtime invariants   [Contents][Index]


9.7 Convertingpoly_ints

Apoly_int<n,T> can be constructed from up ton individualT coefficients, with the remaining coefficientsbeing implicitly zero. In particular, this means that everypoly_int<n,T> can be constructed from a singlescalarT, or something compatible withT.

Also, apoly_int<n,T> can be constructed fromapoly_int<n,U> ifT can be constructedfromU.

The following functions provide other forms of conversion,or test whether such a conversion would succeed.

value.is_constant ()

Return true ifpoly_intvalue is a compile-time constant.

value.is_constant (&c1)

Return true ifpoly_intvalue is a compile-time constant,storing it inc1 if so.c1 must be able to hold allconstant values ofvalue without loss of precision.

value.to_constant ()

Assert thatvalue is a compile-time constant and return its value.When using this function, please add a comment explaining why thecondition is known to hold (for example, because an earlier phaseof analysis rejected non-constants).

value.to_shwi (&p2)

Return true if ‘poly_int<N,T>value can berepresented without loss of precision as a‘poly_int<N,HOST_WIDE_INT>’, storing it in thatform inp2 if so.

value.to_uhwi (&p2)

Return true if ‘poly_int<N,T>value can berepresented without loss of precision as a‘poly_int<N,unsigned HOST_WIDE_INT>’, storing it in thatform inp2 if so.

value.force_shwi ()

Forcibly convert each coefficient of ‘poly_int<N,T>value toHOST_WIDE_INT, truncating any that are out of range.Return the result as a ‘poly_int<N,HOST_WIDE_INT>’.

value.force_uhwi ()

Forcibly convert each coefficient of ‘poly_int<N,T>value tounsigned HOST_WIDE_INT, truncating any that areout of range. Return the result as a‘poly_int<N,unsigned HOST_WIDE_INT>’.

wi::shwi (value,precision)

Return apoly_int with the same value asvalue, but withthe coefficients converted fromHOST_WIDE_INT towide_int.precision specifies the precision of thewide_int cofficients;if this is wider than aHOST_WIDE_INT, the coefficients ofvalue will be sign-extended to fit.

wi::uhwi (value,precision)

Likewi::shwi, except thatvalue has coefficients oftypeunsigned HOST_WIDE_INT. Ifprecision is wider thanaHOST_WIDE_INT, the coefficients ofvalue will bezero-extended to fit.

wi::sext (value,precision)

Return apoly_int of the same type asvalue, sign-extendingevery coefficient from the lowprecision bits. This in effectapplieswi::sext to each coefficient individually.

wi::zext (value,precision)

Likewi::sext, but for zero extension.

poly_wide_int::from (value,precision,sign)

Convertvalue to apoly_wide_int in which each coefficienthasprecision bits. Extend the coefficients according tosign if the coefficients have fewer bits.

poly_offset_int::from (value,sign)

Convertvalue to apoly_offset_int, extending its coefficientsaccording tosign if they have fewer bits thanoffset_int.

poly_widest_int::from (value,sign)

Convertvalue to apoly_widest_int, extending its coefficientsaccording tosign if they have fewer bits thanwidest_int.


Next:Miscellaneouspoly_int routines, Previous:Computing bounds onpoly_ints, Up:Sizes and offsets as runtime invariants   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp