source: src/SymTab/ManglerCommon.cc@ 8d182b1

Last change on this file since 8d182b1 was 4ac402d, checked in by Andrew Beach <ajbeach@…>, 23 months ago

Added a missing include (not sure how that slipped through) and did some other replacements so the new ast is the source of constants.

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[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
[b66d14a]12// Last Modified On : Mon Jan 11 21:23:10 2021
13// Update Count : 29
[d1e0979]14//
15
16#include "Mangler.h"
[4ac402d]17
18#include "AST/Decl.hpp"
19#include "AST/Type.hpp"
[d1e0979]20
21namespace SymTab {
22 namespace Mangler {
[642bc83]23 namespace Encoding {
24 const std::string manglePrefix = "_X";
[ada4575]25
[e15853c]26 // GENERATED START, DO NOT EDIT
[6fd1955]27 // GENERATED BY BasicTypes-gen.cc
[cdcddfe1]28 // NOTES ON MANGLING:
29 // * Itanium spec says that Float80 encodes to "e" (like LongDouble), but the distinct lengths cause resolution problems.
30 // * Float128 is supposed to encode to "g", but I wanted it to mangle equal to LongDouble.
31 // * Mangling for non-standard complex types is by best guess
32 // * _FloatN is supposed to encode as "DF"N"_"; modified for same reason as above.
33 // * unused mangling identifiers:
34 // - "z" ellipsis
35 // - "Dd" IEEE 754r 64-bit decimal floating point (borrowed for _Float32x)
36 // - "De" IEEE 754r 128-bit decimal floating point
37 // - "Df" IEEE 754r 32-bit decimal floating point
38 // - "Dh" IEEE 754r 16-bit decimal floating point (borrowed for _Float16)
39 // - "DF"N"_" ISO/IEC TS 18661 N-bit binary floating point (_FloatN)
40 // - "Di" char32_t
41 // - "Ds" char16_t
[7d55e4d]42 const std::string basicTypes[ast::BasicType::NUMBER_OF_BASIC_TYPES] = {
[cdcddfe1]43 "b", // _Bool
[e15853c]44 "c", // char
45 "a", // signed char
46 "h", // unsigned char
47 "s", // signed short int
48 "t", // unsigned short int
49 "i", // signed int
50 "j", // unsigned int
51 "l", // signed long int
52 "m", // unsigned long int
53 "x", // signed long long int
54 "y", // unsigned long long int
55 "n", // __int128
56 "o", // unsigned __int128
[cdcddfe1]57 "DF16_", // _Float16
[e15853c]58 "CDF16_", // _Float16 _Complex
[cdcddfe1]59 "DF32_", // _Float32
[e15853c]60 "CDF32_", // _Float32 _Complex
61 "f", // float
62 "Cf", // float _Complex
[cdcddfe1]63 "DF32x_", // _Float32x
[e15853c]64 "CDF32x_", // _Float32x _Complex
[cdcddfe1]65 "DF64_", // _Float64
[e15853c]66 "CDF64_", // _Float64 _Complex
67 "d", // double
68 "Cd", // double _Complex
[cdcddfe1]69 "DF64x_", // _Float64x
[e15853c]70 "CDF64x_", // _Float64x _Complex
[cdcddfe1]71 "Dq", // __float80
72 "DF128_", // _Float128
[e15853c]73 "CDF128_", // _Float128 _Complex
[cdcddfe1]74 "g", // __float128
[e15853c]75 "e", // long double
76 "Ce", // long double _Complex
[cdcddfe1]77 "DF128x_", // _Float128x
[e15853c]78 "CDF128x_", // _Float128x _Complex
79 }; // basicTypes
80 // GENERATED END
[ada4575]81 static_assert(
[4ac402d]82 sizeof(basicTypes)/sizeof(basicTypes[0]) == ast::BasicType::NUMBER_OF_BASIC_TYPES,
[ada4575]83 "Each basic type kind should have a corresponding mangler letter"
84 );
[d1e0979]85
[642bc83]86 const std::map<int, std::string> qualifiers = {
[4ac402d]87 { ast::CV::Const, "K" },
88 { ast::CV::Volatile, "V" },
89 { ast::CV::Atomic, "DA" }, // A is array, so need something unique for atmoic. For now, go with multiletter DA
90 { ast::CV::Mutex, "X" },
[642bc83]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
[b66d14a]107 "BDS", // dtype + sized
[07de76b]108 "BO", // otype
[0e73845]109 "BF", // ftype
110 "BT", // ttype
[b66d14a]111 "BAL", // array length type
[0e73845]112 };
113 static_assert(
[4ac402d]114 sizeof(typeVariables) / sizeof(typeVariables[0]) == ast::TypeDecl::NUMBER_OF_KINDS,
[0e73845]115 "Each type variable kind should have a corresponding mangler prefix"
116 );
117
[7804e2a]118 const std::string struct_t = "S";
119 const std::string union_t = "U";
120 const std::string enum_t = "M";
[d8cb7df]121 const std::string type = "Y";
[7804e2a]122
[642bc83]123 const std::string autogen = "autogen__";
124 const std::string intrinsic = "intrinsic__";
125 } // namespace Encoding
[d1e0979]126 } // namespace Mangler
127} // namespace SymTab
Note: See TracBrowser for help on using the repository browser.