1 //===-- RISCVISAUtils.h - RISC-V ISA Utilities ------------------*- C++ -*-===// 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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Utilities shared by TableGen and RISCVISAInfo. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_SUPPORT_RISCVISAUTILS_H 14 #define LLVM_SUPPORT_RISCVISAUTILS_H 15 16 #include "llvm/ADT/StringRef.h" 17 #include <map> 18 #include <string> 19 20 namespace llvm { 21 22 namespace RISCVISAUtils { 23 constexpr StringLiteral AllStdExts = "mafdqlcbkjtpvnh"; 24 25 /// Represents the major and version number components of a RISC-V extension. 26 struct ExtensionVersion { 27 unsigned Major; 28 unsigned Minor; 29 }; 30 31 bool compareExtension(const std::string &LHS, const std::string &RHS); 32 33 /// Helper class for OrderedExtensionMap. 34 struct ExtensionComparator { operatorExtensionComparator35 bool operator()(const std::string &LHS, const std::string &RHS) const { 36 return compareExtension(LHS, RHS); 37 } 38 }; 39 40 /// OrderedExtensionMap is std::map, it's specialized to keep entries 41 /// in canonical order of extension. 42 typedef std::map<std::string, ExtensionVersion, ExtensionComparator> 43 OrderedExtensionMap; 44 45 } // namespace RISCVISAUtils 46 47 } // namespace llvm 48 49 #endif 50