Chromium Code Reviews| Index: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp |
| diff --git a/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp b/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp |
| index 50f0893fce7e2defdde30787b81c77bc3f361ea3..899c378ee603f467f94eb93d3ce9b6399cda2fd8 100644 |
| --- a/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp |
| +++ b/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp |
| @@ -77,6 +77,21 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) { |
| // Get the 4th 16-bits. |
| Value = ((Value + 0x800080008000LL) >> 48) & 0xffff; |
| break; |
| + // @LOCALMOD-START |
| + case Mips::fixup_Mips_NACL_LONG_BRANCH_HI16: |
| + // Resolve LUi part of the LUi/ADDiu long branch offset calculation. |
| + // The Value is the offset of the target basic block from the LUi |
| + // instruction. Since we need offset from the next instruction (ADDiu), |
| + // we modify if by -4. Get the high 16-bits. Since the immediate from the |
| + // ADDiu is treated as signed, add 1 if bit 15 is 1. |
| + Value = ((Value - 4 + 0x8000) >> 16) & 0xffff; |
| + break; |
| + case Mips::fixup_Mips_NACL_LONG_BRANCH_LO16: |
| + // Resolve ADDiu part of the LUi/ADDiu long branch offset calculation. |
| + // Get the low 16-bits. |
| + Value = Value & 0xffff; |
| + break; |
| + // @LOCALMOD-END |
| } |
| return Value; |
| @@ -98,6 +113,24 @@ public: |
| MCELFObjectTargetWriter::getOSABI(OSType), IsLittle, Is64Bit); |
| } |
| + // @LOCALMOD-START |
| + /// processFixupValue - Target hook to process the literal value of a fixup |
| + /// if necessary. |
| + void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout, |
| + const MCFixup &Fixup, const MCFragment *DF, |
| + MCValue &Target, uint64_t &Value, |
| + bool &IsResolved) { |
| + if (OSType == Triple::NaCl) { |
|
Mark Seaborn
2013/10/24 23:38:43
Isn't this check unnecessary? Checking getKind()
petarj
2013/11/21 18:23:42
Done.
|
| + if ((unsigned)Fixup.getKind() == Mips::fixup_Mips_NACL_LONG_BRANCH_HI16 |
| + || ((unsigned)Fixup.getKind() |
| + == Mips::fixup_Mips_NACL_LONG_BRANCH_LO16)) { |
| + // We don't need to emit relocation for long branch fixup. |
| + IsResolved = true; |
| + } |
| + } |
| + } |
| + // @LOCALMOD-END |
| + |
| /// ApplyFixup - Apply the \p Value for given \p Fixup into the provided |
| /// data fragment, at the offset specified by the fixup and following the |
| /// fixup kind as appropriate. |
| @@ -189,7 +222,13 @@ public: |
| { "fixup_Mips_GOT_HI16", 0, 16, 0 }, |
| { "fixup_Mips_GOT_LO16", 0, 16, 0 }, |
| { "fixup_Mips_CALL_HI16", 0, 16, 0 }, |
| - { "fixup_Mips_CALL_LO16", 0, 16, 0 } |
| + { "fixup_Mips_CALL_LO16", 0, 16, 0 }, |
| + // @LOCALMOD-START |
| + { "fixup_Mips_NACL_LONG_BRANCH_HI16", 0, 16, |
| + MCFixupKindInfo::FKF_IsPCRel }, |
| + { "fixup_Mips_NACL_LONG_BRANCH_LO16", 0, 16, |
| + MCFixupKindInfo::FKF_IsPCRel } |
| + // @LOCALMOD-END |
| }; |
| if (Kind < FirstTargetFixupKind) |