+ (tp->type_op != type_enumeration) && (tp->type_op != type_method)) {
+ if (tp->type_op == type_primitive)
+ tp->size = size;
+ else {
+ /* argh: we must allow to set negative values as "invalid size" */
+ tp->size = (size >= 0) ? (size + 7) & ~7 : size;
+ assert(tp->size == size && "setting a bit size is NOT allowed for this type");
+ }
+ }
+}
+
+void
+set_type_size_bytes(type *tp, int size) {
+ set_type_size_bits(tp, 8*size);
+}
+
+int get_type_alignment_bytes(type *tp) {
+ int align = get_type_alignment_bits(tp);
+
+ return align < 0 ? align : (align + 7) >> 3;
+}
+
+int get_type_alignment_bits(type *tp) {
+ int align = 8;
+
+ if (tp->align > 0)
+ return tp->align;
+
+ /* alignment NOT set calculate it "on demand" */
+ if (tp->mode)
+ align = get_mode_size_bits(tp->mode);
+ else if (is_array_type(tp))
+ align = get_type_alignment_bits(get_array_element_type(tp));
+ else if (is_compound_type(tp)) {
+ int i, n = get_compound_n_members(tp);
+
+ align = 0;
+ for (i = 0; i < n; ++i) {
+ type *t = get_entity_type(get_compound_member(tp, i));
+ int a = get_type_alignment_bits(t);
+
+ if (a > align)
+ align = a;
+ }
+ }
+ else if (is_method_type(tp))
+ align = 0;
+
+ /* write back */
+ tp->align = align;
+
+ return align;