Evan Cheng | 9421470 | 2011-07-01 20:45:01 +0000 | [diff] [blame^] | 1 | //===-- MCSubtargetInfo.cpp - Subtarget Information -----------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 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" |
| 15 | #include <algorithm> |
| 16 | |
| 17 | using namespace llvm; |
| 18 | |
| 19 | InstrItineraryData |
| 20 | MCSubtargetInfo::getInstrItineraryForCPU(StringRef CPU) const { |
| 21 | assert(ProcItins && "Instruction itineraries information not available!"); |
| 22 | |
| 23 | #ifndef NDEBUG |
| 24 | for (size_t i = 1; i < NumProcs; i++) { |
| 25 | assert(strcmp(ProcItins[i - 1].Key, ProcItins[i].Key) < 0 && |
| 26 | "Itineraries table is not sorted"); |
| 27 | } |
| 28 | #endif |
| 29 | |
| 30 | // Find entry |
| 31 | SubtargetInfoKV KV; |
| 32 | KV.Key = CPU.data(); |
| 33 | const SubtargetInfoKV *Found = |
| 34 | std::lower_bound(ProcItins, ProcItins+NumProcs, KV); |
| 35 | if (Found == ProcItins+NumProcs || StringRef(Found->Key) != CPU) { |
| 36 | errs() << "'" << CPU |
| 37 | << "' is not a recognized processor for this target" |
| 38 | << " (ignoring processor)\n"; |
| 39 | return InstrItineraryData(); |
| 40 | } |
| 41 | |
| 42 | return InstrItineraryData(Stages, OperandCycles, ForwardingPathes, |
| 43 | (InstrItinerary *)Found->Value); |
| 44 | } |