1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 typedef long unsigned int size_t;
4 typedef long int intmax_t;
5 typedef long unsigned int uintmax_t;
6 extern void *xmalloc (size_t) __attribute__ ((__malloc__
));
7 extern const char *trim_filename (const char *);
8 extern void error (const char *, ...);
10 static __inline
void *
11 __inline_memcpy_chk (void *__dest
, const void *__src
, size_t __len
)
13 return __builtin___memcpy_chk (__dest
, __src
, __len
, __builtin_object_size (__dest
, 0));
16 typedef unsigned int hashval_t
;
17 typedef hashval_t (*htab_hash
) (const void *);
18 typedef int (*htab_eq
) (const void *, const void *);
19 typedef void (*htab_del
) (void *);
20 typedef int (*htab_trav
) (void **, void *);
21 typedef void *(*htab_alloc
) (size_t, size_t);
22 typedef void (*htab_free
) (void *);
24 typedef void *(*htab_alloc_with_arg
) (void *, size_t, size_t);
25 typedef void (*htab_free_with_arg
) (void *, void *);
34 unsigned int searches
;
35 unsigned int collisions
;
39 htab_alloc_with_arg alloc_with_arg_f
;
40 htab_free_with_arg free_with_arg_f
;
41 unsigned int size_prime_index
;
44 typedef struct htab
*htab_t
;
45 enum insert_option
{NO_INSERT
, INSERT
};
46 extern void * htab_find (htab_t
, const void *);
47 extern void ** htab_find_slot (htab_t
, const void *, enum insert_option
);
49 enum mode_class
{ MODE_RANDOM
, MODE_CC
, MODE_INT
, MODE_PARTIAL_INT
, MODE_FRACT
, MODE_UFRACT
, MODE_ACCUM
, MODE_UACCUM
, MODE_FLOAT
, MODE_DECIMAL_FLOAT
, MODE_COMPLEX_INT
, MODE_COMPLEX_FLOAT
, MODE_VECTOR_INT
, MODE_VECTOR_FRACT
, MODE_VECTOR_UFRACT
, MODE_VECTOR_ACCUM
, MODE_VECTOR_UACCUM
, MODE_VECTOR_FLOAT
, MAX_MODE_CLASS
};
51 static const char *const mode_class_names
[MAX_MODE_CLASS
] =
53 "MODE_RANDOM", "MODE_CC", "MODE_INT", "MODE_PARTIAL_INT", "MODE_FRACT", "MODE_UFRACT", "MODE_ACCUM", "MODE_UACCUM", "MODE_FLOAT", "MODE_DECIMAL_FLOAT", "MODE_COMPLEX_INT", "MODE_COMPLEX_FLOAT", "MODE_VECTOR_INT", "MODE_VECTOR_FRACT", "MODE_VECTOR_UFRACT", "MODE_VECTOR_ACCUM", "MODE_VECTOR_UACCUM", "MODE_VECTOR_FLOAT"
57 struct mode_data
*next
;
61 unsigned int precision
;
62 unsigned int bytesize
;
63 unsigned int ncomponents
;
64 unsigned int alignment
;
67 struct mode_data
*component
;
68 struct mode_data
*wider
;
69 struct mode_data
*wider_2x
;
71 struct mode_data
*contained
;
73 struct mode_data
*next_cont
;
82 static struct mode_data
*modes
[MAX_MODE_CLASS
];
83 static unsigned int n_modes
[MAX_MODE_CLASS
];
84 static struct mode_data
*void_mode
;
86 static const struct mode_data blank_mode
= {
87 0, "<unknown>", MAX_MODE_CLASS
,
90 "<unknown>", 0, 0, 0, 0
93 static htab_t modes_by_name
;
95 static __inline__
struct mode_data
*
96 find_mode (const char *name
)
101 return (struct mode_data
*) htab_find (modes_by_name
, &key
);
104 static struct mode_data
*
105 new_mode (enum mode_class cl
, const char *name
,
106 const char *file
, unsigned int line
)
109 static unsigned int count
= 0;
111 m
= find_mode (name
);
114 error ("%s:%d: duplicate definition of mode \"%s\"",
115 trim_filename (file
), line
, name
);
116 error ("%s:%d: previous definition here", m
->file
, m
->line
);
120 m
= ((struct mode_data
*) xmalloc (sizeof (struct mode_data
)));
121 ((__builtin_object_size (m
, 0) != (size_t) -1) ? __builtin___memcpy_chk (m
, &blank_mode
, sizeof (struct mode_data
), __builtin_object_size (m
, 0)) : __inline_memcpy_chk (m
, &blank_mode
, sizeof (struct mode_data
)));
125 m
->file
= trim_filename (file
);
127 m
->counter
= count
++;
133 *htab_find_slot (modes_by_name
, m
, INSERT
) = m
;
139 make_int_mode (const char *name
,
140 unsigned int precision
, unsigned int bytesize
,
141 const char *file
, unsigned int line
)
143 struct mode_data
*m
= new_mode (MODE_INT
, name
, file
, line
);
144 m
->bytesize
= bytesize
;
145 m
->precision
= precision
;
151 make_int_mode ("HI", -1U, 2, "../../work/gcc/machmode.def", 182);
155 main (int argc
, char **argv
)