1 //===-- MCSubtargetInfo.cpp - Subtarget Information -----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCSubtargetInfo.h"
11 #include "llvm/MC/MCInstrItineraries.h"
12 #include "llvm/MC/SubtargetFeature.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Support/raw_ostream.h"
19 void MCSubtargetInfo::InitMCSubtargetInfo(StringRef CPU
, StringRef FS
,
20 const SubtargetFeatureKV
*PF
,
21 const SubtargetFeatureKV
*PD
,
22 const SubtargetInfoKV
*PI
,
26 unsigned NF
, unsigned NP
) {
32 ForwardingPathes
= FP
;
36 SubtargetFeatures
Features(FS
);
37 FeatureBits
= Features
.getFeatureBits(CPU
, ProcDesc
, NumProcs
,
38 ProcFeatures
, NumFeatures
);
42 /// ReInitMCSubtargetInfo - Change CPU (and optionally supplemented with
43 /// feature string) and recompute feature bits.
44 uint64_t MCSubtargetInfo::ReInitMCSubtargetInfo(StringRef CPU
, StringRef FS
) {
45 SubtargetFeatures
Features(FS
);
46 FeatureBits
= Features
.getFeatureBits(CPU
, ProcDesc
, NumProcs
,
47 ProcFeatures
, NumFeatures
);
51 /// ToggleFeature - Toggle a feature and returns the re-computed feature
52 /// bits. This version does not change the implied bits.
53 uint64_t MCSubtargetInfo::ToggleFeature(uint64_t FB
) {
58 /// ToggleFeature - Toggle a feature and returns the re-computed feature
59 /// bits. This version will also change all implied bits.
60 uint64_t MCSubtargetInfo::ToggleFeature(StringRef FS
) {
61 SubtargetFeatures Features
;
62 FeatureBits
= Features
.ToggleFeature(FeatureBits
, FS
,
63 ProcFeatures
, NumFeatures
);
69 MCSubtargetInfo::getInstrItineraryForCPU(StringRef CPU
) const {
70 assert(ProcItins
&& "Instruction itineraries information not available!");
73 for (size_t i
= 1; i
< NumProcs
; i
++) {
74 assert(strcmp(ProcItins
[i
- 1].Key
, ProcItins
[i
].Key
) < 0 &&
75 "Itineraries table is not sorted");
82 const SubtargetInfoKV
*Found
=
83 std::lower_bound(ProcItins
, ProcItins
+NumProcs
, KV
);
84 if (Found
== ProcItins
+NumProcs
|| StringRef(Found
->Key
) != CPU
) {
86 << "' is not a recognized processor for this target"
87 << " (ignoring processor)\n";
88 return InstrItineraryData();
91 return InstrItineraryData(Stages
, OperandCycles
, ForwardingPathes
,
92 (InstrItinerary
*)Found
->Value
);