summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2015-05-05 03:22:19 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2015-05-05 03:22:19 -0400
commitd0d933facc9085727c12f53de76a2cb879ded4c8 (patch)
tree6f4bbec33f85ff63e9804cafa00a735cad31c551 /src
parenteb1a9977bfcf53652cc7ddbb948ed63262b794be (diff)
downloadgem5-d0d933facc9085727c12f53de76a2cb879ded4c8.tar.xz
cpu: Work around gcc 4.9 issues with Num_OpClasses
This patch fixes a recent issue with gcc 4.9 (and possibly more) being convinced that indices outside the array bounds are used when initialising the FUPool members.
Diffstat (limited to 'src')
-rw-r--r--src/cpu/minor/execute.cc2
-rw-r--r--src/cpu/o3/fu_pool.cc6
-rw-r--r--src/cpu/o3/fu_pool.hh5
-rw-r--r--src/cpu/op_class.hh69
4 files changed, 40 insertions, 42 deletions
diff --git a/src/cpu/minor/execute.cc b/src/cpu/minor/execute.cc
index 706fdf010..ea325e28c 100644
--- a/src/cpu/minor/execute.cc
+++ b/src/cpu/minor/execute.cc
@@ -150,7 +150,7 @@ Execute::Execute(const std::string &name_,
}
/** Check that there is a functional unit for all operation classes */
- for (int op_class = No_OpClass + 1; op_class < Num_OpClass; op_class++) {
+ for (int op_class = No_OpClass + 1; op_class < Num_OpClasses; op_class++) {
bool found_fu = false;
unsigned int fu_index = 0;
diff --git a/src/cpu/o3/fu_pool.cc b/src/cpu/o3/fu_pool.cc
index dab7dbed2..b99eeab69 100644
--- a/src/cpu/o3/fu_pool.cc
+++ b/src/cpu/o3/fu_pool.cc
@@ -87,10 +87,8 @@ FUPool::FUPool(const Params *p)
funcUnits.clear();
- for (int i = 0; i < Num_OpClasses; ++i) {
- maxOpLatencies[i] = Cycles(0);
- pipelined[i] = true;
- }
+ maxOpLatencies.fill(Cycles(0));
+ pipelined.fill(true);
//
// Iterate through the list of FUDescData structures
diff --git a/src/cpu/o3/fu_pool.hh b/src/cpu/o3/fu_pool.hh
index 8b501fc81..e6bb8cb8e 100644
--- a/src/cpu/o3/fu_pool.hh
+++ b/src/cpu/o3/fu_pool.hh
@@ -43,6 +43,7 @@
#ifndef __CPU_O3_FU_POOL_HH__
#define __CPU_O3_FU_POOL_HH__
+#include <array>
#include <bitset>
#include <list>
#include <string>
@@ -71,9 +72,9 @@ class FUPool : public SimObject
{
private:
/** Maximum op execution latencies, per op class. */
- Cycles maxOpLatencies[Num_OpClasses];
+ std::array<Cycles, Num_OpClasses> maxOpLatencies;
/** Whether op is pipelined or not. */
- bool pipelined[Num_OpClasses];
+ std::array<bool, Num_OpClasses> pipelined;
/** Bitvector listing capabilities of this FU pool. */
std::bitset<Num_OpClasses> capabilityList;
diff --git a/src/cpu/op_class.hh b/src/cpu/op_class.hh
index 2dc7a3674..ffdd84eb4 100644
--- a/src/cpu/op_class.hh
+++ b/src/cpu/op_class.hh
@@ -51,41 +51,40 @@
*/
using Enums::OpClass;
using Enums::No_OpClass;
-using Enums::Num_OpClass;
-const OpClass IntAluOp = Enums::IntAlu;
-const OpClass IntMultOp = Enums::IntMult;
-const OpClass IntDivOp = Enums::IntDiv;
-const OpClass FloatAddOp = Enums::FloatAdd;
-const OpClass FloatCmpOp = Enums::FloatCmp;
-const OpClass FloatCvtOp = Enums::FloatCvt;
-const OpClass FloatMultOp = Enums::FloatMult;
-const OpClass FloatDivOp = Enums::FloatDiv;
-const OpClass FloatSqrtOp = Enums::FloatSqrt;
-const OpClass SimdAddOp = Enums::SimdAdd;
-const OpClass SimdAddAccOp = Enums::SimdAddAcc;
-const OpClass SimdAluOp = Enums::SimdAlu;
-const OpClass SimdCmpOp = Enums::SimdCmp;
-const OpClass SimdCvtOp = Enums::SimdCvt;
-const OpClass SimdMiscOp = Enums::SimdMisc;
-const OpClass SimdMultOp = Enums::SimdMult;
-const OpClass SimdMultAccOp = Enums::SimdMultAcc;
-const OpClass SimdShiftOp = Enums::SimdShift;
-const OpClass SimdShiftAccOp = Enums::SimdShiftAcc;
-const OpClass SimdSqrtOp = Enums::SimdSqrt;
-const OpClass SimdFloatAddOp = Enums::SimdFloatAdd;
-const OpClass SimdFloatAluOp = Enums::SimdFloatAlu;
-const OpClass SimdFloatCmpOp = Enums::SimdFloatCmp;
-const OpClass SimdFloatCvtOp = Enums::SimdFloatCvt;
-const OpClass SimdFloatDivOp = Enums::SimdFloatDiv;
-const OpClass SimdFloatMiscOp = Enums::SimdFloatMisc;
-const OpClass SimdFloatMultOp = Enums::SimdFloatMult;
-const OpClass SimdFloatMultAccOp = Enums::SimdFloatMultAcc;
-const OpClass SimdFloatSqrtOp = Enums::SimdFloatSqrt;
-const OpClass MemReadOp = Enums::MemRead;
-const OpClass MemWriteOp = Enums::MemWrite;
-const OpClass IprAccessOp = Enums::IprAccess;
-const OpClass InstPrefetchOp = Enums::InstPrefetch;
-const OpClass Num_OpClasses = Num_OpClass;
+static const OpClass IntAluOp = Enums::IntAlu;
+static const OpClass IntMultOp = Enums::IntMult;
+static const OpClass IntDivOp = Enums::IntDiv;
+static const OpClass FloatAddOp = Enums::FloatAdd;
+static const OpClass FloatCmpOp = Enums::FloatCmp;
+static const OpClass FloatCvtOp = Enums::FloatCvt;
+static const OpClass FloatMultOp = Enums::FloatMult;
+static const OpClass FloatDivOp = Enums::FloatDiv;
+static const OpClass FloatSqrtOp = Enums::FloatSqrt;
+static const OpClass SimdAddOp = Enums::SimdAdd;
+static const OpClass SimdAddAccOp = Enums::SimdAddAcc;
+static const OpClass SimdAluOp = Enums::SimdAlu;
+static const OpClass SimdCmpOp = Enums::SimdCmp;
+static const OpClass SimdCvtOp = Enums::SimdCvt;
+static const OpClass SimdMiscOp = Enums::SimdMisc;
+static const OpClass SimdMultOp = Enums::SimdMult;
+static const OpClass SimdMultAccOp = Enums::SimdMultAcc;
+static const OpClass SimdShiftOp = Enums::SimdShift;
+static const OpClass SimdShiftAccOp = Enums::SimdShiftAcc;
+static const OpClass SimdSqrtOp = Enums::SimdSqrt;
+static const OpClass SimdFloatAddOp = Enums::SimdFloatAdd;
+static const OpClass SimdFloatAluOp = Enums::SimdFloatAlu;
+static const OpClass SimdFloatCmpOp = Enums::SimdFloatCmp;
+static const OpClass SimdFloatCvtOp = Enums::SimdFloatCvt;
+static const OpClass SimdFloatDivOp = Enums::SimdFloatDiv;
+static const OpClass SimdFloatMiscOp = Enums::SimdFloatMisc;
+static const OpClass SimdFloatMultOp = Enums::SimdFloatMult;
+static const OpClass SimdFloatMultAccOp = Enums::SimdFloatMultAcc;
+static const OpClass SimdFloatSqrtOp = Enums::SimdFloatSqrt;
+static const OpClass MemReadOp = Enums::MemRead;
+static const OpClass MemWriteOp = Enums::MemWrite;
+static const OpClass IprAccessOp = Enums::IprAccess;
+static const OpClass InstPrefetchOp = Enums::InstPrefetch;
+static const OpClass Num_OpClasses = Enums::Num_OpClass;
#endif // __CPU__OP_CLASS_HH__