mageec  0.1.0
MAchine Guided Energy Efficient Compilation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
mageec.cpp
Go to the documentation of this file.
1 /* MAGEEC Main Coordinator
2  Copyright (C) 2013, 2014 Embecosm Limited and University of Bristol
3 
4  This file is part of MAGEEC.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 
20 #include "mageec/mageec.h"
21 #include "mageec/mageec-ml.h"
22 #include <iostream>
23 
24 using namespace mageec;
25 
26 int mageec_framework::init (std::string compiler_version,
27  std::string compiler_target)
28 {
29  std::cerr << "MAGEEC: Targetting '" << compiler_version << "' for '"
30  << compiler_target << "'" << std::endl;
31 
32  return ml.init (compiler_version, compiler_target);
33 }
34 
35 void mageec_framework::new_file (std::string filename)
36 {
37  std::cerr << "MAGEEC: New source file " << filename << std::endl;
38  featset.clear();
39  ml.new_file();
40 }
41 
43 {
44  std::cerr << "MAGEEC: End of source file" << std::endl;
45  featset.clear();
46  ml.end_file();
47 }
48 
50 {
51  std::cerr << "MAGEEC: Finish" << std::endl;
52  ml.finish();
53 }
54 
55 std::vector<mageec_pass*> mageec_framework::all_passes (void)
56 {
57  return ml.all_passes();
58 }
59 
60 void mageec_framework::take_features (std::string name,
61  std::vector<mageec_feature*> features)
62 {
63  featset[name] = features;
64 }
65 
67  std::string function)
68 {
69  // If we don't have a feature set, we use the compiler's decision.
70  if (featset.count(function) == 0)
71  return NATIVE_DECISION;
72 
73  std::vector<mageec_feature*> featureset = featset[function];
74 
75  mageec_pass *mpass = new basic_pass(pass);
76  decision d = ml.make_decision(mpass, featureset);
77  return d;
78 }