Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions llvm/lib/Target/AVR/AVRTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===-- 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);
}
7 changes: 1 addition & 6 deletions llvm/lib/Target/AVR/AVRTargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/AVR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_llvm_target(AVRCodeGen
AVRSubtarget.cpp
AVRTargetMachine.cpp
AVRTargetObjectFile.cpp
AVRTargetTransformInfo.cpp

DEPENDS
intrinsics_gen
Expand Down