view gen/structs.h @ 94:61615fa85940 trunk

[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca"). Added support for array .sort and .reverse properties. Fixed some bugs with pointer arithmetic. Disabled some DMD AST optimizations that was messing things up, destroying valuable information. Added a KDevelop project file, this is what I use for coding LLVMDC now :) Other minor stuff.
author lindquist
date Mon, 12 Nov 2007 06:32:46 +0100
parents 058d3925950e
children 5071469303d4
line wrap: on
line source

#ifndef LLVMD_GEN_STRUCTS_H
#define LLVMD_GEN_STRUCTS_H

struct StructInitializer;
const llvm::Type* DtoStructType(Type* t);
llvm::Value* DtoStructZeroInit(llvm::Value* v);
llvm::Value* DtoStructCopy(llvm::Value* dst, llvm::Value* src);
llvm::Constant* DtoConstStructInitializer(StructInitializer* si);
llvm::Value* DtoIndexStruct(llvm::Value* ptr, StructDeclaration* sd, Type* t, unsigned os, std::vector<unsigned>& idxs);

struct DUnionField
{
    unsigned offset;
    size_t size;
    std::vector<const llvm::Type*> types;
    llvm::Constant* init;
    size_t initsize;

    DUnionField() {
        offset = 0;
        size = 0;
        init = NULL;
        initsize = 0;
    }
};

struct DUnionIdx
{
    unsigned idx,idxos;
    llvm::Constant* c;

    DUnionIdx()
    : idx(0), c(0) {}
    DUnionIdx(unsigned _idx, unsigned _idxos, llvm::Constant* _c)
    : idx(_idx), idxos(_idxos), c(_c) {}
    bool operator<(const DUnionIdx& i) const {
        return (idx < i.idx) || (idx == i.idx && idxos < i.idxos);
    }
};

class DUnion
{
    std::vector<DUnionField> fields;
public:
    DUnion();
    llvm::Constant* getConst(std::vector<DUnionIdx>& in);
};

#endif