view gen/abi.h @ 1004:45ed9e125a00

Remove initialization of padding of reals, ireals and creals. According to the spec and C ABIs, the contents of padding is undefined. This was breaking dstress creal_01,02,03,07,08,09 and 20 on x86-64. The code was apparently added to fix creal_13,14 and 15, which explicitly compare padding and assert if it's different. I'd argue those tests are broken. (Also, on x86-64 they *also* fail) The tests this fixes, on the other hand, are basic arithmetic.
author Frits van Bommel <fvbommel wxs.nl>
date Fri, 27 Feb 2009 19:41:25 +0100
parents 420ef073448d
children e8c6dbcd33d1
line wrap: on
line source

#ifndef __LDC_GEN_ABI_H__
#define __LDC_GEN_ABI_H__

#include <vector>

struct Type;
namespace llvm
{
    class Type;
    class Value;
}

// return rewrite rule
struct ABIRetRewrite
{
    // get original value from rewritten one
    virtual LLValue* get(LLValue* v) = 0;

    // rewrite original value
    virtual LLValue* put(LLValue* v) = 0;

    // returns target type of this rewrite
    virtual const LLType* type(const LLType* t) = 0;

    // test if rewrite applies
    virtual bool test(TypeFunction* tf) = 0;
};


// interface called by codegen
struct TargetABI
{
    static TargetABI* getTarget();

    TargetABI();

    const llvm::Type* getRetType(TypeFunction* tf, const llvm::Type* t);
    llvm::Value* getRet(TypeFunction* tf, llvm::Value* v);
    llvm::Value* putRet(TypeFunction* tf, llvm::Value* v);

    virtual bool returnInArg(Type* t) = 0;
    virtual bool passByRef(Type* t) = 0;

protected:
    std::vector<ABIRetRewrite*> retOps;
    ABIRetRewrite* findRetRewrite(TypeFunction* tf);
};

#endif