[svn r127] Updated the lphobos build scripts a little. Created a new rebuild profile.

Removed some potentially very long logging lines.
Added support for inner classes.
This commit is contained in:
Tomas Lindquist Olsen
2007-11-28 03:01:51 +01:00
parent 0665531549
commit 667b6339f3
9 changed files with 158 additions and 120 deletions

View File

@@ -131,12 +131,8 @@ void DtoResolveClass(ClassDeclaration* cd)
else
*ts->llvmType = structtype;
if (cd->isNested()) {
assert(0 && "nested classes not implemented");
}
else {
gIR->module->addTypeName(cd->mangle(), ts->llvmType->get());
}
// name the type
gIR->module->addTypeName(cd->mangle(), ts->llvmType->get());
// build interface info type
std::vector<const llvm::Type*> infoTypes;
@@ -231,8 +227,8 @@ void DtoDeclareClass(ClassDeclaration* cd)
gIR->classes.push_back(cd);
bool needs_definition = false;
if (cd->parent->isModule()) {
needs_definition = (cd->getModule() == gIR->dmodule);
if (cd->getModule() == gIR->dmodule) {
needs_definition = true;
}
// interface vtables are emitted by the class implementing them
@@ -319,7 +315,7 @@ void DtoDeclareClass(ClassDeclaration* cd)
DtoDeclareClassInfo(cd);
// typeinfo
if (cd->parent->isModule() && cd->getModule() == gIR->dmodule)
if (needs_definition)
cd->type->getTypeInfo(NULL);
}
@@ -520,8 +516,7 @@ void DtoDefineClass(ClassDeclaration* cd)
assert(cd->type->ty == Tclass);
TypeClass* ts = (TypeClass*)cd->type;
bool def = false;
if (cd->parent->isModule() && cd->getModule() == gIR->dmodule) {
if (cd->getModule() == gIR->dmodule) {
// interfaces don't have initializers
if (!cd->isInterfaceDeclaration()) {
cd->llvmInit->setInitializer(cd->llvmConstInit);
@@ -542,11 +537,10 @@ void DtoDefineClass(ClassDeclaration* cd)
irstruct->interfaceInfos->setInitializer(arrInit);
}
}
def = true;
}
// generate classinfo
if (def) DtoDefineClassInfo(cd);
// generate classinfo
DtoDefineClassInfo(cd);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -752,7 +746,7 @@ static llvm::Constant* build_offti_entry(VarDeclaration* vd)
llvm::Constant* c = isaConstant(vd->type->vtinfo->llvmValue);
const llvm::Type* tiTy = llvm::PointerType::get(Type::typeinfo->type->llvmType->get());
Logger::cout() << "tiTy = " << *tiTy << '\n';
//Logger::cout() << "tiTy = " << *tiTy << '\n';
types.push_back(tiTy);
inits.push_back(llvm::ConstantExpr::getBitCast(c, tiTy));

View File

@@ -60,7 +60,7 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const llvm::Type* thistype
std::vector<const llvm::Type*> paramvec;
if (retinptr) {
Logger::cout() << "returning through pointer parameter: " << *rettype << '\n';
//Logger::cout() << "returning through pointer parameter: " << *rettype << '\n';
paramvec.push_back(rettype);
}

View File

