comparison ir/irtypefunction.cpp @ 1364:46f6365a50d7

Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P Added -v-cg switch, which right now just prints "codegen: module.name (module/name.d)" to stdout, this can really help figuring out where, in some complex build command, things go wrong.
author Tomas Lindquist Olsen <tomas.l.olsen gmail com>
date Sat, 16 May 2009 18:19:52 +0200
parents
children 755abafbf25d
comparison
equal deleted inserted replaced
1363:b7c8506e1eed 1364:46f6365a50d7
1 #include "llvm/DerivedTypes.h"
2 #include "mtype.h"
3
4 #include "gen/irstate.h"
5 #include "gen/tollvm.h"
6 #include "gen/functions.h"
7
8 #include "ir/irtypefunction.h"
9
10 IrTypeFunction::IrTypeFunction(Type * dt)
11 : IrType(dt, llvm::OpaqueType::get())
12 {
13 irfty = NULL;
14 }
15
16 const llvm::Type * IrTypeFunction::buildType()
17 {
18 const llvm::Type* T;
19 TypeFunction* tf = (TypeFunction*)dtype;
20 if (tf->funcdecl)
21 T = DtoFunctionType(tf->funcdecl);
22 else
23 T = DtoFunctionType(tf,NULL,NULL);
24
25 llvm::cast<llvm::OpaqueType>(pa.get())->refineAbstractTypeTo(T);
26 return pa.get();
27 }
28
29 //////////////////////////////////////////////////////////////////////////////
30
31 IrTypeDelegate::IrTypeDelegate(Type * dt)
32 : IrType(dt, llvm::OpaqueType::get())
33 {
34 }
35
36 const llvm::Type * IrTypeDelegate::buildType()
37 {
38 assert(dtype->ty == Tdelegate);
39 const LLType* i8ptr = getVoidPtrType();
40 const LLType* func = DtoFunctionType(dtype->nextOf(), NULL, Type::tvoid->pointerTo());
41 const LLType* funcptr = getPtrToType(func);
42 const LLStructType* dgtype = LLStructType::get(i8ptr, funcptr, NULL);
43 gIR->module->addTypeName(dtype->toChars(), dgtype);
44
45 llvm::cast<llvm::OpaqueType>(pa.get())->refineAbstractTypeTo(dgtype);
46 return pa.get();
47 }