[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 |
---|
[ada4575] | 12 | // Last Modified On : Thu Feb 14 17:06:37 2019 |
---|
| 13 | // Update Count : 26 |
---|
[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"; |
---|
[ada4575] | 24 | |
---|
[e15853c] | 25 | // GENERATED START, DO NOT EDIT |
---|
[6fd1955] | 26 | // GENERATED BY BasicTypes-gen.cc |
---|
[cdcddfe1] | 27 | // NOTES ON MANGLING: |
---|
| 28 | // * Itanium spec says that Float80 encodes to "e" (like LongDouble), but the distinct lengths cause resolution problems. |
---|
| 29 | // * Float128 is supposed to encode to "g", but I wanted it to mangle equal to LongDouble. |
---|
| 30 | // * Mangling for non-standard complex types is by best guess |
---|
| 31 | // * _FloatN is supposed to encode as "DF"N"_"; modified for same reason as above. |
---|
| 32 | // * unused mangling identifiers: |
---|
| 33 | // - "z" ellipsis |
---|
| 34 | // - "Dd" IEEE 754r 64-bit decimal floating point (borrowed for _Float32x) |
---|
| 35 | // - "De" IEEE 754r 128-bit decimal floating point |
---|
| 36 | // - "Df" IEEE 754r 32-bit decimal floating point |
---|
| 37 | // - "Dh" IEEE 754r 16-bit decimal floating point (borrowed for _Float16) |
---|
| 38 | // - "DF"N"_" ISO/IEC TS 18661 N-bit binary floating point (_FloatN) |
---|
| 39 | // - "Di" char32_t |
---|
| 40 | // - "Ds" char16_t |
---|
| 41 | const std::string basicTypes[BasicType::NUMBER_OF_BASIC_TYPES] = { |
---|
| 42 | "b", // _Bool |
---|
[e15853c] | 43 | "c", // char |
---|
| 44 | "a", // signed char |
---|
| 45 | "h", // unsigned char |
---|
| 46 | "s", // signed short int |
---|
| 47 | "t", // unsigned short int |
---|
| 48 | "i", // signed int |
---|
| 49 | "j", // unsigned int |
---|
| 50 | "l", // signed long int |
---|
| 51 | "m", // unsigned long int |
---|
| 52 | "x", // signed long long int |
---|
| 53 | "y", // unsigned long long int |
---|
| 54 | "n", // __int128 |
---|
| 55 | "o", // unsigned __int128 |
---|
[cdcddfe1] | 56 | "DF16_", // _Float16 |
---|
[e15853c] | 57 | "CDF16_", // _Float16 _Complex |
---|
[cdcddfe1] | 58 | "DF32_", // _Float32 |
---|
[e15853c] | 59 | "CDF32_", // _Float32 _Complex |
---|
| 60 | "f", // float |
---|
| 61 | "Cf", // float _Complex |
---|
[cdcddfe1] | 62 | "DF32x_", // _Float32x |
---|
[e15853c] | 63 | "CDF32x_", // _Float32x _Complex |
---|
[cdcddfe1] | 64 | "DF64_", // _Float64 |
---|
[e15853c] | 65 | "CDF64_", // _Float64 _Complex |
---|
| 66 | "d", // double |
---|
| 67 | "Cd", // double _Complex |
---|
[cdcddfe1] | 68 | "DF64x_", // _Float64x |
---|
[e15853c] | 69 | "CDF64x_", // _Float64x _Complex |
---|
[cdcddfe1] | 70 | "Dq", // __float80 |
---|
| 71 | "DF128_", // _Float128 |
---|
[e15853c] | 72 | "CDF128_", // _Float128 _Complex |
---|
[cdcddfe1] | 73 | "g", // __float128 |
---|
[e15853c] | 74 | "e", // long double |
---|
| 75 | "Ce", // long double _Complex |
---|
[cdcddfe1] | 76 | "DF128x_", // _Float128x |
---|
[e15853c] | 77 | "CDF128x_", // _Float128x _Complex |
---|
| 78 | }; // basicTypes |
---|
| 79 | // GENERATED END |
---|
[ada4575] | 80 | static_assert( |
---|
| 81 | sizeof(basicTypes)/sizeof(basicTypes[0]) == BasicType::NUMBER_OF_BASIC_TYPES, |
---|
| 82 | "Each basic type kind should have a corresponding mangler letter" |
---|
| 83 | ); |
---|
[d1e0979] | 84 | |
---|
[642bc83] | 85 | const std::map<int, std::string> qualifiers = { |
---|
[7804e2a] | 86 | { Type::Const, "K" }, |
---|
[642bc83] | 87 | { Type::Volatile, "V" }, |
---|
[90ed538] | 88 | { Type::Atomic, "DA" }, // A is array, so need something unique for atmoic. For now, go with multiletter DA |
---|
[7804e2a] | 89 | { Type::Mutex, "X" }, |
---|
[642bc83] | 90 | { Type::Lvalue, "L" }, |
---|
| 91 | }; |
---|
| 92 | |
---|
[7804e2a] | 93 | const std::string void_t = "v"; |
---|
[642bc83] | 94 | const std::string zero = "Z"; |
---|
| 95 | const std::string one = "O"; |
---|
| 96 | |
---|
| 97 | const std::string function = "F"; |
---|
| 98 | const std::string tuple = "T"; |
---|
| 99 | const std::string pointer = "P"; |
---|
| 100 | const std::string array = "A"; |
---|
| 101 | const std::string qualifiedTypeStart = "N"; |
---|
| 102 | const std::string qualifiedTypeEnd = "E"; |
---|
| 103 | |
---|
[0e73845] | 104 | const std::string forall = "Q"; |
---|
| 105 | const std::string typeVariables[] = { |
---|
| 106 | "BD", // dtype |
---|
| 107 | "BF", // ftype |
---|
| 108 | "BT", // ttype |
---|
| 109 | }; |
---|
| 110 | static_assert( |
---|
| 111 | sizeof(typeVariables)/sizeof(typeVariables[0]) == TypeDecl::NUMBER_OF_KINDS, |
---|
| 112 | "Each type variable kind should have a corresponding mangler prefix" |
---|
| 113 | ); |
---|
| 114 | |
---|
[7804e2a] | 115 | const std::string struct_t = "S"; |
---|
| 116 | const std::string union_t = "U"; |
---|
| 117 | const std::string enum_t = "M"; |
---|
[d8cb7df] | 118 | const std::string type = "Y"; |
---|
[7804e2a] | 119 | |
---|
[642bc83] | 120 | const std::string autogen = "autogen__"; |
---|
| 121 | const std::string intrinsic = "intrinsic__"; |
---|
| 122 | } // namespace Encoding |
---|
[d1e0979] | 123 | } // namespace Mangler |
---|
| 124 | } // namespace SymTab |
---|