comparison gen/tollvm.cpp @ 109:5ab8e92611f9 trunk

[svn r113] Added initial support for associative arrays (AAs). Fixed some problems with the string runtime support functions. Fixed initialization of array of structs. Fixed slice assignment where LHS is slice but RHS is dynamic array. Fixed problems with result of assignment expressions. Fixed foreach problems with key type mismatches.
author lindquist
date Wed, 21 Nov 2007 04:13:15 +0100
parents 288fe1029e1f
children 27b9f749d9fe
comparison
equal deleted inserted replaced
108:288fe1029e1f 109:5ab8e92611f9
175 } 175 }
176 176
177 // associative arrays 177 // associative arrays
178 case Taarray: 178 case Taarray:
179 { 179 {
180 // TODO this is a kludge 180 TypeAArray* taa = (TypeAArray*)t;
181 return llvm::PointerType::get(llvm::Type::Int8Ty); 181 std::vector<const llvm::Type*> types;
182 types.push_back(DtoType(taa->key));
183 types.push_back(DtoType(taa->next));
184 return llvm::PointerType::get(llvm::StructType::get(types));
182 } 185 }
183 186
184 default: 187 default:
185 printf("trying to convert unknown type with value %d\n", t->ty); 188 printf("trying to convert unknown type with value %d\n", t->ty);
186 assert(0); 189 assert(0);
1234 ); 1237 );
1235 } 1238 }
1236 1239
1237 ////////////////////////////////////////////////////////////////////////////////////////// 1240 //////////////////////////////////////////////////////////////////////////////////////////
1238 1241
1242 void DtoMemSetZero(llvm::Value* dst, llvm::Value* nbytes)
1243 {
1244 llvm::Type* arrty = llvm::PointerType::get(llvm::Type::Int8Ty);
1245 llvm::Value *dstarr;
1246 if (dst->getType() == arrty)
1247 {
1248 dstarr = dst;
1249 }
1250 else
1251 {
1252 dstarr = new llvm::BitCastInst(dst,arrty,"tmp",gIR->scopebb());
1253 }
1254
1255 llvm::Function* fn = (global.params.is64bit) ? LLVM_DeclareMemSet64() : LLVM_DeclareMemSet32();
1256 std::vector<llvm::Value*> llargs;
1257 llargs.resize(4);
1258 llargs[0] = dstarr;
1259 llargs[1] = llvm::ConstantInt::get(llvm::Type::Int8Ty, 0, false);
1260 llargs[2] = nbytes;
1261 llargs[3] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0, false);
1262
1263 new llvm::CallInst(fn, llargs.begin(), llargs.end(), "", gIR->scopebb());
1264 }
1265
1266 //////////////////////////////////////////////////////////////////////////////////////////
1267
1239 void DtoMemCpy(llvm::Value* dst, llvm::Value* src, llvm::Value* nbytes) 1268 void DtoMemCpy(llvm::Value* dst, llvm::Value* src, llvm::Value* nbytes)
1240 { 1269 {
1241 assert(dst->getType() == src->getType()); 1270 assert(dst->getType() == src->getType());
1242 1271
1243 llvm::Type* arrty = llvm::PointerType::get(llvm::Type::Int8Ty); 1272 llvm::Type* arrty = llvm::PointerType::get(llvm::Type::Int8Ty);