Changeset 1149:5ebe8224988b
- Timestamp:
- 03/27/09 18:17:04
(3 years ago)
- Author:
- Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
- branch:
- default
- Message:
Fixed problems introduced by previous commits that prevented Tango from compiling.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1148 |
r1149 |
|
| 146 | 146 | cd->ir.irStruct = irstruct; |
|---|
| 147 | 147 | |
|---|
| | 148 | // create the type |
|---|
| | 149 | const LLType* t = LLArrayType::get(getVoidPtrType(), cd->vtbl.dim); |
|---|
| | 150 | assert(!ts->ir.type); |
|---|
| | 151 | ts->ir.type = new LLPATypeHolder(getPtrToType(t)); |
|---|
| | 152 | |
|---|
| | 153 | // ... and ClassInfo |
|---|
| | 154 | std::string varname("_D"); |
|---|
| | 155 | varname.append(cd->mangle()); |
|---|
| | 156 | varname.append("11__InterfaceZ"); |
|---|
| | 157 | |
|---|
| | 158 | // create global |
|---|
| | 159 | irstruct->classInfo = new llvm::GlobalVariable(irstruct->classInfoOpaque.get(), false, DtoLinkage(cd), NULL, varname, gIR->module); |
|---|
| | 160 | |
|---|
| 148 | 161 | // handle base interfaces |
|---|
| 149 | 162 | if (cd->baseclasses.dim) |
|---|
| … | … | |
| 168 | 181 | } |
|---|
| 169 | 182 | } |
|---|
| 170 | | |
|---|
| 171 | | // create the type |
|---|
| 172 | | const LLType* t = LLArrayType::get(getVoidPtrType(), cd->vtbl.dim); |
|---|
| 173 | | assert(!ts->ir.type); |
|---|
| 174 | | ts->ir.type = new LLPATypeHolder(getPtrToType(t)); |
|---|
| 175 | 183 | |
|---|
| 176 | 184 | // request declaration |
|---|
| … | … | |
| 239 | 247 | |
|---|
| 240 | 248 | // ... and initZ |
|---|
| 241 | | std::string initname("_D"); |
|---|
| 242 | | initname.append(cd->mangle()); |
|---|
| 243 | | initname.append("6__initZ"); |
|---|
| 244 | | irstruct->init = new llvm::GlobalVariable(irstruct->initOpaque.get(), true, _linkage, NULL, initname, gIR->module); |
|---|
| | 249 | varname = "_D"; |
|---|
| | 250 | varname.append(cd->mangle()); |
|---|
| | 251 | varname.append("6__initZ"); |
|---|
| | 252 | irstruct->init = new llvm::GlobalVariable(irstruct->initOpaque.get(), true, _linkage, NULL, varname, gIR->module); |
|---|
| | 253 | |
|---|
| | 254 | // ... and ClassInfo |
|---|
| | 255 | varname = "_D"; |
|---|
| | 256 | varname.append(cd->mangle()); |
|---|
| | 257 | varname.append("7__ClassZ"); |
|---|
| | 258 | |
|---|
| | 259 | // create global |
|---|
| | 260 | irstruct->classInfo = new llvm::GlobalVariable(irstruct->classInfoOpaque.get(), false, _linkage, NULL, varname, gIR->module); |
|---|
| 245 | 261 | |
|---|
| 246 | 262 | // push state |
|---|
| … | … | |
| 778 | 794 | // refine __initZ global type to the one of the initializer |
|---|
| 779 | 795 | llvm::cast<llvm::OpaqueType>(irstruct->initOpaque.get())->refineAbstractTypeTo(irstruct->constInit->getType()); |
|---|
| | 796 | |
|---|
| | 797 | // build initializers for static member variables |
|---|
| | 798 | size_t n = irstruct->staticVars.size(); |
|---|
| | 799 | for (size_t i = 0; i < n; ++i) |
|---|
| | 800 | { |
|---|
| | 801 | DtoConstInitGlobal(irstruct->staticVars[i]); |
|---|
| | 802 | } |
|---|
| | 803 | // This is all we use it for. Clear the memory! |
|---|
| | 804 | irstruct->staticVars.clear(); |
|---|
| 780 | 805 | |
|---|
| 781 | 806 | // if (Logger::enabled()) |
|---|
| … | … | |
| 1334 | 1359 | ClassDeclaration* cinfo = ClassDeclaration::classinfo; |
|---|
| 1335 | 1360 | DtoResolveClass(cinfo); |
|---|
| 1336 | | |
|---|
| 1337 | | // do the mangle |
|---|
| 1338 | | std::string gname("_D"); |
|---|
| 1339 | | gname.append(cd->mangle()); |
|---|
| 1340 | | if (!cd->isInterfaceDeclaration()) |
|---|
| 1341 | | gname.append("7__ClassZ"); |
|---|
| 1342 | | else |
|---|
| 1343 | | gname.append("11__InterfaceZ"); |
|---|
| 1344 | | |
|---|
| 1345 | | // create global |
|---|
| 1346 | | irstruct->classInfo = new llvm::GlobalVariable(irstruct->classInfoOpaque.get(), false, DtoLinkage(cd), NULL, gname, gIR->module); |
|---|
| 1347 | 1361 | } |
|---|
| 1348 | 1362 | |
|---|
| r1148 |
r1149 |
|
| 84 | 84 | return; |
|---|
| 85 | 85 | } |
|---|
| | 86 | |
|---|
| | 87 | if (AggregateDeclaration* ad = isMember()) |
|---|
| | 88 | ad->codegen(p); |
|---|
| 86 | 89 | |
|---|
| 87 | 90 | // global variable or magic |
|---|
| … | … | |
| 136 | 139 | gIR->usedArray.push_back(DtoBitCast(gvar, getVoidPtrType())); |
|---|
| 137 | 140 | |
|---|
| 138 | | DtoConstInitGlobal(this); |
|---|
| | 141 | // don't initialize static struct members yet, they might be of the struct type |
|---|
| | 142 | // which doesn't have a static initializer yet. |
|---|
| | 143 | if (AggregateDeclaration* ad = isMember()) |
|---|
| | 144 | ad->ir.irStruct->staticVars.push_back(this); |
|---|
| | 145 | else |
|---|
| | 146 | DtoConstInitGlobal(this); |
|---|
| 139 | 147 | } |
|---|
| 140 | 148 | else |
|---|
| r1148 |
r1149 |
|
| 302 | 302 | Logger::println("Ignoring unittest %s", fdecl->toPrettyChars()); |
|---|
| 303 | 303 | return; // ignore declaration completely |
|---|
| 304 | | } |
|---|
| 305 | | |
|---|
| 306 | | // is imported and we don't have access? |
|---|
| 307 | | if (fdecl->getModule() != gIR->dmodule) |
|---|
| 308 | | { |
|---|
| 309 | | if (fdecl->prot() == PROTprivate) |
|---|
| 310 | | { |
|---|
| 311 | | Logger::println("Ignoring private imported function %s", fdecl->toPrettyChars()); |
|---|
| 312 | | return; |
|---|
| 313 | | } |
|---|
| 314 | 304 | } |
|---|
| 315 | 305 | |
|---|
| r1147 |
r1149 |
|
| 5 | 5 | |
|---|
| 6 | 6 | #include "gen/llvm.h" |
|---|
| | 7 | #include "llvm/LinkAllVMCore.h" |
|---|
| 7 | 8 | #include "llvm/Linker.h" |
|---|
| | 9 | #include "llvm/System/Signals.h" |
|---|
| 8 | 10 | #include "llvm/Target/SubtargetFeature.h" |
|---|
| 9 | 11 | #include "llvm/Target/TargetMachine.h" |
|---|
| 10 | 12 | #include "llvm/Target/TargetMachineRegistry.h" |
|---|
| 11 | | #include "llvm/LinkAllVMCore.h" |
|---|
| 12 | 13 | |
|---|
| 13 | 14 | #include <stdio.h> |
|---|
| … | … | |
| 118 | 119 | int main(int argc, char** argv) |
|---|
| 119 | 120 | { |
|---|
| | 121 | // stack trace on signals |
|---|
| | 122 | llvm::sys::PrintStackTraceOnErrorSignal(); |
|---|
| | 123 | |
|---|
| 120 | 124 | Array files; |
|---|
| 121 | 125 | char *p, *ext; |
|---|
| r1148 |
r1149 |
|
| 98 | 98 | |
|---|
| 99 | 99 | // force constant initialization of the symbol |
|---|
| 100 | | si->ad->codegen(Type::sir);; |
|---|
| 101 | | |
|---|
| 102 | | // get formal type |
|---|
| 103 | | const llvm::StructType* structtype = isaStruct(ts->ir.type->get()); |
|---|
| 104 | | |
|---|
| 105 | | #if 0 |
|---|
| 106 | | // log it |
|---|
| 107 | | if (Logger::enabled()) |
|---|
| 108 | | Logger::cout() << "llvm struct type: " << *structtype << '\n'; |
|---|
| 109 | | #endif |
|---|
| | 100 | si->ad->codegen(Type::sir); |
|---|
| 110 | 101 | |
|---|
| 111 | 102 | // sanity check |
|---|
| … | … | |
| 242 | 233 | |
|---|
| 243 | 234 | // there might still be padding after the last one, make sure that is defaulted/zeroed as well |
|---|
| 244 | | size_t structsize = getTypePaddedSize(structtype); |
|---|
| | 235 | size_t structsize = si->ad->structsize; |
|---|
| 245 | 236 | |
|---|
| 246 | 237 | // if there is space before the next explicit initializer |
|---|
| … | … | |
| 646 | 637 | llvm::cast<llvm::OpaqueType>(irstruct->initOpaque.get())->refineAbstractTypeTo(irstruct->constInit->getType()); |
|---|
| 647 | 638 | |
|---|
| | 639 | // build initializers for static member variables |
|---|
| | 640 | size_t n = irstruct->staticVars.size(); |
|---|
| | 641 | for (size_t i = 0; i < n; ++i) |
|---|
| | 642 | { |
|---|
| | 643 | DtoConstInitGlobal(irstruct->staticVars[i]); |
|---|
| | 644 | } |
|---|
| | 645 | // This is all we use it for. Clear the memory! |
|---|
| | 646 | irstruct->staticVars.clear(); |
|---|
| | 647 | |
|---|
| 648 | 648 | gIR->structs.pop_back(); |
|---|
| 649 | 649 | |
|---|
| r1117 |
r1149 |
|
| 327 | 327 | ctxarg = gIR->ir->CreateExtractValue(fnval->getRVal(), 0, ".ptr"); |
|---|
| 328 | 328 | } |
|---|
| 329 | | assert(ctxarg->getType() == argiter->get()); |
|---|
| | 329 | ctxarg = DtoBitCast(ctxarg, argiter->get()); |
|---|
| 330 | 330 | ++argiter; |
|---|
| 331 | 331 | args.push_back(ctxarg); |
|---|
| r1148 |
r1149 |
|
| 970 | 970 | if (VarDeclaration* vd = vexp->var->isVarDeclaration()) |
|---|
| 971 | 971 | { |
|---|
| | 972 | vd->codegen(Type::sir); |
|---|
| 972 | 973 | LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue()); |
|---|
| 973 | 974 | assert(llc); |
|---|
| r946 |
r1149 |
|
| 151 | 151 | // composite type debug description |
|---|
| 152 | 152 | llvm::DICompositeType diCompositeType; |
|---|
| | 153 | |
|---|
| | 154 | std::vector<VarDeclaration*> staticVars; |
|---|
| 153 | 155 | }; |
|---|
| 154 | 156 | |
|---|