[ARM] MVE sext costs
[llvm-complete.git] / lib / MCA / Stages / InstructionTables.cpp
blobadeefb45ec2d9691293d6bd82a921b541725f0a4
1 //===--------------------- InstructionTables.cpp ----------------*- 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 /// \file
9 ///
10 /// This file implements the method InstructionTables::execute().
11 /// Method execute() prints a theoretical resource pressure distribution based
12 /// on the information available in the scheduling model, and without running
13 /// the pipeline.
14 ///
15 //===----------------------------------------------------------------------===//
17 #include "llvm/MCA/Stages/InstructionTables.h"
19 namespace llvm {
20 namespace mca {
22 Error InstructionTables::execute(InstRef &IR) {
23 const InstrDesc &Desc = IR.getInstruction()->getDesc();
24 UsedResources.clear();
26 // Identify the resources consumed by this instruction.
27 for (const std::pair<uint64_t, ResourceUsage> Resource : Desc.Resources) {
28 // Skip zero-cycle resources (i.e., unused resources).
29 if (!Resource.second.size())
30 continue;
31 unsigned Cycles = Resource.second.size();
32 unsigned Index = std::distance(
33 Masks.begin(), std::find(Masks.begin(), Masks.end(), Resource.first));
34 const MCProcResourceDesc &ProcResource = *SM.getProcResource(Index);
35 unsigned NumUnits = ProcResource.NumUnits;
36 if (!ProcResource.SubUnitsIdxBegin) {
37 // The number of cycles consumed by each unit.
38 for (unsigned I = 0, E = NumUnits; I < E; ++I) {
39 ResourceRef ResourceUnit = std::make_pair(Index, 1U << I);
40 UsedResources.emplace_back(
41 std::make_pair(ResourceUnit, ResourceCycles(Cycles, NumUnits)));
43 continue;
46 // This is a group. Obtain the set of resources contained in this
47 // group. Some of these resources may implement multiple units.
48 // Uniformly distribute Cycles across all of the units.
49 for (unsigned I1 = 0; I1 < NumUnits; ++I1) {
50 unsigned SubUnitIdx = ProcResource.SubUnitsIdxBegin[I1];
51 const MCProcResourceDesc &SubUnit = *SM.getProcResource(SubUnitIdx);
52 // Compute the number of cycles consumed by each resource unit.
53 for (unsigned I2 = 0, E2 = SubUnit.NumUnits; I2 < E2; ++I2) {
54 ResourceRef ResourceUnit = std::make_pair(SubUnitIdx, 1U << I2);
55 UsedResources.emplace_back(std::make_pair(
56 ResourceUnit, ResourceCycles(Cycles, NumUnits * SubUnit.NumUnits)));
61 // Send a fake instruction issued event to all the views.
62 HWInstructionIssuedEvent Event(IR, UsedResources);
63 notifyEvent<HWInstructionIssuedEvent>(Event);
64 return ErrorSuccess();
67 } // namespace mca
68 } // namespace llvm