From 36be9b5af4695db835fee8617ba3c1e3319ad262 Mon Sep 17 00:00:00 2001 From: kai Date: Sat, 16 Mar 2013 21:35:03 +0100 Subject: [PATCH] Better encoding of basic types. The new code distinguishes between bool, int, char, float and complex types. --- gen/todebug.cpp | 58 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 03497f1f..f542a675 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -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 ); }