source: src/SymTab/ManglerCommon.cc @ cdcddfe1

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since cdcddfe1 was cdcddfe1, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

add signedness to cost model and _FloatNN

  • Property mode set to 100644
File size: 5.5 KB
Line 
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 : Fri Feb  8 09:02:18 2019
13// Update Count     : 22
14//
15
16#include "Mangler.h"
17#include "SynTree/Type.h"
18#include "SynTree/Declaration.h"
19
20namespace SymTab {
21        namespace Mangler {
22                namespace Encoding {
23                        const std::string manglePrefix = "_X";
24#if 0
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#endif
66                        // ****************************************************************************
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                        // ****************************************************************************
82                        const std::string basicTypes[BasicType::NUMBER_OF_BASIC_TYPES] = {
83                                "b",        // _Bool
84                                "c",        // Char
85                                "a",        // SignedChar
86                                "h",        // UnsignedChar
87                                "s",        // ShortSignedInt
88                                "t",        // ShortUnsignedInt
89                                "i",        // SignedInt
90                                "j",        // UnsignedInt
91                                "l",        // LongSignedInt
92                                "m",        // LongUnsignedInt
93                                "x",        // LongLongSignedInt
94                                "y",        // LongLongUnsignedInt
95                                "n",        // SignedInt128
96                                "o",        // UnsignedInt128
97                                "DF16_",    // _Float16
98                                "CDF16_",   // _Float16Complex
99                                "DF32_",    // _Float32
100                                "CDF32_",   // _Float32Complex
101                                "f",        // Float
102                                "Cf",       // FloatComplex
103                                "DF32x_",   // _Float32x
104                                "CDF32x_",  // _Float32xComplex
105                                "DF64_",    // _Float64
106                                "CDF64_",   // _Float64Complex
107                                "d",        // Double
108                                "Cd",       // DoubleComplex
109                                "DF64x_",   // _Float64x
110                                "CDF64x_",  // _Float64xComplex
111                                "Dq",       // __float80
112                                "DF128_",   // _Float128
113                                "CDF128_",  // _Float128Complex
114                                "g",        // __float128
115                                "e",        // LongDouble
116                                "Ce",       // LongDoubleComplex
117                                "DF128x_",  // _Float128x
118                                "CDF128x_", // _Float128xComplex
119                        };
120
121                        const std::map<int, std::string> qualifiers = {
122                                { Type::Const, "K" },
123                                { Type::Volatile, "V" },
124                                { Type::Atomic, "DA" }, // A is array, so need something unique for atmoic. For now, go with multiletter DA
125                                { Type::Mutex, "X" },
126                                { Type::Lvalue, "L" },
127                        };
128
129                        const std::string void_t = "v";
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
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
151                        const std::string struct_t = "S";
152                        const std::string union_t = "U";
153                        const std::string enum_t = "M";
154                        const std::string type = "Y";
155
156                        const std::string autogen = "autogen__";
157                        const std::string intrinsic = "intrinsic__";
158                } // namespace Encoding
159        } // namespace Mangler
160} // namespace SymTab
Note: See TracBrowser for help on using the repository browser.