@@ -35,26 +35,6 @@ namespace adjust {
3535
3636using namespace llvm ;
3737
38- static void signed_width (unsigned Width, uint64_t Value,
39- std::string Description, const MCFixup &Fixup,
40- MCContext *Ctx = nullptr ) {
41- if (!isIntN (Width, Value)) {
42- std::string Diagnostic = " out of range " + Description;
43-
44- int64_t Min = minIntN (Width);
45- int64_t Max = maxIntN (Width);
46-
47- Diagnostic += " (expected an integer in the range " + std::to_string (Min) +
48- " to " + std::to_string (Max) + " )" ;
49-
50- if (Ctx) {
51- Ctx->reportError (Fixup.getLoc (), Diagnostic);
52- } else {
53- llvm_unreachable (Diagnostic.c_str ());
54- }
55- }
56- }
57-
5838static void unsigned_width (unsigned Width, uint64_t Value,
5939 std::string Description, const MCFixup &Fixup,
6040 MCContext *Ctx = nullptr ) {
@@ -85,20 +65,6 @@ static void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
8565 AVR::fixups::adjustBranchTarget (Value);
8666}
8767
88- // / Adjusts the value of a relative branch target before fixup application.
89- static void adjustRelativeBranch (unsigned Size, const MCFixup &Fixup,
90- uint64_t &Value, MCContext *Ctx = nullptr ) {
91- // Jumps are relative to the current instruction.
92- Value -= 2 ;
93-
94- // We have one extra bit of precision because the value is rightshifted by
95- // one.
96- signed_width (Size + 1 , Value, std::string (" branch target" ), Fixup, Ctx);
97-
98- // Rightshifts the value by one.
99- AVR::fixups::adjustBranchTarget (Value);
100- }
101-
10268// / 22-bit absolute fixup.
10369// /
10470// / Resolves to:
@@ -116,33 +82,6 @@ static void fixup_call(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
11682 Value = (top << 6 ) | (middle << 3 ) | (bottom << 0 );
11783}
11884
119- // / 7-bit PC-relative fixup.
120- // /
121- // / Resolves to:
122- // / 0000 00kk kkkk k000
123- // / Offset of 0 (so the result is left shifted by 3 bits before application).
124- static void fixup_7_pcrel (unsigned Size, const MCFixup &Fixup, uint64_t &Value,
125- MCContext *Ctx = nullptr ) {
126- adjustRelativeBranch (Size, Fixup, Value, Ctx);
127-
128- // Because the value may be negative, we must mask out the sign bits
129- Value &= 0x7f ;
130- }
131-
132- // / 12-bit PC-relative fixup.
133- // / Yes, the fixup is 12 bits even though the name says otherwise.
134- // /
135- // / Resolves to:
136- // / 0000 kkkk kkkk kkkk
137- // / Offset of 0 (so the result isn't left-shifted before application).
138- static void fixup_13_pcrel (unsigned Size, const MCFixup &Fixup, uint64_t &Value,
139- MCContext *Ctx = nullptr ) {
140- adjustRelativeBranch (Size, Fixup, Value, Ctx);
141-
142- // Because the value may be negative, we must mask out the sign bits
143- Value &= 0xfff ;
144- }
145-
14685// / 6-bit fixup for the immediate operand of the STD/LDD family of
14786// / instructions.
14887// /
@@ -264,10 +203,8 @@ void AVRAsmBackend::adjustFixupValue(const MCFixup &Fixup,
264203 default :
265204 llvm_unreachable (" unhandled fixup" );
266205 case AVR::fixup_7_pcrel:
267- adjust::fixup_7_pcrel (Size, Fixup, Value, Ctx);
268- break ;
269206 case AVR::fixup_13_pcrel:
270- adjust::fixup_13_pcrel (Size, Fixup, Value, Ctx);
207+ // Emitted as relocations, no fixup required.
271208 break ;
272209 case AVR::fixup_call:
273210 adjust::fixup_call (Size, Fixup, Value, Ctx);
@@ -518,8 +455,6 @@ bool AVRAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
518455 return Fixup.getKind () >= FirstLiteralRelocationKind;
519456 case AVR::fixup_7_pcrel:
520457 case AVR::fixup_13_pcrel:
521- // Always resolve relocations for PC-relative branches
522- return false ;
523458 case AVR::fixup_call:
524459 return true ;
525460 }
0 commit comments