static type_t *add_modifiers(type_t *type, decl_modifiers_t modifiers) { if (is_typeref(type) || !is_type_function(type)) { return type; } if ((type->function.modifiers & modifiers) == modifiers) return type; type_t* new_type = duplicate_type(type); new_type->function.modifiers |= modifiers; return identify_new_type(new_type); }
static type_t *change_calling_convention(type_t *type, cc_kind_t cconv) { if (is_typeref(type) || !is_type_function(type)) { return type; } if (type->function.calling_convention == cconv) return type; type_t* new_type = duplicate_type(type); new_type->function.calling_convention = cconv; return identify_new_type(new_type); }
static ir_tarval *fold_call_builtin(call_expression_t const *const call) { expression_t const *const function = call->function; assert(function->kind == EXPR_REFERENCE); reference_expression_t const *const ref = &function->reference; assert(ref->entity->kind == ENTITY_FUNCTION); type_t *expr_type = skip_typeref(ref->base.type); assert(is_type_pointer(expr_type)); type_t *function_type = skip_typeref(expr_type->pointer.points_to); assert(is_type_function(function_type)); switch (ref->entity->function.btk) { case BUILTIN_INF: return fold_builtin_inf(function_type); case BUILTIN_NAN: return fold_builtin_nan(call, function_type); default: panic("builtin is no constant"); } }
bool is_type_object(const type_t *type) { return !is_type_function(type) && !is_type_incomplete(type); }