Better encoding of basic types.

The new code distinguishes between bool, int, char, float and complex types.
This commit is contained in:
kai
2013-03-16 21:35:03 +01:00
parent 46f8d999c5
commit 36be9b5af4

View File

@@ -84,28 +84,56 @@ static llvm::DIType dwarfBasicType(Type* type)
LLType* T = DtoType(type);
// find encoding
unsigned id;
if (t->isintegral())
unsigned Encoding;
switch (t->ty)
{
if (type->isunsigned())
id = DW_ATE_unsigned;
else
id = DW_ATE_signed;
}
else if (t->isfloating())
{
id = DW_ATE_float;
}
else
{
llvm_unreachable("unsupported basic type for debug info");
case Tbool:
Encoding = DW_ATE_boolean;
break;
case Tchar:
case Twchar:
case Tdchar:
Encoding = type->isunsigned() ? DW_ATE_unsigned_char
: DW_ATE_signed_char;
break;
case Tint8:
case Tint16:
case Tint32:
case Tint64:
case Tint128:
Encoding = DW_ATE_signed;
break;
case Tuns8:
case Tuns16:
case Tuns32:
case Tuns64:
case Tuns128:
Encoding = DW_ATE_unsigned;
break;
case Tfloat32:
case Tfloat64:
case Tfloat80:
Encoding = DW_ATE_float;
break;
case Timaginary32:
case Timaginary64:
case Timaginary80:
Encoding = DW_ATE_imaginary_float;
break;
case Tcomplex32:
case Tcomplex64:
case Tcomplex80:
Encoding = DW_ATE_complex_float;
break;
default:
llvm_unreachable("Unsupported basic type for debug info");
}
return gIR->dibuilder.createBasicType(
type->toChars(), // name
getTypeBitSize(T), // size (bits)
getABITypeAlign(T)*8, // align (bits)
id
Encoding
);
}