//===-- RISCVISAUtils.cpp - RISC-V ISA Utilities --------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Utilities shared by TableGen and RISCVISAInfo. // //===----------------------------------------------------------------------===// #include "llvm/Support/RISCVISAUtils.h" #include "llvm/ADT/StringExtras.h" #include <cassert> usingnamespacellvm; // We rank extensions in the following order: // -Single letter extensions in canonical order. // -Unknown single letter extensions in alphabetical order. // -Multi-letter extensions starting with 'z' sorted by canonical order of // the second letter then sorted alphabetically. // -Multi-letter extensions starting with 's' in alphabetical order. // -(TODO) Multi-letter extensions starting with 'zxm' in alphabetical order. // -X extensions in alphabetical order. // -Unknown multi-letter extensions in alphabetical order. // These flags are used to indicate the category. The first 6 bits store the // single letter extension rank for single letter and multi-letter extensions // starting with 'z'. enum RankFlags { … }; // Get the rank for single-letter extension, lower value meaning higher // priority. static unsigned singleLetterExtensionRank(char Ext) { … } // Get the rank for multi-letter extension, lower value meaning higher // priority/order in canonical order. static unsigned getExtensionRank(const std::string &ExtName) { … } // Compare function for extension. // Only compare the extension name, ignore version comparison. bool llvm::RISCVISAUtils::compareExtension(const std::string &LHS, const std::string &RHS) { … }