David Monahan | de80307 | 2020-01-30 12:44:23 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
David Monahan | de80307 | 2020-01-30 12:44:23 +0000 | [diff] [blame] | 7 | #include <map> |
| 8 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 9 | namespace arm |
David Monahan | de80307 | 2020-01-30 12:44:23 +0000 | [diff] [blame] | 10 | { |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 11 | namespace pipe |
David Monahan | de80307 | 2020-01-30 12:44:23 +0000 | [diff] [blame] | 12 | { |
| 13 | |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 14 | class ICounterMappings |
| 15 | { |
| 16 | public: |
Cathal Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame^] | 17 | virtual uint16_t GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const = 0; |
| 18 | virtual const std::pair<uint16_t, std::string>& GetBackendId(uint16_t globalCounterId) const = 0; |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 19 | virtual ~ICounterMappings() {} |
| 20 | }; |
| 21 | |
| 22 | class IRegisterCounterMapping |
| 23 | { |
| 24 | public: |
| 25 | virtual void RegisterMapping(uint16_t globalCounterId, |
| 26 | uint16_t backendCounterId, |
Cathal Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame^] | 27 | const std::string& backendId) = 0; |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 28 | virtual void Reset() = 0; |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 29 | virtual ~IRegisterCounterMapping() {} |
| 30 | }; |
| 31 | |
| 32 | class CounterIdMap : public ICounterMappings, public IRegisterCounterMapping |
David Monahan | de80307 | 2020-01-30 12:44:23 +0000 | [diff] [blame] | 33 | { |
| 34 | |
| 35 | public: |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 36 | CounterIdMap() = default; |
| 37 | virtual ~CounterIdMap() {} |
| 38 | void RegisterMapping(uint16_t globalCounterId, |
| 39 | uint16_t backendCounterId, |
Cathal Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame^] | 40 | const std::string& backendId) override; |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 41 | void Reset() override; |
Cathal Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame^] | 42 | uint16_t GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const override; |
| 43 | const std::pair<uint16_t, std::string>& GetBackendId(uint16_t globalCounterId) const override; |
David Monahan | de80307 | 2020-01-30 12:44:23 +0000 | [diff] [blame] | 44 | private: |
Cathal Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame^] | 45 | std::map<uint16_t, std::pair<uint16_t, std::string>> m_GlobalCounterIdMap; |
| 46 | std::map<std::pair<uint16_t, std::string>, uint16_t> m_BackendCounterIdMap; |
David Monahan | de80307 | 2020-01-30 12:44:23 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 49 | } // namespace pipe |
| 50 | } // namespace arm |