source: src/Parser/LinkageSpec.h @ 2a3d446

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 2a3d446 was 39156ed, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

add assignment declarations using "default" implementation required by g++-9

  • Property mode set to 100644
File size: 2.6 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// LinkageSpec.h --
8//
9// Author           : Rodolfo G. Esteves
10// Created On       : Sat May 16 13:24:28 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Jul 10 16:02:34 2019
13// Update Count     : 18
14//
15
16#pragma once
17
18#include <string>
19
20#include "Common/CodeLocation.h"
21
22namespace LinkageSpec {
23        // All linkage specs are some combination of these flags:
24        enum { Mangle = 1 << 0, Generate = 1 << 1, Overrideable = 1 << 2, Builtin = 1 << 3, GccBuiltin = 1 << 4, NoOfSpecs = 1 << 5, };
25
26        union Spec {
27                unsigned int val;
28                struct {
29                        bool is_mangled : 1;
30                        bool is_generatable : 1;
31                        bool is_overridable : 1;
32                        bool is_builtin : 1;
33                        bool is_gcc_builtin : 1;
34                };
35                constexpr Spec( unsigned int val ) : val( val ) {}
36                constexpr Spec( Spec const & other ) : val( other.val ) {}
37                constexpr Spec & operator=( const Spec & ) = default;
38                // Operators may go here.
39                // Supports == and !=
40                constexpr operator unsigned int() const { return val; }
41        };
42
43
44        Spec linkageUpdate( CodeLocation location, Spec old_spec, const std::string * cmd );
45        /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
46         * If cmd = "Cforall" returns old_spec Spec with is_mangled = true
47         */
48
49        std::string linkageName( Spec );
50
51        // To Update: LinkageSpec::isXyz( cur_spec ) -> cur_spec.is_xyz
52        inline bool isMangled( Spec spec ) { return spec.is_mangled; }
53        inline bool isGeneratable( Spec spec ) { return spec.is_generatable; }
54        inline bool isOverridable( Spec spec ) { return spec.is_overridable; }
55        inline bool isBuiltin( Spec spec ) { return spec.is_builtin; }
56        inline bool isGccBuiltin( Spec spec ) { return spec.is_gcc_builtin; }
57
58        // Pre-defined flag combinations:
59        // C built-in defined in prelude
60        constexpr Spec const Intrinsic = { Mangle | Generate | Overrideable | Builtin };
61        // ordinary
62        constexpr Spec const Cforall = { Mangle | Generate };
63        // not overloadable, not mangled
64        constexpr Spec const C = { Generate };
65        // built by translator (struct assignment)
66        constexpr Spec const AutoGen = { Mangle | Generate | Overrideable };
67        // gcc internal
68        constexpr Spec const Compiler = { Mangle | Builtin | GccBuiltin };
69        // mangled builtins
70        constexpr Spec const BuiltinCFA = { Mangle | Generate | Builtin };
71        // non-mangled builtins
72        constexpr Spec const BuiltinC = { Generate | Builtin };
73};
74
75// Local Variables: //
76// tab-width: 4 //
77// mode: c++ //
78// compile-command: "make install" //
79// End: //
Note: See TracBrowser for help on using the repository browser.