Next: Miscellaneous `poly_int`

routines, Previous: Computing bounds on `poly_int`

s, Up: poly_int [Contents][Index]

`poly_int`

sA `poly_int<`

can be constructed from up to
`n`, `T`>`n` individual `T` coefficients, with the remaining coefficients
being implicitly zero. In particular, this means that every
`poly_int<`

can be constructed from a single
scalar `n`, `T`>`T`, or something compatible with `T`.

Also, a `poly_int<`

can be constructed from
a `n`, `T`>`poly_int<`

if `n`, `U`>`T` can be constructed
from `U`.

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

- ‘
’`value`.is_constant () Return true if

`poly_int`

`value`is a compile-time constant.- ‘
’`value`.is_constant (&`c1`) Return true if

`poly_int`

`value`is a compile-time constant, storing it in`c1`if so.`c1`must be able to hold all constant values of`value`without loss of precision.- ‘
’`value`.to_constant () Assert that

`value`is a compile-time constant and return its value. When using this function, please add a comment explaining why the condition is known to hold (for example, because an earlier phase of analysis rejected non-constants).- ‘
’`value`.to_shwi (&`p2`) Return true if ‘

`poly_int<`’`N`,`T`>`value`can be represented without loss of precision as a ‘`poly_int<`’, storing it in that form in`N`,`HOST_WIDE_INT`

>`p2`if so.- ‘
’`value`.to_uhwi (&`p2`) Return true if ‘

`poly_int<`’`N`,`T`>`value`can be represented without loss of precision as a ‘`poly_int<`’, storing it in that form in`N`,`unsigned HOST_WIDE_INT`

>`p2`if so.- ‘
’`value`.force_shwi () Forcibly convert each coefficient of ‘

`poly_int<`’`N`,`T`>`value`to`HOST_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`to`unsigned HOST_WIDE_INT`

, truncating any that are out of range. Return the result as a ‘`poly_int<`’.`N`,`unsigned HOST_WIDE_INT`

>- ‘
`wi::shwi (`’`value`,`precision`) Return a

`poly_int`

with the same value as`value`, but with the coefficients converted from`HOST_WIDE_INT`

to`wide_int`

.`precision`specifies the precision of the`wide_int`

cofficients; if this is wider than a`HOST_WIDE_INT`

, the coefficients of`value`will be sign-extended to fit.- ‘
`wi::uhwi (`’`value`,`precision`) Like

`wi::shwi`

, except that`value`has coefficients of type`unsigned HOST_WIDE_INT`

. If`precision`is wider than a`HOST_WIDE_INT`

, the coefficients of`value`will be zero-extended to fit.- ‘
`wi::sext (`’`value`,`precision`) Return a

`poly_int`

of the same type as`value`, sign-extending every coefficient from the low`precision`bits. This in effect applies`wi::sext`

to each coefficient individually.- ‘
`wi::zext (`’`value`,`precision`) Like

`wi::sext`

, but for zero extension.- ‘
`poly_wide_int::from (`’`value`,`precision`,`sign`) Convert

`value`to a`poly_wide_int`

in which each coefficient has`precision`bits. Extend the coefficients according to`sign`if the coefficients have fewer bits.- ‘
`poly_offset_int::from (`’`value`,`sign`) Convert

`value`to a`poly_offset_int`

, extending its coefficients according to`sign`if they have fewer bits than`offset_int`

.- ‘
`poly_widest_int::from (`’`value`,`sign`) Convert

`value`to a`poly_widest_int`

, extending its coefficients according to`sign`if they have fewer bits than`widest_int`

.

`poly_int`

routines, Previous: Computing bounds on `poly_int`

s, Up: poly_int [Contents][Index]