mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 15:17:25 +00:00
Use std::bitset for SubtargetFeatures
Previously, subtarget features were a bitfield with the underlying type being uint64_t. Since several targets (X86 and ARM, in particular) have hit or were very close to hitting this bound, switching the features to use a bitset. No functional change. The first two times this was committed (r229831, r233055), it caused several buildbot failures. At least some of the ARM and MIPS ones were due to gcc/binutils issues, and should now be fixed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237234 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -144,8 +144,9 @@ public:
|
||||
const uint16_t *ImplicitUses; // Registers implicitly read by this instr
|
||||
const uint16_t *ImplicitDefs; // Registers implicitly defined by this instr
|
||||
const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands
|
||||
uint64_t
|
||||
FeatureBitset
|
||||
DeprecatedFeatureMask; // Feature bits that this is deprecated on, if any
|
||||
|
||||
// A complex method to determine is a certain is deprecated or not, and return
|
||||
// the reason for deprecation.
|
||||
bool (*ComplexDeprecationInfo)(MCInst &, MCSubtargetInfo &, std::string &);
|
||||
@@ -168,7 +169,7 @@ public:
|
||||
std::string &Info) const {
|
||||
if (ComplexDeprecationInfo)
|
||||
return ComplexDeprecationInfo(MI, STI, Info);
|
||||
if ((DeprecatedFeatureMask & STI.getFeatureBits()) != 0) {
|
||||
if ((STI.getFeatureBits() & DeprecatedFeatureMask).any()) {
|
||||
// FIXME: it would be nice to include the subtarget feature here.
|
||||
Info = "deprecated";
|
||||
return true;
|
||||
|
||||
@@ -42,7 +42,7 @@ class MCSubtargetInfo {
|
||||
const InstrStage *Stages; // Instruction itinerary stages
|
||||
const unsigned *OperandCycles; // Itinerary operand cycles
|
||||
const unsigned *ForwardingPaths; // Forwarding paths
|
||||
uint64_t FeatureBits; // Feature bits for current CPU + FS
|
||||
FeatureBitset FeatureBits; // Feature bits for current CPU + FS
|
||||
|
||||
public:
|
||||
void InitMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS,
|
||||
@@ -67,13 +67,13 @@ public:
|
||||
|
||||
/// getFeatureBits - Return the feature bits.
|
||||
///
|
||||
uint64_t getFeatureBits() const {
|
||||
const FeatureBitset& getFeatureBits() const {
|
||||
return FeatureBits;
|
||||
}
|
||||
|
||||
/// setFeatureBits - Set the feature bits.
|
||||
///
|
||||
void setFeatureBits(uint64_t FeatureBits_) { FeatureBits = FeatureBits_; }
|
||||
void setFeatureBits(FeatureBitset& FeatureBits_) { FeatureBits = FeatureBits_; }
|
||||
|
||||
/// InitMCProcessorInfo - Set or change the CPU (optionally supplemented with
|
||||
/// feature string). Recompute feature bits and scheduling model.
|
||||
@@ -84,11 +84,15 @@ public:
|
||||
|
||||
/// ToggleFeature - Toggle a feature and returns the re-computed feature
|
||||
/// bits. This version does not change the implied bits.
|
||||
uint64_t ToggleFeature(uint64_t FB);
|
||||
FeatureBitset ToggleFeature(uint64_t FB);
|
||||
|
||||
/// ToggleFeature - Toggle a feature and returns the re-computed feature
|
||||
/// bits. This version will also change all implied bits.
|
||||
uint64_t ToggleFeature(StringRef FS);
|
||||
/// bits. This version does not change the implied bits.
|
||||
FeatureBitset ToggleFeature(const FeatureBitset& FB);
|
||||
|
||||
/// ToggleFeature - Toggle a set of features and returns the re-computed
|
||||
/// feature bits. This version will also change all implied bits.
|
||||
FeatureBitset ToggleFeature(StringRef FS);
|
||||
|
||||
/// getSchedModelForCPU - Get the machine model of a CPU.
|
||||
///
|
||||
|
||||
@@ -21,11 +21,29 @@
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include <bitset>
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
class StringRef;
|
||||
|
||||
// A container class for subtarget features.
|
||||
// This is convenient because std::bitset does not have a constructor
|
||||
// with an initializer list of set bits.
|
||||
const unsigned MAX_SUBTARGET_FEATURES = 64;
|
||||
class FeatureBitset : public std::bitset<MAX_SUBTARGET_FEATURES> {
|
||||
public:
|
||||
// Cannot inherit constructors because it's not supported by VC++..
|
||||
FeatureBitset() : bitset() {}
|
||||
|
||||
FeatureBitset(const bitset<MAX_SUBTARGET_FEATURES>& B) : bitset(B) {}
|
||||
|
||||
FeatureBitset(std::initializer_list<unsigned> Init) : bitset() {
|
||||
for (auto I = Init.begin() , E = Init.end(); I != E; ++I)
|
||||
set(*I);
|
||||
}
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
///
|
||||
/// SubtargetFeatureKV - Used to provide key value pairs for feature and
|
||||
@@ -34,8 +52,8 @@ namespace llvm {
|
||||
struct SubtargetFeatureKV {
|
||||
const char *Key; // K-V key string
|
||||
const char *Desc; // Help descriptor
|
||||
uint64_t Value; // K-V integer value
|
||||
uint64_t Implies; // K-V bit mask
|
||||
FeatureBitset Value; // K-V integer value
|
||||
FeatureBitset Implies; // K-V bit mask
|
||||
|
||||
// Compare routine for std::lower_bound
|
||||
bool operator<(StringRef S) const {
|
||||
@@ -82,11 +100,11 @@ public:
|
||||
|
||||
/// ToggleFeature - Toggle a feature and returns the newly updated feature
|
||||
/// bits.
|
||||
uint64_t ToggleFeature(uint64_t Bits, StringRef String,
|
||||
FeatureBitset ToggleFeature(FeatureBitset Bits, StringRef String,
|
||||
ArrayRef<SubtargetFeatureKV> FeatureTable);
|
||||
|
||||
/// Get feature bits of a CPU.
|
||||
uint64_t getFeatureBits(StringRef CPU,
|
||||
FeatureBitset getFeatureBits(StringRef CPU,
|
||||
ArrayRef<SubtargetFeatureKV> CPUTable,
|
||||
ArrayRef<SubtargetFeatureKV> FeatureTable);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user