source: src/Parser/LinkageSpec.h @ ef2eade

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since ef2eade was 41e8217, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

formatting

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