1 //===--------------------- Support.h ----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// Helper functions used by various pipeline components.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TOOLS_LLVM_MCA_SUPPORT_H
16 #define LLVM_TOOLS_LLVM_MCA_SUPPORT_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/MC/MCSchedule.h"
24 /// Populates vector Masks with processor resource masks.
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.
34 /// ResourceA -- Mask: 0b001
35 /// ResourceB -- Mask: 0b010
36 /// ResourceAB -- Mask: 0b100 U (ResourceA::Mask | ResourceB::Mask) == 0b111
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.
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);
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);