[d1e0979] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // Mangler.h -- |
---|
| 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Sun May 17 21:44:03 2015 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[e15853c] | 12 | // Last Modified On : Thu Feb 14 08:12:17 2019 |
---|
| 13 | // Update Count : 25 |
---|
[d1e0979] | 14 | // |
---|
| 15 | |
---|
| 16 | #include "Mangler.h" |
---|
| 17 | #include "SynTree/Type.h" |
---|
[0e73845] | 18 | #include "SynTree/Declaration.h" |
---|
[d1e0979] | 19 | |
---|
| 20 | namespace SymTab { |
---|
| 21 | namespace Mangler { |
---|
[642bc83] | 22 | namespace Encoding { |
---|
| 23 | const std::string manglePrefix = "_X"; |
---|
[cdcddfe1] | 24 | #if 0 |
---|
[642bc83] | 25 | const std::string basicTypes[] = { |
---|
| 26 | "b", // Bool |
---|
| 27 | "c", // Char |
---|
| 28 | "a", // SignedChar |
---|
| 29 | "h", // UnsignedChar |
---|
| 30 | "s", // ShortSignedInt |
---|
| 31 | "t", // ShortUnsignedInt |
---|
| 32 | "i", // SignedInt |
---|
| 33 | "j", // UnsignedInt |
---|
| 34 | "l", // LongSignedInt |
---|
| 35 | "m", // LongUnsignedInt |
---|
| 36 | "x", // LongLongSignedInt |
---|
| 37 | "y", // LongLongUnsignedInt |
---|
| 38 | "f", // Float |
---|
| 39 | "d", // Double |
---|
| 40 | "e", // LongDouble |
---|
| 41 | "Cf", // FloatComplex |
---|
| 42 | "Cd", // DoubleComplex |
---|
| 43 | "Ce", // LongDoubleComplex |
---|
| 44 | // Note: imaginary is not an overloadable type in C++ |
---|
[cdcddfe1] | 45 | // "If", // FloatImaginary |
---|
| 46 | // "Id", // DoubleImaginary |
---|
| 47 | // "Ie", // LongDoubleImaginary |
---|
[642bc83] | 48 | "n", // SignedInt128 |
---|
| 49 | "o", // UnsignedInt128 |
---|
| 50 | "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 |
---|
| 51 | "g", // Float128 |
---|
| 52 | // "z", // ellipsis |
---|
| 53 | // "Dd" // # IEEE 754r decimal floating point (64 bits) |
---|
| 54 | // "De" // # IEEE 754r decimal floating point (128 bits) |
---|
| 55 | // "Df" // # IEEE 754r decimal floating point (32 bits) |
---|
| 56 | // "Dh" // # IEEE 754r half-precision floating point (16 bits) |
---|
| 57 | // "DF"N_ // # ISO/IEC TS 18661 binary floating point type _FloatN (N bits) |
---|
| 58 | // "Di" // char32_t |
---|
| 59 | // "Ds" // char16_t |
---|
| 60 | }; |
---|
| 61 | static_assert( |
---|
| 62 | sizeof(basicTypes)/sizeof(basicTypes[0]) == BasicType::NUMBER_OF_BASIC_TYPES, |
---|
| 63 | "Each basic type kind should have a corresponding mangler letter" |
---|
| 64 | ); |
---|
[cdcddfe1] | 65 | #endif |
---|
[e15853c] | 66 | // GENERATED START, DO NOT EDIT |
---|
[cdcddfe1] | 67 | // NOTES ON MANGLING: |
---|
| 68 | // * Itanium spec says that Float80 encodes to "e" (like LongDouble), but the distinct lengths cause resolution problems. |
---|
| 69 | // * Float128 is supposed to encode to "g", but I wanted it to mangle equal to LongDouble. |
---|
| 70 | // * Mangling for non-standard complex types is by best guess |
---|
| 71 | // * _FloatN is supposed to encode as "DF"N"_"; modified for same reason as above. |
---|
| 72 | // * unused mangling identifiers: |
---|
| 73 | // - "z" ellipsis |
---|
| 74 | // - "Dd" IEEE 754r 64-bit decimal floating point (borrowed for _Float32x) |
---|
| 75 | // - "De" IEEE 754r 128-bit decimal floating point |
---|
| 76 | // - "Df" IEEE 754r 32-bit decimal floating point |
---|
| 77 | // - "Dh" IEEE 754r 16-bit decimal floating point (borrowed for _Float16) |
---|
| 78 | // - "DF"N"_" ISO/IEC TS 18661 N-bit binary floating point (_FloatN) |
---|
| 79 | // - "Di" char32_t |
---|
| 80 | // - "Ds" char16_t |
---|
| 81 | const std::string basicTypes[BasicType::NUMBER_OF_BASIC_TYPES] = { |
---|
| 82 | "b", // _Bool |
---|
[e15853c] | 83 | "c", // char |
---|
| 84 | "a", // signed char |
---|
| 85 | "h", // unsigned char |
---|
| 86 | "s", // signed short int |
---|
| 87 | "t", // unsigned short int |
---|
| 88 | "i", // signed int |
---|
| 89 | "j", // unsigned int |
---|
| 90 | "l", // signed long int |
---|
| 91 | "m", // unsigned long int |
---|
| 92 | "x", // signed long long int |
---|
| 93 | "y", // unsigned long long int |
---|
| 94 | "n", // __int128 |
---|
| 95 | "o", // unsigned __int128 |
---|
[cdcddfe1] | 96 | "DF16_", // _Float16 |
---|
[e15853c] | 97 | "CDF16_", // _Float16 _Complex |
---|
[cdcddfe1] | 98 | "DF32_", // _Float32 |
---|
[e15853c] | 99 | "CDF32_", // _Float32 _Complex |
---|
| 100 | "f", // float |
---|
| 101 | "Cf", // float _Complex |
---|
[cdcddfe1] | 102 | "DF32x_", // _Float32x |
---|
[e15853c] | 103 | "CDF32x_", // _Float32x _Complex |
---|
[cdcddfe1] | 104 | "DF64_", // _Float64 |
---|
[e15853c] | 105 | "CDF64_", // _Float64 _Complex |
---|
| 106 | "d", // double |
---|
| 107 | "Cd", // double _Complex |
---|
[cdcddfe1] | 108 | "DF64x_", // _Float64x |
---|
[e15853c] | 109 | "CDF64x_", // _Float64x _Complex |
---|
[cdcddfe1] | 110 | "Dq", // __float80 |
---|
| 111 | "DF128_", // _Float128 |
---|
[e15853c] | 112 | "CDF128_", // _Float128 _Complex |
---|
[cdcddfe1] | 113 | "g", // __float128 |
---|
[e15853c] | 114 | "e", // long double |
---|
| 115 | "Ce", // long double _Complex |
---|
[cdcddfe1] | 116 | "DF128x_", // _Float128x |
---|
[e15853c] | 117 | "CDF128x_", // _Float128x _Complex |
---|
| 118 | }; // basicTypes |
---|
| 119 | // GENERATED END |
---|
[d1e0979] | 120 | |
---|
[642bc83] | 121 | const std::map<int, std::string> qualifiers = { |
---|
[7804e2a] | 122 | { Type::Const, "K" }, |
---|
[642bc83] | 123 | { Type::Volatile, "V" }, |
---|
[90ed538] | 124 | { Type::Atomic, "DA" }, // A is array, so need something unique for atmoic. For now, go with multiletter DA |
---|
[7804e2a] | 125 | { Type::Mutex, "X" }, |
---|
[642bc83] | 126 | { Type::Lvalue, "L" }, |
---|
| 127 | }; |
---|
| 128 | |
---|
[7804e2a] | 129 | const std::string void_t = "v"; |
---|
[642bc83] | 130 | const std::string zero = "Z"; |
---|
| 131 | const std::string one = "O"; |
---|
| 132 | |
---|
| 133 | const std::string function = "F"; |
---|
| 134 | const std::string tuple = "T"; |
---|
| 135 | const std::string pointer = "P"; |
---|
| 136 | const std::string array = "A"; |
---|
| 137 | const std::string qualifiedTypeStart = "N"; |
---|
| 138 | const std::string qualifiedTypeEnd = "E"; |
---|
| 139 | |
---|
[0e73845] | 140 | const std::string forall = "Q"; |
---|
| 141 | const std::string typeVariables[] = { |
---|
| 142 | "BD", // dtype |
---|
| 143 | "BF", // ftype |
---|
| 144 | "BT", // ttype |
---|
| 145 | }; |
---|
| 146 | static_assert( |
---|
| 147 | sizeof(typeVariables)/sizeof(typeVariables[0]) == TypeDecl::NUMBER_OF_KINDS, |
---|
| 148 | "Each type variable kind should have a corresponding mangler prefix" |
---|
| 149 | ); |
---|
| 150 | |
---|
[7804e2a] | 151 | const std::string struct_t = "S"; |
---|
| 152 | const std::string union_t = "U"; |
---|
| 153 | const std::string enum_t = "M"; |
---|
[d8cb7df] | 154 | const std::string type = "Y"; |
---|
[7804e2a] | 155 | |
---|
[642bc83] | 156 | const std::string autogen = "autogen__"; |
---|
| 157 | const std::string intrinsic = "intrinsic__"; |
---|
| 158 | } // namespace Encoding |
---|
[d1e0979] | 159 | } // namespace Mangler |
---|
| 160 | } // namespace SymTab |
---|