[llvm] [AArch64] Support instruction fusion for MCA (PR #215789)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 11:12:08 PDT 2026
================
@@ -0,0 +1,354 @@
+//===--------------- AArch64CustomBehaviour.cpp -----------------*-C++ -* -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file defines custom behaviour for MCA that is not expressed in the
+/// schedule model.
+///
+//===----------------------------------------------------------------------===//
+
+#include "AArch64InstrInfo.h"
+#include "AArch64Subtarget.h"
+#include "TargetInfo/AArch64TargetInfo.h"
+#include "llvm-c/Visibility.h"
+#include "llvm/MC/TargetRegistry.h"
+#include "llvm/MCA/CustomBehaviour.h"
+#include "llvm/TargetParser/TargetParser.h"
+
+using namespace llvm;
+using namespace mca;
+
+class AArch64InstrPostProcess : public InstrPostProcess {
+ mca::Instruction *PreviousInst;
+ const MCInst *PreviousMCI;
+
+public:
+ AArch64InstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
+ : InstrPostProcess(STI, MCII), PreviousInst(nullptr),
+ PreviousMCI(nullptr) {}
+
+ ~AArch64InstrPostProcess() override = default;
+
+ void postProcessInstruction(mca::Instruction &Inst,
+ const MCInst &MCI) override;
+ void resetState() override;
+};
+
+/// AES encoding or decoding.
+static bool isAESPair(const MCInst &First, const MCInst &Second) {
----------------
mshockwave wrote:
As @tomershafir also pointed out, we really should generate a MCInst version of macro fusion patterns from TableGen. But let's do it in another patch.
https://github.com/llvm/llvm-project/pull/215789
More information about the llvm-commits
mailing list