[PATCH] D155570: [AVR] Enable verifyInstructionPredicates for AVR
Jianjian Guan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 20:43:52 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb33db4f9151: [AVR] Enable verifyInstructionPredicates for AVR (authored by jacquesguan).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155570/new/
https://reviews.llvm.org/D155570
Files:
llvm/lib/Target/AVR/AVRAsmPrinter.cpp
llvm/lib/Target/AVR/AVRInstrInfo.cpp
llvm/lib/Target/AVR/AVRInstrInfo.h
llvm/lib/Target/AVR/AVRSubtarget.cpp
llvm/test/CodeGen/AVR/branch-relaxation-long.ll
Index: llvm/test/CodeGen/AVR/branch-relaxation-long.ll
===================================================================
--- llvm/test/CodeGen/AVR/branch-relaxation-long.ll
+++ llvm/test/CodeGen/AVR/branch-relaxation-long.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=avr | FileCheck %s
+; RUN: llc < %s -march=avr -mattr=avr3 | FileCheck %s
; CHECK-LABEL: relax_to_jmp:
; CHECK: cpi r{{[0-9]+}}, 0
Index: llvm/lib/Target/AVR/AVRSubtarget.cpp
===================================================================
--- llvm/lib/Target/AVR/AVRSubtarget.cpp
+++ llvm/lib/Target/AVR/AVRSubtarget.cpp
@@ -29,7 +29,7 @@
AVRSubtarget::AVRSubtarget(const Triple &TT, const std::string &CPU,
const std::string &FS, const AVRTargetMachine &TM)
- : AVRGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
+ : AVRGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), InstrInfo(*this),
TLInfo(TM, initializeSubtargetDependencies(CPU, FS, TM)) {
// Parse features string.
ParseSubtargetFeatures(CPU, /*TuneCPU*/ CPU, FS);
Index: llvm/lib/Target/AVR/AVRInstrInfo.h
===================================================================
--- llvm/lib/Target/AVR/AVRInstrInfo.h
+++ llvm/lib/Target/AVR/AVRInstrInfo.h
@@ -23,6 +23,8 @@
namespace llvm {
+class AVRSubtarget;
+
namespace AVRCC {
/// AVR specific condition codes.
@@ -63,7 +65,7 @@
/// Utilities related to the AVR instruction set.
class AVRInstrInfo : public AVRGenInstrInfo {
public:
- explicit AVRInstrInfo();
+ explicit AVRInstrInfo(AVRSubtarget &STI);
const AVRRegisterInfo &getRegisterInfo() const { return RI; }
const MCInstrDesc &getBrCond(AVRCC::CondCodes CC) const;
@@ -116,6 +118,9 @@
private:
const AVRRegisterInfo RI;
+
+protected:
+ const AVRSubtarget &STI;
};
} // end namespace llvm
Index: llvm/lib/Target/AVR/AVRInstrInfo.cpp
===================================================================
--- llvm/lib/Target/AVR/AVRInstrInfo.cpp
+++ llvm/lib/Target/AVR/AVRInstrInfo.cpp
@@ -35,8 +35,9 @@
namespace llvm {
-AVRInstrInfo::AVRInstrInfo()
- : AVRGenInstrInfo(AVR::ADJCALLSTACKDOWN, AVR::ADJCALLSTACKUP), RI() {}
+AVRInstrInfo::AVRInstrInfo(AVRSubtarget &STI)
+ : AVRGenInstrInfo(AVR::ADJCALLSTACKDOWN, AVR::ADJCALLSTACKUP), RI(),
+ STI(STI) {}
void AVRInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI,
@@ -569,7 +570,10 @@
// insertBranch or some hypothetical "insertDirectBranch".
// See lib/CodeGen/RegisterRelaxation.cpp for details.
// We end up here when a jump is too long for a RJMP instruction.
- BuildMI(&MBB, DL, get(AVR::JMPk)).addMBB(&NewDestBB);
+ if (STI.hasJMPCALL())
+ BuildMI(&MBB, DL, get(AVR::JMPk)).addMBB(&NewDestBB);
+ else
+ report_fatal_error("cannot create long jump without FeatureJMPCALL");
}
} // end of namespace llvm
Index: llvm/lib/Target/AVR/AVRAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/AVR/AVRAsmPrinter.cpp
+++ llvm/lib/Target/AVR/AVRAsmPrinter.cpp
@@ -189,9 +189,8 @@
}
void AVRAsmPrinter::emitInstruction(const MachineInstr *MI) {
- // FIXME: Enable feature predicate checks once all the test pass.
- // AVR_MC::verifyInstructionPredicates(MI->getOpcode(),
- // getSubtargetInfo().getFeatureBits());
+ AVR_MC::verifyInstructionPredicates(MI->getOpcode(),
+ getSubtargetInfo().getFeatureBits());
AVRMCInstLower MCInstLowering(OutContext, *this);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155570.541828.patch
Type: text/x-patch
Size: 3570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230719/42ddc1ff/attachment.bin>
More information about the llvm-commits
mailing list