2005-10-21 19:00:04 +00:00
|
|
|
//===- SubtargetEmitter.h - Generate subtarget enumerations -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by James M. Laskey and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This tablegen backend emits subtarget enumerations.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef SUBTARGET_EMITTER_H
|
|
|
|
#define SUBTARGET_EMITTER_H
|
|
|
|
|
|
|
|
#include "TableGenBackend.h"
|
2005-10-27 19:47:21 +00:00
|
|
|
#include "llvm/Target/TargetInstrItineraries.h"
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2005-10-21 19:00:04 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2005-10-27 19:47:21 +00:00
|
|
|
//
|
|
|
|
// Convenience types.
|
|
|
|
//
|
|
|
|
typedef std::map<std::string, unsigned> IntMap;
|
|
|
|
typedef std::vector<InstrItinerary> IntineraryList;
|
|
|
|
typedef std::vector<IntineraryList> ProcessorList;
|
|
|
|
|
2005-10-21 19:00:04 +00:00
|
|
|
class SubtargetEmitter : public TableGenBackend {
|
2005-10-27 19:47:21 +00:00
|
|
|
|
2005-10-21 19:00:04 +00:00
|
|
|
RecordKeeper &Records;
|
2005-10-26 17:30:34 +00:00
|
|
|
std::string Target;
|
2005-10-25 15:16:36 +00:00
|
|
|
|
2005-10-26 17:30:34 +00:00
|
|
|
void Enumeration(std::ostream &OS, const char *ClassName, bool isBits);
|
2005-10-25 15:16:36 +00:00
|
|
|
void FeatureKeyValues(std::ostream &OS);
|
|
|
|
void CPUKeyValues(std::ostream &OS);
|
2005-10-27 19:47:21 +00:00
|
|
|
unsigned CollectAllItinClasses(IntMap &ItinClassesMap);
|
|
|
|
void FormItineraryString(Record *ItinData, std::string &ItinString,
|
|
|
|
unsigned &N);
|
|
|
|
void EmitStageData(std::ostream &OS, unsigned N,
|
|
|
|
IntMap &ItinClassesMap, ProcessorList &ProcList);
|
|
|
|
void EmitProcessData(std::ostream &OS, ProcessorList &ProcList);
|
|
|
|
void EmitData(std::ostream &OS);
|
|
|
|
void ParseFeaturesFunction(std::ostream &OS);
|
2005-10-25 15:16:36 +00:00
|
|
|
|
2005-10-21 19:00:04 +00:00
|
|
|
public:
|
|
|
|
SubtargetEmitter(RecordKeeper &R) : Records(R) {}
|
|
|
|
|
|
|
|
// run - Output the subtarget enumerations, returning true on failure.
|
|
|
|
void run(std::ostream &o);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|