blob: fd8d8b5a23b3826f39f81d414de5d4980a5727c8 [file] [log] [blame]
Andrea Di Biagio4704f032018-03-20 12:25:54 +00001//===--------------------- 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///
Matt Davisdea343d2018-06-25 16:53:00 +000011/// Helper functions used by various pipeline components.
Andrea Di Biagio4704f032018-03-20 12:25:54 +000012///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TOOLS_LLVM_MCA_SUPPORT_H
16#define LLVM_TOOLS_LLVM_MCA_SUPPORT_H
17
Andrea Di Biagiobdc67062018-06-01 14:35:21 +000018#include "llvm/ADT/ArrayRef.h"
Andrea Di Biagio4704f032018-03-20 12:25:54 +000019#include "llvm/ADT/SmallVector.h"
20#include "llvm/MC/MCSchedule.h"
21
22namespace 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.
46void computeProcResourceMasks(const llvm::MCSchedModel &SM,
47 llvm::SmallVectorImpl<uint64_t> &Masks);
Andrea Di Biagiobdc67062018-06-01 14:35:21 +000048
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).
53double computeBlockRThroughput(const llvm::MCSchedModel &SM,
54 unsigned DispatchWidth, unsigned NumMicroOps,
55 llvm::ArrayRef<unsigned> ProcResourceUsage);
Andrea Di Biagio4704f032018-03-20 12:25:54 +000056} // namespace mca
57
58#endif