Skip to content

Commit 160f5ca

Browse files
authored
[AVR][NFC] Split AVRTargetTransformInfo.h to AVRTargetTransformInfo.cpp (#152841)
1 parent 91cdd35 commit 160f5ca

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===-- AVRTargetTransformInfo.cpp - AVR specific TTI ---------------------===//
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+
#include "AVRTargetTransformInfo.h"
10+
#include "llvm/CodeGen/CostTable.h"
11+
12+
using namespace llvm;
13+
14+
bool AVRTTIImpl::isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
15+
const TargetTransformInfo::LSRCost &C2) const {
16+
// AVR specific here are "instruction number 1st priority".
17+
// If we need to emit adds inside the loop to add up base registers, then
18+
// we need at least one extra temporary register.
19+
unsigned C1NumRegs = C1.NumRegs + (C1.NumBaseAdds != 0);
20+
unsigned C2NumRegs = C2.NumRegs + (C2.NumBaseAdds != 0);
21+
return std::tie(C1.Insns, C1NumRegs, C1.AddRecCost, C1.NumIVMuls,
22+
C1.NumBaseAdds, C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
23+
std::tie(C2.Insns, C2NumRegs, C2.AddRecCost, C2.NumIVMuls,
24+
C2.NumBaseAdds, C2.ScaleCost, C2.ImmCost, C2.SetupCost);
25+
}

llvm/lib/Target/AVR/AVRTargetTransformInfo.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@ class AVRTTIImpl final : public BasicTTIImplBase<AVRTTIImpl> {
4343
TLI(ST->getTargetLowering()) {}
4444

4545
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1,
46-
const TargetTransformInfo::LSRCost &C2) const override {
47-
if (C2.Insns == ~0u)
48-
return true;
49-
return 2 * C1.Insns + C1.AddRecCost + C1.SetupCost + C1.NumRegs <
50-
2 * C2.Insns + C2.AddRecCost + C2.SetupCost + C2.NumRegs;
51-
}
46+
const TargetTransformInfo::LSRCost &C2) const override;
5247
};
5348

5449
} // end namespace llvm

llvm/lib/Target/AVR/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ add_llvm_target(AVRCodeGen
2929
AVRSubtarget.cpp
3030
AVRTargetMachine.cpp
3131
AVRTargetObjectFile.cpp
32+
AVRTargetTransformInfo.cpp
3233

3334
DEPENDS
3435
intrinsics_gen

0 commit comments

Comments
 (0)