1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
|
/******************************************************************************
Copyright (c) 2007-2024, Intel Corp.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#undef MAKE_INCLUDE
#define MAKE_INCLUDE
#undef F_FLOAT
#define F_FLOAT
#define __F_SUFFIX DPML_NULL_MACRO_TOKEN
#ifndef BUILD_FILE_NAME
# define BUILD_FILE_NAME dpml_globals.h
#endif
#include "build.h"
#include "op_system.h"
#include "compiler.h"
#include "architecture.h"
#include "f_format.h"
#include "dpml_names.h"
/*
* For each data type required by the system, this routine generates bit
* patterns for the indicated values in the following order:
*/
#define NAN_INDEX 0
#define POS_ZERO_INDEX 1
#define NEG_ZERO_INDEX 2
#define POS_TINY_INDEX 3
#define NEG_TINY_INDEX 4
#define POS_HUGE_INDEX 5
#define NEG_HUGE_INDEX 6
#define POS_INFINITY_INDEX 7
#define NEG_INFINITY_INDEX 8
#define POS_ULP_FACTOR_INDEX 9
#define NEG_ULP_FACTOR_INDEX 10
#define POS_ONE_INDEX 11
#define NEG_ONE_INDEX 12
/*
* The globals data is stored in the GLOBALS TABLE as a sequence of
* records. If only IEEE values are needed, each record is 32 bytes in
* length; if VAX values are required in addition to the IEEE values, then
* each record is 64 bytes in length. The fields in the records are
* arranged in the following format:
*
* IEEE values only:
* +---+---+---+---+---+---+---+---+---+---+
* | s | | t | x |
* byte +---+---+---+---+---+---+---+---+---+---+
* offset: 0 8 16
*
* Both IEEE and VAX values:
* +---+---+---+---+---+---+---+---+---+---+
* | s | | t | x |
* byte +---+---+---+---+---+---+---+---+---+---+
* offset: 0 8 16
* +---+---+---+---+---+---+---+---+---+---+
* | f | | g | |
* byte +---+---+---+---+---+---+---+---+---+---+
* offset: 32 40
*
*
* The address of the global item with index N and data type T is given by
*
* GLOBAL_ADDR( T, N ) = ( char* )GLOBALS_TABLE +
* 8 * T +
* BYTES_PER_TABLE_ENTRY * I
*
*/
/*
* In addition to the actual values, this routine also sets up a table
* of address that allows type independent accessing of the values.
* Values are generated only for those data types actually supported by
* the platform. The BIT_IS_SET macro is used to determine which
* "bits" are set in the FLOAT_TYPES macro
*/
#define BIT_IS_SET(i,n) (((i) >> (n)) - (((i) >> ((n)+1)) << 1))
/*
* Along with each set of constants, a symbolic constant for an enumerated
* type is generated. These constants have been chosen to allow for easy access
* to the globals table.
*
* #define _s_TYPE 0
* #define _t_TYPE 1
* #define _x_TYPE 2
* #define _f_TYPE 4
* #define _g_TYPE 5
* #define _d_TYPE 5
*
* (Note: These _{g,t,f,s,x}_TYPE constants are only referenced by
* nt_exception.c, and the F_TYPE_ENUM macro (see below).
* The F_TYPE_ENUM macro, in turn, is only referenced via the GLOBAL macro
* (see below) and via ADD_ERR_CODE_TYPE defined in dpml_exception.h.)
*
* These enumerated types are used to provide type independent access of all
* DPML global values. For example, to access a positive one, use either:
*
* *((F_TYPE*)GLOBAL_ADDR(PASTE_3(_,F_CHAR,_TYPE),POS_ONE_INDEX))
* or
* GLOBAL(POS_ONE_INDEX)
* or
* POS_ONE
*/
/*
* These macros are used to print out the table values and ensure that
* the values are printed out in the right order.
*
* NOTE: Extending mphoc to deal with NaN's, infinities, signed
* zeros and ROP's would make life a lot simpler here.
*
* NOTE: Although platforms that contain the VAX g and d float data type
* are little endian, the word containing the exponent comes first.
*/
# define PR_SINGLE(a) printf("\t"#a", 0, \n") ;
#if (ENDIANESS == big_endian)
# define PR_DOUBLE(a,b) printf("\t"#a", "#b", \n") ;
# define PR_QUAD(a,b,x,y) printf("\t"#a", "#b", "#x", "#y", \n") ;
#else
# define PR_DOUBLE(a,b) printf("\t"#b", "#a", \n") ;
# define PR_QUAD(a,b,x,y) printf("\t"#y", "#x", "#b", "#a", \n") ;
#endif
#if (BITS_PER_TABLE_WORD != 32)
# error "BITS_PER_TABLE_WORD must be 32"
#endif
#include "mphoc_macros.h"
# define TMP_FILE ADD_EXTENSION(BUILD_FILE_NAME,tmp)
@divert divertText
printf( "#if !defined(GLOBALS_TABLE)\n"
"# define GLOBALS_TABLE __INTERNAL_NAME(globals_table)\n"
"#endif\n\n" );
do_f = (BIT_IS_SET(FLOAT_TYPES, f_floating));
do_g = (BIT_IS_SET(FLOAT_TYPES, g_floating));
do_s = (BIT_IS_SET(FLOAT_TYPES, s_floating));
do_t = (BIT_IS_SET(FLOAT_TYPES, t_floating));
do_x = (BIT_IS_SET(FLOAT_TYPES, x_floating));
do_d = (BIT_IS_SET(FLOAT_TYPES, d_floating));
/* We assume there are really only 2 different table formats: {s, t, x} */
/* and {s, t, x, f, g}, which use 32 and 64 bytes respectively. */
bytes_per_table_entry = 0 ;
table_padding = 0 ;
if ( do_s ) {
printf( "#define _s_TYPE 0\n" ) ;
bytes_per_table_entry = bytes_per_table_entry + 8 ;
}
if ( do_t ) {
printf( "#define _t_TYPE 1\n" ) ;
bytes_per_table_entry = bytes_per_table_entry + 8 ;
}
if ( do_x ) {
printf( "#define _x_TYPE 2\n" ) ;
bytes_per_table_entry = bytes_per_table_entry + 16 ;
}
if ( do_f ) {
printf( "#define _f_TYPE 4\n" ) ;
bytes_per_table_entry = bytes_per_table_entry + 8 ;
}
if ( do_g ) {
printf( "#define _g_TYPE 5\n" ) ;
bytes_per_table_entry = bytes_per_table_entry + 8 ;
}
if ( do_d ) {
printf( "#define _d_TYPE 5\n" ) ;
bytes_per_table_entry = bytes_per_table_entry + 8 ;
}
if ( bytes_per_table_entry <= 32 ) {
table_padding = 32 - bytes_per_table_entry ;
bytes_per_table_entry = 32 ;
}
else {
table_padding = 64 - bytes_per_table_entry ;
bytes_per_table_entry = 64 ;
}
table_padding = table_padding / 4 ;
# define PAD_TABLE \
if ( table_padding ) { \
printf( "\t0," ) ; \
for ( i = 1 ; i < table_padding ; i++ ) \
printf( " 0," ) ; \
printf( "\n" ) ; \
} \
printf("#ifdef GLOBAL_TABLE_VALUES\n\n");
START_GLOBAL_TABLE(GLOBALS_TABLE, offset);
/* NOTE: the order in which the following statements occur *MUST* match */
/* the enumeration for the _{s,t,x,f,g,d}_TYPE constants above. */
/* NaNs and reserved operands */
if (do_s)
PR_SINGLE(S_NAN_HI)
if (do_t)
PR_DOUBLE(T_NAN_HI, NAN_LO)
if (do_x)
PR_QUAD(X_NAN_HI, NAN_LO, NAN_LO, NAN_LO)
if (do_f)
PR_SINGLE(0x00008000)
if (do_g)
PR_DOUBLE(0x00000000, 0x00008000)
if (do_d)
PR_DOUBLE(0x00000000, 0x00008000)
PAD_TABLE ;
/* POS ZERO */
if (do_s)
PR_SINGLE(0x00000000)
if (do_t)
PR_DOUBLE(0x00000000, 0x00000000)
if (do_x)
PR_QUAD(0x00000000, 0x00000000, 0x00000000, 0x00000000)
if (do_f)
PR_SINGLE(0x00000000)
if (do_g)
PR_DOUBLE(0x00000000, 0x00000000)
if (do_d)
PR_DOUBLE(0x00000000, 0x00000000)
PAD_TABLE ;
/* NEG ZERO */
if (do_s)
PR_SINGLE(0x80000000)
if (do_t)
PR_DOUBLE(0x80000000, 0x00000000)
if (do_x)
PR_QUAD(0x80000000, 0x00000000, 0x00000000, 0x00000000)
if (do_f)
PR_SINGLE(0x00000000)
if (do_g)
PR_DOUBLE(0x00000000, 0x00000000)
if (do_d)
PR_DOUBLE(0x00000000, 0x00000000)
PAD_TABLE ;
/* POS TINY */
if (do_s)
PR_SINGLE(0x00000001)
if (do_t)
PR_DOUBLE(0x00000000, 0x00000001)
if (do_x)
PR_QUAD(0x00000000, 0x00000000, 0x00000000, 0x00000001)
if (do_f)
PR_SINGLE(0x00000080)
if (do_g)
PR_DOUBLE(0x00000000, 0x00000010)
if (do_d)
PR_DOUBLE(0x00000000, 0x00000080)
PAD_TABLE ;
/* NEG TINY */
if (do_s)
PR_SINGLE(0x80000001)
if (do_t)
PR_DOUBLE(0x80000000, 0x00000001)
if (do_x)
PR_QUAD(0x80000000, 0x00000000, 0x00000000, 0x00000001)
if (do_f)
PR_SINGLE(0x00008080)
if (do_g)
PR_DOUBLE(0x00000000, 0x00008010)
if (do_d)
PR_DOUBLE(0x00000000, 0x00008080)
PAD_TABLE ;
/* POS HUGE */
if (do_s)
PR_SINGLE(0x7f7fffff)
if (do_t)
PR_DOUBLE(0x7fefffff, 0xffffffff)
if (do_x)
PR_QUAD(0x7ffeffff, 0xffffffff, 0xffffffff, 0xffffffff)
if (do_f)
PR_SINGLE(0xffff7fff)
if (do_g)
PR_DOUBLE(0xffffffff, 0xffff7fff)
if (do_d)
PR_DOUBLE(0xffffffff, 0xffff7fff)
PAD_TABLE ;
/* NEG HUGE */
if (do_s)
PR_SINGLE(0xff7fffff)
if (do_t)
PR_DOUBLE(0xffefffff, 0xffffffff)
if (do_x)
PR_QUAD(0xfffeffff, 0xffffffff, 0xffffffff, 0xffffffff)
if (do_f)
PR_SINGLE(0xffffffff)
if (do_g)
PR_DOUBLE(0xffffffff, 0xffffffff)
if (do_d)
PR_DOUBLE(0xffffffff, 0xffffffff)
PAD_TABLE ;
/* POS INFINITY */
if (do_s)
PR_SINGLE(0x7f800000)
if (do_t)
PR_DOUBLE(0x7ff00000, 0x00000000)
if (do_x)
PR_QUAD(0x7fff0000, 0x00000000, 0x00000000, 0x00000000)
if (do_f)
PR_SINGLE(0xffff7fff)
if (do_g)
PR_DOUBLE(0xffffffff, 0xffff7fff)
if (do_d)
PR_DOUBLE(0xffffffff, 0xffff7fff)
PAD_TABLE ;
/* NEG INFINITY */
if (do_s)
PR_SINGLE(0xff800000)
if (do_t)
PR_DOUBLE(0xfff00000, 0x00000000)
if (do_x)
PR_QUAD(0xffff0000, 0x00000000, 0x00000000, 0x00000000)
if (do_f)
PR_SINGLE(0xffffffff)
if (do_g)
PR_DOUBLE(0xffffffff, 0xffffffff)
if (do_d)
PR_DOUBLE(0xffffffff, 0xffffffff)
PAD_TABLE ;
/* POS ULP FACTOR */
if (do_s)
PR_SINGLE(0x34000000)
if (do_t)
PR_DOUBLE(0x3cb00000, 0x00000000)
if (do_x)
PR_QUAD(0x3f8f0000, 0x00000000, 0x00000000, 0x00000000)
if (do_f)
PR_SINGLE(0x00003500)
if (do_g)
PR_DOUBLE(0x00000000, 0x00003cd0)
if (do_d)
PR_DOUBLE(0x00000000, 0x00002500)
PAD_TABLE ;
/* NEG ULP FACTOR */
if (do_s)
PR_SINGLE(0xb4000000)
if (do_t)
PR_DOUBLE(0xbcb00000, 0x00000000)
if (do_x)
PR_QUAD(0xbf8f0000, 0x00000000, 0x00000000, 0x00000000)
if (do_f)
PR_SINGLE(0x0000b500)
if (do_g)
PR_DOUBLE(0x00000000, 0x0000bcd0)
if (do_d)
PR_DOUBLE(0x00000000, 0x0000a500)
PAD_TABLE ;
/* POS ONE */
if (do_s)
PR_SINGLE(0x3f800000)
if (do_t)
PR_DOUBLE(0x3ff00000, 0x00000000)
if (do_x)
PR_QUAD(0x3fff0000, 0x00000000, 0x00000000, 0x00000000)
if (do_f)
PR_SINGLE(0x00004080)
if (do_g)
PR_DOUBLE(0x00000000, 0x00004010)
if (do_d)
PR_DOUBLE(0x00000000, 0x00004080)
PAD_TABLE ;
/* NEG ONE */
if (do_s)
PR_SINGLE(0xbf800000)
if (do_t)
PR_DOUBLE(0xbff00000, 0x00000000)
if (do_x)
PR_QUAD(0xbfff0000, 0x00000000, 0x00000000, 0x00000000)
if (do_f)
PR_SINGLE(0x0000c080)
if (do_g)
PR_DOUBLE(0x00000000, 0x0000c010)
if (do_d)
PR_DOUBLE(0x00000000, 0x0000c080)
PAD_TABLE ;
END_TABLE;
printf("#else\n\n");
printf(" extern TABLE_UNION GLOBALS_TABLE[];\n");
printf("#endif\n\n");
/*
* Print out defines so that other routines can access the tables
* Specifically, for each generic value in the globals table
* generate a type independent symbolic constant (these are only used
* by dpml_error_codes.c).
*/
# define DEFINE_INDEX(n) printf("#define\t" STR(n) "_INDEX\t%i\n", PASTE_2(n, _INDEX))
DEFINE_INDEX(NAN);
DEFINE_INDEX(POS_ZERO);
DEFINE_INDEX(NEG_ZERO);
DEFINE_INDEX(POS_TINY);
DEFINE_INDEX(NEG_TINY);
DEFINE_INDEX(POS_HUGE);
DEFINE_INDEX(NEG_HUGE);
DEFINE_INDEX(POS_INFINITY);
DEFINE_INDEX(NEG_INFINITY);
DEFINE_INDEX(POS_ULP_FACTOR);
DEFINE_INDEX(NEG_ULP_FACTOR);
DEFINE_INDEX(POS_ONE);
DEFINE_INDEX(NEG_ONE);
printf("#define\tF_TYPE_ENUM\tPASTE_3(_, F_CHAR, _TYPE)\n");
if ( bytes_per_table_entry == 32 )
printf( "#define GLOBALS_OFFSET( t, n ) ( ( t << 3 ) + ( n << 5 ) )\n" ) ;
else
printf( "#define GLOBALS_OFFSET( t, n ) ( ( t << 3 ) + ( n << 6 ) )\n" ) ;
printf("#define\tGLOBAL(n)\t*((F_TYPE *)"
" ((char *) GLOBALS_TABLE + GLOBALS_OFFSET(F_TYPE_ENUM,n) ))\n");
printf("#define\tGLOBAL_ADDR(t,n)\t((void *)"
" ((char *) GLOBALS_TABLE + GLOBALS_OFFSET(t,n) ))\n");
# define DEFINE_VALUE(n) printf("#define\t" STR(n) \
"\tGLOBAL(" STR(n) "_INDEX)\n")
DEFINE_VALUE(NAN);
DEFINE_VALUE(POS_ZERO);
DEFINE_VALUE(NEG_ZERO);
DEFINE_VALUE(POS_TINY);
DEFINE_VALUE(NEG_TINY);
DEFINE_VALUE(POS_HUGE);
DEFINE_VALUE(NEG_HUGE);
DEFINE_VALUE(POS_INFINITY);
DEFINE_VALUE(NEG_INFINITY);
DEFINE_VALUE(POS_ULP_FACTOR);
DEFINE_VALUE(NEG_ULP_FACTOR);
DEFINE_VALUE(POS_ONE);
DEFINE_VALUE(NEG_ONE);
@end_divert
@eval my $tableText; \
my $outText = MphocEval( GetStream( "divertText" ) ); \
my $defineText = Egrep( "#define", $outText, \$tableText ); \
$outText = "$tableText\n\n$defineText"; \
my $headerText = GetHeaderText( STR(BUILD_FILE_NAME), \
"DPML global constants", __FILE__ ); \
print "$headerText\n\n$outText\n";
|