using namespace llvm;
-static ManagedStatic<X86InstrFMA3Info> X86InstrFMA3InfoObj;
-X86InstrFMA3Info *X86InstrFMA3Info::getX86InstrFMA3Info() {
- return &*X86InstrFMA3InfoObj;
-}
-
#define FMA3BASE(X132, X213, X231, Attrs) \
{ { X132, X213, X231 }, Attrs },
FMA3_AVX512_VECTOR_GROUP(VFMSUBADD)
};
-X86InstrFMA3Info::X86InstrFMA3Info() {
- for (const X86InstrFMA3Group &G : Groups) {
- OpcodeToGroup[G.Opcodes[0]] = &G;
- OpcodeToGroup[G.Opcodes[1]] = &G;
- OpcodeToGroup[G.Opcodes[2]] = &G;
+namespace {
+
+struct X86InstrFMA3Info {
+ /// A map that is used to find the group of FMA opcodes using any FMA opcode
+ /// from the group.
+ DenseMap<unsigned, const X86InstrFMA3Group *> OpcodeToGroup;
+
+ /// Constructor. Just creates an object of the class.
+ X86InstrFMA3Info() {
+ for (const X86InstrFMA3Group &G : Groups) {
+ OpcodeToGroup[G.Opcodes[0]] = &G;
+ OpcodeToGroup[G.Opcodes[1]] = &G;
+ OpcodeToGroup[G.Opcodes[2]] = &G;
+ }
}
+};
+
+}
+
+static ManagedStatic<X86InstrFMA3Info> X86FMA3InfoObj;
+
+/// Returns a reference to a group of FMA3 opcodes to where the given
+/// \p Opcode is included. If the given \p Opcode is not recognized as FMA3
+/// and not included into any FMA3 group, then nullptr is returned.
+const X86InstrFMA3Group *llvm::getFMA3Group(unsigned Opcode) {
+ auto &Map = X86FMA3InfoObj->OpcodeToGroup;
+ auto I = Map.find(Opcode);
+ if (I != Map.end())
+ return I->second;
+
+ return nullptr;
}
}
};
-/// This class provides information about all existing FMA3 opcodes
-///
-class X86InstrFMA3Info final {
-private:
- /// A map that is used to find the group of FMA opcodes using any FMA opcode
- /// from the group.
- DenseMap<unsigned, const X86InstrFMA3Group *> OpcodeToGroup;
-
-public:
- /// Returns the reference to an object of this class. It is assumed that
- /// only one object may exist.
- static X86InstrFMA3Info *getX86InstrFMA3Info();
-
- /// Constructor. Just creates an object of the class.
- X86InstrFMA3Info();
-
- /// Returns a reference to a group of FMA3 opcodes to where the given
- /// \p Opcode is included. If the given \p Opcode is not recognized as FMA3
- /// and not included into any FMA3 group, then nullptr is returned.
- static const X86InstrFMA3Group *getFMA3Group(unsigned Opcode) {
- // Find the group including the given opcode.
- const X86InstrFMA3Info *FMA3Info = getX86InstrFMA3Info();
- auto I = FMA3Info->OpcodeToGroup.find(Opcode);
- if (I == FMA3Info->OpcodeToGroup.end())
- return nullptr;
-
- return I->second;
- }
-
- /// Returns true iff the given \p Opcode is recognized as FMA3 by this class.
- static bool isFMA3(unsigned Opcode) {
- return getFMA3Group(Opcode) != nullptr;
- }
-};
+/// Returns a reference to a group of FMA3 opcodes to where the given
+/// \p Opcode is included. If the given \p Opcode is not recognized as FMA3
+/// and not included into any FMA3 group, then nullptr is returned.
+const X86InstrFMA3Group *getFMA3Group(unsigned Opcode);
} // end namespace llvm
OpIdx1, OpIdx2);
}
- const X86InstrFMA3Group *FMA3Group =
- X86InstrFMA3Info::getFMA3Group(MI.getOpcode());
+ const X86InstrFMA3Group *FMA3Group = getFMA3Group(MI.getOpcode());
if (FMA3Group) {
unsigned Opc =
getFMA3OpcodeToCommuteOperands(MI, OpIdx1, OpIdx2, *FMA3Group);
}
default:
- const X86InstrFMA3Group *FMA3Group =
- X86InstrFMA3Info::getFMA3Group(MI.getOpcode());
+ const X86InstrFMA3Group *FMA3Group = getFMA3Group(MI.getOpcode());
if (FMA3Group)
return findThreeSrcCommutedOpIndices(MI, SrcOpIdx1, SrcOpIdx2,
FMA3Group->isIntrinsic());