Mercurial > hg > CbC > CbC_gcc
comparison gcc/ada/gcc-interface/cuintp.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 04ced10e8804 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
4 * * | 4 * * |
5 * C U I N T P * | 5 * C U I N T P * |
6 * * | 6 * * |
7 * C Implementation File * | 7 * C Implementation File * |
8 * * | 8 * * |
9 * Copyright (C) 1992-2016, Free Software Foundation, Inc. * | 9 * Copyright (C) 1992-2019, Free Software Foundation, Inc. * |
10 * * | 10 * * |
11 * GNAT is free software; you can redistribute it and/or modify it under * | 11 * GNAT is free software; you can redistribute it and/or modify it under * |
12 * terms of the GNU General Public License as published by the Free Soft- * | 12 * terms of the GNU General Public License as published by the Free Soft- * |
13 * ware Foundation; either version 3, or (at your option) any later ver- * | 13 * ware Foundation; either version 3, or (at your option) any later ver- * |
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- * | 14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- * |
140 { | 140 { |
141 tree gnu_type = TREE_TYPE (Input), gnu_base, gnu_temp; | 141 tree gnu_type = TREE_TYPE (Input), gnu_base, gnu_temp; |
142 /* UI_Base is defined so that 5 Uint digits is sufficient to hold the | 142 /* UI_Base is defined so that 5 Uint digits is sufficient to hold the |
143 largest possible signed 64-bit value. */ | 143 largest possible signed 64-bit value. */ |
144 const int Max_For_Dint = 5; | 144 const int Max_For_Dint = 5; |
145 int v[Max_For_Dint], i; | 145 int v[Max_For_Dint]; |
146 Vector_Template temp; | 146 Vector_Template temp; |
147 Int_Vector vec; | 147 Int_Vector vec; |
148 | 148 |
149 #if HOST_BITS_PER_WIDE_INT == 64 | 149 #if HOST_BITS_PER_WIDE_INT < 64 |
150 /* On 64-bit hosts, tree_fits_shwi_p tells whether the input fits in a | 150 #error unsupported HOST_BITS_PER_WIDE_INT setting |
151 signed 64-bit integer. Then a truncation tells whether it fits | 151 #endif |
152 | |
153 /* On 64-bit hosts, tree_fits_shwi_p tells whether the input fits in | |
154 a signed 64-bit integer. Then a truncation tells whether it fits | |
152 in a signed 32-bit integer. */ | 155 in a signed 32-bit integer. */ |
153 if (tree_fits_shwi_p (Input)) | 156 if (tree_fits_shwi_p (Input)) |
154 { | 157 { |
155 HOST_WIDE_INT hw_input = tree_to_shwi (Input); | 158 HOST_WIDE_INT hw_input = tree_to_shwi (Input); |
156 if (hw_input == (int) hw_input) | 159 if (hw_input == (int) hw_input) |
157 return UI_From_Int (hw_input); | 160 return UI_From_Int (hw_input); |
158 } | 161 } |
159 else | 162 else |
160 return No_Uint; | 163 return No_Uint; |
161 #else | |
162 /* On 32-bit hosts, tree_fits_shwi_p tells whether the input fits in a | |
163 signed 32-bit integer. Then a sign test tells whether it fits | |
164 in a signed 64-bit integer. */ | |
165 if (tree_fits_shwi_p (Input)) | |
166 return UI_From_Int (tree_to_shwi (Input)); | |
167 | |
168 gcc_assert (TYPE_PRECISION (gnu_type) <= 64); | |
169 if (TYPE_UNSIGNED (gnu_type) | |
170 && TYPE_PRECISION (gnu_type) == 64 | |
171 && wi::neg_p (Input, SIGNED)) | |
172 return No_Uint; | |
173 #endif | |
174 | 164 |
175 gnu_base = build_int_cst (gnu_type, UI_Base); | 165 gnu_base = build_int_cst (gnu_type, UI_Base); |
176 gnu_temp = Input; | 166 gnu_temp = Input; |
177 | 167 |
178 for (i = Max_For_Dint - 1; i >= 0; i--) | 168 for (int i = Max_For_Dint - 1; i >= 0; i--) |
179 { | 169 { |
180 v[i] = tree_to_shwi (fold_build1 (ABS_EXPR, gnu_type, | 170 v[i] = tree_to_shwi (fold_build1 (ABS_EXPR, gnu_type, |
181 fold_build2 (TRUNC_MOD_EXPR, gnu_type, | 171 fold_build2 (TRUNC_MOD_EXPR, gnu_type, |
182 gnu_temp, gnu_base))); | 172 gnu_temp, gnu_base))); |
183 gnu_temp = fold_build2 (TRUNC_DIV_EXPR, gnu_type, gnu_temp, gnu_base); | 173 gnu_temp = fold_build2 (TRUNC_DIV_EXPR, gnu_type, gnu_temp, gnu_base); |