main['GCC'] = CXX_version and CXX_version.find('g++') >= 0
main['SUNCC'] = CXX_V and CXX_V.find('Sun C++') >= 0
main['ICC'] = CXX_V and CXX_V.find('Intel') >= 0
-main['CLANG'] = CXX_V and CXX_V.find('clang') >= 0
+main['CLANG'] = CXX_version and CXX_version.find('clang') >= 0
if main['GCC'] + main['SUNCC'] + main['ICC'] + main['CLANG'] > 1:
print 'Error: How can we have two at the same time?'
Exit(1)
main.Append(CCFLAGS=['-pipe'])
main.Append(CCFLAGS=['-fno-strict-aliasing'])
main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
- main.Append(CXXFLAGS=['-Wno-deprecated'])
# Read the GCC version to check for versions with bugs
# Note CCVERSION doesn't work here because it is run with the CC
# before we override it from the command line
not compareVersions(gcc_version, '4.4.2'):
print 'Info: Tree vectorizer in GCC 4.4.1 & 4.4.2 is buggy, disabling.'
main.Append(CCFLAGS=['-fno-tree-vectorize'])
+ if compareVersions(gcc_version, '4.6') >= 0:
+ main.Append(CXXFLAGS=['-std=c++0x'])
elif main['ICC']:
pass #Fix me... add warning flags once we clean up icc warnings
elif main['SUNCC']:
main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef'])
main.Append(CCFLAGS=['-Wno-tautological-compare'])
main.Append(CCFLAGS=['-Wno-self-assign'])
+ # Ruby makes frequent use of extraneous parantheses in the printing
+ # of if-statements
+ main.Append(CCFLAGS=['-Wno-parentheses'])
+
+ if compareVersions(clang_version, "3") >= 0:
+ main.Append(CXXFLAGS=['-std=c++0x'])
else:
print 'Error: Don\'t know what compiler options to use for your compiler.'
print ' Please fix SConstruct and src/SConscript and try again.'
Import('main')
+from m5.util import compareVersions
+
elf_files = []
def ElfFile(filename):
elf_files.append(File(filename))
m4env = main.Clone()
if m4env['GCC']:
- major,minor,dot = [int(x) for x in m4env['GCC_VERSION'].split('.')]
- if major >= 4:
+ if compareVersions(m4env['GCC_VERSION'], '4') >= 0:
m4env.Append(CCFLAGS=['-Wno-pointer-sign'])
+ if compareVersions(m4env['GCC_VERSION'], '4.6') >= 0:
+ m4env.Append(CCFLAGS=['-Wno-unused-but-set-variable',
+ '-Wno-implicit-function-declaration'])
if m4env['CLANG']:
m4env.Append(CCFLAGS=['-Wno-initializer-overrides', '-Wno-pointer-sign'])
m4env.Append(CCFLAGS=['-Wno-implicit'])
namespace {
-const char data_${sym}[] = {
+const uint8_t data_${sym}[] = {
''')
code.indent()
step = 16
swig_env.Append(CCFLAGS='-Wno-sign-compare')
swig_env.Append(CCFLAGS='-Wno-parentheses')
swig_env.Append(CCFLAGS='-Wno-unused-label')
- if compareVersions(env['GCC_VERSION'], '4.6.0') != -1:
+ if compareVersions(env['GCC_VERSION'], '4.6') >= 0:
swig_env.Append(CCFLAGS='-Wno-unused-but-set-variable')
if env['CLANG']:
swig_env.Append(CCFLAGS=['-Wno-unused-label'])
# Debug binary
ccflags = {}
-if env['GCC'] or env['CLANG']:
+if env['GCC']:
if sys.platform == 'sunos5':
ccflags['debug'] = '-gstabs+'
else:
ccflags['opt'] = '-g -O'
ccflags['fast'] = '-fast'
ccflags['prof'] = '-fast -g -pg'
+elif env['CLANG']:
+ ccflags['debug'] = '-g -O0'
+ ccflags['opt'] = '-g -O3'
+ ccflags['fast'] = '-O3'
+ ccflags['prof'] = '-O3 -g -pg'
else:
print 'Unknown compiler, please fix compiler options'
Exit(1)
}};
output exec {{
-#include <math.h>
+#include <cmath>
#include "arch/alpha/registers.hh"
#include "arch/alpha/regredir.hh"
#include "base/bitfield.hh"
#include "base/misc.hh"
#include "base/trace.hh"
-using namespace std;
namespace AlphaISA
{
#include "sim/sim_exit.hh"
using namespace ArmISA;
-using std::isnan;
+
}};
} // namespace ArmISA
-namespace __hash_namespace {
+__hash_namespace_begin
template<>
struct hash<ArmISA::ExtMachInst> : public hash<uint32_t> {
size_t operator()(const ArmISA::ExtMachInst &emi) const {
return hash<uint32_t>::operator()((uint32_t)emi);
};
};
-}
+__hash_namespace_end
#endif
}};
output decoder {{
-#include <math.h>
+#include <cmath>
#include "arch/mips/dsp.hh"
#include "arch/mips/dt_constants.hh"
}};
output exec {{
-#include <math.h>
+#include <cmath>
#include "arch/generic/memhelpers.hh"
#include "arch/mips/dsp.hh"
#include "cpu/thread_context.hh"
using namespace PowerISA;
-using std::isnan;
}};
output exec {{
#include "sim/sim_exit.hh"
using namespace PowerISA;
-using std::isnan;
}};
} // PowerISA namespace
-namespace __hash_namespace {
+__hash_namespace_begin
template<>
struct hash<PowerISA::ExtMachInst> : public hash<uint32_t> {
};
};
-} // namespace __hash_namespace
+__hash_namespace_end
#endif // __ARCH_POWER_TYPES_HH__
0x47: FpUnimpl::fmovrqlez();
0x51: fcmps({{
uint8_t fcc;
- if (isnan(Frs1s) || isnan(Frs2s))
+ if (std::isnan(Frs1s) || std::isnan(Frs2s))
fcc = 3;
else if (Frs1s < Frs2s)
fcc = 1;
}});
0x52: fcmpd({{
uint8_t fcc;
- if (isnan(Frs1) || isnan(Frs2))
+ if (std::isnan(Frs1) || std::isnan(Frs2))
fcc = 3;
else if (Frs1 < Frs2)
fcc = 1;
0x53: FpUnimpl::fcmpq();
0x55: fcmpes({{
uint8_t fcc = 0;
- if (isnan(Frs1s) || isnan(Frs2s))
+ if (std::isnan(Frs1s) || std::isnan(Frs2s))
fault = new FpExceptionIEEE754;
if (Frs1s < Frs2s)
fcc = 1;
}});
0x56: fcmped({{
uint8_t fcc = 0;
- if (isnan(Frs1) || isnan(Frs2))
+ if (std::isnan(Frs1) || std::isnan(Frs2))
fault = new FpExceptionIEEE754;
if (Frs1 < Frs2)
fcc = 1;
#include "base/bitfield.hh"
#include "base/misc.hh"
#include "base/trace.hh"
-using namespace std;
namespace SparcISA
{
if (intersect(r))
return tree.end();
- return tree.insert(std::make_pair<TlbRange,TlbEntry*>(r, d)).first;
+ return tree.insert(std::make_pair(r, d)).first;
}
size_t
// OF = SF = AF = 0
ccFlagBits = ccFlagBits & ~(OFBit | SFBit | AFBit |
ZFBit | PFBit | CFBit);
- if (isnan(FpSrcReg1) || isnan(FpSrcReg2))
+ if (std::isnan(FpSrcReg1) || std::isnan(FpSrcReg2))
ccFlagBits = ccFlagBits | (ZFBit | PFBit | CFBit);
else if(FpSrcReg1 < FpSrcReg2)
ccFlagBits = ccFlagBits | CFBit;
}
uint64_t resBits = 0;
- bool nanop = isnan(arg1) || isnan(arg2);
+ bool nanop = std::isnan(arg1) || std::isnan(arg2);
switch (ext & mask(3)) {
case 0:
if (arg1 == arg2 && !nanop)
// OF = SF = AF = 0
ccFlagBits = ccFlagBits & ~(OFBit | SFBit | AFBit |
ZFBit | PFBit | CFBit);
- if (isnan(arg1) || isnan(arg2))
+ if (std::isnan(arg1) || std::isnan(arg2))
ccFlagBits = ccFlagBits | (ZFBit | PFBit | CFBit);
else if(arg1 < arg2)
ccFlagBits = ccFlagBits | CFBit;
}
-namespace __hash_namespace {
+__hash_namespace_begin
template<>
struct hash<X86ISA::ExtMachInst> {
size_t operator()(const X86ISA::ExtMachInst &emi) const {
emi.stackSize ^ emi.dispSize;
};
};
-}
+__hash_namespace_end
// These two functions allow ExtMachInst to be used with SERIALIZE_SCALAR
// and UNSERIALIZE_SCALAR.
/*
+ * Copyright (c) 2012 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2003-2005 The Regents of The University of Michigan
* All rights reserved.
*
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
+ * Andreas Hansson
*/
#ifndef __HASHMAP_HH__
#define __HASHMAP_HH__
-#if defined(__GNUC__) && __GNUC__ >= 3
+#if defined(__GNUC__)
+
+// for compilers that deprecate ext/hash_map, i.e. gcc >= 4.3 and
+// clang, use unordered_map
+
+// we need to determine what is available, as in the non-c++0x case,
+// e.g. gcc >= 4.3 and <= 4.5, the containers are in the std::tr1
+// namespace, and only gcc >= 4.6 (with -std=c++0x) adds the final
+// container implementation in the std namespace
+
+#if defined(__clang__)
+// align with -std=c++0x only for clang >= 3.0 in CCFLAGS and also
+// check if the header is present as this depends on what clang was
+// built against, using XCode clang 3.1, for example, the header is
+// not present without adding -stdlib=libc++
+#if (__clang_major__ >= 3 && __has_include(<unordered_map>))
+#define HAVE_STD_UNORDERED_MAP 1
+#else
+// we only support clang versions above 2.9 and these all have the tr1
+// unordered_map
+#define HAVE_STD_TR1_UNORDERED_MAP 1
+#endif
+#else
+// align with -std=c++0x only for gcc >= 4.6 in CCFLAGS, contrary to
+// clang we can rely entirely on the compiler version
+#if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
+#define HAVE_STD_UNORDERED_MAP 1
+#else
+#define HAVE_STD_TR1_UNORDERED_MAP 1
+#endif
+#endif
+
+// set a default value of 0
+#ifndef HAVE_STD_UNORDERED_MAP
+#define HAVE_STD_UNORDERED_MAP 0
+#endif
+
+// set a default value of 0
+#ifndef HAVE_STD_TR1_UNORDERED_MAP
+#define HAVE_STD_TR1_UNORDERED_MAP 0
+#endif
+
+// now we are ready to deal with the actual includes based on what is
+// available
+#if (HAVE_STD_UNORDERED_MAP || HAVE_STD_TR1_UNORDERED_MAP)
+
+#define hash_map unordered_map
+#define hash_multimap unordered_multimap
+#define hash_set unordered_set
+#define hash_multiset unordered_multiset
+
+// these versions also have an existing hash function for strings
+#define HAVE_STRING_HASH 1
+
+#if HAVE_STD_UNORDERED_MAP
+
+// clang or gcc >= 4.6
+#include <unordered_map>
+#include <unordered_set>
+// note that this assumes that -std=c++0x is added to the command line
+// which is done in the SConstruct CXXFLAGS for gcc >= 4.6 and clang
+// >= 3.0
+#define __hash_namespace std
+#define __hash_namespace_begin namespace std {
+#define __hash_namespace_end }
+#else
+// clang <= 3.0, gcc >= 4.3 and < 4.6
+#include <tr1/unordered_map>
+#include <tr1/unordered_set>
+#define __hash_namespace std::tr1
+#define __hash_namespace_begin namespace std { namespace tr1 {
+#define __hash_namespace_end } }
+#endif
+#else
+// gcc < 4.3
#include <ext/hash_map>
#include <ext/hash_set>
+#define __hash_namespace __gnu_cxx
+#define __hash_namespace_begin namespace __gnu_cxx {
+#define __hash_namespace_end }
+#endif
#else
+// non GNU compiler
#include <hash_map>
#include <hash_set>
+#define __hash_namsepace std
+#define __hash_namespace_begin namespace std {
+#define __hash_namespace_end }
#endif
#include <string>
#include "base/types.hh"
-#if defined(__GNUC__) && __GNUC__ >= 3
- #define __hash_namespace __gnu_cxx
-#else
- #define __hash_namespace std
-#endif
-
namespace m5 {
using ::__hash_namespace::hash_multimap;
using ::__hash_namespace::hash_multiset;
// Some default Hashing Functions
//
-namespace __hash_namespace {
-#if defined(__APPLE__) || !defined(__LP64__) && !defined(__alpha__) && !defined(__SUNPRO_CC)
+__hash_namespace_begin
+#if !defined(__LP64__) && !defined(__alpha__) && !defined(__SUNPRO_CC)
template<>
struct hash<uint64_t> {
size_t operator()(uint64_t r) const {
};
#endif
+// if the hash functions for strings are not already defined, then
+// declare them here
+#if !defined(HAVE_STRING_HASH)
template<>
struct hash<std::string> {
size_t operator()(const std::string &s) const {
return (__stl_hash_string(r.first.c_str())) ^ r.second;
}
};
-} // namespace __hash_namespace
+#endif
+__hash_namespace_end
#endif // __HASHMAP_HH__
* Steve Reinhardt
*/
+#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
inline bool
operator<(const Range<T> &range, const U &pos)
{
- return range.end < pos;
+ // with -std=gnu++0x, gcc and clang get confused when range.end is
+ // compared to pos using the operator "<", and the parser expects it
+ // to be the opening bracket for a template parameter,
+ // i.e. range.end<pos>(...);, the reason seems to be the range-type
+ // iteration introduced in c++11 where begin and end are members
+ // that return iterators
+ return operator<(range.end, pos);
}
/**
{
stringstream val;
- if (!isnan(value)) {
+ if (!std::isnan(value)) {
if (precision != -1)
val.precision(precision);
else if (value == rint(value))
ScalarPrint::operator()(ostream &stream) const
{
if ((flags.isSet(nozero) && value == 0.0) ||
- (flags.isSet(nonan) && isnan(value)))
+ (flags.isSet(nonan) && std::isnan(value)))
return;
stringstream pdfstr, cdfstr;
- if (!isnan(pdf))
+ if (!std::isnan(pdf))
ccprintf(pdfstr, "%.2f%%", pdf * 100.0);
- if (!isnan(cdf))
+ if (!std::isnan(cdf))
ccprintf(cdfstr, "%.2f%%", cdf * 100.0);
ccprintf(stream, "%-40s %12s %10s %10s", name,
inFrontEnd(true), frontSked(NULL), backSked(NULL),
squashingStage(0), predictTaken(false), procDelaySlotOnMispred(false),
fetchMemReq(NULL), dataMemReq(NULL), instEffAddr(0), eaCalcDone(false),
- lqIdx(0), sqIdx(0), instListIt(NULL), onInstList(false)
+ lqIdx(0), sqIdx(0), onInstList(false)
{
for(int i = 0; i < MaxInstSrcRegs; i++) {
_readySrcRegIdx[i] = false;
#include <cassert>
#include <iomanip>
+#include <iostream>
#include "base/hashmap.hh"
#include "mem/ruby/common/TypeDefines.hh"
return (m_address >> number);
}
-class Address;
-namespace __hash_namespace {
+__hash_namespace_begin
template <> struct hash<Address>
{
size_t
return (size_t)s.getAddress();
}
};
-} // namespace __hash_namespace
+__hash_namespace_end
namespace std {
template <> struct equal_to<Address>
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <algorithm>
+
#include "mem/ruby/common/NetDest.hh"
NetDest::NetDest()
* Proceedings of the 48th Design Automation Conference (DAC'11)
*/
-// C includes
-#include <assert.h>
-#include <stdio.h>
-
// C++ includes
+#include <cassert>
#include <fstream>
#include <iostream>
#include <vector>
#include "FaultModel.hh"
#include "base/misc.hh"
+using namespace std;
+
#define MAX(a,b) ((a > b) ? (a) : (b))
// C++ includes
#include <string>
-using namespace std;
// GEM5 includes
#include "params/FaultModel.hh"
int number_of_buff_per_data_vc,
int number_of_buff_per_ctrl_vc);
- string fault_type_to_string(int fault_type_index);
+ std::string fault_type_to_string(int fault_type_index);
// the following 2 functions are called at runtime, to get the probability
// of each fault type (fault_vector) or the aggregate fault probability
void print(void);
private:
- vector <system_conf> configurations;
- vector <system_conf> routers;
- vector <int> temperature_weights;
+ std::vector <system_conf> configurations;
+ std::vector <system_conf> routers;
+ std::vector <int> temperature_weights;
};
#endif // __MEM_RUBY_NETWORK_FAULT_MODEL_HH__
#include "mem/ruby/network/Topology.hh"
#include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
+using namespace std;
+
BaseGarnetNetwork::BaseGarnetNetwork(const Params *p)
: Network(p)
{
#include "mem/ruby/network/orion/Type.hh"
-using namespace std;
-
class TechParameter;
class OrionConfig
void set_in_buf_num_set(uint32_t in_buf_num_set_);
void set_flit_width(uint32_t flit_width_);
- void read_file(const string& filename_);
- void print_config(ostream& out_);
+ void read_file(const std::string& filename_);
+ void print_config(std::ostream& out_);
public:
template<class T>
- T get(const string& key_) const;
+ T get(const std::string& key_) const;
const TechParameter* get_tech_param_ptr() const { return m_tech_param_ptr; }
uint32_t get_num_in_port() const { return m_num_in_port; }
uint32_t get_num_out_port() const { return m_num_out_port; }
uint32_t get_flit_width() const { return m_flit_width; }
private:
- map<string, string> m_params_map;
+ std::map<std::string, std::string> m_params_map;
TechParameter* m_tech_param_ptr;
uint32_t m_num_in_port;
protected:
struct key_not_found
{
- string m_key;
- key_not_found(const string& key_ = string()) : m_key(key_)
+ std::string m_key;
+ key_not_found(const std::string& key_ = string()) : m_key(key_)
{}
};
template<class T>
- static T string_as_T(const string& str_);
+ static T string_as_T(const std::string& str_);
template<class T>
- static string T_as_string(const T& t_);
+ static std::string T_as_string(const T& t_);
private:
- static string ms_param_name[];
+ static std::string ms_param_name[];
};
template<class T>
T OrionConfig::get(const string& key_) const
{
- map<string, string>::const_iterator it;
+ std::map<std::string, std::string>::const_iterator it;
it = m_params_map.find(key_);
if (it == m_params_map.end())
{
- cerr << key_ << " NOT FOUND!" << endl;
+ std::cerr << key_ << " NOT FOUND!" << std::endl;
throw key_not_found(key_);
}
return string_as_T<T>(it->second);
}
else
{
- cerr << "Invalid bool value: '" << str_ << "'. Treated as FALSE." << endl;
+ std::cerr << "Invalid bool value: '" << str_ <<
+ "'. Treated as FALSE." << std::endl;
ret = false;
}
return ret;
#include "mem/ruby/network/orion/OrionConfig.hh"
#include "OrionRouter.hh"
+using namespace std;
+
OrionRouter::OrionRouter(
uint32_t num_in_port_,
uint32_t num_out_port_,
#include "mem/ruby/network/orion/Type.hh"
-using namespace std;
-
class OrionConfig;
class TechParameter
// Allows use of times() library call, which determines virtual runtime
#include <sys/resource.h>
#include <sys/times.h>
+#include <sys/types.h>
+#include <unistd.h>
#include <algorithm>
#include <fstream>
Address line_address = address;
line_address.makeLineAddress();
PerfectCacheLineState<ENTRY>& line_state = m_map[line_address];
- AccessPermission old_perm = line_state.m_permission;
line_state.m_permission = new_perm;
}
* Created by slicc definition of Module "${{self.short}}"
*/
+#include <sys/types.h>
+#include <unistd.h>
+
#include <cassert>
#include <sstream>
#include <string>
// Auto generated C++ code started by $__file__:$__line__
// ${ident}: ${{self.short}}
+#include <sys/types.h>
+#include <unistd.h>
+
#include <cassert>
#include "base/misc.hh"
EmbeddedPython *EmbeddedPython::importer = NULL;
PyObject *EmbeddedPython::importerModule = NULL;
EmbeddedPython::EmbeddedPython(const char *filename, const char *abspath,
- const char *modpath, const char *code, int zlen, int len)
+ const char *modpath, const unsigned char *code, int zlen, int len)
: filename(filename), abspath(abspath), modpath(modpath), code(code),
zlen(zlen), len(len)
{
*/
#include <list>
+#include <inttypes.h>
+
#ifndef PyObject_HEAD
struct _object;
typedef _object PyObject;
const char *filename;
const char *abspath;
const char *modpath;
- const char *code;
+ const uint8_t *code;
int zlen;
int len;
EmbeddedPython(const char *filename, const char *abspath,
- const char *modpath, const char *code, int zlen, int len);
+ const char *modpath, const uint8_t *code, int zlen, int len);
PyObject *getCode() const;
bool addModule() const;