Use BranchProbability instead of floating points in IfConverter.
[llvm/stm8.git] / lib / MC / MCSubtargetInfo.cpp
blobb1b86fe61e0fd0d5fbfe00e86b91ef6dcc86485e
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 //===----------------------------------------------------------------------===//
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>
17 using namespace llvm;
19 void MCSubtargetInfo::InitMCSubtargetInfo(StringRef CPU, StringRef FS,
20 const SubtargetFeatureKV *PF,
21 const SubtargetFeatureKV *PD,
22 const SubtargetInfoKV *PI,
23 const InstrStage *IS,
24 const unsigned *OC,
25 const unsigned *FP,
26 unsigned NF, unsigned NP) {
27 ProcFeatures = PF;
28 ProcDesc = PD;
29 ProcItins = PI;
30 Stages = IS;
31 OperandCycles = OC;
32 ForwardingPathes = FP;
33 NumFeatures = NF;
34 NumProcs = NP;
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);
48 return FeatureBits;
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) {
54 FeatureBits ^= FB;
55 return FeatureBits;
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);
64 return FeatureBits;
68 InstrItineraryData
69 MCSubtargetInfo::getInstrItineraryForCPU(StringRef CPU) const {
70 assert(ProcItins && "Instruction itineraries information not available!");
72 #ifndef NDEBUG
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");
77 #endif
79 // Find entry
80 SubtargetInfoKV KV;
81 KV.Key = CPU.data();
82 const SubtargetInfoKV *Found =
83 std::lower_bound(ProcItins, ProcItins+NumProcs, KV);
84 if (Found == ProcItins+NumProcs || StringRef(Found->Key) != CPU) {
85 errs() << "'" << 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);