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/ADT/Triple.h"
15 #include "llvm/Support/raw_ostream.h"
21 MCSubtargetInfo::InitMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS,
22 const SubtargetFeatureKV *PF,
23 const SubtargetFeatureKV *PD,
24 const SubtargetInfoKV *PI,
28 unsigned NF, unsigned NP) {
35 ForwardingPathes = FP;
39 SubtargetFeatures Features(FS);
40 FeatureBits = Features.getFeatureBits(CPU, ProcDesc, NumProcs,
41 ProcFeatures, NumFeatures);
45 /// ReInitMCSubtargetInfo - Change CPU (and optionally supplemented with
46 /// feature string) and recompute feature bits.
47 uint64_t MCSubtargetInfo::ReInitMCSubtargetInfo(StringRef CPU, StringRef FS) {
48 SubtargetFeatures Features(FS);
49 FeatureBits = Features.getFeatureBits(CPU, ProcDesc, NumProcs,
50 ProcFeatures, NumFeatures);
54 /// ToggleFeature - Toggle a feature and returns the re-computed feature
55 /// bits. This version does not change the implied bits.
56 uint64_t MCSubtargetInfo::ToggleFeature(uint64_t FB) {
61 /// ToggleFeature - Toggle a feature and returns the re-computed feature
62 /// bits. This version will also change all implied bits.
63 uint64_t MCSubtargetInfo::ToggleFeature(StringRef FS) {
64 SubtargetFeatures Features;
65 FeatureBits = Features.ToggleFeature(FeatureBits, FS,
66 ProcFeatures, NumFeatures);
72 MCSubtargetInfo::getInstrItineraryForCPU(StringRef CPU) const {
73 assert(ProcItins && "Instruction itineraries information not available!");
76 for (size_t i = 1; i < NumProcs; i++) {
77 assert(strcmp(ProcItins[i - 1].Key, ProcItins[i].Key) < 0 &&
78 "Itineraries table is not sorted");
85 const SubtargetInfoKV *Found =
86 std::lower_bound(ProcItins, ProcItins+NumProcs, KV);
87 if (Found == ProcItins+NumProcs || StringRef(Found->Key) != CPU) {
89 << "' is not a recognized processor for this target"
90 << " (ignoring processor)\n";
91 return InstrItineraryData();
94 return InstrItineraryData(Stages, OperandCycles, ForwardingPathes,
95 (InstrItinerary *)Found->Value);