<div dir="ltr">Thanks!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 7, 2019 at 5:49 PM Fangrui Song via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: maskray<br>
Date: Mon Oct 7 01:52:07 2019<br>
New Revision: 373886<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=373886&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=373886&view=rev</a><br>
Log:<br>
[ELF][MIPS] De-template writeValue. NFC<br>
<br>
Depends on D68561.<br>
<br>
Modified:<br>
lld/trunk/ELF/Arch/Mips.cpp<br>
<br>
Modified: lld/trunk/ELF/Arch/Mips.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/Mips.cpp?rev=373886&r1=373885&r2=373886&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/Mips.cpp?rev=373886&r1=373885&r2=373886&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Arch/Mips.cpp (original)<br>
+++ lld/trunk/ELF/Arch/Mips.cpp Mon Oct 7 01:52:07 2019<br>
@@ -213,7 +213,6 @@ template <endianness E> static uint32_t<br>
return v;<br>
}<br>
<br>
-template <endianness E><br>
static void writeValue(uint8_t *loc, uint64_t v, uint8_t bitsSize,<br>
uint8_t shift) {<br>
uint32_t instr = read32(loc);<br>
@@ -230,7 +229,7 @@ static void writeShuffleValue(uint8_t *l<br>
if (E == support::little)<br>
std::swap(words[0], words[1]);<br>
<br>
- writeValue<E>(loc, v, bitsSize, shift);<br>
+ writeValue(loc, v, bitsSize, shift);<br>
<br>
if (E == support::little)<br>
std::swap(words[0], words[1]);<br>
@@ -246,7 +245,6 @@ static void writeMicroRelocation16(uint8<br>
}<br>
<br>
template <class ELFT> void MIPS<ELFT>::writePltHeader(uint8_t *buf) const {<br>
- const endianness e = ELFT::TargetEndianness;<br>
if (isMicroMips()) {<br>
uint64_t gotPlt = in.gotPlt->getVA();<br>
uint64_t plt = in.plt->getVA();<br>
@@ -302,16 +300,15 @@ template <class ELFT> void MIPS<ELFT>::w<br>
write32(buf + 28, 0x2718fffe); // subu $24, $24, 2<br>
<br>
uint64_t gotPlt = in.gotPlt->getVA();<br>
- writeValue<e>(buf, gotPlt + 0x8000, 16, 16);<br>
- writeValue<e>(buf + 4, gotPlt, 16, 0);<br>
- writeValue<e>(buf + 8, gotPlt, 16, 0);<br>
+ writeValue(buf, gotPlt + 0x8000, 16, 16);<br>
+ writeValue(buf + 4, gotPlt, 16, 0);<br>
+ writeValue(buf + 8, gotPlt, 16, 0);<br>
}<br>
<br>
template <class ELFT><br>
void MIPS<ELFT>::writePlt(uint8_t *buf, uint64_t gotPltEntryAddr,<br>
uint64_t pltEntryAddr, int32_t index,<br>
unsigned relOff) const {<br>
- const endianness e = ELFT::TargetEndianness;<br>
if (isMicroMips()) {<br>
// Overwrite trap instructions written by Writer::writeTrapInstr.<br>
memset(buf, 0, pltEntrySize);<br>
@@ -341,9 +338,9 @@ void MIPS<ELFT>::writePlt(uint8_t *buf,<br>
write32(buf + 4, loadInst); // l[wd] $25, %lo(.got.plt entry)($15)<br>
write32(buf + 8, jrInst); // jr $25 / jr.hb $25<br>
write32(buf + 12, addInst); // [d]addiu $24, $15, %lo(.got.plt entry)<br>
- writeValue<e>(buf, gotPltEntryAddr + 0x8000, 16, 16);<br>
- writeValue<e>(buf + 4, gotPltEntryAddr, 16, 0);<br>
- writeValue<e>(buf + 12, gotPltEntryAddr, 16, 0);<br>
+ writeValue(buf, gotPltEntryAddr + 0x8000, 16, 16);<br>
+ writeValue(buf + 4, gotPltEntryAddr, 16, 0);<br>
+ writeValue(buf + 12, gotPltEntryAddr, 16, 0);<br>
}<br>
<br>
template <class ELFT><br>
@@ -494,7 +491,7 @@ static uint64_t fixupCrossModeJump(uint8<br>
case R_MIPS_26: {<br>
uint32_t inst = read32(loc) >> 26;<br>
if (inst == 0x3 || inst == 0x1d) { // JAL or JALX<br>
- writeValue<e>(loc, 0x1d << 26, 32, 0);<br>
+ writeValue(loc, 0x1d << 26, 32, 0);<br>
return val;<br>
}<br>
break;<br>
@@ -558,17 +555,17 @@ void MIPS<ELFT>::relocateOne(uint8_t *lo<br>
write64(loc, val);<br>
break;<br>
case R_MIPS_26:<br>
- writeValue<e>(loc, val, 26, 2);<br>
+ writeValue(loc, val, 26, 2);<br>
break;<br>
case R_MIPS_GOT16:<br>
// The R_MIPS_GOT16 relocation's value in "relocatable" linking mode<br>
// is updated addend (not a GOT index). In that case write high 16 bits<br>
// to store a correct addend value.<br>
if (config->relocatable) {<br>
- writeValue<e>(loc, val + 0x8000, 16, 16);<br>
+ writeValue(loc, val + 0x8000, 16, 16);<br>
} else {<br>
checkInt(loc, val, 16, type);<br>
- writeValue<e>(loc, val, 16, 0);<br>
+ writeValue(loc, val, 16, 0);<br>
}<br>
break;<br>
case R_MICROMIPS_GOT16:<br>
@@ -595,7 +592,7 @@ void MIPS<ELFT>::relocateOne(uint8_t *lo<br>
case R_MIPS_PCLO16:<br>
case R_MIPS_TLS_DTPREL_LO16:<br>
case R_MIPS_TLS_TPREL_LO16:<br>
- writeValue<e>(loc, val, 16, 0);<br>
+ writeValue(loc, val, 16, 0);<br>
break;<br>
case R_MICROMIPS_GPREL16:<br>
case R_MICROMIPS_TLS_GD:<br>
@@ -621,7 +618,7 @@ void MIPS<ELFT>::relocateOne(uint8_t *lo<br>
case R_MIPS_PCHI16:<br>
case R_MIPS_TLS_DTPREL_HI16:<br>
case R_MIPS_TLS_TPREL_HI16:<br>
- writeValue<e>(loc, val + 0x8000, 16, 16);<br>
+ writeValue(loc, val + 0x8000, 16, 16);<br>
break;<br>
case R_MICROMIPS_CALL_HI16:<br>
case R_MICROMIPS_GOT_HI16:<br>
@@ -631,10 +628,10 @@ void MIPS<ELFT>::relocateOne(uint8_t *lo<br>
writeShuffleValue<e>(loc, val + 0x8000, 16, 16);<br>
break;<br>
case R_MIPS_HIGHER:<br>
- writeValue<e>(loc, val + 0x80008000, 16, 32);<br>
+ writeValue(loc, val + 0x80008000, 16, 32);<br>
break;<br>
case R_MIPS_HIGHEST:<br>
- writeValue<e>(loc, val + 0x800080008000, 16, 48);<br>
+ writeValue(loc, val + 0x800080008000, 16, 48);<br>
break;<br>
case R_MIPS_JALR:<br>
val -= 4;<br>
@@ -657,25 +654,25 @@ void MIPS<ELFT>::relocateOne(uint8_t *lo<br>
case R_MIPS_PC16:<br>
checkAlignment(loc, val, 4, type);<br>
checkInt(loc, val, 18, type);<br>
- writeValue<e>(loc, val, 16, 2);<br>
+ writeValue(loc, val, 16, 2);<br>
break;<br>
case R_MIPS_PC19_S2:<br>
checkAlignment(loc, val, 4, type);<br>
checkInt(loc, val, 21, type);<br>
- writeValue<e>(loc, val, 19, 2);<br>
+ writeValue(loc, val, 19, 2);<br>
break;<br>
case R_MIPS_PC21_S2:<br>
checkAlignment(loc, val, 4, type);<br>
checkInt(loc, val, 23, type);<br>
- writeValue<e>(loc, val, 21, 2);<br>
+ writeValue(loc, val, 21, 2);<br>
break;<br>
case R_MIPS_PC26_S2:<br>
checkAlignment(loc, val, 4, type);<br>
checkInt(loc, val, 28, type);<br>
- writeValue<e>(loc, val, 26, 2);<br>
+ writeValue(loc, val, 26, 2);<br>
break;<br>
case R_MIPS_PC32:<br>
- writeValue<e>(loc, val, 32, 0);<br>
+ writeValue(loc, val, 32, 0);<br>
break;<br>
case R_MICROMIPS_26_S1:<br>
case R_MICROMIPS_PC26_S1:<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>