From 2e8718bcbb9ee54a0a8f492782d86dc49c96a344 Mon Sep 17 00:00:00 2001 From: Dylan McKay Date: Sun, 30 Apr 2017 23:33:52 +0000 Subject: [AVR] Fix a bug so that we now emit R_AVR_16 fixups with the correct offset Before this, the LDS/STS instructions would have their opcodes overwritten while linking. llvm-svn: 301782 --- llvm/lib/Target/AVR/AVRInstrInfo.td | 10 +++++----- llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp | 4 ++-- llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Target/AVR/AVRInstrInfo.td b/llvm/lib/Target/AVR/AVRInstrInfo.td index 693d80a1c06..09104669366 100644 --- a/llvm/lib/Target/AVR/AVRInstrInfo.td +++ b/llvm/lib/Target/AVR/AVRInstrInfo.td @@ -183,33 +183,33 @@ def call_target : Operand // A 16-bit address (which can lead to an R_AVR_16 relocation). def imm16 : Operand { - let EncoderMethod = "encodeImm"; + let EncoderMethod = "encodeImm"; } /// A 6-bit immediate used in the ADIW/SBIW instructions. def imm_arith6 : Operand { - let EncoderMethod = "encodeImm"; + let EncoderMethod = "encodeImm"; } /// An 8-bit immediate inside an instruction with the same format /// as the `LDI` instruction (the `FRdK` format). def imm_ldi8 : Operand { - let EncoderMethod = "encodeImm"; + let EncoderMethod = "encodeImm"; } /// A 5-bit port number used in SBIC and friends (the `FIOBIT` format). def imm_port5 : Operand { - let EncoderMethod = "encodeImm"; + let EncoderMethod = "encodeImm"; } /// A 6-bit port number used in the `IN` instruction and friends (the /// `FIORdA` format. def imm_port6 : Operand { - let EncoderMethod = "encodeImm"; + let EncoderMethod = "encodeImm"; } // Addressing mode pattern reg+imm6 diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp index c3d43ebb407..4dbbce8c205 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp @@ -177,7 +177,7 @@ unsigned AVRMCCodeEmitter::encodeComplement(const MCInst &MI, unsigned OpNo, return (~0) - Imm; } -template +template unsigned AVRMCCodeEmitter::encodeImm(const MCInst &MI, unsigned OpNo, SmallVectorImpl &Fixups, const MCSubtargetInfo &STI) const { @@ -193,7 +193,7 @@ unsigned AVRMCCodeEmitter::encodeImm(const MCInst &MI, unsigned OpNo, } MCFixupKind FixupKind = static_cast(Fixup); - Fixups.push_back(MCFixup::create(0, MO.getExpr(), FixupKind, MI.getLoc())); + Fixups.push_back(MCFixup::create(Offset, MO.getExpr(), FixupKind, MI.getLoc())); return 0; } diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h index 4cee8d904c9..883abf8db78 100644 --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h @@ -69,7 +69,8 @@ private: const MCSubtargetInfo &STI) const; /// Encodes an immediate value with a given fixup. - template + /// \tparam Offset The offset into the instruction for the fixup. + template unsigned encodeImm(const MCInst &MI, unsigned OpNo, SmallVectorImpl &Fixups, const MCSubtargetInfo &STI) const; -- cgit v1.2.3