1 //===-- LVSort.h ------------------------------------------------*- 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 // This file defines the sort algorithms. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSORT_H 14 #define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSORT_H 15 16 #include "llvm/Support/Compiler.h" 17 18 namespace llvm { 19 namespace logicalview { 20 21 class LVObject; 22 23 // Object Sorting Mode. 24 enum class LVSortMode { 25 None = 0, // No given sort. 26 Kind, // Sort by kind. 27 Line, // Sort by line. 28 Name, // Sort by name. 29 Offset // Sort by offset. 30 }; 31 32 // Type of function to be called when sorting an object. 33 using LVSortValue = int; 34 using LVSortFunction = LVSortValue (*)(const LVObject *LHS, 35 const LVObject *RHS); 36 37 // Get the comparator function, based on the command line options. 38 LLVM_ABI LVSortFunction getSortFunction(); 39 40 // Comparator functions that can be used for sorting. 41 LLVM_ABI LVSortValue compareKind(const LVObject *LHS, const LVObject *RHS); 42 LLVM_ABI LVSortValue compareLine(const LVObject *LHS, const LVObject *RHS); 43 LLVM_ABI LVSortValue compareName(const LVObject *LHS, const LVObject *RHS); 44 LLVM_ABI LVSortValue compareOffset(const LVObject *LHS, const LVObject *RHS); 45 LLVM_ABI LVSortValue compareRange(const LVObject *LHS, const LVObject *RHS); 46 LLVM_ABI LVSortValue sortByKind(const LVObject *LHS, const LVObject *RHS); 47 LLVM_ABI LVSortValue sortByLine(const LVObject *LHS, const LVObject *RHS); 48 LLVM_ABI LVSortValue sortByName(const LVObject *LHS, const LVObject *RHS); 49 50 } // end namespace logicalview 51 } // end namespace llvm 52 53 #endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSORT_H 54