[llvm] r257215 - [Hexagon] Replace a static member variable in HexagonCVIResource (NFC)
Tobias Edler von Koch via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 8 14:07:25 PST 2016
Author: tobiasvk
Date: Fri Jan 8 16:07:25 2016
New Revision: 257215
URL: http://llvm.org/viewvc/llvm-project?rev=257215&view=rev
Log:
[Hexagon] Replace a static member variable in HexagonCVIResource (NFC)
This creates one instance of TUL per HexagonShuffler, which avoids thread-safety
issues with future changes.
Modified:
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp?rev=257215&r1=257214&r2=257215&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp Fri Jan 8 16:07:25 2016
@@ -95,14 +95,7 @@ unsigned HexagonResource::setWeight(unsi
return (Weight);
}
-HexagonCVIResource::TypeUnitsAndLanes *HexagonCVIResource::TUL;
-
-bool HexagonCVIResource::SetUp = HexagonCVIResource::setup();
-
-bool HexagonCVIResource::setup() {
- assert(!TUL);
- TUL = new (TypeUnitsAndLanes);
-
+void HexagonCVIResource::SetupTUL(TypeUnitsAndLanes *TUL, StringRef CPU) {
(*TUL)[HexagonII::TypeCVI_VA] =
UnitsAndLanes(CVI_XLANE | CVI_SHIFT | CVI_MPY0 | CVI_MPY1, 1);
(*TUL)[HexagonII::TypeCVI_VA_DV] = UnitsAndLanes(CVI_XLANE | CVI_MPY0, 2);
@@ -123,13 +116,12 @@ bool HexagonCVIResource::setup() {
(*TUL)[HexagonII::TypeCVI_VM_NEW_ST] = UnitsAndLanes(CVI_NONE, 0);
(*TUL)[HexagonII::TypeCVI_VM_STU] = UnitsAndLanes(CVI_XLANE, 1);
(*TUL)[HexagonII::TypeCVI_HIST] = UnitsAndLanes(CVI_XLANE, 4);
-
- return true;
}
-HexagonCVIResource::HexagonCVIResource(MCInstrInfo const &MCII, unsigned s,
+HexagonCVIResource::HexagonCVIResource(TypeUnitsAndLanes *TUL,
+ MCInstrInfo const &MCII, unsigned s,
MCInst const *id)
- : HexagonResource(s) {
+ : HexagonResource(s), TUL(TUL) {
unsigned T = HexagonMCInstrInfo::getType(MCII, *id);
if (TUL->count(T)) {
@@ -153,6 +145,7 @@ HexagonShuffler::HexagonShuffler(MCInstr
MCSubtargetInfo const &STI)
: MCII(MCII), STI(STI) {
reset();
+ HexagonCVIResource::SetupTUL(&TUL, STI.getCPU());
}
void HexagonShuffler::reset() {
@@ -163,7 +156,7 @@ void HexagonShuffler::reset() {
void HexagonShuffler::append(MCInst const *ID, MCInst const *Extender,
unsigned S, bool X) {
- HexagonInstr PI(MCII, ID, Extender, S, X);
+ HexagonInstr PI(&TUL, MCII, ID, Extender, S, X);
Packet.push_back(PI);
}
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h?rev=257215&r1=257214&r2=257215&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h Fri Jan 8 16:07:25 2016
@@ -20,6 +20,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCSubtargetInfo.h"
using namespace llvm;
@@ -53,9 +54,11 @@ public:
// HVX insn resources.
class HexagonCVIResource : public HexagonResource {
+public:
typedef std::pair<unsigned, unsigned> UnitsAndLanes;
typedef llvm::DenseMap<unsigned, UnitsAndLanes> TypeUnitsAndLanes;
+private:
// Available HVX slots.
enum {
CVI_NONE = 0,
@@ -65,9 +68,7 @@ class HexagonCVIResource : public Hexago
CVI_MPY1 = 1 << 3
};
- static bool SetUp;
- static bool setup();
- static TypeUnitsAndLanes *TUL;
+ TypeUnitsAndLanes *TUL;
// Count of adjacent slots that the insn requires to be executed.
unsigned Lanes;
@@ -81,7 +82,9 @@ class HexagonCVIResource : public Hexago
void setStore(bool f = true) { Store = f; };
public:
- HexagonCVIResource(MCInstrInfo const &MCII, unsigned s, MCInst const *id);
+ HexagonCVIResource(TypeUnitsAndLanes *TUL, MCInstrInfo const &MCII,
+ unsigned s, MCInst const *id);
+ static void SetupTUL(TypeUnitsAndLanes *TUL, StringRef CPU);
bool isValid() const { return (Valid); };
unsigned getLanes() const { return (Lanes); };
@@ -100,10 +103,11 @@ class HexagonInstr {
bool SoloException;
public:
- HexagonInstr(MCInstrInfo const &MCII, MCInst const *id,
+ HexagonInstr(HexagonCVIResource::TypeUnitsAndLanes *T,
+ MCInstrInfo const &MCII, MCInst const *id,
MCInst const *Extender, unsigned s, bool x = false)
- : ID(id), Extender(Extender), Core(s), CVI(MCII, s, id),
- SoloException(x){};
+ : ID(id), Extender(Extender), Core(s), CVI(T, MCII, s, id),
+ SoloException(x) {};
MCInst const *getDesc() const { return (ID); };
@@ -136,6 +140,8 @@ class HexagonShuffler {
// Shuffling error code.
unsigned Error;
+ HexagonCVIResource::TypeUnitsAndLanes TUL;
+
protected:
int64_t BundleFlags;
MCInstrInfo const &MCII;
More information about the llvm-commits
mailing list