source: src/Parser/LinkageSpec.h @ ecd4923

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since ecd4923 was 6b0b624, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

change #ifndef to #pragma once

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