mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
Merge branch 'master' into merge-2.061-2
This commit is contained in:
commit
bfc23acf30
6 changed files with 45 additions and 43 deletions
|
@ -70,18 +70,14 @@ LLStructType* DtoArrayType(Type* arrayTy)
|
||||||
if (elemty == LLType::getVoidTy(gIR->context()))
|
if (elemty == LLType::getVoidTy(gIR->context()))
|
||||||
elemty = LLType::getInt8Ty(gIR->context());
|
elemty = LLType::getInt8Ty(gIR->context());
|
||||||
|
|
||||||
llvm::SmallVector<LLType*, 2> elems;
|
llvm::Type *elems[] = { DtoSize_t(), getPtrToType(elemty) };
|
||||||
elems.push_back(DtoSize_t());
|
return llvm::StructType::get(gIR->context(), elems, false);
|
||||||
elems.push_back(getPtrToType(elemty));
|
|
||||||
return LLStructType::get(gIR->context(), llvm::makeArrayRef(elems));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LLStructType* DtoArrayType(LLType* t)
|
LLStructType* DtoArrayType(LLType* t)
|
||||||
{
|
{
|
||||||
llvm::SmallVector<LLType*, 2> elems;
|
llvm::Type *elems[] = { DtoSize_t(), getPtrToType(t) };
|
||||||
elems.push_back(DtoSize_t());
|
return llvm::StructType::get(gIR->context(), elems, false);
|
||||||
elems.push_back(getPtrToType(t));
|
|
||||||
return LLStructType::get(gIR->context(), llvm::makeArrayRef(elems));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -72,10 +72,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Type* rt = f->next;
|
Type* rt = f->next;
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 302
|
||||||
llvm::Attribute a;
|
llvm::AttrBuilder attrBuilder;
|
||||||
#elif LDC_LLVM_VER == 302
|
|
||||||
llvm::Attributes a;
|
|
||||||
#else
|
#else
|
||||||
llvm::Attributes a = None;
|
llvm::Attributes a = None;
|
||||||
#endif
|
#endif
|
||||||
|
@ -121,8 +119,17 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
|
||||||
if (f->isref)
|
if (f->isref)
|
||||||
t = t->pointerTo();
|
t = t->pointerTo();
|
||||||
#endif
|
#endif
|
||||||
|
#if LDC_LLVM_VER >= 302
|
||||||
|
attrBuilder.addAttribute(DtoShouldExtend(t));
|
||||||
|
#else
|
||||||
a = DtoShouldExtend(t);
|
a = DtoShouldExtend(t);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if LDC_LLVM_VER >= 303
|
||||||
|
llvm::Attribute a = llvm::Attribute::get(gIR->context(), attrBuilder);
|
||||||
|
#elif LDC_LLVM_VER == 302
|
||||||
|
llvm::Attributes a = llvm::Attributes::get(gIR->context(), attrBuilder);
|
||||||
|
#endif
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
fty.ret = new IrFuncTyArg(rt, f->isref, a);
|
fty.ret = new IrFuncTyArg(rt, f->isref, a);
|
||||||
#else
|
#else
|
||||||
|
@ -202,10 +209,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Type* argtype = arg->type;
|
Type* argtype = arg->type;
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 302
|
||||||
llvm::Attribute a;
|
llvm::AttrBuilder attrBuilder;
|
||||||
#elif LDC_LLVM_VER == 302
|
|
||||||
llvm::Attributes a;
|
|
||||||
#else
|
#else
|
||||||
llvm::Attributes a = None;
|
llvm::Attributes a = None;
|
||||||
#endif
|
#endif
|
||||||
|
@ -222,9 +227,9 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
|
||||||
else if (abi->passByVal(byref ? argtype->pointerTo() : argtype))
|
else if (abi->passByVal(byref ? argtype->pointerTo() : argtype))
|
||||||
{
|
{
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
if (!byref) a = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(a).addAttribute(llvm::Attribute::ByVal));
|
if (!byref) attrBuilder.addAttribute(llvm::Attribute::ByVal);
|
||||||
#elif LDC_LLVM_VER == 302
|
#elif LDC_LLVM_VER == 302
|
||||||
if (!byref) a = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(a).addAttribute(llvm::Attributes::ByVal));
|
if (!byref) attrBuilder.addAttribute(llvm::Attributes::ByVal);
|
||||||
#else
|
#else
|
||||||
if (!byref) a |= llvm::Attribute::ByVal;
|
if (!byref) a |= llvm::Attribute::ByVal;
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,15 +239,17 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
|
||||||
// sext/zext
|
// sext/zext
|
||||||
else if (!byref)
|
else if (!byref)
|
||||||
{
|
{
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 302
|
||||||
a = llvm::Attribute::get(gIR->context(), llvm::AttrBuilder(a).addAttributes(DtoShouldExtend(argtype)));
|
attrBuilder.addAttribute(DtoShouldExtend(argtype));
|
||||||
#elif LDC_LLVM_VER == 302
|
|
||||||
a = llvm::Attributes::get(gIR->context(), llvm::AttrBuilder(a).addAttributes(DtoShouldExtend(argtype)));
|
|
||||||
#else
|
#else
|
||||||
a |= DtoShouldExtend(argtype);
|
a |= DtoShouldExtend(argtype);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#if LDC_LLVM_VER >= 303
|
||||||
|
llvm::Attribute a = llvm::Attribute::get(gIR->context(), attrBuilder);
|
||||||
|
#elif LDC_LLVM_VER == 302
|
||||||
|
llvm::Attributes a = llvm::Attributes::get(gIR->context(), attrBuilder);
|
||||||
|
#endif
|
||||||
fty.args.push_back(new IrFuncTyArg(argtype, byref, a));
|
fty.args.push_back(new IrFuncTyArg(argtype, byref, a));
|
||||||
lidx++;
|
lidx++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,9 @@ bool DtoIsPassedByRef(Type* type)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
llvm::Attribute DtoShouldExtend(Type* type)
|
llvm::Attribute::AttrKind DtoShouldExtend(Type* type)
|
||||||
|
#elif LDC_LLVM_VER == 302
|
||||||
|
llvm::Attributes::AttrVal DtoShouldExtend(Type* type)
|
||||||
#else
|
#else
|
||||||
llvm::Attributes DtoShouldExtend(Type* type)
|
llvm::Attributes DtoShouldExtend(Type* type)
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,9 +58,9 @@ llvm::Attributes DtoShouldExtend(Type* type)
|
||||||
case Tint8:
|
case Tint8:
|
||||||
case Tint16:
|
case Tint16:
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
return llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::SExt));
|
return llvm::Attribute::SExt;
|
||||||
#elif LDC_LLVM_VER == 302
|
#elif LDC_LLVM_VER == 302
|
||||||
return llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::SExt));
|
return llvm::Attributes::SExt;
|
||||||
#else
|
#else
|
||||||
return llvm::Attribute::SExt;
|
return llvm::Attribute::SExt;
|
||||||
#endif
|
#endif
|
||||||
|
@ -66,18 +68,18 @@ llvm::Attributes DtoShouldExtend(Type* type)
|
||||||
case Tuns8:
|
case Tuns8:
|
||||||
case Tuns16:
|
case Tuns16:
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
return llvm::Attribute::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attribute::ZExt));
|
return llvm::Attribute::ZExt;
|
||||||
#elif LDC_LLVM_VER == 302
|
#elif LDC_LLVM_VER == 302
|
||||||
return llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::ZExt));
|
return llvm::Attributes::ZExt;
|
||||||
#else
|
#else
|
||||||
return llvm::Attribute::ZExt;
|
return llvm::Attribute::ZExt;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
return llvm::Attribute();
|
return llvm::Attribute::None;
|
||||||
#elif LDC_LLVM_VER == 302
|
#elif LDC_LLVM_VER == 302
|
||||||
return llvm::Attributes();
|
return llvm::Attributes::None;
|
||||||
#else
|
#else
|
||||||
return llvm::Attribute::None;
|
return llvm::Attribute::None;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -35,7 +35,9 @@ bool DtoIsPassedByRef(Type* type);
|
||||||
|
|
||||||
// should argument be zero or sign extended
|
// should argument be zero or sign extended
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
llvm::Attribute DtoShouldExtend(Type* type);
|
llvm::Attribute::AttrKind DtoShouldExtend(Type* type);
|
||||||
|
#elif LDC_LLVM_VER == 302
|
||||||
|
llvm::Attributes::AttrVal DtoShouldExtend(Type* type);
|
||||||
#else
|
#else
|
||||||
llvm::Attributes DtoShouldExtend(Type* type);
|
llvm::Attributes DtoShouldExtend(Type* type);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,10 +57,8 @@ IrTypeBasic* IrTypeBasic::get(Type* dt)
|
||||||
|
|
||||||
LLType* IrTypeBasic::getComplexType(llvm::LLVMContext& ctx, LLType* type)
|
LLType* IrTypeBasic::getComplexType(llvm::LLVMContext& ctx, LLType* type)
|
||||||
{
|
{
|
||||||
llvm::SmallVector<LLType*, 2> types;
|
llvm::Type *types[] = { type, type };
|
||||||
types.push_back(type);
|
return llvm::StructType::get(ctx, types, false);
|
||||||
types.push_back(type);
|
|
||||||
return llvm::StructType::get(ctx, types);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -257,10 +255,8 @@ IrTypeArray* IrTypeArray::get(Type* dt)
|
||||||
// just as for pointers.
|
// just as for pointers.
|
||||||
if (!dt->irtype)
|
if (!dt->irtype)
|
||||||
{
|
{
|
||||||
llvm::SmallVector<LLType*, 2> types;
|
llvm::Type *types[] = { DtoSize_t(), llvm::PointerType::get(elemType, 0) };
|
||||||
types.push_back(DtoSize_t());
|
LLType* at = llvm::StructType::get(llvm::getGlobalContext(), types, false);
|
||||||
types.push_back(llvm::PointerType::get(elemType, 0));
|
|
||||||
LLType* at = llvm::StructType::get(llvm::getGlobalContext(), types/*, t->toChars()*/);
|
|
||||||
dt->irtype = new IrTypeArray(dt, at);
|
dt->irtype = new IrTypeArray(dt, at);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,10 +72,9 @@ IrTypeDelegate* IrTypeDelegate::get(Type* dt)
|
||||||
"picked up random pre-existing type?"
|
"picked up random pre-existing type?"
|
||||||
);
|
);
|
||||||
|
|
||||||
llvm::SmallVector<LLType*, 2> types;
|
llvm::Type *types[] = { getVoidPtrType(),
|
||||||
types.push_back(getVoidPtrType());
|
getPtrToType(dt->nextOf()->irtype->getLLType()) };
|
||||||
types.push_back(getPtrToType(dt->nextOf()->irtype->getLLType()));
|
LLStructType* lt = LLStructType::get(gIR->context(), types, false);
|
||||||
LLStructType* lt = LLStructType::get(gIR->context(), types);
|
|
||||||
dt->irtype = new IrTypeDelegate(dt, lt);
|
dt->irtype = new IrTypeDelegate(dt, lt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue