| [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
 | 
|---|
 | 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"
 | 
|---|
| [0e73845] | 18 | #include "SynTree/Declaration.h"
 | 
|---|
| [d1e0979] | 19 | 
 | 
|---|
 | 20 | namespace SymTab {
 | 
|---|
 | 21 |         namespace Mangler {
 | 
|---|
| [642bc83] | 22 |                 namespace Encoding {
 | 
|---|
 | 23 |                         const std::string manglePrefix = "_X";
 | 
|---|
| [d1e0979] | 24 | 
 | 
|---|
| [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++
 | 
|---|
 | 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 |                         );
 | 
|---|
| [d1e0979] | 65 | 
 | 
|---|
| [642bc83] | 66 |                         const std::map<int, std::string> qualifiers = {
 | 
|---|
| [7804e2a] | 67 |                                 { Type::Const, "K" },
 | 
|---|
| [642bc83] | 68 |                                 { Type::Volatile, "V" },
 | 
|---|
| [90ed538] | 69 |                                 { Type::Atomic, "DA" }, // A is array, so need something unique for atmoic. For now, go with multiletter DA
 | 
|---|
| [7804e2a] | 70 |                                 { Type::Mutex, "X" },
 | 
|---|
| [642bc83] | 71 |                                 { Type::Lvalue, "L" },
 | 
|---|
 | 72 |                         };
 | 
|---|
 | 73 | 
 | 
|---|
| [7804e2a] | 74 |                         const std::string void_t = "v";
 | 
|---|
| [642bc83] | 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 | 
 | 
|---|
| [0e73845] | 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 | 
 | 
|---|
| [7804e2a] | 96 |                         const std::string struct_t = "S";
 | 
|---|
 | 97 |                         const std::string union_t = "U";
 | 
|---|
 | 98 |                         const std::string enum_t = "M";
 | 
|---|
| [d8cb7df] | 99 |                         const std::string type = "Y";
 | 
|---|
| [7804e2a] | 100 | 
 | 
|---|
| [642bc83] | 101 |                         const std::string autogen = "autogen__";
 | 
|---|
 | 102 |                         const std::string intrinsic = "intrinsic__";
 | 
|---|
 | 103 |                 } // namespace Encoding
 | 
|---|
| [d1e0979] | 104 |         } // namespace Mangler
 | 
|---|
 | 105 | } // namespace SymTab
 | 
|---|