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 |
---|
12 | // Last Modified On : Sat Jul 22 09:45:30 2017 |
---|
13 | // Update Count : 15 |
---|
14 | // |
---|
15 | |
---|
16 | #include "Mangler.h" |
---|
17 | #include "SynTree/Type.h" |
---|
18 | #include "SynTree/Declaration.h" |
---|
19 | |
---|
20 | namespace SymTab { |
---|
21 | namespace Mangler { |
---|
22 | namespace Encoding { |
---|
23 | const std::string manglePrefix = "_X"; |
---|
24 | |
---|
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++ |
---|
45 | "If", // FloatImaginary |
---|
46 | "Id", // DoubleImaginary |
---|
47 | "Ie", // LongDoubleImaginary |
---|
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 | ); |
---|
65 | |
---|
66 | const std::map<int, std::string> qualifiers = { |
---|
67 | { Type::Const, "K" }, |
---|
68 | { Type::Volatile, "V" }, |
---|
69 | { Type::Atomic, "DA" }, // A is array, so need something unique for atmoic. For now, go with multiletter DA |
---|
70 | { Type::Mutex, "X" }, |
---|
71 | { Type::Lvalue, "L" }, |
---|
72 | }; |
---|
73 | |
---|
74 | const std::string void_t = "v"; |
---|
75 | const std::string zero = "Z"; |
---|
76 | const std::string one = "O"; |
---|
77 | |
---|
78 | const std::string function = "F"; |
---|
79 | const std::string tuple = "T"; |
---|
80 | const std::string pointer = "P"; |
---|
81 | const std::string array = "A"; |
---|
82 | const std::string qualifiedTypeStart = "N"; |
---|
83 | const std::string qualifiedTypeEnd = "E"; |
---|
84 | |
---|
85 | const std::string forall = "Q"; |
---|
86 | const std::string typeVariables[] = { |
---|
87 | "BD", // dtype |
---|
88 | "BF", // ftype |
---|
89 | "BT", // ttype |
---|
90 | }; |
---|
91 | static_assert( |
---|
92 | sizeof(typeVariables)/sizeof(typeVariables[0]) == TypeDecl::NUMBER_OF_KINDS, |
---|
93 | "Each type variable kind should have a corresponding mangler prefix" |
---|
94 | ); |
---|
95 | |
---|
96 | const std::string struct_t = "S"; |
---|
97 | const std::string union_t = "U"; |
---|
98 | const std::string enum_t = "M"; |
---|
99 | const std::string type = "Y"; |
---|
100 | |
---|
101 | const std::string autogen = "autogen__"; |
---|
102 | const std::string intrinsic = "intrinsic__"; |
---|
103 | } // namespace Encoding |
---|
104 | } // namespace Mangler |
---|
105 | } // namespace SymTab |
---|