1 //=- StructuralHash.h - Structural Hash Printing --*- 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 #ifndef LLVM_ANALYSIS_STRUCTURALHASH_H 10 #define LLVM_ANALYSIS_STRUCTURALHASH_H 11 12 #include "llvm/IR/PassManager.h" 13 14 namespace llvm { 15 16 enum class StructuralHashOptions { 17 None, /// Hash with opcode only. 18 Detailed, /// Hash with opcode and operands. 19 CallTargetIgnored, /// Ignore call target operand when computing hash. 20 }; 21 22 /// Printer pass for StructuralHashes 23 class StructuralHashPrinterPass 24 : public PassInfoMixin<StructuralHashPrinterPass> { 25 raw_ostream &OS; 26 const StructuralHashOptions Options; 27 28 public: 29 explicit StructuralHashPrinterPass(raw_ostream &OS, 30 StructuralHashOptions Options) 31 : OS(OS), Options(Options) {} 32 33 PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM); 34 35 static bool isRequired() { return true; } 36 }; 37 38 } // namespace llvm 39 40 #endif // LLVM_ANALYSIS_STRUCTURALHASH_H 41