1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
//
// Copyright © 2020,2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <cstdint>
#include <map>
#include <string>
namespace arm
{
namespace pipe
{
class ICounterMappings
{
public:
virtual uint16_t GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const = 0;
virtual const std::pair<uint16_t, std::string>& GetBackendId(uint16_t globalCounterId) const = 0;
virtual ~ICounterMappings() {}
};
class IRegisterCounterMapping
{
public:
virtual void RegisterMapping(uint16_t globalCounterId,
uint16_t backendCounterId,
const std::string& backendId) = 0;
virtual void Reset() = 0;
virtual ~IRegisterCounterMapping() {}
};
class CounterIdMap : public ICounterMappings, public IRegisterCounterMapping
{
public:
CounterIdMap() = default;
virtual ~CounterIdMap() {}
void RegisterMapping(uint16_t globalCounterId,
uint16_t backendCounterId,
const std::string& backendId) override;
void Reset() override;
uint16_t GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const override;
const std::pair<uint16_t, std::string>& GetBackendId(uint16_t globalCounterId) const override;
private:
std::map<uint16_t, std::pair<uint16_t, std::string>> m_GlobalCounterIdMap;
std::map<std::pair<uint16_t, std::string>, uint16_t> m_BackendCounterIdMap;
};
} // namespace pipe
} // namespace arm
|