MCSubtargetInfo.h revision ffc0e73046f737d75e0a62b3a83ef19bcef111e3
1//==-- llvm/MC/MCSubtargetInfo.h - Subtarget Information ---------*- C++ -*-==//
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// This file describes the subtarget options of a Target machine.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_MC_MCSUBTARGET_H
15#define LLVM_MC_MCSUBTARGET_H
16
17#include "llvm/MC/SubtargetFeature.h"
18#include "llvm/MC/MCInstrItineraries.h"
19
20namespace llvm {
21
22class StringRef;
23
24//===----------------------------------------------------------------------===//
25///
26/// MCSubtargetInfo - Generic base class for all target subtargets.
27///
28class MCSubtargetInfo {
29  const SubtargetFeatureKV *ProcFeatures;  // Processor feature list
30  const SubtargetFeatureKV *ProcDesc;  // Processor descriptions
31  const SubtargetInfoKV *ProcItins;    // Scheduling itineraries
32  const InstrStage *Stages;            // Instruction stages
33  const unsigned *OperandCycles;       // Operand cycles
34  const unsigned *ForwardingPathes;    // Forwarding pathes
35  unsigned NumFeatures;                // Number of processor features
36  unsigned NumProcs;                   // Number of processors
37
38  uint64_t FeatureBits;                // Feature bits for current CPU + FS
39
40public:
41  void InitMCSubtargetInfo(StringRef CPU, StringRef FS,
42                           const SubtargetFeatureKV *PF,
43                           const SubtargetFeatureKV *PD,
44                           const SubtargetInfoKV *PI, const InstrStage *IS,
45                           const unsigned *OC, const unsigned *FP,
46                           unsigned NF, unsigned NP);
47
48  /// getFeatureBits - Get the feature bits.
49  ///
50  uint64_t getFeatureBits() const {
51    return FeatureBits;
52  }
53
54  /// ReInitMCSubtargetInfo - Change CPU (and optionally supplemented with
55  /// feature string), recompute and return feature bits.
56  uint64_t ReInitMCSubtargetInfo(StringRef CPU, StringRef FS);
57
58  /// ToggleFeature - Toggle a feature and returns the re-computed feature
59  /// bits. This version does not change the implied bits.
60  uint64_t ToggleFeature(uint64_t FB);
61
62  /// ToggleFeature - Toggle a feature and returns the re-computed feature
63  /// bits. This version will also change all implied bits.
64  uint64_t ToggleFeature(StringRef FS);
65
66  /// getInstrItineraryForCPU - Get scheduling itinerary of a CPU.
67  ///
68  InstrItineraryData getInstrItineraryForCPU(StringRef CPU) const;
69};
70
71} // End llvm namespace
72
73#endif
74