| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2017-2021 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
|
| 9 |
#ifndef _IGA_KERNEL_HPP |
| 10 |
#define _IGA_KERNEL_HPP |
| 11 |
// WARNING: the IR is subject to change without any notice. External tools |
| 12 |
// should use the official interfaces in the external API. Those interfaces |
| 13 |
// are tested between releases and maintained even with changes to the IR. |
| 14 |
|
| 15 |
#include "../ErrorHandler.hpp" |
| 16 |
#include "../MemManager/MemManager.hpp" |
| 17 |
#include "../MemManager/StdArenaAllocator.hpp" |
| 18 |
#include "../Models/Models.hpp" |
| 19 |
#include "Block.hpp" |
| 20 |
#include "Instruction.hpp" |
| 21 |
|
| 22 |
#include <list> |
| 23 |
|
| 24 |
namespace iga { |
| 25 |
typedef std::list<iga::Block *, std_arena_based_allocator<iga::Block *>> |
| 26 |
BlockList; |
| 27 |
|
| 28 |
class Kernel { |
| 29 |
public: |
| 30 |
Kernel(const Model &model); |
| 31 |
~Kernel(); |
| 32 |
// disabling copy constructor to prevent problems with |
| 33 |
// shallow copy and mem manager |
| 34 |
Kernel(const Kernel &) = delete; |
| 35 |
Kernel &operator=(const Kernel &) = delete; |
| 36 |
|
| 37 |
void resetIds(); |
| 38 |
|
| 39 |
MemManager &getMemManager() { return m_mem; } |
| 40 |
const Model &getModel() const { return m_model; } |
| 41 |
const BlockList &getBlockList() const { return m_blocks; } |
| 42 |
BlockList &getBlockList() { return m_blocks; } |
| 43 |
size_t getInstructionCount() const; |
| 44 |
|
| 45 |
/////////////////////////////////////////////////////////////////////// |
| 46 |
// Kernel construction API's |
| 47 |
/////////////////////////////////////////////////////////////////////// |
| 48 |
|
| 49 |
// Creates a block at a given PC. The block must be appended to |
| 50 |
// the kernel. |
| 51 |
Block *createBlock(); |
| 52 |
void appendBlock(Block *blk); |
| 53 |
|
| 54 |
// Instruction constructors, the instruction returned must be appended |
| 55 |
// to a block or some other storage |
| 56 |
Instruction *createBasicInstruction(const OpSpec &op, const Predication &pred, |
| 57 |
const RegRef &freg, ExecSize execSize, |
| 58 |
ChannelOffset choff, MaskCtrl mc, |
| 59 |
FlagModifier fm, |
| 60 |
Subfunction sf); // InvalidFC::INVALID; |
| 61 |
|
| 62 |
Instruction *createBranchInstruction(const OpSpec &op, |
| 63 |
const Predication &predOpnd, |
| 64 |
const RegRef &flagReg, ExecSize execSize, |
| 65 |
ChannelOffset choff, MaskCtrl ectr, |
| 66 |
Subfunction sf); |
| 67 |
|
| 68 |
Instruction *createSendInstruction(const OpSpec &op, SFID sfid, |
| 69 |
const Predication &predOpnd, |
| 70 |
const RegRef &flagReg, ExecSize execSize, |
| 71 |
ChannelOffset choff, MaskCtrl ectr, |
| 72 |
uint32_t exDescImm, |
| 73 |
const SendDesc &extDesc, |
| 74 |
const SendDesc &msgDesc); |
| 75 |
|
| 76 |
// The ind0 and ind1 s0 subregs are in terms of *bytes* not QW |
| 77 |
// (as should be src0 in when indirect/gather send is used) |
| 78 |
Instruction *createSendgInstruction(const OpSpec &op, SFID sfid, |
| 79 |
const Predication &predOpnd, |
| 80 |
const RegRef &flagReg, ExecSize execSize, |
| 81 |
ChannelOffset choff, MaskCtrl ectr, |
| 82 |
int src0Len, int src1Len, RegRef id0, |
| 83 |
RegRef id1, uint64_t desc); |
| 84 |
|
| 85 |
Instruction *createThryldInstruction(); |
| 86 |
Instruction *createNopInstruction(); |
| 87 |
Instruction *createIllegalInstruction(); |
| 88 |
Instruction *createSyncNopInstruction(SWSB sw); |
| 89 |
Instruction *createSyncAllRdInstruction(SWSB sw); |
| 90 |
Instruction *createSyncAllWrInstruction(SWSB sw); |
| 91 |
Instruction * |
| 92 |
createInlineBinaryInstruction(const Instruction::InlineBinaryType &binary); |
| 93 |
|
| 94 |
private: |
| 95 |
const Model &m_model; |
| 96 |
MemManager m_mem; |
| 97 |
|
| 98 |
BlockList m_blocks; |
| 99 |
}; |
| 100 |
} // namespace iga |
| 101 |
|
| 102 |
#endif |