File: PacketBuilder_mem.cpp

package info (click to toggle)
intel-graphics-compiler 1.0.17791.18-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 102,312 kB
  • sloc: cpp: 935,343; lisp: 286,143; ansic: 16,196; python: 3,279; yacc: 2,487; lex: 1,642; pascal: 300; sh: 174; makefile: 27
file content (90 lines) | stat: -rw-r--r-- 3,213 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
/*========================== begin_copyright_notice ============================

Copyright (C) 2018-2024 Intel Corporation

SPDX-License-Identifier: MIT

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

#include "PacketBuilder.h"
#include "Probe/Assertion.h"
#include <cstdarg>

namespace pktz {
void PacketBuilder::assertMemoryUsageParams(Value *Ptr) {
  IGC_ASSERT_MESSAGE(Ptr->getType() != Int64Ty,
                     "Address appears to be GFX access.  Requires translation "
                     "through BuilderGfxMem.");
}

GetElementPtrInst *
PacketBuilder::GEP(Type *Ty, Value *Ptr,
                   const std::initializer_list<uint32_t> &IndexList,
                   const Twine &Name) {
  std::vector<Value *> Indices;
  for (auto Idx : IndexList)
    Indices.push_back(C(Idx));
  return GEPA(Ty, Ptr, Indices, Name);
}

GetElementPtrInst *PacketBuilder::GEPA(Type *Ty, Value *Ptr,
                                       ArrayRef<Value *> IdxList,
                                       const Twine &Name) {
  return cast<GetElementPtrInst>(IRB->CreateGEP(Ty, Ptr, IdxList, Name));
}

LoadInst *PacketBuilder::LOAD(Type *Ty, Value *Ptr, const Twine &Name) {
  assertMemoryUsageParams(Ptr);
  return IRB->CreateLoad(Ty, Ptr, Name);
}

LoadInst *PacketBuilder::LOAD(Type *Ty, Value *BasePtr,
                              const std::initializer_list<uint32_t> &IndexList,
                              const llvm::Twine &Name) {
  std::vector<Value *> Indices;
  for (auto Idx : IndexList)
    Indices.push_back(C(Idx));
  auto *GEPInst = GEPA(Ty, BasePtr, Indices);
  return PacketBuilder::LOAD(GEPInst->getSourceElementType(), GEPInst, Name);
}

LoadInst *PacketBuilder::ALIGNED_LOAD(Type *Ty, Value *Ptr, IGCLLVM::Align Align,
                                      const Twine &Name) {
  return IRB->CreateAlignedLoad(Ty, Ptr, Align, Name);
}

AllocaInst *PacketBuilder::ALLOCA(Type *Ty, Value *ArraySize,
                                  const Twine &Name) {
  return IRB->CreateAlloca(Ty, ArraySize, Name);
}

Value *PacketBuilder::INT_TO_PTR(Value *V, Type *DestTy, const Twine &Name) {
  return IRB->CreateIntToPtr(V, DestTy, Name);
}

CallInst *PacketBuilder::MASKED_GATHER(Type *Ty, Value *Ptrs, unsigned Align,
                                       Value *Mask, Value *PassThru,
                                       const Twine &Name) {
  return IRB->CreateMaskedGather(
      Ty, Ptrs, IGCLLVM::getAlignmentValueIfNeeded(IGCLLVM::getAlign(Align)),
      Mask, PassThru, Name);
}

CallInst *PacketBuilder::MASKED_SCATTER(Value *Val, Value *Ptrs, unsigned Align,
                                        Value *Mask) {
  return IRB->CreateMaskedScatter(
      Val, Ptrs, IGCLLVM::getAlignmentValueIfNeeded(IGCLLVM::getAlign(Align)),
      Mask);
}

CallInst *PacketBuilder::MASKED_STORE(Value *Val, Value *Ptr, unsigned Align,
                                      Value *Mask) {
  return IRB->CreateMaskedStore(
      Val, Ptr, IGCLLVM::getAlignmentValueIfNeeded(IGCLLVM::getAlign(Align)),
      Mask);
}

StoreInst *PacketBuilder::STORE(Value *Val, Value *Ptr, bool IsVolatile) {
  return IRB->CreateStore(Val, Ptr, IsVolatile);
}
} // namespace pktz