1 //===--- CodeGenHwModes.h ---------------------------------------*- 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 // Classes to parse and store HW mode information for instruction selection. 10 //===----------------------------------------------------------------------===// 11 12 #ifndef LLVM_UTILS_TABLEGEN_CODEGENHWMODES_H 13 #define LLVM_UTILS_TABLEGEN_CODEGENHWMODES_H 14 15 #include "llvm/ADT/StringMap.h" 16 #include <map> 17 #include <string> 18 #include <vector> 19 20 // HwModeId -> list of predicates (definition) 21 22 namespace llvm { 23 class Record; 24 class RecordKeeper; 25 26 struct CodeGenHwModes; 27 28 struct HwMode { 29 HwMode(Record *R); 30 StringRef Name; 31 std::string Features; 32 void dump() const; 33 }; 34 35 struct HwModeSelect { 36 HwModeSelect(Record *R, CodeGenHwModes &CGH); 37 typedef std::pair<unsigned, Record*> PairType; 38 std::vector<PairType> Items; 39 void dump() const; 40 }; 41 42 struct CodeGenHwModes { 43 enum : unsigned { DefaultMode = 0 }; 44 static StringRef DefaultModeName; 45 46 CodeGenHwModes(RecordKeeper &R); 47 unsigned getHwModeId(StringRef Name) const; getModeCodeGenHwModes48 const HwMode &getMode(unsigned Id) const { 49 assert(Id != 0 && "Mode id of 0 is reserved for the default mode"); 50 return Modes[Id-1]; 51 } 52 const HwModeSelect &getHwModeSelect(Record *R) const; getNumModeIdsCodeGenHwModes53 unsigned getNumModeIds() const { return Modes.size()+1; } 54 void dump() const; 55 56 private: 57 RecordKeeper &Records; 58 StringMap<unsigned> ModeIds; // HwMode (string) -> HwModeId 59 std::vector<HwMode> Modes; 60 std::map<Record*,HwModeSelect> ModeSelects; 61 }; 62 } 63 64 #endif // LLVM_UTILS_TABLEGEN_CODEGENHWMODES_H 65