GCC Middle and Back End API Reference
wide-int-print.h
Go to the documentation of this file.
1/* Print wide integers.
2 Copyright (C) 2013-2024 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 3, or (at your option) any
9later version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT
12ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef WIDE_INT_PRINT_H
21#define WIDE_INT_PRINT_H
22
23#include <stdio.h>
24
25#define WIDE_INT_PRINT_BUFFER_SIZE (WIDE_INT_MAX_INL_PRECISION / 4 + 4)
26
27/* Printing functions. */
28
29extern void print_dec (const wide_int_ref &wi, char *buf, signop sgn);
30extern void print_dec (const wide_int_ref &wi, FILE *file, signop sgn);
31extern void print_decs (const wide_int_ref &wi, char *buf);
32extern void print_decs (const wide_int_ref &wi, FILE *file);
33extern void print_decu (const wide_int_ref &wi, char *buf);
34extern void print_decu (const wide_int_ref &wi, FILE *file);
35extern void print_hex (const wide_int_ref &wi, char *buf);
36extern void print_hex (const wide_int_ref &wi, FILE *file);
37extern void pp_wide_int_large (pretty_printer *, const wide_int_ref &, signop);
38
39inline bool
40print_dec_buf_size (const wide_int_ref &wi, signop sgn, unsigned int *len)
41{
42 unsigned int l = wi.get_len ();
43 if ((l != 1 || sgn == UNSIGNED) && wi::neg_p (wi))
44 l = WIDE_INT_MAX_HWIS (wi.get_precision ());
45 l = l * HOST_BITS_PER_WIDE_INT / 3 + 3;
46 *len = l;
48}
49
50inline bool
51print_decs_buf_size (const wide_int_ref &wi, unsigned int *len)
52{
53 return print_dec_buf_size (wi, SIGNED, len);
54}
55
56inline bool
57print_decu_buf_size (const wide_int_ref &wi, unsigned int *len)
58{
59 return print_dec_buf_size (wi, UNSIGNED, len);
60}
61
62inline bool
63print_hex_buf_size (const wide_int_ref &wi, unsigned int *len)
64{
65 unsigned int l;
66 if (wi::neg_p (wi))
67 l = WIDE_INT_MAX_HWIS (wi.get_precision ());
68 else
69 l = wi.get_len ();
70 l = l * HOST_BITS_PER_WIDE_INT / 4 + 4;
71 *len = l;
73}
74
75#endif /* WIDE_INT_PRINT_H */
Definition wide-int.h:776
Definition pretty-print.h:244
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
#define HOST_BITS_PER_WIDE_INT
Definition hwint.h:53
Definition double-int.h:439
UNARY_PREDICATE neg_p(const T &, signop=SIGNED)
signop
Definition signop.h:28
@ UNSIGNED
Definition signop.h:30
@ SIGNED
Definition signop.h:29
#define UNLIKELY(x)
Definition system.h:759
void print_decs(const wide_int_ref &wi, char *buf)
Definition wide-int-print.cc:55
void print_hex(const wide_int_ref &wi, char *buf)
Definition wide-int-print.cc:141
bool print_decs_buf_size(const wide_int_ref &wi, unsigned int *len)
Definition wide-int-print.h:51
void print_decu(const wide_int_ref &wi, char *buf)
Definition wide-int-print.cc:91
void pp_wide_int_large(pretty_printer *, const wide_int_ref &, signop)
Definition wide-int-print.cc:183
void print_dec(const wide_int_ref &wi, char *buf, signop sgn)
Definition wide-int-print.cc:34
#define WIDE_INT_PRINT_BUFFER_SIZE
Definition wide-int-print.h:25
bool print_hex_buf_size(const wide_int_ref &wi, unsigned int *len)
Definition wide-int-print.h:63
bool print_dec_buf_size(const wide_int_ref &wi, signop sgn, unsigned int *len)
Definition wide-int-print.h:40
bool print_decu_buf_size(const wide_int_ref &wi, unsigned int *len)
Definition wide-int-print.h:57
#define WIDE_INT_MAX_HWIS(PRECISION)
Definition wide-int.h:284