view ir/irvar.cpp @ 1351:8d501abecd24

Initial (but disabled) fix for ticket #294 , the actual part that fixes the bug is in a #if 0 block as I'm afraid it will cause regressions. I'm most likely not going to be around tonight, and maybe not tomorrow as well, so I'm pushing it in case someone wants to run some serious testing/investigate the problem noted in llvmhelpers.cpp : realignOffset .
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Thu, 14 May 2009 17:20:17 +0200
parents 0c03ba6f7c24
children 8d086d552909
line wrap: on
line source

#include "gen/llvm.h"
#include "declaration.h"
#include "ir/irvar.h"


//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

IrVar::IrVar(VarDeclaration* var)
{
    V = var;
    value = NULL;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

IrGlobal::IrGlobal(VarDeclaration* v): IrVar(v),
    type(llvm::OpaqueType::get())
{
    constInit = NULL;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

IrLocal::IrLocal(VarDeclaration* v) : IrVar(v)
{
    nestedIndex = -1;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

IrField::IrField(VarDeclaration* v) : IrVar(v)
{
    assert(V->ir.irField == NULL && "field for this variable already exists");
    V->ir.irField = this;

    if (v->aggrIndex)
    {
        index = v->aggrIndex;
        unionOffset = 0;
    }
    else
    {
        index = 0;
        unionOffset = v->offset;
    }
    constInit = NULL;
}

extern LLConstant* get_default_initializer(
    VarDeclaration* vd,
    Initializer* init);

llvm::Constant * IrField::getDefaultInit()
{
    if (constInit)
        return constInit;
    constInit = get_default_initializer(V, V->init);
    return constInit;
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////