blob: 1874bf03bd864068034d671d7c28740e23f0ec88 [file] [log] [blame]
Evan Cheng94214702011-07-01 20:45:01 +00001//===-- 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
17using namespace llvm;
18
19InstrItineraryData
20MCSubtargetInfo::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}
Evan Cheng2416b892011-07-02 00:43:44 +000045
46/// getFeatureBits - Get the feature bits for a CPU (optionally supplemented
47/// with feature string).
48uint64_t MCSubtargetInfo::getFeatureBits(StringRef CPU, StringRef FS) const {
49 SubtargetFeatures Features(FS);
50 return Features.getFeatureBits(CPU, ProcDesc, NumProcs,
51 ProcFeatures, NumFeatures);
52}