source: src/AST/LinkageSpec.hpp @ 221c542e

Last change on this file since 221c542e was c7ebbec, checked in by Andrew Beach <ajbeach@…>, 11 months ago

Reorganization of Linkage::Spec. is_mangled represented two properties with is_gcc_builtin separating them in one case. The second property is_overloadable which replaces is_gcc_builtin.

  • Property mode set to 100644
File size: 2.0 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.hpp --
8//
9// Author           : Aaron B. Moss
10// Created On       : Thu May 9 10:00:00 2019
11// Last Modified By : Aaron B. Moss
12// Last Modified On : Thu May 9 10:00:00 2019
13// Update Count     : 1
14//
15
16#pragma once
17
18#include <string>
19
20#include "Bitfield.hpp"
21#include "Common/CodeLocation.h"
22
23namespace ast {
24
25namespace Linkage {
26
27/// Bitflags for linkage specifiers
28enum {
29        Mangle       = 1 << 0,
30        Generate     = 1 << 1,
31        Overrideable = 1 << 2,
32        Builtin      = 1 << 3,
33        Overloadable = 1 << 4,
34};
35
36/// Bitflag type for storage classes
37struct spec_flags {
38        union {
39                unsigned int val;
40                struct {
41                        bool is_mangled      : 1;
42                        bool is_generatable  : 1;
43                        bool is_overrideable : 1;
44                        bool is_builtin      : 1;
45                        bool is_overloadable : 1;
46                };
47        };
48
49        constexpr spec_flags( unsigned int val ) : val(val) {}
50};
51
52using Spec = bitfield<spec_flags>;
53
54/// Updates `spec` based on `cmd` (should be "C" or "Cforall").
55Spec update( const CodeLocation & loc, Spec spec, const std::string * cmd );
56
57/// A human-readable name for this spec
58std::string name( Spec spec );
59
60// Pre-defined flag combinations
61
62/// C built-in defined in prelude
63constexpr Spec Intrinsic  = { Mangle | Generate | Overrideable | Builtin | Overloadable };
64/// Ordinary Cforall
65constexpr Spec Cforall    = { Mangle | Generate | Overloadable };
66/// C code: not overloadable, not mangled
67constexpr Spec C          = { Generate };
68/// Built by translator (e.g. struct assignment)
69constexpr Spec AutoGen    = { Mangle | Generate | Overrideable | Overloadable };
70/// GCC internal
71constexpr Spec Compiler   = { Builtin | Overloadable };
72/// Mangled builtins
73constexpr Spec BuiltinCFA = { Mangle | Generate | Builtin | Overloadable };
74/// Non-mangled builtins
75constexpr Spec BuiltinC   = { Generate | Builtin };
76
77}
78
79}
80
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.