GCC Middle and Back End API Reference
fixed-value.h
Go to the documentation of this file.
1/* Fixed-point arithmetic support.
2 Copyright (C) 2006-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 under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; 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 GCC_FIXED_VALUE_H
21#define GCC_FIXED_VALUE_H
22
23struct GTY(()) fixed_value
24{
25 double_int data; /* Store data up to 2 wide integers. */
26 scalar_mode_pod mode; /* Use machine mode to know IBIT and FBIT. */
27};
28
29#define FIXED_VALUE_TYPE struct fixed_value
30
31#define MAX_FCONST0 18 /* For storing 18 fixed-point zeros per
32 fract, ufract, accum, and uaccum modes . */
33#define MAX_FCONST1 8 /* For storing 8 fixed-point ones per accum
34 and uaccum modes. */
35/* Constant fixed-point values 0 and 1. */
39/* Macros to access fconst0 and fconst1 via machine modes. */
40#define FCONST0(mode) fconst0[mode - QQmode]
41#define FCONST1(mode) fconst1[mode - HAmode]
43/* Return a CONST_FIXED with value R and mode M. */
44#define CONST_FIXED_FROM_FIXED_VALUE(r, m) \
45 const_fixed_from_fixed_value (r, m)
47
48/* Construct a FIXED_VALUE from a bit payload and machine mode MODE.
49 The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */
51
52/* Return a CONST_FIXED from a bit payload and machine mode MODE.
53 The bits in PAYLOAD are sign-extended/zero-extended according to MODE. */
54inline rtx
56 scalar_mode mode)
57{
58 return
60 mode);
61}
62
63/* Initialize from a decimal or hexadecimal string. */
64extern void fixed_from_string (FIXED_VALUE_TYPE *, const char *,
66
67/* In tree.cc: wrap up a FIXED_VALUE_TYPE in a tree node. */
69
70/* Extend or truncate to a new mode. */
72 const FIXED_VALUE_TYPE *, bool);
73
74/* Convert to a fixed-point mode from an integer. */
76 double_int, bool, bool);
77
78/* Convert to a fixed-point mode from a real. */
80 const REAL_VALUE_TYPE *, bool);
81
82/* Convert to a real mode from a fixed-point. */
84 const FIXED_VALUE_TYPE *);
85
86/* Compare two fixed-point objects for bitwise identity. */
87extern bool fixed_identical (const FIXED_VALUE_TYPE *, const FIXED_VALUE_TYPE *);
88
89/* Calculate a hash value. */
90extern unsigned int fixed_hash (const FIXED_VALUE_TYPE *);
91
92#define FIXED_VALUES_IDENTICAL(x, y) fixed_identical (&(x), &(y))
94/* Determine whether a fixed-point value X is negative. */
95#define FIXED_VALUE_NEGATIVE(x) fixed_isneg (&(x))
96
97/* Render F as a decimal floating point constant. */
98extern void fixed_to_decimal (char *str, const FIXED_VALUE_TYPE *, size_t);
99
100/* Binary or unary arithmetic on tree_code. */
101extern bool fixed_arithmetic (FIXED_VALUE_TYPE *, int, const FIXED_VALUE_TYPE *,
102 const FIXED_VALUE_TYPE *, bool);
103
104/* Compare fixed-point values by tree_code. */
105extern bool fixed_compare (int, const FIXED_VALUE_TYPE *,
106 const FIXED_VALUE_TYPE *);
107
108/* Determine whether a fixed-point value X is negative. */
109extern bool fixed_isneg (const FIXED_VALUE_TYPE *);
110
111#endif /* GCC_FIXED_VALUE_H */
Definition machmode.h:493
#define GTY(x)
Definition coretypes.h:41
union tree_node * tree
Definition coretypes.h:97
rtx const_fixed_from_double_int(double_int payload, scalar_mode mode)
Definition fixed-value.h:53
FIXED_VALUE_TYPE fconst0[MAX_FCONST0]
Definition emit-rtl.cc:116
FIXED_VALUE_TYPE fconst1[MAX_FCONST1]
Definition emit-rtl.cc:117
void fixed_from_string(FIXED_VALUE_TYPE *, const char *, scalar_mode)
Definition fixed-value.cc:111
#define MAX_FCONST1
Definition fixed-value.h:32
bool fixed_compare(int, const FIXED_VALUE_TYPE *, const FIXED_VALUE_TYPE *)
Definition fixed-value.cc:765
#define FIXED_VALUE_TYPE
Definition fixed-value.h:29
bool fixed_convert(FIXED_VALUE_TYPE *, scalar_mode, const FIXED_VALUE_TYPE *, bool)
Definition fixed-value.cc:805
void real_convert_from_fixed(REAL_VALUE_TYPE *, scalar_mode, const FIXED_VALUE_TYPE *)
Definition fixed-value.cc:1092
bool fixed_isneg(const FIXED_VALUE_TYPE *)
Definition fixed-value.cc:1109
tree build_fixed(tree, FIXED_VALUE_TYPE)
Definition tree.cc:2373
#define MAX_FCONST0
Definition fixed-value.h:31
void fixed_to_decimal(char *str, const FIXED_VALUE_TYPE *, size_t)
Definition fixed-value.cc:154
rtx const_fixed_from_fixed_value(FIXED_VALUE_TYPE, machine_mode)
Definition emit-rtl.cc:601
bool fixed_convert_from_int(FIXED_VALUE_TYPE *, scalar_mode, double_int, bool, bool)
Definition fixed-value.cc:949
bool fixed_arithmetic(FIXED_VALUE_TYPE *, int, const FIXED_VALUE_TYPE *, const FIXED_VALUE_TYPE *, bool)
Definition fixed-value.cc:726
bool fixed_identical(const FIXED_VALUE_TYPE *, const FIXED_VALUE_TYPE *)
Definition fixed-value.cc:30
FIXED_VALUE_TYPE fixed_from_double_int(double_int, scalar_mode)
Definition fixed-value.cc:89
unsigned int fixed_hash(const FIXED_VALUE_TYPE *)
Definition fixed-value.cc:40
bool fixed_convert_from_real(FIXED_VALUE_TYPE *, scalar_mode, const REAL_VALUE_TYPE *, bool)
Definition fixed-value.cc:1033
#define REAL_VALUE_TYPE
Definition real.h:68
Definition double-int.h:50
Definition fixed-value.h:24
double_int data
Definition fixed-value.h:25
scalar_mode_pod mode
Definition fixed-value.h:26
Definition rtl.h:312