diff --git a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp --- a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp +++ b/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); diff --git a/llvm/lib/Target/AVR/AVRInstrInfo.h b/llvm/lib/Target/AVR/AVRInstrInfo.h --- a/llvm/lib/Target/AVR/AVRInstrInfo.h +++ b/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 diff --git a/llvm/lib/Target/AVR/AVRInstrInfo.cpp b/llvm/lib/Target/AVR/AVRInstrInfo.cpp --- a/llvm/lib/Target/AVR/AVRInstrInfo.cpp +++ b/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 diff --git a/llvm/lib/Target/AVR/AVRSubtarget.cpp b/llvm/lib/Target/AVR/AVRSubtarget.cpp --- a/llvm/lib/Target/AVR/AVRSubtarget.cpp +++ b/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); diff --git a/llvm/test/CodeGen/AVR/branch-relaxation-long.ll b/llvm/test/CodeGen/AVR/branch-relaxation-long.ll --- a/llvm/test/CodeGen/AVR/branch-relaxation-long.ll +++ b/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