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 *);
10 __inline_memcpy_chk (void *__dest
, const void *__src
, size_t __len
)
12 return __builtin___memcpy_chk (__dest
, __src
, __len
, __builtin_object_size (__dest
, 0));
15 typedef unsigned int hashval_t
;
16 typedef hashval_t (*htab_hash
) (const void *);
17 typedef int (*htab_eq
) (const void *, const void *);
18 typedef void (*htab_del
) (void *);
19 typedef int (*htab_trav
) (void **, void *);
20 typedef void *(*htab_alloc
) (size_t, size_t);
21 typedef void (*htab_free
) (void *);
23 typedef void *(*htab_alloc_with_arg
) (void *, size_t, size_t);
24 typedef void (*htab_free_with_arg
) (void *, void *);
33 unsigned int searches
;
34 unsigned int collisions
;
38 htab_alloc_with_arg alloc_with_arg_f
;
39 htab_free_with_arg free_with_arg_f
;
40 unsigned int size_prime_index
;
43 typedef struct htab
*htab_t
;
44 enum insert_option
{NO_INSERT
, INSERT
};
45 extern void * htab_find (htab_t
, const void *);
46 extern void ** htab_find_slot (htab_t
, const void *, enum insert_option
);
48 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
};
50 static const char *const mode_class_names
[MAX_MODE_CLASS
] =
52 "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"
56 struct mode_data
*next
;
60 unsigned int precision
;
61 unsigned int bytesize
;
62 unsigned int ncomponents
;
63 unsigned int alignment
;
66 struct mode_data
*component
;
67 struct mode_data
*wider
;
68 struct mode_data
*wider_2x
;
70 struct mode_data
*contained
;
72 struct mode_data
*next_cont
;
81 static struct mode_data
*modes
[MAX_MODE_CLASS
];
82 static unsigned int n_modes
[MAX_MODE_CLASS
];
83 static struct mode_data
*void_mode
;
85 static const struct mode_data blank_mode
= {
86 0, "<unknown>", MAX_MODE_CLASS
,
89 "<unknown>", 0, 0, 0, 0
92 static htab_t modes_by_name
;
94 static __inline__
struct mode_data
*
95 find_mode (const char *name
)
100 return (struct mode_data
*) htab_find (modes_by_name
, &key
);
103 static struct mode_data
*
104 new_mode (enum mode_class cl
, const char *name
,
105 const char *file
, unsigned int line
)
108 static unsigned int count
= 0;
110 m
= find_mode (name
);
113 error ("%s:%d: duplicate definition of mode \"%s\"",
114 trim_filename (file
), line
, name
);
115 error ("%s:%d: previous definition here", m
->file
, m
->line
);
119 m
= ((struct mode_data
*) xmalloc (sizeof (struct mode_data
)));
120 ((__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
)));
124 m
->file
= trim_filename (file
);
126 m
->counter
= count
++;
132 *htab_find_slot (modes_by_name
, m
, INSERT
) = m
;
138 make_int_mode (const char *name
,
139 unsigned int precision
, unsigned int bytesize
,
140 const char *file
, unsigned int line
)
142 struct mode_data
*m
= new_mode (MODE_INT
, name
, file
, line
);
143 m
->bytesize
= bytesize
;
144 m
->precision
= precision
;
150 make_int_mode ("HI", -1U, 2, "../../work/gcc/machmode.def", 182);
154 main (int argc
, char **argv
)