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