diff --git a/SConstruct b/SConstruct --- a/SConstruct +++ b/SConstruct @@ -473,6 +473,7 @@ 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 if main['GCC'] + main['SUNCC'] + main['ICC'] > 1: print 'Error: How can we have two at the same time?' Exit(1) @@ -501,6 +502,16 @@ main.Append(CCFLAGS=['-library=stlport4']) main.Append(CCFLAGS=['-xar']) #main.Append(CCFLAGS=['-instances=semiexplicit']) +elif main['CLANG']: + main.Append(CCFLAGS=['-pipe']) + main.Append(CCFLAGS=['-fno-strict-aliasing']) + main.Append(CCFLAGS=['-Wall', '-Wno-sign-compare', '-Wundef']) + main.Append(CCFLAGS=['-Wno-overloaded-virtual', '-Wno-mismatched-tags']) + main.Append(CCFLAGS=['-Wno-self-assign', '-Wno-tautological-compare']) + main.Append(CCFLAGS=['-Wno-empty-body', '-Wno-unused-function']) + main.Append(CCFLAGS=['-Wno-sizeof-pointer-memaccess', '-Wno-unused-label']) + main.Append(CXXFLAGS=['-Wno-deprecated']) + else: print 'Error: Don\'t know what compiler options to use for your compiler.' print ' Please fix SConstruct and src/SConscript and try again.' diff --git a/src/SConscript b/src/SConscript --- a/src/SConscript +++ b/src/SConscript @@ -946,6 +946,11 @@ ccflags['opt'] = '-g -O' ccflags['fast'] = '-fast' ccflags['prof'] = '-fast -g -pg' +elif env['CLANG']: + ccflags['debug'] = '-ggdb3 -O0' + ccflags['opt'] = '-g -O3' + ccflags['fast'] = '-O3' + ccflags['prof'] = '-O3 -g -pg' else: print 'Unknown compiler, please fix compiler options' Exit(1) diff --git a/src/arch/alpha/isa_traits.hh b/src/arch/alpha/isa_traits.hh --- a/src/arch/alpha/isa_traits.hh +++ b/src/arch/alpha/isa_traits.hh @@ -132,4 +132,6 @@ } // namespace AlphaISA +using namespace AlphaISA; + #endif // __ARCH_ALPHA_ISA_TRAITS_HH__ diff --git a/src/arch/alpha/tlb.cc b/src/arch/alpha/tlb.cc --- a/src/arch/alpha/tlb.cc +++ b/src/arch/alpha/tlb.cc @@ -63,7 +63,7 @@ : BaseTLB(p), size(p->size), nlu(0) { table = new TlbEntry[size]; - memset(table, 0, sizeof(TlbEntry[size])); + memset(table, 0, sizeof(TlbEntry) * size); flushCache(); } @@ -279,7 +279,7 @@ TLB::flushAll() { DPRINTF(TLB, "flushAll\n"); - memset(table, 0, sizeof(TlbEntry[size])); + memset(table, 0, sizeof(TlbEntry) * size); flushCache(); lookupTable.clear(); nlu = 0; diff --git a/src/arch/arm/insts/static_inst.hh b/src/arch/arm/insts/static_inst.hh --- a/src/arch/arm/insts/static_inst.hh +++ b/src/arch/arm/insts/static_inst.hh @@ -46,6 +46,7 @@ #include "arch/arm/utility.hh" #include "base/trace.hh" #include "cpu/static_inst.hh" +#include "sim/byteswap.hh" namespace ArmISA { diff --git a/src/arch/arm/insts/vfp.hh b/src/arch/arm/insts/vfp.hh --- a/src/arch/arm/insts/vfp.hh +++ b/src/arch/arm/insts/vfp.hh @@ -107,6 +107,9 @@ VfpRoundZero = 3 }; +static inline float bitsToFp(uint64_t, float); +static inline uint32_t fpToBits(float); + template static inline bool flushToZero(fpType &op) diff --git a/src/arch/arm/isa/templates/basic.isa b/src/arch/arm/isa/templates/basic.isa --- a/src/arch/arm/isa/templates/basic.isa +++ b/src/arch/arm/isa/templates/basic.isa @@ -49,7 +49,8 @@ // Basic instruction class constructor template. def template BasicConstructor {{ - inline %(class_name)s::%(class_name)s(ExtMachInst machInst) : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s) + // Note: constructor should not inline + %(class_name)s::%(class_name)s(ExtMachInst machInst) : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s) { %(constructor)s; if (!(condCode == COND_AL || condCode == COND_UC)) { diff --git a/src/arch/x86/bios/intelmp.cc b/src/arch/x86/bios/intelmp.cc --- a/src/arch/x86/bios/intelmp.cc +++ b/src/arch/x86/bios/intelmp.cc @@ -78,7 +78,9 @@ uint8_t checkSum = 0; while(guestVal) { checkSum += guestVal; - guestVal >>= 8; + // clang++ says "shift count >= width of type" on + // "guestVal >>= 8" + guestVal /= 256; } return checkSum; } diff --git a/src/arch/x86/isa_traits.hh b/src/arch/x86/isa_traits.hh --- a/src/arch/x86/isa_traits.hh +++ b/src/arch/x86/isa_traits.hh @@ -87,4 +87,6 @@ }; }; +using namespace X86ISA; + #endif // __ARCH_X86_ISATRAITS_HH__ diff --git a/src/base/fast_alloc.cc b/src/base/fast_alloc.cc --- a/src/base/fast_alloc.cc +++ b/src/base/fast_alloc.cc @@ -40,10 +40,6 @@ #if USE_FAST_ALLOC -#ifdef __GNUC__ -#pragma implementation -#endif - void *FastAlloc::freeLists[Num_Buckets]; #if FAST_ALLOC_STATS diff --git a/src/base/range_map.hh b/src/base/range_map.hh --- a/src/base/range_map.hh +++ b/src/base/range_map.hh @@ -215,7 +215,7 @@ { std::pair p; p = find(r); - if (p.first->first.start == r.start && p.first->first.end == r.end || + if ((p.first->first.start == r.start && p.first->first.end == r.end) || p.first == tree.end()) return tree.insert(std::make_pair,V>(r, d)); else diff --git a/src/base/stl_helpers.hh b/src/base/stl_helpers.hh --- a/src/base/stl_helpers.hh +++ b/src/base/stl_helpers.hh @@ -72,7 +72,7 @@ // Treat all objects in an stl container as pointers to heap objects, // calling delete on each one and zeroing the pointers along the way -template class C, typename A> +template