LLVM  8.0.1
X86InstrFMA3Info.h
Go to the documentation of this file.
1 //===- X86InstrFMA3Info.h - X86 FMA3 Instruction Information ----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the implementation of the classes providing information
11 // about existing X86 FMA3 opcodes, classifying and grouping them.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_X86_UTILS_X86INSTRFMA3INFO_H
16 #define LLVM_LIB_TARGET_X86_UTILS_X86INSTRFMA3INFO_H
17 
18 #include "X86.h"
19 #include "llvm/ADT/DenseMap.h"
20 #include <cassert>
21 #include <cstdint>
22 #include <set>
23 
24 namespace llvm {
25 
26 /// This class is used to group {132, 213, 231} forms of FMA opcodes together.
27 /// Each of the groups has either 3 opcodes, Also, each group has an attributes
28 /// field describing it.
30  /// An array holding 3 forms of FMA opcodes.
31  uint16_t Opcodes[3];
32 
33  /// This bitfield specifies the attributes associated with the created
34  /// FMA groups of opcodes.
35  uint16_t Attributes;
36 
37  enum {
41  };
42 
43  enum : uint16_t {
44  /// This bit must be set in the 'Attributes' field of FMA group if such
45  /// group of FMA opcodes consists of FMA intrinsic opcodes.
46  Intrinsic = 0x1,
47 
48  /// This bit must be set in the 'Attributes' field of FMA group if such
49  /// group of FMA opcodes consists of AVX512 opcodes accepting a k-mask and
50  /// passing the elements from the 1st operand to the result of the operation
51  /// when the correpondings bits in the k-mask are unset.
52  KMergeMasked = 0x2,
53 
54  /// This bit must be set in the 'Attributes' field of FMA group if such
55  /// group of FMA opcodes consists of AVX512 opcodes accepting a k-zeromask.
56  KZeroMasked = 0x4,
57  };
58 
59  /// Returns the 132 form of FMA opcode.
60  unsigned get132Opcode() const {
61  return Opcodes[Form132];
62  }
63 
64  /// Returns the 213 form of FMA opcode.
65  unsigned get213Opcode() const {
66  return Opcodes[Form213];
67  }
68 
69  /// Returns the 231 form of FMA opcode.
70  unsigned get231Opcode() const {
71  return Opcodes[Form231];
72  }
73 
74  /// Returns true iff the group of FMA opcodes holds intrinsic opcodes.
75  bool isIntrinsic() const { return (Attributes & Intrinsic) != 0; }
76 
77  /// Returns true iff the group of FMA opcodes holds k-merge-masked opcodes.
78  bool isKMergeMasked() const {
79  return (Attributes & KMergeMasked) != 0;
80  }
81 
82  /// Returns true iff the group of FMA opcodes holds k-zero-masked opcodes.
83  bool isKZeroMasked() const { return (Attributes &KZeroMasked) != 0; }
84 
85  /// Returns true iff the group of FMA opcodes holds any of k-masked opcodes.
86  bool isKMasked() const {
87  return (Attributes & (KMergeMasked | KZeroMasked)) != 0;
88  }
89 
90  bool operator<(const X86InstrFMA3Group &RHS) const {
91  return Opcodes[0] < RHS.Opcodes[0];
92  }
93 };
94 
95 /// Returns a reference to a group of FMA3 opcodes to where the given
96 /// \p Opcode is included. If the given \p Opcode is not recognized as FMA3
97 /// and not included into any FMA3 group, then nullptr is returned.
98 const X86InstrFMA3Group *getFMA3Group(unsigned Opcode, uint64_t TSFlags);
99 
100 } // end namespace llvm
101 
102 #endif // LLVM_LIB_TARGET_X86_UTILS_X86INSTRFMA3INFO_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This class is used to group {132, 213, 231} forms of FMA opcodes together.
bool isKMasked() const
Returns true iff the group of FMA opcodes holds any of k-masked opcodes.
bool isKMergeMasked() const
Returns true iff the group of FMA opcodes holds k-merge-masked opcodes.
unsigned get213Opcode() const
Returns the 213 form of FMA opcode.
bool operator<(const X86InstrFMA3Group &RHS) const
This bit must be set in the &#39;Attributes&#39; field of FMA group if such group of FMA opcodes consists of ...
unsigned get231Opcode() const
Returns the 231 form of FMA opcode.
bool isIntrinsic() const
Returns true iff the group of FMA opcodes holds intrinsic opcodes.
const X86InstrFMA3Group * getFMA3Group(unsigned Opcode, uint64_t TSFlags)
Returns a reference to a group of FMA3 opcodes to where the given Opcode is included.
uint16_t Opcodes[3]
An array holding 3 forms of FMA opcodes.
This bit must be set in the &#39;Attributes&#39; field of FMA group if such group of FMA opcodes consists of ...
This bit must be set in the &#39;Attributes&#39; field of FMA group if such group of FMA opcodes consists of ...
uint16_t Attributes
This bitfield specifies the attributes associated with the created FMA groups of opcodes.
bool isKZeroMasked() const
Returns true iff the group of FMA opcodes holds k-zero-masked opcodes.
unsigned get132Opcode() const
Returns the 132 form of FMA opcode.