brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 412f323 Raw
50 lines · c
1//===- TargetFeaturesEmitter.h- Generate CPU Target features ----===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// Defines the TargetFeaturesEmitter class, which is used to export10// CPU target features and CPU subtypes.11//12//===----------------------------------------------------------------------===//13 14#ifndef LLVM_UTILS_TABLEGEN_BASIC_EMITTARGETFEATURE_H15#define LLVM_UTILS_TABLEGEN_BASIC_EMITTARGETFEATURE_H16 17#include "llvm/ADT/DenseMap.h"18#include "llvm/TableGen/Record.h"19 20namespace llvm {21/// Sorting predicate to sort record pointers by their22/// FieldName field.23struct LessRecordFieldFieldName {24  bool operator()(const Record *Rec1, const Record *Rec2) const {25    return Rec1->getValueAsString("FieldName") <26           Rec2->getValueAsString("FieldName");27  }28};29 30using FeatureMapTy = DenseMap<const Record *, unsigned>;31 32class TargetFeaturesEmitter {33protected:34  const RecordKeeper &Records;35  std::string Target;36 37public:38  TargetFeaturesEmitter(const RecordKeeper &R);39  static void printFeatureMask(raw_ostream &OS,40                               ArrayRef<const Record *> FeatureList,41                               const FeatureMapTy &FeatureMap);42  FeatureMapTy enumeration(raw_ostream &OS);43  void printFeatureKeyValues(raw_ostream &OS, const FeatureMapTy &FeatureMap);44  void printCPUKeyValues(raw_ostream &OS, const FeatureMapTy &FeatureMap);45  virtual void run(raw_ostream &O);46  virtual ~TargetFeaturesEmitter() = default;47};48} // namespace llvm49#endif50