File: PayloadMapping.hpp

package info (click to toggle)
intel-graphics-compiler2 2.16.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 106,644 kB
  • sloc: cpp: 805,640; lisp: 287,672; ansic: 16,414; python: 3,952; yacc: 2,588; lex: 1,666; pascal: 313; sh: 186; makefile: 35
file content (97 lines) | stat: -rw-r--r-- 4,670 bytes parent folder | download
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*========================== begin_copyright_notice ============================

Copyright (C) 2017-2021 Intel Corporation

SPDX-License-Identifier: MIT

============================= end_copyright_notice ===========================*/

//===----------------------------------------------------------------------===//
//
// A helper class that returns a mapping from message generating
// intrinsic (e.g. sample, load, urb_write) arguments to their respective
// positions in the payload message.
//
//===----------------------------------------------------------------------===//

#pragma once
#include "Compiler/CISACodeGen/Platform.hpp"
#include "Compiler/CodeGenPublic.h"
#include "common/LLVMWarningsPush.hpp"
#include <llvm/IR/Function.h>
#include <llvm/IR/Instruction.h>
#include <llvm/IR/IntrinsicInst.h>
#include "common/LLVMWarningsPop.hpp"
#include "Compiler/CISACodeGen/helper.h"
#include "GenISAIntrinsics/GenIntrinsicInst.h"
#include "common/Types.hpp"
#include "Probe/Assertion.h"

namespace IGC {

class PayloadMapping {
  friend class CoalescingEngine;

public:
  void ValidateNumberofSources(EOPCODE opCode, bool isCube, uint &numberofSrcs);

  typedef llvm::DenseMap<std::pair<const llvm::Instruction *, uint>, llvm::Value *> PayloadMappingCache;

protected:
  PayloadMapping() : m_CodeGenContext(nullptr) {}
  PayloadMapping(CodeGenContext *ctx) : m_CodeGenContext(ctx) {}

  /// ------------------------------
  uint GetNumPayloadElements(const llvm::Instruction *inst);
  uint GetNumPayloadElements_URBWrite(const llvm::GenIntrinsicInst *inst);
  uint GetNumPayloadElements_RTWrite(const llvm::GenIntrinsicInst *inst);
  uint GetNumPayloadElements_DSRTWrite(const llvm::GenIntrinsicInst *inst);
  uint GetNumPayloadElements_LDMS(const llvm::GenIntrinsicInst *inst);
  uint GetNonAdjustedNumPayloadElements_Sample(const llvm::SampleIntrinsic *inst);
  uint GetNumPayloadElements_Sample(const llvm::SampleIntrinsic *inst);
  uint GetNumPayloadElements_AtomicTyped(const llvm::GenIntrinsicInst *inst);

  /// ------------------------------
  /// \brief Get the mapping from the payload element (at position index)
  /// to intrinsic argument value. Indexing is zero based.
  llvm::Value *GetPayloadElementToValueMapping(const llvm::Instruction *inst, uint index);
  llvm::Value *GetPayloadElementToValueMapping_URBWrite(const llvm::GenIntrinsicInst *inst, uint index);
  llvm::Value *GetPayloadElementToValueMapping_RTWrite(const llvm::GenIntrinsicInst *inst, const uint index);
  llvm::Value *GetPayloadElementToValueMapping_DSRTWrite(const llvm::GenIntrinsicInst *inst, const uint index);
  uint GetNonAdjustedPayloadElementIndexToValueIndexMapping_sample(const llvm::SampleIntrinsic *inst, uint index);
  llvm::Value *GetPayloadElementToValueMapping_LDMS(const llvm::SamplerLoadIntrinsic *inst, const uint index);
  llvm::Value *GetNonAdjustedPayloadElementToValueMapping_sample(const llvm::SampleIntrinsic *inst, const uint index);
  llvm::Value *GetPayloadElementToValueMapping_sample(const llvm::SampleIntrinsic *inst, const uint index);
  llvm::Value *GetPayloadElementToValueMapping_AtomicTyped(const llvm::AtomicTypedIntrinsic *inst, const uint index);

  // Handling of non-homogeneous payloads (RT write)
  const llvm::Instruction *GetSupremumOfNonHomogeneousPart(const llvm::Instruction *inst1,
                                                           const llvm::Instruction *inst2);
  int GetRightReservedOffset(const llvm::Instruction *inst, SIMDMode simdMode);
  int GetLeftReservedOffset(const llvm::Instruction *inst, SIMDMode simdMode);
  bool HasNonHomogeneousPayloadElements(const llvm::Instruction *inst);
  const llvm::Instruction *GetSupremumOfNonHomogeneousPart_RTWrite(const llvm::RTWriteIntrinsic *inst1,
                                                                   const llvm::RTWriteIntrinsic *inst2);
  template <typename T> int GetLeftReservedOffset_RTWrite(const T *inst, SIMDMode simdMode);
  template <typename T> int GetRightReservedOffset_RTWrite(const T *inst, SIMDMode simdMode);
  template <typename T> bool HasNonHomogeneousPayloadElements_RTWrite(const T *inst);

  /// ------------------------------
  bool IsUndefOrZeroImmediate(const llvm::Value *value);
  bool IsZeroLOD(const llvm::SampleIntrinsic *inst);
  bool DoPeelFirstElement(const llvm::Instruction *inst);

  bool DoesAllowSplit(const llvm::Instruction *inst) {
    IGC_ASSERT(llvm::isa<llvm::GenIntrinsicInst>(inst));
    if (llvm::dyn_cast<llvm::SampleIntrinsic>(inst)) {
      return true;
    }
    return false;
  }

private:
  CodeGenContext *m_CodeGenContext;
  PayloadMappingCache m_PayloadMappingCache;
};

} // End namespace IGC