1 //===--------------------- Support.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 /// \file 10 /// 11 /// Helper functions used by various pipeline components. 12 /// 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_TOOLS_LLVM_MCA_SUPPORT_H 16 #define LLVM_TOOLS_LLVM_MCA_SUPPORT_H 17 18 #include "llvm/ADT/ArrayRef.h" 19 #include "llvm/ADT/SmallVector.h" 20 #include "llvm/MC/MCSchedule.h" 21 22 namespace mca { 23 24 /// Populates vector Masks with processor resource masks. 25 /// 26 /// The number of bits set in a mask depends on the processor resource type. 27 /// Each processor resource mask has at least one bit set. For groups, the 28 /// number of bits set in the mask is equal to the cardinality of the group plus 29 /// one. Excluding the most significant bit, the remaining bits in the mask 30 /// identify processor resources that are part of the group. 31 /// 32 /// Example: 33 /// 34 /// ResourceA -- Mask: 0b001 35 /// ResourceB -- Mask: 0b010 36 /// ResourceAB -- Mask: 0b100 U (ResourceA::Mask | ResourceB::Mask) == 0b111 37 /// 38 /// ResourceAB is a processor resource group containing ResourceA and ResourceB. 39 /// Each resource mask uniquely identifies a resource; both ResourceA and 40 /// ResourceB only have one bit set. 41 /// ResourceAB is a group; excluding the most significant bit in the mask, the 42 /// remaining bits identify the composition of the group. 43 /// 44 /// Resource masks are used by the ResourceManager to solve set membership 45 /// problems with simple bit manipulation operations. 46 void computeProcResourceMasks(const llvm::MCSchedModel &SM, 47 llvm::SmallVectorImpl<uint64_t> &Masks); 48 49 /// Compute the reciprocal block throughput from a set of processor resource 50 /// cycles. The reciprocal block throughput is computed as the MAX between: 51 /// - NumMicroOps / DispatchWidth 52 /// - ProcResourceCycles / #ProcResourceUnits (for every consumed resource). 53 double computeBlockRThroughput(const llvm::MCSchedModel &SM, 54 unsigned DispatchWidth, unsigned NumMicroOps, 55 llvm::ArrayRef<unsigned> ProcResourceUsage); 56 } // namespace mca 57 58 #endif 59