[llvm] [AVR] Avr fix build with lld (PR #152841)
Tom Vijlbrief via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 9 00:26:36 PDT 2025
https://github.com/tomtor created https://github.com/llvm/llvm-project/pull/152841
See https://github.com/llvm/llvm-project/pull/152028
@benshi001
>From 92239c84ddcb20aaffca804fcfcfcaeddc44f37f Mon Sep 17 00:00:00 2001
From: Tom Vijlbrief <tvijlbrief at gmail.com>
Date: Thu, 7 Aug 2025 12:06:32 +0200
Subject: [PATCH 1/2] Really Add .cpp
---
.../lib/Target/AVR/AVRTargetTransformInfo.cpp | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 llvm/lib/Target/AVR/AVRTargetTransformInfo.cpp
diff --git a/llvm/lib/Target/AVR/AVRTargetTransformInfo.cpp b/llvm/lib/Target/AVR/AVRTargetTransformInfo.cpp
new file mode 100644
index 0000000000000..b068068366f96
--- /dev/null
+++ b/llvm/lib/Target/AVR/AVRTargetTransformInfo.cpp
@@ -0,0 +1,27 @@
+//===-- AVRTargetTransformInfo.cpp - AVR specific TTI ---------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "AVRTargetTransformInfo.h"
+#include "llvm/CodeGen/CostTable.h"
+
+using namespace llvm;
+
+bool AVRTTIImpl::isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
+ const TargetTransformInfo::LSRCost &C2) const {
+ // AVR specific here are "instruction number 1st priority".
+ // If we need to emit adds inside the loop to add up base registers, then
+ // we need at least one extra temporary register.
+ unsigned C1NumRegs = C1.NumRegs + (C1.NumBaseAdds != 0);
+ unsigned C2NumRegs = C2.NumRegs + (C2.NumBaseAdds != 0);
+ return std::tie(C1.Insns, C1NumRegs, C1.AddRecCost,
+ C1.NumIVMuls, C1.NumBaseAdds,
+ C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
+ std::tie(C2.Insns, C2NumRegs, C2.AddRecCost,
+ C2.NumIVMuls, C2.NumBaseAdds,
+ C2.ScaleCost, C2.ImmCost, C2.SetupCost);
+}
>From 9dda75e7e4bdaf5a02629dff0453e2d97d476338 Mon Sep 17 00:00:00 2001
From: Tom Vijlbrief <tvijlbrief at gmail.com>
Date: Thu, 7 Aug 2025 12:00:16 +0200
Subject: [PATCH 2/2] Add .cpp
---
llvm/lib/Target/AVR/AVRTargetTransformInfo.h | 7 +------
llvm/lib/Target/AVR/CMakeLists.txt | 1 +
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Target/AVR/AVRTargetTransformInfo.h b/llvm/lib/Target/AVR/AVRTargetTransformInfo.h
index 5ef2e6abc75fc..0daeeb8f11cfe 100644
--- a/llvm/lib/Target/AVR/AVRTargetTransformInfo.h
+++ b/llvm/lib/Target/AVR/AVRTargetTransformInfo.h
@@ -43,12 +43,7 @@ class AVRTTIImpl final : public BasicTTIImplBase<AVRTTIImpl> {
TLI(ST->getTargetLowering()) {}
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
- const TargetTransformInfo::LSRCost &C2) const override {
- if (C2.Insns == ~0u)
- return true;
- return 2 * C1.Insns + C1.AddRecCost + C1.SetupCost + C1.NumRegs <
- 2 * C2.Insns + C2.AddRecCost + C2.SetupCost + C2.NumRegs;
- }
+ const TargetTransformInfo::LSRCost &C2) const override;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/AVR/CMakeLists.txt b/llvm/lib/Target/AVR/CMakeLists.txt
index 781dac02c7083..864936d1f6155 100644
--- a/llvm/lib/Target/AVR/CMakeLists.txt
+++ b/llvm/lib/Target/AVR/CMakeLists.txt
@@ -29,6 +29,7 @@ add_llvm_target(AVRCodeGen
AVRSubtarget.cpp
AVRTargetMachine.cpp
AVRTargetObjectFile.cpp
+ AVRTargetTransformInfo.cpp
DEPENDS
intrinsics_gen
More information about the llvm-commits
mailing list