Skip to content

Commit 7d500b1

Browse files
committed
SPARC: Remove unneeded MCFixupKindInfo::FKF_IsPCRel
SPARC now sets PCRel at fixup creation and no longer needs to the MCAssembler::evaluateFixup workaround that checks MCFixupKindInfo::FKF_IsPCRel.
1 parent 83fbd86 commit 7d500b1

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

llvm/lib/MC/MCAssembler.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ bool MCAssembler::evaluateFixup(const MCFragment &F, MCFixup &Fixup,
161161
return true;
162162
}
163163

164-
bool IsResolved = false;
164+
// TODO: Require targets to set PCRel at fixup creation time.
165165
unsigned FixupFlags = getBackend().getFixupKindInfo(Fixup.getKind()).Flags;
166-
bool IsPCRel = FixupFlags & MCFixupKindInfo::FKF_IsPCRel;
166+
if (FixupFlags & MCFixupKindInfo::FKF_IsPCRel)
167+
Fixup.setPCRel();
168+
bool IsResolved = false;
167169
if (FixupFlags & MCFixupKindInfo::FKF_IsTarget) {
168170
IsResolved = getBackend().evaluateTargetFixup(Fixup, Target, Value);
169171
} else {
@@ -177,7 +179,7 @@ bool MCAssembler::evaluateFixup(const MCFragment &F, MCFixup &Fixup,
177179

178180
bool ShouldAlignPC =
179181
FixupFlags & MCFixupKindInfo::FKF_IsAlignedDownTo32Bits;
180-
if (IsPCRel) {
182+
if (Fixup.isPCRel()) {
181183
uint64_t Offset = getFragmentOffset(F) + Fixup.getOffset();
182184

183185
// A number of ARM fixups in Thumb mode require that the effective PC
@@ -202,8 +204,6 @@ bool MCAssembler::evaluateFixup(const MCFragment &F, MCFixup &Fixup,
202204

203205
if (IsResolved && mc::isRelocRelocation(Fixup.getKind()))
204206
IsResolved = false;
205-
if (IsPCRel)
206-
Fixup.setPCRel();
207207
getBackend().applyFixup(F, Fixup, Target, Contents, Value, IsResolved);
208208
return true;
209209
}

llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ std::optional<MCFixupKind> SparcAsmBackend::getFixupKind(StringRef Name) const {
182182
MCFixupKindInfo SparcAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
183183
// clang-format off
184184
const static MCFixupKindInfo InfosBE[Sparc::NumTargetFixupKinds] = {
185-
// name offset bits flags
186-
{ "fixup_sparc_call30", 2, 30, MCFixupKindInfo::FKF_IsPCRel },
187-
{ "fixup_sparc_13", 19, 13, 0 },
185+
// name offset bits flags
186+
{"fixup_sparc_call30", 2, 30, 0},
187+
{"fixup_sparc_13", 19, 13, 0},
188188
};
189189

190190
const static MCFixupKindInfo InfosLE[Sparc::NumTargetFixupKinds] = {
191-
// name offset bits flags
192-
{ "fixup_sparc_call30", 0, 30, MCFixupKindInfo::FKF_IsPCRel },
193-
{ "fixup_sparc_13", 0, 13, 0 },
191+
// name offset bits flags
192+
{"fixup_sparc_call30", 0, 30, 0},
193+
{"fixup_sparc_13", 0, 13, 0},
194194
};
195195
// clang-format on
196196

@@ -208,22 +208,22 @@ MCFixupKindInfo SparcAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
208208
MCFixupKindInfo Info{};
209209
switch (uint16_t(Kind)) {
210210
case ELF::R_SPARC_PC10:
211-
Info = {"", 22, 10, MCFixupKindInfo::FKF_IsPCRel};
211+
Info = {"", 22, 10, 0};
212212
break;
213213
case ELF::R_SPARC_PC22:
214-
Info = {"", 10, 22, MCFixupKindInfo::FKF_IsPCRel};
214+
Info = {"", 10, 22, 0};
215215
break;
216216
case ELF::R_SPARC_WDISP10:
217-
Info = {"", 0, 32, MCFixupKindInfo::FKF_IsPCRel};
217+
Info = {"", 0, 32, 0};
218218
break;
219219
case ELF::R_SPARC_WDISP16:
220-
Info = {"", 0, 32, MCFixupKindInfo::FKF_IsPCRel};
220+
Info = {"", 0, 32, 0};
221221
break;
222222
case ELF::R_SPARC_WDISP19:
223-
Info = {"", 13, 19, MCFixupKindInfo::FKF_IsPCRel};
223+
Info = {"", 13, 19, 0};
224224
break;
225225
case ELF::R_SPARC_WDISP22:
226-
Info = {"", 10, 22, MCFixupKindInfo::FKF_IsPCRel};
226+
Info = {"", 10, 22, 0};
227227
break;
228228

229229
case ELF::R_SPARC_HI22:

llvm/lib/Target/Sparc/MCTargetDesc/SparcMCCodeEmitter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static void addFixup(SmallVectorImpl<MCFixup> &Fixups, uint32_t Offset,
101101
case ELF::R_SPARC_WDISP16:
102102
case ELF::R_SPARC_WDISP19:
103103
case ELF::R_SPARC_WDISP22:
104+
case Sparc::fixup_sparc_call30:
104105
PCRel = true;
105106
}
106107
Fixups.push_back(MCFixup::create(Offset, Value, Kind, PCRel));

0 commit comments

Comments
 (0)