#include <assert.h>
#include <string.h>
#include <stdbool.h>
+#include <limits.h>
#include <libfirm/firm.h>
#include <libfirm/adt/obst.h>
*/
static ir_type *create_atomic_type(const atomic_type_t *type)
{
- dbg_info *dbgi = get_dbg_info(&type->base.source_position);
- atomic_type_kind_t kind = type->akind;
- ir_mode *mode = _atomic_modes[kind];
- ident *id = get_mode_ident(mode);
- ir_type *irtype = new_d_type_primitive(id, mode, dbgi);
+ atomic_type_kind_t kind = type->akind;
+ ir_mode *mode = _atomic_modes[kind];
+ ident *id = get_mode_ident(mode);
+ ir_type *irtype = new_type_primitive(id, mode);
set_type_alignment_bytes(irtype, type->base.alignment);
*/
static ir_type *create_complex_type(const complex_type_t *type)
{
- dbg_info *dbgi = get_dbg_info(&type->base.source_position);
- atomic_type_kind_t kind = type->akind;
- ir_mode *mode = _atomic_modes[kind];
- ident *id = get_mode_ident(mode);
+ atomic_type_kind_t kind = type->akind;
+ ir_mode *mode = _atomic_modes[kind];
+ ident *id = get_mode_ident(mode);
(void) id;
- (void) dbgi;
/* FIXME: finish the array */
return NULL;
*/
static ir_type *create_imaginary_type(const imaginary_type_t *type)
{
- dbg_info *dbgi = get_dbg_info(&type->base.source_position);
atomic_type_kind_t kind = type->akind;
ir_mode *mode = _atomic_modes[kind];
ident *id = get_mode_ident(mode);
- ir_type *irtype = new_d_type_primitive(id, mode, dbgi);
+ ir_type *irtype = new_type_primitive(id, mode);
set_type_alignment_bytes(irtype, type->base.alignment);
ident *id = id_unique("functiontype.%u");
int n_parameters = count_parameters(function_type);
int n_results = return_type == type_void ? 0 : 1;
- dbg_info *dbgi = get_dbg_info(&function_type->base.source_position);
- ir_type *irtype = new_d_type_method(id, n_parameters, n_results, dbgi);
+ ir_type *irtype = new_type_method(id, n_parameters, n_results);
if (return_type != type_void) {
ir_type *restype = get_ir_type(return_type);
case CC_THISCALL:
/* Hmm, leave default, not accepted by the parser yet. */
- warningf(&function_type->base.source_position, "THISCALL calling convention not supported yet");
break;
}
return irtype;
{
type_t *points_to = type->points_to;
ir_type *ir_points_to = get_ir_type_incomplete(points_to);
- dbg_info *dbgi = get_dbg_info(&type->base.source_position);
- ir_type *ir_type = new_d_type_pointer(id_unique("pointer.%u"),
- ir_points_to, mode_P_data, dbgi);
+ ir_type *ir_type = new_type_pointer(id_unique("pointer.%u"),
+ ir_points_to, mode_P_data);
return ir_type;
}
ir_type *ir_element_type = get_ir_type(element_type);
ident *id = id_unique("array.%u");
- dbg_info *dbgi = get_dbg_info(&type->base.source_position);
- ir_type *ir_type = new_d_type_array(id, 1, ir_element_type, dbgi);
+ ir_type *ir_type = new_type_array(id, 1, ir_element_type);
const int align = get_type_alignment_bytes(ir_element_type);
set_type_alignment_bytes(ir_type, align);
id = id_unique("__anonymous_struct.%u");
}
}
- dbg_info *dbgi = get_dbg_info(&type->base.source_position);
+ dbg_info *dbgi = get_dbg_info(&declaration->source_position);
if (is_union) {
irtype = new_d_type_union(id, dbgi);
continue;
}
if (l->last_case >= l->first_case)
- num_cases += l->last_case - l->first_case;
+ num_cases += l->last_case - l->first_case + 1;
if (l->last_case > def_nr)
def_nr = l->last_case;
}
- if (def_nr + 1 < 0) {
- /* Bad: an overflow occurred, we cannot be sure that the
- * maximum + 1 is a free number. Scan the values a second
- * time to find a free number.
- */
+ if (def_nr == INT_MAX) {
+ /* Bad: an overflow will occurr, we cannot be sure that the
+ * maximum + 1 is a free number. Scan the values a second
+ * time to find a free number.
+ */
unsigned char *bits = xmalloc((num_cases + 7) >> 3);
- unsigned long i;
memset(bits, 0, (num_cases + 7) >> 3);
for (case_label_statement_t *l = statement->first_case; l != NULL; l = l->next) {
/* default case */
continue;
}
- for (long cns = l->first_case; cns <= l->last_case; ++cns) {
- if (cns >= 0 && (unsigned long)cns < num_cases)
+ unsigned long start = l->first_case > 0 ? (unsigned long)l->first_case : 0;
+ if (start < num_cases && l->last_case >= 0) {
+ unsigned long end = (unsigned long)l->last_case < num_cases ?
+ (unsigned long)l->last_case : num_cases - 1;
+ for (unsigned long cns = start; cns <= end; ++cns) {
bits[cns >> 3] |= (1 << (cns & 7));
+ }
}
}
/* We look at the first num_cases constants:
* one, or they are non densed, so we will find one free
* there...
*/
+ unsigned long i;
for (i = 0; i < num_cases; ++i)
- if ((bits[i >> 3] & (i & 7)) == 0)
+ if ((bits[i >> 3] & (1 << (i & 7))) == 0)
break;
free(bits);