return;
resize_to = ceil_po2(size);
-
- if (resize_to < 4)
- resize_to = 4;
+ resize_to = MAX(resize_to, 4);
resize(self, resize_to);
}
*/
static inline void init_size(HashSet *self, size_t initial_size)
{
- if (initial_size < 4)
- initial_size = 4;
+ initial_size = MAX(initial_size, 4);
self->entries = Alloc(initial_size);
SetRangeEmpty(self->entries, initial_size);
#define endof(x) ((x) + lengthof(x))
+#undef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
#endif
return idx_class;
expression_classification_t const ref_addr = is_object_with_constant_address(array_access->array_ref);
expression_classification_t const ref_ptr = is_constant_pointer(array_access->array_ref);
- return ref_addr > ref_ptr ? ref_addr : ref_ptr;
+ return MAX(ref_addr, ref_ptr);
}
case EXPR_UNARY_DEREFERENCE:
{
if (architecture_modulo_shift == 0)
return 0;
- if (type_size < architecture_modulo_shift)
- return architecture_modulo_shift;
- return type_size;
+ return MAX(type_size, architecture_modulo_shift);
}
static ir_mode *init_atomic_ir_mode(atomic_type_kind_t kind)
break;
case ENTITY_STRUCT:
case ENTITY_UNION:
- if (alignment > (int)entity->compound.alignment) {
- entity->compound.alignment = alignment;
- }
+ entity->compound.alignment = MAX(entity->compound.alignment, (il_alignment_t)alignment);
break;
default:
t = c->condition;
int const nt = internal_check_printf_format(t, arg, spec);
int const nf = internal_check_printf_format(c->false_expression, arg, spec);
- return nt > nf ? nt : nf;
+ return MAX(nt, nf);
}
if (fmt_expr->kind != EXPR_STRING_LITERAL)
#include <libfirm/be.h>
#include <libfirm/statev.h>
+#include "adt/util.h"
#include "ast_t.h"
#include "preprocessor.h"
#include "token_t.h"
{
if (architecture_modulo_shift == 0)
return 0;
- if (type_size < architecture_modulo_shift)
- return architecture_modulo_shift;
- return type_size;
+ return MAX(type_size, architecture_modulo_shift);
}
static bool is_ia32_cpu(const char *architecture)
type_t *first_type = first->type;
first_type = skip_typeref(first_type);
if (is_type_array(first_type)) {
- size_t index = first->v.index;
- if (index > path->max_index)
- path->max_index = index;
+ path->max_index = MAX(path->max_index, first->v.index);
}
/* append to initializers list */
case TYPE_ARRAY:
return get_type_alignment(type->array.element_type);
case TYPE_TYPEDEF: {
- il_alignment_t alignment
- = get_type_alignment(type->typedeft.typedefe->type);
- if (type->typedeft.typedefe->alignment > alignment)
- alignment = type->typedeft.typedefe->alignment;
-
- return alignment;
+ il_alignment_t const alignment = get_type_alignment(type->typedeft.typedefe->type);
+ return MAX(alignment, type->typedeft.typedefe->alignment);
}
case TYPE_TYPEOF:
return get_type_alignment(type->typeoft.typeof_type);
type_t *const base_type = skip_typeref(member->declaration.type);
il_alignment_t base_alignment = get_type_alignment_compound(base_type);
il_alignment_t alignment_mask = base_alignment-1;
- if (base_alignment > alignment)
- alignment = base_alignment;
+ alignment = MAX(alignment, base_alignment);
size_t bit_size = member->compound_member.bit_size;
if (!packed) {
}
il_alignment_t m_alignment = get_type_alignment_compound(m_type);
- if (m_alignment > alignment)
- alignment = m_alignment;
+ alignment = MAX(alignment, m_alignment);
if (!compound->packed) {
il_size_t const new_offset = round_up2(offset, m_alignment);
entry->compound_member.offset = 0;
il_size_t m_size = get_type_size(m_type);
- if (m_size > size)
- size = m_size;
+ size = MAX(size, m_size);
il_alignment_t m_alignment = get_type_alignment_compound(m_type);
- if (m_alignment > alignment)
- alignment = m_alignment;
+ alignment = MAX(alignment, m_alignment);
}
size = round_up2(size, alignment);