const out_val *out_aalloct(out_ctx *octx, type *ty) { return out_aalloc(octx, type_size(ty, NULL), type_align(ty, NULL), ty); }
void decl_size_align_inc_bitfield(decl *d, unsigned *const sz, unsigned *const align) { type *ty = decl_type_for_bitfield(d); *sz = type_size(ty, NULL); *align = type_align(ty, NULL); }
static unsigned decl_align1(decl *d) { unsigned al = 0; if(!type_is(d->ref, type_func) && d->bits.var.align.resolved) al = d->bits.var.align.resolved; return al ? al : type_align(d->ref, &d->where); }
unsigned type_align(type *r, const where *from) { struct_union_enum_st *sue; type *test; attribute *align; align = type_attr_present(r, attr_aligned); if(align){ if(align->bits.align){ consty k; const_fold(align->bits.align, &k); assert(k.type == CONST_NUM && K_INTEGRAL(k.bits.num)); return k.bits.num.val.i; } return platform_align_max(); } if((sue = type_is_s_or_u(r))) /* safe - can't have an instance without a ->sue */ return sue->align; if(type_is(r, type_ptr) || type_is(r, type_block)) { return platform_word_size(); } if((test = type_is(r, type_btype))) return btype_align(test->bits.type, from); if((test = type_is(r, type_array))) return type_align(test->ref, from); return 1; }