Ignore:
Timestamp:
Aug 2, 2018, 11:09:03 AM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
4285544e
Parents:
3bbd012
Message:

Modify name mangling scheme to more closely resembly itanium C++ name mangling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/ManglerCommon.cc

    r3bbd012 r642bc83  
    1919namespace SymTab {
    2020        namespace Mangler {
    21                 const char * btLetter[] = {
    22                         "b",  // Bool
    23                         "c",  // Char
    24                         "Sc", // SignedChar
    25                         "Uc", // UnsignedChar
    26                         "s",  // ShortSignedInt
    27                         "Us", // ShortUnsignedInt
    28                         "i",  // SignedInt
    29                         "Ui", // UnsignedInt
    30                         "l",  // LongSignedInt
    31                         "Ul", // LongUnsignedInt
    32                         "q",  // LongLongSignedInt
    33                         "Uq", // LongLongUnsignedInt
    34                         "f",  // Float
    35                         "d",  // Double
    36                         "r",  // LongDouble
    37                         "Xf", // FloatComplex
    38                         "Xd", // DoubleComplex
    39                         "Xr", // LongDoubleComplex
    40                         "If", // FloatImaginary
    41                         "Id", // DoubleImaginary
    42                         "Ir", // LongDoubleImaginary
    43                         "w",  // SignedInt128
    44                         "Uw", // UnsignedInt128
    45                         "x",  // Float80
    46                         "y",  // Float128
    47                 };
    48                 const int numBtLetter = sizeof(btLetter)/sizeof(btLetter[0]);
    49                 static_assert(
    50                         numBtLetter == BasicType::NUMBER_OF_BASIC_TYPES,
    51                         "Each basic type kind should have a corresponding mangler letter"
    52                 );
     21                namespace Encoding {
     22                        const std::string manglePrefix = "_X";
    5323
    54                 const std::map<int, const char *> qualifierLetter = {
    55                         { Type::Const, "C" },
    56                         { Type::Volatile, "V" },
    57                         { Type::Atomic, "A" }, // A = Atomic, A0 = Array and forall parameter...
    58                         { Type::Mutex, "M" },
    59                         { Type::Lvalue, "L" },
    60                 };
     24                        const std::string basicTypes[] = {
     25                                "b",  // Bool
     26                                "c",  // Char
     27                                "a",  // SignedChar
     28                                "h",  // UnsignedChar
     29                                "s",  // ShortSignedInt
     30                                "t",  // ShortUnsignedInt
     31                                "i",  // SignedInt
     32                                "j",  // UnsignedInt
     33                                "l",  // LongSignedInt
     34                                "m",  // LongUnsignedInt
     35                                "x",  // LongLongSignedInt
     36                                "y",  // LongLongUnsignedInt
     37                                "f",  // Float
     38                                "d",  // Double
     39                                "e",  // LongDouble
     40                                "Cf", // FloatComplex
     41                                "Cd", // DoubleComplex
     42                                "Ce", // LongDoubleComplex
     43                                // Note: imaginary is not an overloadable type in C++
     44                                "If", // FloatImaginary
     45                                "Id", // DoubleImaginary
     46                                "Ie", // LongDoubleImaginary
     47                                "n",  // SignedInt128
     48                                "o",  // UnsignedInt128
     49                                "Dq",  // Float80 -- TODO: itanium says Float80 and LongDouble both encode to "e", but doing this causes problems with constructing long double, because the cost tables are incorrect
     50                                "g",  // Float128
     51                                // "z", // ellipsis
     52                                // "Dd" // # IEEE 754r decimal floating point (64 bits)
     53                                // "De" // # IEEE 754r decimal floating point (128 bits)
     54                                // "Df" // # IEEE 754r decimal floating point (32 bits)
     55                                // "Dh" // # IEEE 754r half-precision floating point (16 bits)
     56                                // "DF"N_ // # ISO/IEC TS 18661 binary floating point type _FloatN (N bits)
     57                                // "Di" // char32_t
     58                                // "Ds" // char16_t
     59                        };
     60                        static_assert(
     61                                sizeof(basicTypes)/sizeof(basicTypes[0]) == BasicType::NUMBER_OF_BASIC_TYPES,
     62                                "Each basic type kind should have a corresponding mangler letter"
     63                        );
    6164
    62                 const std::string nameSeparator = "__cfa__";
     65                        const std::map<int, std::string> qualifiers = {
     66                                { Type::Const, "C" },
     67                                { Type::Volatile, "V" },
     68                                { Type::Atomic, "A" }, // A = Atomic, A0 = Array and forall parameter...
     69                                { Type::Mutex, "M" },
     70                                { Type::Lvalue, "L" },
     71                        };
     72
     73                        const std::string voidType = "v";
     74                        const std::string zero = "Z";
     75                        const std::string one = "O";
     76
     77                        const std::string function = "F";
     78                        const std::string tuple = "T";
     79                        const std::string pointer = "P";
     80                        const std::string array = "A";
     81                        const std::string qualifiedTypeStart = "N";
     82                        const std::string qualifiedTypeEnd = "E";
     83
     84                        const std::string autogen = "autogen__";
     85                        const std::string intrinsic = "intrinsic__";
     86                } // namespace Encoding
    6387        } // namespace Mangler
    6488} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.