[2bb4a01] | 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"
|
---|
[c92bdcc] | 21 | #include "Common/CodeLocation.hpp"
|
---|
[2bb4a01] | 22 |
|
---|
| 23 | namespace ast {
|
---|
| 24 |
|
---|
[a300e4a] | 25 | namespace Linkage {
|
---|
[2bb4a01] | 26 |
|
---|
[260dad7] | 27 | /// Bitflags for linkage specifiers
|
---|
| 28 | enum {
|
---|
| 29 | Mangle = 1 << 0,
|
---|
| 30 | Generate = 1 << 1,
|
---|
| 31 | Overrideable = 1 << 2,
|
---|
| 32 | Builtin = 1 << 3,
|
---|
[c7ebbec] | 33 | Overloadable = 1 << 4,
|
---|
[260dad7] | 34 | };
|
---|
[a300e4a] | 35 |
|
---|
[260dad7] | 36 | /// Bitflag type for storage classes
|
---|
| 37 | struct 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;
|
---|
[c7ebbec] | 45 | bool is_overloadable : 1;
|
---|
[2bb4a01] | 46 | };
|
---|
[a300e4a] | 47 | };
|
---|
[2bb4a01] | 48 |
|
---|
[260dad7] | 49 | constexpr spec_flags( unsigned int val ) : val(val) {}
|
---|
| 50 | };
|
---|
| 51 |
|
---|
| 52 | using Spec = bitfield<spec_flags>;
|
---|
| 53 |
|
---|
[c7ebbec] | 54 | /// Updates `spec` based on `cmd` (should be "C" or "Cforall").
|
---|
| 55 | Spec update( const CodeLocation & loc, Spec spec, const std::string * cmd );
|
---|
[260dad7] | 56 |
|
---|
| 57 | /// A human-readable name for this spec
|
---|
| 58 | std::string name( Spec spec );
|
---|
| 59 |
|
---|
| 60 | // Pre-defined flag combinations
|
---|
| 61 |
|
---|
| 62 | /// C built-in defined in prelude
|
---|
[c7ebbec] | 63 | constexpr Spec Intrinsic = { Mangle | Generate | Overrideable | Builtin | Overloadable };
|
---|
[260dad7] | 64 | /// Ordinary Cforall
|
---|
[c7ebbec] | 65 | constexpr Spec Cforall = { Mangle | Generate | Overloadable };
|
---|
[260dad7] | 66 | /// C code: not overloadable, not mangled
|
---|
| 67 | constexpr Spec C = { Generate };
|
---|
| 68 | /// Built by translator (e.g. struct assignment)
|
---|
[c7ebbec] | 69 | constexpr Spec AutoGen = { Mangle | Generate | Overrideable | Overloadable };
|
---|
[260dad7] | 70 | /// GCC internal
|
---|
[c7ebbec] | 71 | constexpr Spec Compiler = { Builtin | Overloadable };
|
---|
[260dad7] | 72 | /// Mangled builtins
|
---|
[c7ebbec] | 73 | constexpr Spec BuiltinCFA = { Mangle | Generate | Builtin | Overloadable };
|
---|
[260dad7] | 74 | /// Non-mangled builtins
|
---|
| 75 | constexpr Spec BuiltinC = { Generate | Builtin };
|
---|
| 76 |
|
---|
[a300e4a] | 77 | }
|
---|
[2bb4a01] | 78 |
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | // Local Variables: //
|
---|
| 82 | // tab-width: 4 //
|
---|
| 83 | // mode: c++ //
|
---|
| 84 | // compile-command: "make install" //
|
---|
| 85 | // End: //
|
---|