Mercurial > projects > ldc
comparison gen/toir.c @ 53:06ccc817acd4 trunk
[svn r57] Added most basic TypeInfo (rebuild lphobos).
Fixed some SymOffExp bugs.
Added another typeinfo test case.
author | lindquist |
---|---|
date | Tue, 23 Oct 2007 07:16:02 +0200 |
parents | 0c77619e803b |
children | 28e99b04a132 |
comparison
equal
deleted
inserted
replaced
52:0c77619e803b | 53:06ccc817acd4 |
---|---|
1056 } | 1056 } |
1057 else { | 1057 else { |
1058 Logger::cout() << "what are we calling? : " << *funcval << '\n'; | 1058 Logger::cout() << "what are we calling? : " << *funcval << '\n'; |
1059 } | 1059 } |
1060 assert(llfnty); | 1060 assert(llfnty); |
1061 Logger::cout() << "Function LLVM type: " << *llfnty << '\n'; | 1061 //Logger::cout() << "Function LLVM type: " << *llfnty << '\n'; |
1062 | 1062 |
1063 // argument handling | 1063 // argument handling |
1064 llvm::FunctionType::param_iterator argiter = llfnty->param_begin(); | 1064 llvm::FunctionType::param_iterator argiter = llfnty->param_begin(); |
1065 int j = 0; | 1065 int j = 0; |
1066 | 1066 |
1130 for (int i=0; i<n; ++i) | 1130 for (int i=0; i<n; ++i) |
1131 { | 1131 { |
1132 Logger::cout() << *llargs[i] << '\n'; | 1132 Logger::cout() << *llargs[i] << '\n'; |
1133 } | 1133 } |
1134 | 1134 |
1135 Logger::cout() << "Calling: " << *funcval->getType() << '\n'; | 1135 //Logger::cout() << "Calling: " << *funcval->getType() << '\n'; |
1136 | 1136 |
1137 // call the function | 1137 // call the function |
1138 llvm::CallInst* call = new llvm::CallInst(funcval, llargs.begin(), llargs.end(), varname, p->scopebb()); | 1138 llvm::CallInst* call = new llvm::CallInst(funcval, llargs.begin(), llargs.end(), varname, p->scopebb()); |
1139 if (retinptr) | 1139 if (retinptr) |
1140 e->mem = llargs[0]; | 1140 e->mem = llargs[0]; |
1153 | 1153 |
1154 ////////////////////////////////////////////////////////////////////////////////////////// | 1154 ////////////////////////////////////////////////////////////////////////////////////////// |
1155 | 1155 |
1156 elem* CastExp::toElem(IRState* p) | 1156 elem* CastExp::toElem(IRState* p) |
1157 { | 1157 { |
1158 Logger::print("CastExp::toElem: %s\n", toChars()); | 1158 Logger::print("CastExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1159 LOG_SCOPE; | 1159 LOG_SCOPE; |
1160 elem* e = new elem; | 1160 elem* e = new elem; |
1161 elem* u = e1->toElem(p); | 1161 elem* u = e1->toElem(p); |
1162 const llvm::Type* tolltype = LLVM_DtoType(to); | 1162 const llvm::Type* tolltype = LLVM_DtoType(to); |
1163 Type* fromtype = LLVM_DtoDType(e1->type); | 1163 Type* fromtype = LLVM_DtoDType(e1->type); |
1361 } | 1361 } |
1362 else if (offset == 0) { | 1362 else if (offset == 0) { |
1363 e = new elem; | 1363 e = new elem; |
1364 assert(llvalue); | 1364 assert(llvalue); |
1365 e->mem = llvalue; | 1365 e->mem = llvalue; |
1366 const llvm::Type* llt = LLVM_DtoType(t); | |
1367 if (llvalue->getType() != llt) { | |
1368 Logger::cout() << "llt is:" << *llt << '\n'; | |
1369 //const llvm::PointerType* vpty = llvm::PointerType::get(llvm::Type::Int8Ty); | |
1370 e->mem = p->ir->CreateBitCast(e->mem, llt, "tmp"); | |
1371 } | |
1366 e->type = elem::VAL; | 1372 e->type = elem::VAL; |
1367 } | 1373 } |
1368 else { | 1374 else { |
1369 assert(0); | 1375 assert(0); |
1370 } | 1376 } |
1463 | 1469 |
1464 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); | 1470 llvm::Value* zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false); |
1465 llvm::Value* vtblidx = llvm::ConstantInt::get(llvm::Type::Int32Ty, (size_t)fdecl->vtblIndex, false); | 1471 llvm::Value* vtblidx = llvm::ConstantInt::get(llvm::Type::Int32Ty, (size_t)fdecl->vtblIndex, false); |
1466 funcval = LLVM_DtoGEP(e->arg, zero, zero, "tmp", p->scopebb()); | 1472 funcval = LLVM_DtoGEP(e->arg, zero, zero, "tmp", p->scopebb()); |
1467 funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb()); | 1473 funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb()); |
1468 funcval = LLVM_DtoGEP(funcval, zero, vtblidx, "tmp", p->scopebb()); | 1474 funcval = LLVM_DtoGEP(funcval, zero, vtblidx, toChars(), p->scopebb()); |
1469 funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb()); | 1475 funcval = new llvm::LoadInst(funcval,"tmp",p->scopebb()); |
1470 assert(funcval->getType() == fdecl->llvmValue->getType()); | 1476 assert(funcval->getType() == fdecl->llvmValue->getType()); |
1471 e->callconv = LLVM_DtoCallingConv(fdecl->linkage); | 1477 e->callconv = LLVM_DtoCallingConv(fdecl->linkage); |
1472 } | 1478 } |
1473 e->val = funcval; | 1479 e->val = funcval; |
1922 e->val = LLVM_DtoStaticArrayCompare(op,l->mem,r->mem); | 1928 e->val = LLVM_DtoStaticArrayCompare(op,l->mem,r->mem); |
1923 } | 1929 } |
1924 else if (t->ty == Tarray) | 1930 else if (t->ty == Tarray) |
1925 { | 1931 { |
1926 e->val = LLVM_DtoDynArrayCompare(op,l->mem,r->mem); | 1932 e->val = LLVM_DtoDynArrayCompare(op,l->mem,r->mem); |
1933 } | |
1934 else if (t->ty == Tdelegate) | |
1935 { | |
1936 e->val = LLVM_DtoCompareDelegate(op,l->mem,r->mem); | |
1927 } | 1937 } |
1928 else | 1938 else |
1929 { | 1939 { |
1930 assert(0 && "Unsupported EqualExp type"); | 1940 assert(0 && "Unsupported EqualExp type"); |
1931 } | 1941 } |