[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 | // |
---|
[79970ed] | 7 | // LinkageSpec.cc -- |
---|
| 8 | // |
---|
[b87a5ed] | 9 | // Author : Rodolfo G. Esteves |
---|
| 10 | // Created On : Sat May 16 13:22:09 2015 |
---|
[fa4805f] | 11 | // Last Modified By : Andrew Beach |
---|
| 12 | // Last Modified On : Wed Jun 28 11:51:00 2017 |
---|
| 13 | // Update Count : 24 |
---|
[79970ed] | 14 | // |
---|
[b87a5ed] | 15 | |
---|
[f2a4f6c] | 16 | #include <memory> |
---|
[51b7345] | 17 | #include <string> |
---|
| 18 | #include <cassert> |
---|
[faddbd8] | 19 | using namespace std; |
---|
[51b7345] | 20 | |
---|
| 21 | #include "LinkageSpec.h" |
---|
[d3b7937] | 22 | #include "Common/SemanticError.h" |
---|
[51b7345] | 23 | |
---|
[faddbd8] | 24 | LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) { |
---|
| 25 | unique_ptr<const string> guard( spec ); // allocated by lexer |
---|
| 26 | if ( *spec == "\"Cforall\"" ) { |
---|
[b87a5ed] | 27 | return Cforall; |
---|
[faddbd8] | 28 | } else if ( *spec == "\"C\"" ) { |
---|
[b87a5ed] | 29 | return C; |
---|
[fa4805f] | 30 | } else if ( *spec == "\"BuiltinC\"" ) { |
---|
| 31 | return BuiltinC; |
---|
[b87a5ed] | 32 | } else { |
---|
[faddbd8] | 33 | throw SemanticError( "Invalid linkage specifier " + *spec ); |
---|
[ab57786] | 34 | } // if |
---|
[51b7345] | 35 | } |
---|
| 36 | |
---|
[faddbd8] | 37 | string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) { |
---|
| 38 | assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs ); |
---|
[8b7ee09] | 39 | static const char *linkageKinds[LinkageSpec::NoOfSpecs] = { |
---|
[fa4805f] | 40 | "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in", "cfa built-in", "c built-in", |
---|
[3b8e52c] | 41 | }; |
---|
| 42 | return linkageKinds[linkage]; |
---|
[51b7345] | 43 | } |
---|
| 44 | |
---|
[fa4805f] | 45 | bool LinkageSpec::isMangled( Spec spec ) { |
---|
[faddbd8] | 46 | assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs ); |
---|
[8b7ee09] | 47 | static bool decoratable[LinkageSpec::NoOfSpecs] = { |
---|
[fa4805f] | 48 | // Intrinsic, Cforall, C, AutoGen, Compiler, |
---|
[79970ed] | 49 | true, true, false, true, false, |
---|
[fa4805f] | 50 | // Builtin, BuiltinC, |
---|
| 51 | true, false, |
---|
[3b8e52c] | 52 | }; |
---|
[ab57786] | 53 | return decoratable[spec]; |
---|
[51b7345] | 54 | } |
---|
| 55 | |
---|
[ab57786] | 56 | bool LinkageSpec::isGeneratable( Spec spec ) { |
---|
[faddbd8] | 57 | assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs ); |
---|
[8b7ee09] | 58 | static bool generatable[LinkageSpec::NoOfSpecs] = { |
---|
[fa4805f] | 59 | // Intrinsic, Cforall, C, AutoGen, Compiler, |
---|
[79970ed] | 60 | true, true, true, true, false, |
---|
[fa4805f] | 61 | // Builtin, BuiltinC, |
---|
| 62 | true, true, |
---|
[3b8e52c] | 63 | }; |
---|
[ab57786] | 64 | return generatable[spec]; |
---|
[51b7345] | 65 | } |
---|
| 66 | |
---|
[ab57786] | 67 | bool LinkageSpec::isOverridable( Spec spec ) { |
---|
[79970ed] | 68 | assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs ); |
---|
[8b7ee09] | 69 | static bool overridable[LinkageSpec::NoOfSpecs] = { |
---|
[fa4805f] | 70 | // Intrinsic, Cforall, C, AutoGen, Compiler, |
---|
[79970ed] | 71 | true, false, false, true, false, |
---|
[fa4805f] | 72 | // Builtin, BuiltinC, |
---|
| 73 | false, false, |
---|
[3b8e52c] | 74 | }; |
---|
[ab57786] | 75 | return overridable[spec]; |
---|
[4aa0858] | 76 | } |
---|
| 77 | |
---|
[ab57786] | 78 | bool LinkageSpec::isBuiltin( Spec spec ) { |
---|
[79970ed] | 79 | assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs ); |
---|
[8b7ee09] | 80 | static bool builtin[LinkageSpec::NoOfSpecs] = { |
---|
[fa4805f] | 81 | // Intrinsic, Cforall, C, AutoGen, Compiler, |
---|
[79970ed] | 82 | true, false, false, false, true, |
---|
[fa4805f] | 83 | // Builtin, BuiltinC, |
---|
| 84 | true, true, |
---|
[3b8e52c] | 85 | }; |
---|
[ab57786] | 86 | return builtin[spec]; |
---|
[51b7345] | 87 | } |
---|
[b87a5ed] | 88 | |
---|
| 89 | // Local Variables: // |
---|
| 90 | // tab-width: 4 // |
---|
| 91 | // mode: c++ // |
---|
| 92 | // compile-command: "make install" // |
---|
| 93 | // End: // |
---|