MLIR
23.0.0git
include
mlir
Dialect
AMDGPU
IR
AMDGPUEnums.h
Go to the documentation of this file.
1
//===- Utils.h - General AMDGPU Enums utilities -----------------*- C++ -*-===//
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
#ifndef MLIR_DIALECT_AMDGPU_UTILS_AMDGPU_ENUMS_H_
9
#define MLIR_DIALECT_AMDGPU_UTILS_AMDGPU_ENUMS_H_
10
11
#include "
mlir/Dialect/AMDGPU/IR/AMDGPUDialect.h
"
12
#include "mlir/Dialect/AMDGPU/IR/AMDGPUEnums.h.inc"
13
#include "llvm/ADT/STLExtras.h"
14
15
namespace
mlir::amdgpu
{
16
17
inline
int32_t
getGlobalPrefetchLLVMEncoding
(amdgpu::LoadTemporalHint hint,
18
amdgpu::Scope scope,
19
bool
isSpeculative) {
20
int32_t immArg =
static_cast<
int32_t
>
(hint);
21
22
// Note that only RT and HT can operate in both speculative and
23
// non-speculative modes. The other variants (NT_RT, RT_NT, NT_HT, etc.)
24
// operate only in the speculative mode and, therefore, do not require
25
// toggling the least significant bit for mode changes
26
// Temporal hint is encoded in lower bits - i.e. [2:0]
27
if
(llvm::is_contained({LoadTemporalHint::RT, LoadTemporalHint::HT}, hint))
28
immArg = isSpeculative ? immArg : immArg | 1;
29
30
// Prefetch scope level is encoded in upper bits - i.e., [4:3]
31
return
static_cast<
int32_t
>
(scope) << 3 | immArg;
32
}
33
34
}
// namespace mlir::amdgpu
35
36
#endif
AMDGPUDialect.h
mlir::amdgpu
Definition
AMDGPUToROCDL.h:32
mlir::amdgpu::getGlobalPrefetchLLVMEncoding
int32_t getGlobalPrefetchLLVMEncoding(amdgpu::LoadTemporalHint hint, amdgpu::Scope scope, bool isSpeculative)
Definition
AMDGPUEnums.h:17
Generated on
for MLIR by
1.14.0