1 //===------------ rtl.h - Target independent OpenMP target RTL ------------===// 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 // 9 // Declarations for handling RTL plugins. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef _OMPTARGET_RTL_H 14 #define _OMPTARGET_RTL_H 15 16 #include "llvm/ADT/SmallVector.h" 17 18 #include "omptarget.h" 19 20 #include <cstdint> 21 #include <map> 22 23 /// Map between the host entry begin and the translation table. Each 24 /// registered library gets one TranslationTable. Use the map from 25 /// llvm::offloading::EntryTy so that we may quickly determine whether we 26 /// are trying to (re)register an existing lib or really have a new one. 27 struct TranslationTable { 28 __tgt_target_table HostTable; 29 llvm::SmallVector<__tgt_target_table> DeviceTables; 30 31 // Image assigned to a given device. 32 llvm::SmallVector<__tgt_device_image *> 33 TargetsImages; // One image per device ID. 34 35 // Arrays of entries active on the device. 36 llvm::SmallVector<llvm::SmallVector<llvm::offloading::EntryTy>> 37 TargetsEntries; // One table per device ID. 38 39 // Table of entry points or NULL if it was not already computed. 40 llvm::SmallVector<__tgt_target_table *> 41 TargetsTable; // One table per device ID. 42 }; 43 typedef std::map<llvm::offloading::EntryTy *, TranslationTable> 44 HostEntriesBeginToTransTableTy; 45 46 /// Map between the host ptr and a table index 47 struct TableMap { 48 TranslationTable *Table = nullptr; // table associated with the host ptr. 49 uint32_t Index = 0; // index in which the host ptr translated entry is found. 50 TableMap() = default; 51 TableMap(TranslationTable *Table, uint32_t Index) 52 : Table(Table), Index(Index) {} 53 }; 54 typedef std::map<void *, TableMap> HostPtrToTableMapTy; 55 56 #endif 57