@@ -192,7 +192,7 @@ void IfStatement::toIR(IRState* p)
void ScopeStatement::toIR(IRState* p)
{
Logger::println("ScopeStatement::toIR(): %s", toChars());
Logger::println("ScopeStatement::toIR()");
LOG_SCOPE;
llvm::BasicBlock* oldend = p->scopeend();

View File

@@ -1264,7 +1264,7 @@ DValue* DotVarExp::toElem(IRState* p)
Type* t = DtoDType(type);
Type* e1type = DtoDType(e1->type);
Logger::print("e1type=%s\n", e1type->toChars());
//Logger::print("e1type=%s\n", e1type->toChars());
if (VarDeclaration* vd = var->isVarDeclaration()) {
llvm::Value* arrptr;
@@ -1282,13 +1282,13 @@ DValue* DotVarExp::toElem(IRState* p)
std::vector<unsigned> vdoffsets(1,0);
tc->sym->offsetToIndex(vd->type, vd->offset, vdoffsets);
llvm::Value* src = l->getRVal();
Logger::cout() << "src: " << *src << '\n';
//Logger::cout() << "src: " << *src << '\n';
arrptr = DtoGEP(src,vdoffsets,"tmp",p->scopebb());
}
else
assert(0);
Logger::cout() << "mem: " << *arrptr << '\n';
//Logger::cout() << "mem: " << *arrptr << '\n';
return new DVarValue(vd, arrptr, true);
}
else if (FuncDeclaration* fdecl = var->isFuncDeclaration())
@@ -1314,7 +1314,7 @@ DValue* DotVarExp::toElem(IRState* p)
llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
llvm::Value* vtblidx = llvm::ConstantInt::get(llvm::Type::Int32Ty, (size_t)fdecl->vtblIndex, false);
Logger::cout() << "vthis: " << *vthis << '\n';
//Logger::cout() << "vthis: " << *vthis << '\n';
funcval = DtoGEP(vthis, zero, zero, "tmp", p->scopebb());
funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb());
funcval = DtoGEP(funcval, zero, vtblidx, toChars(), p->scopebb());
@@ -1332,7 +1332,7 @@ DValue* DotVarExp::toElem(IRState* p)
return new DFuncValue(fdecl, funcval, vthis2);
}
else {
printf("unknown: %s\n", var->toChars());
printf("unsupported dotvarexp: %s\n", var->toChars());
}
assert(0);
@@ -1756,10 +1756,9 @@ DValue* NewExp::toElem(IRState* p)
Logger::print("NewExp::toElem: %s | %s\n", toChars(), type->toChars());
LOG_SCOPE;
assert(!thisexp);
assert(!newargs);
assert(!newargs && "arguments to new not yet supported");
assert(newtype);
assert(!allocator);
assert(!allocator && "custom allocators not yet supported");
Type* ntype = DtoDType(newtype);
@@ -1809,7 +1808,16 @@ DValue* NewExp::toElem(IRState* p)
if (ntype->ty == Tclass) {
// first apply the static initializer
DtoInitClass((TypeClass*)ntype, emem);
TypeClass* tc = (TypeClass*)ntype;
DtoInitClass(tc, emem);
// set the this var for nested classes
if (thisexp) {
DValue* thisval = thisexp->toElem(p);
size_t idx = 2;
idx += tc->sym->llvmIRStruct->interfaces.size();
DtoStore(thisval->getRVal(), DtoGEPi(emem,0,idx,"tmp"));
}
// then call constructor
if (arguments) {

View File

@@ -1,77 +1,2 @@
#profile=phobos
compiler=llvmdc
inifile=llvmdc.conf
exeext=
objext=bc
version=LLVM
noversion=DigitalMars
noversion=GNU
testversion=linux
testversion=Unix
version=Posix
testversion=Windows
testversion=Win32
testversion=Win64
testversion=X86
testversion=PPC
testversion=X86_64
testversion=PPC64
testversion=D_InlineAsm
testvestion=D_InlineAsm_X86
testversion=D_InlineAsm_PPC
testversion=D_InlineAsm_X86_64
testversion=D_InlineAsm_PPC64
testversion=LittleEndian
testversion=BigEndian
testversion=LLVM64
[compile]
cmd=llvmdc -version=Posix -c $i
flag=$i
incdir=-I$i
libdir=-L-L$i
optimize=-O5
version=-version=$i
[link]
oneatatime=yes
cmd=llvmdc $i -of$o
libdir=-L-L$i
lib=-L-l$i
flag=-L$i
[liblink]
safe=yes
oneatatime=yes
cmd=llvm-link -f -o=$o $i
libdir=
lib=
flag=
[postliblink]
cmd=
[shliblink]
shlibs=no
oneatatime=yes
cmd=llvm-link $i | llc -filetype=dynlib -f -o=$o
libdir=
lib=
flag=
[dyliblink]
dylibs=no
profile=phobos
profile=llvmdc-posix-internal

78
llvmdc-posix-internal Normal file
View File

@@ -0,0 +1,78 @@
# this profile is used to build the runtime and phobos
# don't use it for normal code or you will get linktime conflicts
compiler=llvmdc
inifile=llvmdc.conf
exeext=
objext=bc
version=LLVM
noversion=DigitalMars
noversion=GNU
testversion=linux
testversion=Unix
version=Posix
testversion=Windows
testversion=Win32
testversion=Win64
testversion=X86
testversion=PPC
testversion=X86_64
testversion=PPC64
testversion=D_InlineAsm
testvestion=D_InlineAsm_X86
testversion=D_InlineAsm_PPC
testversion=D_InlineAsm_X86_64
testversion=D_InlineAsm_PPC64
testversion=LittleEndian
testversion=BigEndian
testversion=LLVM64
[compile]
cmd=llvmdc -version=Posix -c $i
flag=$i
incdir=-I$i
libdir=-L-L$i
optimize=-O5
version=-version=$i
[link]
oneatatime=yes
cmd=llvmdc $i -of$o
libdir=-L-L$i
lib=-L-l$i
flag=-L$i
[liblink]
safe=yes
oneatatime=yes
cmd=llvm-link -f -o=$o $i
libdir=
lib=
flag=
[postliblink]
cmd=
[shliblink]
shlibs=no
oneatatime=yes
cmd=llvm-link $i | llc -filetype=dynlib -f -o=$o
libdir=
lib=
flag=
[dyliblink]
dylibs=no

View File

@@ -385,6 +385,7 @@ test/imag1.d
test/imports2.d
test/imports_1of2.d
test/imports_2of2.d
test/innerclass1.d
test/interface1.d
test/interface2.d
test/interface3.d

View File

@@ -5,60 +5,63 @@ mkdir -p obj
rm -f obj/*.bc
rm -f ../lib/*.bc
LLVMDCFLAGS="-c -odobj"
REBUILDFLAGS="-dc=llvmdc-posix-internal -c -oqobj"
echo "compiling contract runtime"
llvmdc internal/contract.d -c -of../lib/llvmdcore.bc -noruntime || exit 1
echo "compiling common runtime"
rebuild internal/arrays.d \
internal/mem.d \
-c -oqobj -dc=llvmdc-posix || exit 1
$REBUILDFLAGS || exit 1
echo "compiling module init backend"
llvm-as -f -o=obj/moduleinit_backend.bc internal/moduleinit_backend.ll || exit 1
llvm-link -f -o=../lib/llvmdcore.bc `ls obj/internal.*.bc` ../lib/llvmdcore.bc obj/moduleinit_backend.bc || exit 1
echo "compiling typeinfo 1"
rebuild typeinfos1.d -c -oqobj -dc=llvmdc-posix || exit 1
rebuild typeinfos1.d $REBUILDFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc `ls obj/typeinfo1.*.bc` ../lib/llvmdcore.bc || exit 1
echo "compiling typeinfo 2"
rebuild typeinfos2.d -c -oqobj -dc=llvmdc-posix || exit 1
rebuild typeinfos2.d $REBUILDFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc `ls obj/typeinfo2.*.bc` ../lib/llvmdcore.bc || exit 1
echo "compiling object/interface casting runtime support"
llvmdc internal/cast.d -c -odobj || exit 1
llvmdc internal/cast.d $LLVMDCFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc obj/cast.bc ../lib/llvmdcore.bc || exit 1
echo "compiling string foreach/switch runtime support"
llvmdc internal/aApply.d -c -odobj || exit 1
llvmdc internal/aApplyR.d -c -odobj || exit 1
llvmdc internal/switch.d -c -odobj || exit 1
llvmdc internal/aApply.d $LLVMDCFLAGS || exit 1
llvmdc internal/aApplyR.d $LLVMDCFLAGS || exit 1
llvmdc internal/switch.d $LLVMDCFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc obj/aApply.bc obj/aApplyR.bc obj/switch.bc ../lib/llvmdcore.bc || exit 1
echo "compiling array runtime support"
llvmdc internal/qsort2.d -c -odobj || exit 1
llvmdc internal/qsort2.d $LLVMDCFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc obj/qsort2.bc ../lib/llvmdcore.bc || exit 1
llvmdc internal/adi.d -c -odobj || exit 1
llvmdc internal/adi.d $LLVMDCFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc obj/adi.bc ../lib/llvmdcore.bc || exit 1
llvmdc internal/aaA.d -c -odobj || exit 1
llvmdc internal/aaA.d $LLVMDCFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc obj/aaA.bc ../lib/llvmdcore.bc || exit 1
echo "compiling object implementation"
llvmdc internal/objectimpl.d -c -odobj || exit 1
llvmdc internal/objectimpl.d $LLVMDCFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc obj/objectimpl.bc ../lib/llvmdcore.bc || exit 1
echo "compiling llvm runtime support"
rebuild llvmsupport.d -c -oqobj -dc=llvmdc-posix || exit 1
rebuild llvmsupport.d $REBUILDFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc `ls obj/llvm.*.bc` ../lib/llvmdcore.bc || exit 1
echo "compiling garbage collector"
llvmdc gc/gclinux.d -c -odobj || exit 1
llvmdc gc/gcstub.d -c -odobj -Igc || exit 1
llvmdc gc/gcbits.d -c -odobj -Igc || exit 1
llvmdc gc/gclinux.d $LLVMDCFLAGS || exit 1
llvmdc gc/gcstub.d $LLVMDCFLAGS -Igc || exit 1
llvmdc gc/gcbits.d $LLVMDCFLAGS -Igc || exit 1
llvm-link -f -o=../lib/llvmdcore.bc obj/gclinux.bc obj/gcstub.bc obj/gcbits.bc ../lib/llvmdcore.bc || exit 1
echo "compiling phobos"
rebuild phobos.d -c -oqobj -dc=llvmdc-posix || exit 1
rebuild phobos.d $REBUILDFLAGS || exit 1
llvm-link -f -o=../lib/llvmdcore.bc `ls obj/std.*.bc` ../lib/llvmdcore.bc || exit 1
echo "optimizing"

29
test/innerclass1.d Normal file
View File

@@ -0,0 +1,29 @@
module innerclass1;
class Outer
{
int i;
class Inner
{
int func()
{
return i;
}
}
}
void main()
{
Outer o = new Outer;
{
o.i = 42;
{
auto i = o.new Inner;
{
int x = i.func();
assert(x == 42);
}
}
}
printf("SUCCESS\n");
}