Example #1
0
void AlignIt( TYPEPTR typ )
{
#if ( _CPU == 8086 ) || ( _CPU == 386 )
    if( OptSize == 0 ) {        /* optimize for time */
        DGAlign( GetTypeAlignment( typ ) );
    }
#else
    DGAlign( max( 4, GetTypeAlignment( typ ) ) );
#endif
}
Example #2
0
void Target::init()
{
    ptrsize = GetPointerSize();
    realsize = GetTypeAllocSize(Type::basic[Tfloat80]);
    realpad = realsize - GetTypeStoreSize(Type::basic[Tfloat80]);
    realalignsize = GetTypeAlignment(Type::basic[Tfloat80]);
}
Example #3
0
static cmp_type CompatibleType( TYPEPTR typ1, TYPEPTR typ2, bool assignment, bool null_ptr  )
{
    cmp_type         ret_val;
    cmp_type         ret_pq;
    type_modifiers   typ1_flags, typ2_flags;
    int              ptr_indir_level;

    ptr_indir_level = 0;
    typ1_flags = FLAG_NONE;
    typ2_flags = FLAG_NONE;
    ret_pq = OK;
    typ1 = SkipTypeFluff( typ1 ); // skip typedefs go into enums base
    typ2 = SkipTypeFluff( typ2 );
    if( typ1->decl_type == TYPE_POINTER && typ2->decl_type == TYPE_POINTER ) {
        // top level pointer
        typ1_flags = typ1->u.p.decl_flags;
        typ2_flags = typ2->u.p.decl_flags;
        // Special dispensation: assigning null pointer constant is allowed even
        // when the pointer size doesn't match. Required for MS compatibility.
        if( assignment && !null_ptr ) {
            type_modifiers  subnot;

            subnot = SUBNOT( typ1_flags, typ2_flags, MASK_QUALIFIERS );
            if( subnot ) {  // allow void * =  unaligned *
                if( subnot & (MASK_QUALIFIERS & ~FLAG_UNALIGNED) ) {
                    ret_pq = PQ;
                } else if( subnot & FLAG_UNALIGNED) {
                    align_type align1;

                    align1 = GetTypeAlignment( typ1->object );
                    if( align1 > 1 ) {
                        ret_pq = PQ;
                    }
                }
            }
            if( (typ1_flags & MASK_ALL_MEM_MODELS) != (typ2_flags & MASK_ALL_MEM_MODELS) ) {
                target_size size1, size2;

                size1 = TypeSize( typ1 );
                size2 = TypeSize( typ2 );
                if( size1 < size2 ) {
                   ret_pq = PT;
                } else if( size1 > size2 ) {
                    ret_pq = PX;
                }
            }
        }
        typ1 = typ1->object;
        typ2 = typ2->object;
        ++ptr_indir_level;
    }
    ret_val = DoCompatibleType( typ1, typ2, ptr_indir_level );
    if( ret_val == OK ) {
        ret_val = ret_pq;
    }
    return( ret_val );
}
Example #4
0
unsigned Target::alignsize (Type* type)
{
    assert (type->isTypeBasic());
    if (type->ty == Tvoid) return 1;
    return GetTypeAlignment(type);
}