source: src/SynTree/LinkageSpec.h @ 1e2de89

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 1e2de89 was 1e2de89, checked in by Andrew Beach <ajbeach@…>, 4 years ago

Wandered into LinkageSpec? and moved an include out of the header.

  • Property mode set to 100644
File size: 2.5 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
[1e2de89]11// Last Modified By : Andrew Beach
12// Last Modified On : Mon Mar  2 16:13:00 2020
13// Update Count     : 21
[b87a5ed]14//
15
[6b0b624]16#pragma once
[51b7345]17
18#include <string>
19
[1e2de89]20struct CodeLocation;
[d55d7a6]21
[54d714e]22namespace LinkageSpec {
[d912bed]23        // Bitflags for linkage specifiers
24        enum {
25                Mangle = 1 << 0,
26                Generate = 1 << 1,
27                Overrideable = 1 << 2,
28                Builtin = 1 << 3,
29                GccBuiltin = 1 << 4,
30        };
[54d714e]31
[d912bed]32        // Bitflag type for storage classes
[54d714e]33        union Spec {
34                unsigned int val;
35                struct {
36                        bool is_mangled : 1;
37                        bool is_generatable : 1;
38                        bool is_overridable : 1;
39                        bool is_builtin : 1;
[13073be]40                        bool is_gcc_builtin : 1;
[54d714e]41                };
42                constexpr Spec( unsigned int val ) : val( val ) {}
[41e8217]43                constexpr Spec( Spec const & other ) : val( other.val ) {}
[39156ed]44                constexpr Spec & operator=( const Spec & ) = default;
[54d714e]45                // Operators may go here.
46                // Supports == and !=
[41e8217]47                constexpr operator unsigned int() const { return val; }
[b87a5ed]48        };
[54d714e]49
50
[d912bed]51        Spec update( CodeLocation location, Spec spec, const std::string * cmd );
52        // If cmd = "C" returns a Spec that is old_spec with is_mangled = false
53        // If cmd = "Cforall" returns old_spec Spec with is_mangled = true
[54d714e]54
[d912bed]55        std::string name( Spec );
[54d714e]56
57        // To Update: LinkageSpec::isXyz( cur_spec ) -> cur_spec.is_xyz
58        inline bool isMangled( Spec spec ) { return spec.is_mangled; }
59        inline bool isGeneratable( Spec spec ) { return spec.is_generatable; }
60        inline bool isOverridable( Spec spec ) { return spec.is_overridable; }
61        inline bool isBuiltin( Spec spec ) { return spec.is_builtin; }
[13073be]62        inline bool isGccBuiltin( Spec spec ) { return spec.is_gcc_builtin; }
[54d714e]63
64        // Pre-defined flag combinations:
65        // C built-in defined in prelude
66        constexpr Spec const Intrinsic = { Mangle | Generate | Overrideable | Builtin };
67        // ordinary
68        constexpr Spec const Cforall = { Mangle | Generate };
69        // not overloadable, not mangled
70        constexpr Spec const C = { Generate };
71        // built by translator (struct assignment)
72        constexpr Spec const AutoGen = { Mangle | Generate | Overrideable };
73        // gcc internal
[13073be]74        constexpr Spec const Compiler = { Mangle | Builtin | GccBuiltin };
[54d714e]75        // mangled builtins
76        constexpr Spec const BuiltinCFA = { Mangle | Generate | Builtin };
77        // non-mangled builtins
78        constexpr Spec const BuiltinC = { Generate | Builtin };
[51b7345]79};
80
[b87a5ed]81// Local Variables: //
82// tab-width: 4 //
83// mode: c++ //
84// compile-command: "make install" //
85// End: //
Note: See TracBrowser for help on using the repository browser.