Vec &Vec::operator /=(const Vec &b) { Assert(Elts() == b.Elts(), "(Vec::/=) Vec sizes don't match"); int i; for (i = 0; i < Elts(); i++) data[i] /= b[i]; return (*this); }
Vec &Vec::operator +=(const Vec &b) { Assert(Elts() == b.Elts(), "(Vec::+=) vector sizes don't match"); int i; for (i = 0; i < Elts(); i++) data[i] += b[i]; return (*this); }
Vec::Vec(const Vec &v) { Assert(v.data != 0, "(Vec) Can't construct from a null vector"); elts = v.Elts(); data = new double[elts]; #ifdef VL_USE_MEMCPY memcpy(data, v.Ref(), sizeof (double) * Elts()); #else for (int i = 0; i < Elts(); i++) data[i] = v[i]; #endif }
Vec &Vec::operator =(const Vec &v) { if (!IsRef()) SetSize(v.Elts()); else Assert(Elts() == v.Elts(), "(Vec::=) Vector sizes don't match"); #ifdef VL_USE_MEMCPY memcpy(data, v.data, sizeof (double) * Elts()); #else for (int i = 0; i < Elts(); i++) data[i] = v[i]; #endif return (*this); }
Vec &Vec::operator /=(double s) { int i; for (i = 0; i < Elts(); i++) data[i] /= s; return (*this); }
Vec &Vec::operator =(const Vec2 &v) { if (!IsRef()) SetSize(v.Elts()); else Assert(Elts() == v.Elts(), "(Vec::=) Vector sizes don't match"); data[0] = v[0]; data[1] = v[1]; return (*this); }
/// PassInMixedRegisters - Given an aggregate value that should be passed in /// mixed integer, floating point, and vector registers, convert it to a /// structure containing the specified struct elements in. void DefaultABI::PassInMixedRegisters(const Type *Ty, std::vector<const Type*> &OrigElts, std::vector<const Type*> &ScalarElts) { // We use VoidTy in OrigElts to mean "this is a word in the aggregate // that occupies storage but has no useful information, and is not passed // anywhere". Happens on x86-64. std::vector<const Type*> Elts(OrigElts); const Type* wordType = getTargetData().getPointerSize() == 4 ? Type::getInt32Ty(getGlobalContext()) : Type::getInt64Ty(getGlobalContext()); for (unsigned i=0, e=Elts.size(); i!=e; ++i) if (OrigElts[i]->isVoidTy()) Elts[i] = wordType; const StructType *STy = StructType::get(getGlobalContext(), Elts, false); unsigned Size = getTargetData().getTypeAllocSize(STy); const StructType *InSTy = dyn_cast<StructType>(Ty); unsigned InSize = 0; // If Ty and STy size does not match then last element is accessing // extra bits. unsigned LastEltSizeDiff = 0; if (InSTy) { InSize = getTargetData().getTypeAllocSize(InSTy); if (InSize < Size) { unsigned N = STy->getNumElements(); const llvm::Type *LastEltTy = STy->getElementType(N-1); if (LastEltTy->isIntegerTy()) LastEltSizeDiff = getTargetData().getTypeAllocSize(LastEltTy) - (Size - InSize); } } for (unsigned i = 0, e = Elts.size(); i != e; ++i) { if (!OrigElts[i]->isVoidTy()) { C.EnterField(i, STy); unsigned RealSize = 0; if (LastEltSizeDiff && i == (e - 1)) RealSize = LastEltSizeDiff; C.HandleScalarArgument(Elts[i], 0, RealSize); ScalarElts.push_back(Elts[i]); C.ExitField(); } } }