llvm.org GIT mirror llvm / c9978ba
MC: Only allow changing feature bits in MCSubtargetInfo Disallow all mutation of `MCSubtargetInfo` expect the feature bits. Besides deleting the assignment operators -- which were dead "code" -- this restricts `InitMCProcessorInfo()` to subclass initialization sequences, and exposes a new more limited function called `setDefaultFeatures()` for use by the ARMAsmParser `.cpu` directive. There's a small functional change here: ARMAsmParser used to adjust `MCSubtargetInfo::CPUSchedModel` as a side effect of calling `InitMCProcessorInfo()`, but I've removed that suspicious behaviour. Since the AsmParser shouldn't be doing any scheduling, there shouldn't be any observable change... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241961 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
3 changed file(s) with 25 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
4444 FeatureBitset FeatureBits; // Feature bits for current CPU + FS
4545
4646 MCSubtargetInfo() = delete;
47 MCSubtargetInfo &operator=(MCSubtargetInfo &&) = delete;
48 MCSubtargetInfo &operator=(const MCSubtargetInfo &) = delete;
4749
4850 public:
51 MCSubtargetInfo(const MCSubtargetInfo &) = default;
4952 MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
5053 ArrayRef PF,
5154 ArrayRef PD,
7477 FeatureBits = FeatureBits_;
7578 }
7679
77 /// InitMCProcessorInfo - Set or change the CPU (optionally supplemented with
78 /// feature string). Recompute feature bits and scheduling model.
80 protected:
81 /// Initialize the scheduling model and feature bits.
82 ///
83 /// FIXME: Find a way to stick this in the constructor, since it should only
84 /// be called during initialization.
7985 void InitMCProcessorInfo(StringRef CPU, StringRef FS);
86
87 public:
88 /// Set the features to the default for the given CPU.
89 void setDefaultFeatures(StringRef CPU);
8090
8191 /// ToggleFeature - Toggle a feature and returns the re-computed feature
8292 /// bits. This version does not change the implied bits.
1616
1717 using namespace llvm;
1818
19 /// InitMCProcessorInfo - Set or change the CPU (optionally supplemented
20 /// with feature string). Recompute feature bits and scheduling model.
21 void
22 MCSubtargetInfo::InitMCProcessorInfo(StringRef CPU, StringRef FS) {
19 static FeatureBitset getFeatures(StringRef CPU, StringRef FS,
20 ArrayRef ProcDesc,
21 ArrayRef ProcFeatures) {
2322 SubtargetFeatures Features(FS);
24 FeatureBits = Features.getFeatureBits(CPU, ProcDesc, ProcFeatures);
23 return Features.getFeatureBits(CPU, ProcDesc, ProcFeatures);
24 }
25
26 void MCSubtargetInfo::InitMCProcessorInfo(StringRef CPU, StringRef FS) {
27 FeatureBits = getFeatures(CPU, FS, ProcDesc, ProcFeatures);
2528 if (!CPU.empty())
2629 CPUSchedModel = &getSchedModelForCPU(CPU);
2730 else
2831 CPUSchedModel = &MCSchedModel::GetDefaultSchedModel();
32 }
33
34 void MCSubtargetInfo::setDefaultFeatures(StringRef CPU) {
35 FeatureBits = getFeatures(CPU, "", ProcDesc, ProcFeatures);
2936 }
3037
3138 MCSubtargetInfo::MCSubtargetInfo(
92119211 return false;
92129212 }
92139213
9214 STI.InitMCProcessorInfo(CPU, "");
9214 STI.setDefaultFeatures(CPU);
92159215 setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
92169216
92179217 return false;