Skip to content

Commit 29704e7

Browse files
author
Michael Kuperstein
committedMar 24, 2015
Revert "Use std::bitset for SubtargetFeatures"
This reverts commit r233055. It still causes buildbot failures (gcc running out of memory on several platforms, and a self-host failure on arm), although less than the previous time. llvm-svn: 233068
1 parent d5cc45f commit 29704e7

33 files changed

+308
-348
lines changed
 

‎llvm/include/llvm/MC/MCInstPrinter.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef LLVM_MC_MCINSTPRINTER_H
1111
#define LLVM_MC_MCINSTPRINTER_H
1212

13-
#include "llvm/MC/SubtargetFeature.h"
1413
#include "llvm/Support/DataTypes.h"
1514
#include "llvm/Support/Format.h"
1615

@@ -42,7 +41,7 @@ class MCInstPrinter {
4241
const MCRegisterInfo &MRI;
4342

4443
/// The current set of available features.
45-
FeatureBitset AvailableFeatures;
44+
uint64_t AvailableFeatures;
4645

4746
/// True if we are printing marked up assembly.
4847
bool UseMarkup;
@@ -59,7 +58,7 @@ class MCInstPrinter {
5958
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
6059
const MCRegisterInfo &mri)
6160
: CommentStream(nullptr), MAI(mai), MII(mii), MRI(mri),
62-
AvailableFeatures(), UseMarkup(0), PrintImmHex(0),
61+
AvailableFeatures(0), UseMarkup(0), PrintImmHex(0),
6362
PrintHexStyle(HexStyle::C) {}
6463

6564
virtual ~MCInstPrinter();
@@ -79,8 +78,8 @@ class MCInstPrinter {
7978
/// printRegName - Print the assembler register name.
8079
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
8180

82-
const FeatureBitset& getAvailableFeatures() const { return AvailableFeatures; }
83-
void setAvailableFeatures(const FeatureBitset& Value) { AvailableFeatures = Value; }
81+
uint64_t getAvailableFeatures() const { return AvailableFeatures; }
82+
void setAvailableFeatures(uint64_t Value) { AvailableFeatures = Value; }
8483

8584
bool getUseMarkup() const { return UseMarkup; }
8685
void setUseMarkup(bool Value) { UseMarkup = Value; }

‎llvm/include/llvm/MC/MCInstrDesc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class MCInstrDesc {
150150
const uint16_t *ImplicitUses; // Registers implicitly read by this instr
151151
const uint16_t *ImplicitDefs; // Registers implicitly defined by this instr
152152
const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands
153-
FeatureBitset DeprecatedFeatureMask; // Feature bits that this is deprecated on, if any
153+
uint64_t DeprecatedFeatureMask;// Feature bits that this is deprecated on, if any
154154
// A complex method to determine is a certain is deprecated or not, and return
155155
// the reason for deprecation.
156156
bool (*ComplexDeprecationInfo)(MCInst &, MCSubtargetInfo &, std::string &);
@@ -173,7 +173,7 @@ class MCInstrDesc {
173173
std::string &Info) const {
174174
if (ComplexDeprecationInfo)
175175
return ComplexDeprecationInfo(MI, STI, Info);
176-
if ((STI.getFeatureBits() & DeprecatedFeatureMask).any()) {
176+
if ((DeprecatedFeatureMask & STI.getFeatureBits()) != 0) {
177177
// FIXME: it would be nice to include the subtarget feature here.
178178
Info = "deprecated";
179179
return true;

‎llvm/include/llvm/MC/MCSubtargetInfo.h

+6-10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class MCSubtargetInfo {
4242
const InstrStage *Stages; // Instruction itinerary stages
4343
const unsigned *OperandCycles; // Itinerary operand cycles
4444
const unsigned *ForwardingPaths; // Forwarding paths
45-
FeatureBitset FeatureBits; // Feature bits for current CPU + FS
45+
uint64_t FeatureBits; // Feature bits for current CPU + FS
4646

4747
public:
4848
void InitMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS,
@@ -67,13 +67,13 @@ class MCSubtargetInfo {
6767

6868
/// getFeatureBits - Return the feature bits.
6969
///
70-
const FeatureBitset& getFeatureBits() const {
70+
uint64_t getFeatureBits() const {
7171
return FeatureBits;
7272
}
7373

7474
/// setFeatureBits - Set the feature bits.
7575
///
76-
void setFeatureBits(FeatureBitset& FeatureBits_) { FeatureBits = FeatureBits_; }
76+
void setFeatureBits(uint64_t FeatureBits_) { FeatureBits = FeatureBits_; }
7777

7878
/// InitMCProcessorInfo - Set or change the CPU (optionally supplemented with
7979
/// feature string). Recompute feature bits and scheduling model.
@@ -84,15 +84,11 @@ class MCSubtargetInfo {
8484

8585
/// ToggleFeature - Toggle a feature and returns the re-computed feature
8686
/// bits. This version does not change the implied bits.
87-
FeatureBitset ToggleFeature(uint64_t FB);
87+
uint64_t ToggleFeature(uint64_t FB);
8888

8989
/// ToggleFeature - Toggle a feature and returns the re-computed feature
90-
/// bits. This version does not change the implied bits.
91-
FeatureBitset ToggleFeature(const FeatureBitset& FB);
92-
93-
/// ToggleFeature - Toggle a set of features and returns the re-computed
94-
/// feature bits. This version will also change all implied bits.
95-
FeatureBitset ToggleFeature(StringRef FS);
90+
/// bits. This version will also change all implied bits.
91+
uint64_t ToggleFeature(StringRef FS);
9692

9793
/// getSchedModelForCPU - Get the machine model of a CPU.
9894
///

‎llvm/include/llvm/MC/SubtargetFeature.h

+4-22
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,11 @@
2121
#include "llvm/ADT/ArrayRef.h"
2222
#include "llvm/ADT/Triple.h"
2323
#include "llvm/Support/DataTypes.h"
24-
#include <bitset>
2524

2625
namespace llvm {
2726
class raw_ostream;
2827
class StringRef;
2928

30-
// A container class for subtarget features.
31-
// This is convenient because std::bitset does not have a constructor
32-
// with an initializer list of set bits.
33-
const unsigned MAX_SUBTARGET_FEATURES = 64;
34-
class FeatureBitset : public std::bitset<MAX_SUBTARGET_FEATURES> {
35-
public:
36-
// Cannot inherit constructors because it's not supported by VC++..
37-
FeatureBitset() : bitset() {}
38-
39-
FeatureBitset(const bitset<MAX_SUBTARGET_FEATURES>& B) : bitset(B) {}
40-
41-
FeatureBitset(std::initializer_list<unsigned> Init) : bitset() {
42-
for (auto I = Init.begin() , E = Init.end(); I != E; ++I)
43-
set(*I);
44-
}
45-
};
46-
4729
//===----------------------------------------------------------------------===//
4830
///
4931
/// SubtargetFeatureKV - Used to provide key value pairs for feature and
@@ -52,8 +34,8 @@ class FeatureBitset : public std::bitset<MAX_SUBTARGET_FEATURES> {
5234
struct SubtargetFeatureKV {
5335
const char *Key; // K-V key string
5436
const char *Desc; // Help descriptor
55-
FeatureBitset Value; // K-V integer value
56-
FeatureBitset Implies; // K-V bit mask
37+
uint64_t Value; // K-V integer value
38+
uint64_t Implies; // K-V bit mask
5739

5840
// Compare routine for std::lower_bound
5941
bool operator<(StringRef S) const {
@@ -100,11 +82,11 @@ class SubtargetFeatures {
10082

10183
/// ToggleFeature - Toggle a feature and returns the newly updated feature
10284
/// bits.
103-
FeatureBitset ToggleFeature(FeatureBitset Bits, StringRef String,
85+
uint64_t ToggleFeature(uint64_t Bits, StringRef String,
10486
ArrayRef<SubtargetFeatureKV> FeatureTable);
10587

10688
/// Get feature bits of a CPU.
107-
FeatureBitset getFeatureBits(StringRef CPU,
89+
uint64_t getFeatureBits(StringRef CPU,
10890
ArrayRef<SubtargetFeatureKV> CPUTable,
10991
ArrayRef<SubtargetFeatureKV> FeatureTable);
11092

‎llvm/lib/MC/MCSubtargetInfo.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,14 @@ MCSubtargetInfo::InitMCSubtargetInfo(StringRef TT, StringRef C, StringRef FS,
6363

6464
/// ToggleFeature - Toggle a feature and returns the re-computed feature
6565
/// bits. This version does not change the implied bits.
66-
FeatureBitset MCSubtargetInfo::ToggleFeature(uint64_t FB) {
67-
FeatureBits.flip(FB);
68-
return FeatureBits;
69-
}
70-
71-
FeatureBitset MCSubtargetInfo::ToggleFeature(const FeatureBitset &FB) {
66+
uint64_t MCSubtargetInfo::ToggleFeature(uint64_t FB) {
7267
FeatureBits ^= FB;
7368
return FeatureBits;
7469
}
7570

7671
/// ToggleFeature - Toggle a feature and returns the re-computed feature
7772
/// bits. This version will also change all implied bits.
78-
FeatureBitset MCSubtargetInfo::ToggleFeature(StringRef FS) {
73+
uint64_t MCSubtargetInfo::ToggleFeature(StringRef FS) {
7974
SubtargetFeatures Features;
8075
FeatureBits = Features.ToggleFeature(FeatureBits, FS, ProcFeatures);
8176
return FeatureBits;

‎llvm/lib/MC/SubtargetFeature.cpp

+11-12
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ std::string SubtargetFeatures::getString() const {
150150
/// feature, set it.
151151
///
152152
static
153-
void SetImpliedBits(FeatureBitset &Bits, const SubtargetFeatureKV *FeatureEntry,
153+
void SetImpliedBits(uint64_t &Bits, const SubtargetFeatureKV *FeatureEntry,
154154
ArrayRef<SubtargetFeatureKV> FeatureTable) {
155155
for (auto &FE : FeatureTable) {
156156
if (FeatureEntry->Value == FE.Value) continue;
157157

158-
if ((FeatureEntry->Implies & FE.Value).any()) {
158+
if (FeatureEntry->Implies & FE.Value) {
159159
Bits |= FE.Value;
160160
SetImpliedBits(Bits, &FE, FeatureTable);
161161
}
@@ -166,13 +166,12 @@ void SetImpliedBits(FeatureBitset &Bits, const SubtargetFeatureKV *FeatureEntry,
166166
/// feature, clear it.
167167
///
168168
static
169-
void ClearImpliedBits(FeatureBitset &Bits,
170-
const SubtargetFeatureKV *FeatureEntry,
169+
void ClearImpliedBits(uint64_t &Bits, const SubtargetFeatureKV *FeatureEntry,
171170
ArrayRef<SubtargetFeatureKV> FeatureTable) {
172171
for (auto &FE : FeatureTable) {
173172
if (FeatureEntry->Value == FE.Value) continue;
174173

175-
if ((FE.Implies & FeatureEntry->Value).any()) {
174+
if (FE.Implies & FeatureEntry->Value) {
176175
Bits &= ~FE.Value;
177176
ClearImpliedBits(Bits, &FE, FeatureTable);
178177
}
@@ -181,8 +180,8 @@ void ClearImpliedBits(FeatureBitset &Bits,
181180

182181
/// ToggleFeature - Toggle a feature and returns the newly updated feature
183182
/// bits.
184-
FeatureBitset
185-
SubtargetFeatures::ToggleFeature(FeatureBitset Bits, StringRef Feature,
183+
uint64_t
184+
SubtargetFeatures::ToggleFeature(uint64_t Bits, StringRef Feature,
186185
ArrayRef<SubtargetFeatureKV> FeatureTable) {
187186

188187
// Find feature in table.
@@ -192,6 +191,7 @@ SubtargetFeatures::ToggleFeature(FeatureBitset Bits, StringRef Feature,
192191
if (FeatureEntry) {
193192
if ((Bits & FeatureEntry->Value) == FeatureEntry->Value) {
194193
Bits &= ~FeatureEntry->Value;
194+
195195
// For each feature that implies this, clear it.
196196
ClearImpliedBits(Bits, FeatureEntry, FeatureTable);
197197
} else {
@@ -212,13 +212,13 @@ SubtargetFeatures::ToggleFeature(FeatureBitset Bits, StringRef Feature,
212212

213213
/// getFeatureBits - Get feature bits a CPU.
214214
///
215-
FeatureBitset
215+
uint64_t
216216
SubtargetFeatures::getFeatureBits(StringRef CPU,
217217
ArrayRef<SubtargetFeatureKV> CPUTable,
218218
ArrayRef<SubtargetFeatureKV> FeatureTable) {
219219

220220
if (CPUTable.empty() || FeatureTable.empty())
221-
return FeatureBitset();
221+
return 0;
222222

223223
#ifndef NDEBUG
224224
for (size_t i = 1, e = CPUTable.size(); i != e; ++i) {
@@ -230,8 +230,7 @@ SubtargetFeatures::getFeatureBits(StringRef CPU,
230230
"CPU features table is not sorted");
231231
}
232232
#endif
233-
// Resulting bits
234-
FeatureBitset Bits;
233+
uint64_t Bits = 0; // Resulting bits
235234

236235
// Check if help is needed
237236
if (CPU == "help")
@@ -248,7 +247,7 @@ SubtargetFeatures::getFeatureBits(StringRef CPU,
248247

249248
// Set the feature implied by this CPU feature, if any.
250249
for (auto &FE : FeatureTable) {
251-
if ((CPUEntry->Value & FE.Value).any())
250+
if (CPUEntry->Value & FE.Value)
252251
SetImpliedBits(Bits, &FE, FeatureTable);
253252
}
254253
} else {

‎llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "llvm/ADT/APFloat.h"
1515
#include "llvm/ADT/SmallVector.h"
1616
#include "llvm/ADT/StringExtras.h"
17-
#include "llvm/MC/SubtargetFeature.h"
1817
#include "llvm/Support/Regex.h"
1918

2019
using namespace llvm;
@@ -246,7 +245,7 @@ const AArch64NamedImmMapper::Mapping AArch64SysReg::MRSMapper::MRSPairs[] = {
246245
{"ich_elsr_el2", ICH_ELSR_EL2}
247246
};
248247

249-
AArch64SysReg::MRSMapper::MRSMapper(const FeatureBitset &FeatureBits)
248+
AArch64SysReg::MRSMapper::MRSMapper(uint64_t FeatureBits)
250249
: SysRegMapper(FeatureBits) {
251250
InstPairs = &MRSPairs[0];
252251
NumInstPairs = llvm::array_lengthof(MRSPairs);
@@ -270,7 +269,7 @@ const AArch64NamedImmMapper::Mapping AArch64SysReg::MSRMapper::MSRPairs[] = {
270269
{"icc_sgi0r_el1", ICC_SGI0R_EL1}
271270
};
272271

273-
AArch64SysReg::MSRMapper::MSRMapper(const FeatureBitset &FeatureBits)
272+
AArch64SysReg::MSRMapper::MSRMapper(uint64_t FeatureBits)
274273
: SysRegMapper(FeatureBits) {
275274
InstPairs = &MSRPairs[0];
276275
NumInstPairs = llvm::array_lengthof(MSRPairs);
@@ -774,7 +773,7 @@ AArch64SysReg::SysRegMapper::fromString(StringRef Name, bool &Valid) const {
774773
}
775774

776775
// Next search for target specific registers
777-
if (FeatureBits[AArch64::ProcCyclone]) {
776+
if (FeatureBits & AArch64::ProcCyclone) {
778777
for (unsigned i = 0; i < array_lengthof(CycloneSysRegPairs); ++i) {
779778
if (CycloneSysRegPairs[i].Name == NameLower) {
780779
Valid = true;
@@ -824,7 +823,7 @@ AArch64SysReg::SysRegMapper::toString(uint32_t Bits) const {
824823
}
825824

826825
// Next search for target specific registers
827-
if (FeatureBits[AArch64::ProcCyclone]) {
826+
if (FeatureBits & AArch64::ProcCyclone) {
828827
for (unsigned i = 0; i < array_lengthof(CycloneSysRegPairs); ++i) {
829828
if (CycloneSysRegPairs[i].Value == Bits) {
830829
return CycloneSysRegPairs[i].Name;

‎llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h

+4-6
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
namespace llvm {
2828

29-
class FeatureBitset;
30-
3129
inline static unsigned getWRegFromXReg(unsigned Reg) {
3230
switch (Reg) {
3331
case AArch64::X0: return AArch64::W0;
@@ -1141,21 +1139,21 @@ namespace AArch64SysReg {
11411139

11421140
const AArch64NamedImmMapper::Mapping *InstPairs;
11431141
size_t NumInstPairs;
1144-
const FeatureBitset &FeatureBits;
1142+
uint64_t FeatureBits;
11451143

1146-
SysRegMapper(const FeatureBitset &FeatureBits) : FeatureBits(FeatureBits) { }
1144+
SysRegMapper(uint64_t FeatureBits) : FeatureBits(FeatureBits) { }
11471145
uint32_t fromString(StringRef Name, bool &Valid) const;
11481146
std::string toString(uint32_t Bits) const;
11491147
};
11501148

11511149
struct MSRMapper : SysRegMapper {
11521150
static const AArch64NamedImmMapper::Mapping MSRPairs[];
1153-
MSRMapper(const FeatureBitset &FeatureBits);
1151+
MSRMapper(uint64_t FeatureBits);
11541152
};
11551153

11561154
struct MRSMapper : SysRegMapper {
11571155
static const AArch64NamedImmMapper::Mapping MRSPairs[];
1158-
MRSMapper(const FeatureBitset &FeatureBits);
1156+
MRSMapper(uint64_t FeatureBits);
11591157
};
11601158

11611159
uint32_t ParseGenericRegister(StringRef Name, bool &Valid);

‎llvm/lib/Target/ARM/ARMAsmPrinter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ bool ARMAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
420420
}
421421

422422
static bool isThumb(const MCSubtargetInfo& STI) {
423-
return STI.getFeatureBits()[ARM::ModeThumb];
423+
return (STI.getFeatureBits() & ARM::ModeThumb) != 0;
424424
}
425425

426426
void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,

‎llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4513,7 +4513,7 @@ breakPartialRegDependency(MachineBasicBlock::iterator MI,
45134513
}
45144514

45154515
bool ARMBaseInstrInfo::hasNOP() const {
4516-
return Subtarget.getFeatureBits()[ARM::HasV6KOps];
4516+
return (Subtarget.getFeatureBits() & ARM::HasV6KOps) != 0;
45174517
}
45184518

45194519
bool ARMBaseInstrInfo::isSwiftFastImmShift(const MachineInstr *MI) const {

‎llvm/lib/Target/ARM/ARMSubtarget.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
263263
}
264264

265265
// NEON f32 ops are non-IEEE 754 compliant. Darwin is ok with it by default.
266-
const FeatureBitset &Bits = getFeatureBits();
267-
if ((Bits[ARM::ProcA5] || Bits[ARM::ProcA8]) && // Where this matters
266+
uint64_t Bits = getFeatureBits();
267+
if ((Bits & ARM::ProcA5 || Bits & ARM::ProcA8) && // Where this matters
268268
(Options.UnsafeFPMath || isTargetDarwin()))
269269
UseNEONForSinglePrecisionFP = true;
270270
}

0 commit comments

Comments
 (0)
Please sign in to comment.