case UnaryOperator::Real:
case UnaryOperator::Imag:
LValue LV = EmitLValue(E->getSubExpr());
-
- llvm::Constant *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
- llvm::Constant *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty,
- E->getOpcode() == UnaryOperator::Imag);
- llvm::Value *Ops[] = {Zero, Idx};
- return LValue::MakeAddr(Builder.CreateGEP(LV.getAddress(), Ops, Ops+2,
- "idx"));
+ unsigned Idx = E->getOpcode() == UnaryOperator::Imag;
+ return LValue::MakeAddr(Builder.CreateStructGEP(LV.getAddress(),
+ Idx, "idx"));
}
}
llvm::Value *V;
unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);
- if (Field->isBitField()) {
- const llvm::Type * FieldTy = ConvertType(Field->getType());
- const llvm::PointerType * BaseTy =
+ if (!Field->isBitField()) {
+ V = Builder.CreateStructGEP(BaseValue, idx, "tmp");
+ } else {
+ const llvm::Type *FieldTy = ConvertType(Field->getType());
+ const llvm::PointerType *BaseTy =
cast<llvm::PointerType>(BaseValue->getType());
unsigned AS = BaseTy->getAddressSpace();
BaseValue = Builder.CreateBitCast(BaseValue,
V = Builder.CreateGEP(BaseValue,
llvm::ConstantInt::get(llvm::Type::Int32Ty, idx),
"tmp");
- } else {
- llvm::Value *Idxs[2] = { llvm::Constant::getNullValue(llvm::Type::Int32Ty),
- llvm::ConstantInt::get(llvm::Type::Int32Ty, idx) };
- V = Builder.CreateGEP(BaseValue,Idxs, Idxs + 2, "tmp");
}
+
// Match union field type.
if (isUnion) {
const llvm::Type * FieldTy = ConvertType(Field->getType());
}
}
- if (Field->isBitField()) {
- CodeGenTypes::BitFieldInfo bitFieldInfo =
- CGM.getTypes().getBitFieldInfo(Field);
- return LValue::MakeBitfield(V, bitFieldInfo.Begin, bitFieldInfo.Size,
- Field->getType()->isSignedIntegerType());
- } else
+ if (!Field->isBitField())
return LValue::MakeAddr(V);
+
+ CodeGenTypes::BitFieldInfo bitFieldInfo =
+ CGM.getTypes().getBitFieldInfo(Field);
+ return LValue::MakeBitfield(V, bitFieldInfo.Begin, bitFieldInfo.Size,
+ Field->getType()->isSignedIntegerType());
}
//===--------------------------------------------------------------------===//
if (const llvm::ArrayType *AType = dyn_cast<llvm::ArrayType>(DestType)) {
unsigned NumInitElements = E->getNumInits();
- llvm::Value *Idxs[] = {
- llvm::Constant::getNullValue(llvm::Type::Int32Ty),
- NULL
- };
- llvm::Value *NextVal = NULL;
unsigned i;
for (i = 0; i != NumInitElements; ++i) {
- Idxs[1] = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
- NextVal = Builder.CreateGEP(DestPtr, Idxs, Idxs + 2,".array");
+ llvm::Value *NextVal = Builder.CreateStructGEP(DestPtr, i, ".array");
Expr *Init = E->getInit(i);
if (isa<InitListExpr>(Init))
CGF.EmitAggExpr(Init, NextVal, VolatileDest);
QualType QType = E->getInit(0)->getType();
const llvm::Type *EType = AType->getElementType();
for (/*Do not initialize i*/; i < NumArrayElements; ++i) {
- Idxs[1] = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
- NextVal = Builder.CreateGEP(DestPtr, Idxs, Idxs + 2,".array");
+ llvm::Value *NextVal = Builder.CreateStructGEP(DestPtr, i, ".array");
if (EType->isFirstClassType())
Builder.CreateStore(llvm::Constant::getNullValue(EType), NextVal);
else
/// load the real and imaginary pieces, returning them as Real/Imag.
ComplexPairTy ComplexExprEmitter::EmitLoadOfComplex(llvm::Value *SrcPtr,
bool isVolatile) {
- llvm::Constant *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
- llvm::Constant *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1);
-
llvm::SmallString<64> Name(SrcPtr->getNameStart(),
SrcPtr->getNameStart()+SrcPtr->getNameLen());
Name += ".realp";
- llvm::Value *Ops[] = {Zero, Zero};
- llvm::Value *RealPtr = Builder.CreateGEP(SrcPtr, Ops, Ops+2, Name.c_str());
+ llvm::Value *RealPtr = Builder.CreateStructGEP(SrcPtr, 0, Name.c_str());
Name.pop_back(); // .realp -> .real
llvm::Value *Real = Builder.CreateLoad(RealPtr, isVolatile, Name.c_str());
Name.resize(Name.size()-4); // .real -> .imagp
Name += "imagp";
- Ops[1] = One; // { Ops = { Zero, One }
- llvm::Value *ImagPtr = Builder.CreateGEP(SrcPtr, Ops, Ops+2, Name.c_str());
+ llvm::Value *ImagPtr = Builder.CreateStructGEP(SrcPtr, 1, Name.c_str());
Name.pop_back(); // .imagp -> .imag
llvm::Value *Imag = Builder.CreateLoad(ImagPtr, isVolatile, Name.c_str());
/// specified value pointer.
void ComplexExprEmitter::EmitStoreOfComplex(ComplexPairTy Val, llvm::Value *Ptr,
bool isVolatile) {
- llvm::Constant *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
- llvm::Constant *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1);
-
- llvm::Value *Ops[] = {Zero, Zero};
- llvm::Value *RealPtr = Builder.CreateGEP(Ptr, Ops, Ops+2, "real");
-
- Ops[1] = One; // { Ops = { Zero, One }
- llvm::Value *ImagPtr = Builder.CreateGEP(Ptr, Ops, Ops+2, "imag");
+ llvm::Value *RealPtr = Builder.CreateStructGEP(Ptr, 0, "real");
+ llvm::Value *ImagPtr = Builder.CreateStructGEP(Ptr, 1, "imag");
Builder.CreateStore(Val.first, RealPtr, isVolatile);
Builder.CreateStore(Val.second, ImagPtr, isVolatile);
isa<llvm::ArrayType>(cast<llvm::PointerType>(V->getType())
->getElementType()) &&
"Doesn't support VLAs yet!");
- llvm::Constant *Idx0 = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
-
- llvm::Value *Ops[] = {Idx0, Idx0};
- V = Builder.CreateGEP(V, Ops, Ops+2, "arraydecay");
+ V = Builder.CreateStructGEP(V, 0, "arraydecay");
// The resultant pointer type can be implicitly casted to other pointer
// types as well, for example void*.
if (isa<llvm::PointerType>(InVal->getType())) {
// FIXME: This isn't right for VLAs.
NextVal = llvm::ConstantInt::get(llvm::Type::Int32Ty, AmountVal);
- NextVal = Builder.CreateGEP(InVal, NextVal);
+ NextVal = Builder.CreateGEP(InVal, NextVal, "ptrincdec");
} else {
// Add the inc/dec to the real part.
if (isa<llvm::IntegerType>(InVal->getType()))