Skip to content

Commit 13b4a09

Browse files
committed
Sparc: Move H44/M44/L44 computation back to adjustFixupValue
Essentially revert the evaluateAsRelocatableImpl part from f39696e. Ensure that absolute relocation evaluation is in one place. SparcAsmBackend.cpp enables better diagnostics if needed.
1 parent f14a4ac commit 13b4a09

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
6868
case ELF::R_SPARC_LO10:
6969
return Value & 0x3ff;
7070

71+
case ELF::R_SPARC_H44:
72+
return (Value >> 22) & 0x3fffff;
73+
case ELF::R_SPARC_M44:
74+
return (Value >> 12) & 0x3ff;
75+
case ELF::R_SPARC_L44:
76+
return Value & 0xfff;
77+
7178
case ELF::R_SPARC_HH22:
7279
return (Value >> 42) & 0x3fffff;
7380
case ELF::R_SPARC_HM10:

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,6 @@ bool SparcMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
141141
if (!getSubExpr()->evaluateAsRelocatable(Res, Asm))
142142
return false;
143143

144-
if (Res.isAbsolute()) {
145-
std::optional<int64_t> V;
146-
auto C = (uint64_t)Res.getConstant();
147-
switch (uint16_t(specifier)) {
148-
case ELF::R_SPARC_H44:
149-
V = (C >> 22) & 0x3fffff;
150-
break;
151-
case ELF::R_SPARC_M44:
152-
V = (C >> 12) & 0x3ff;
153-
break;
154-
case ELF::R_SPARC_L44:
155-
V = C & 0xfff;
156-
break;
157-
}
158-
if (V) {
159-
Res = MCValue::get(*V);
160-
return true;
161-
}
162-
}
163-
164144
Res.setSpecifier(specifier);
165145
return true;
166146
}

0 commit comments

Comments
 (0)