1//===-- AArch64MemoryHints.h - AArch64 Memory Hint Attributes ---*- 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
9#ifndef LLVM_SUPPORT_AARCH64MEMORYHINTS_H
10#define LLVM_SUPPORT_AARCH64MEMORYHINTS_H
11
12namespace llvm {
13enum class AArch64MemoryHint {
14 NONE = 0,
15 STSHH_KEEP = 1,
16 STSHH_STRM = 2,
17 STCPH = 3,
18 SHUH = 4,
19 SHUH_PH = 5,
20};
21
22template <typename Int> inline bool isValidAArch64MemoryHintValue(Int I) {
23 return (Int)AArch64MemoryHint::STSHH_KEEP <= I &&
24 I <= (Int)AArch64MemoryHint::SHUH_PH;
25}
26
27template <typename Int> inline AArch64MemoryHint toAArch64MemoryHint(Int I) {
28 switch (I) {
29 case 0:
30 return AArch64MemoryHint::STSHH_KEEP;
31 case 1:
32 return AArch64MemoryHint::STSHH_STRM;
33 case 2:
34 return AArch64MemoryHint::STCPH;
35 case 3:
36 return AArch64MemoryHint::SHUH;
37 case 4:
38 return AArch64MemoryHint::SHUH_PH;
39 default:
40 return AArch64MemoryHint::NONE;
41 }
42}
43} // namespace llvm
44#endif // LLVM_SUPPORT_AARCH64MEMORYHINTS_H
45