Index: include/llvm/MC/MCExpr.h =================================================================== --- include/llvm/MC/MCExpr.h +++ include/llvm/MC/MCExpr.h @@ -291,6 +291,9 @@ VK_Hexagon_IE, VK_Hexagon_IE_GOT, + VK_Lanai_ABS_HI, + VK_Lanai_ABS_LO, + VK_WebAssembly_FUNCTION, // Function table index, rather than virtual addr VK_TPREL, Index: include/llvm/Object/ELFObjectFile.h =================================================================== --- include/llvm/Object/ELFObjectFile.h +++ include/llvm/Object/ELFObjectFile.h @@ -835,6 +835,8 @@ return "ELF32-avr"; case ELF::EM_HEXAGON: return "ELF32-hexagon"; + case ELF::EM_LANAI: + return "ELF32-lanai"; case ELF::EM_MIPS: return "ELF32-mips"; case ELF::EM_PPC: @@ -891,6 +893,8 @@ return Triple::avr; case ELF::EM_HEXAGON: return Triple::hexagon; + case ELF::EM_LANAI: + return Triple::lanai; case ELF::EM_MIPS: switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) { case ELF::ELFCLASS32: Index: include/llvm/Object/RelocVisitor.h =================================================================== --- include/llvm/Object/RelocVisitor.h +++ include/llvm/Object/RelocVisitor.h @@ -175,6 +175,14 @@ case llvm::ELF::R_ARM_ABS32: return visitELF_ARM_ABS32(R, Value); } + case Triple::lanai: + switch (RelocType) { + case llvm::ELF::R_LANAI_32: + return visitELF_Lanai_32(R, Value); + default: + HasError = true; + return RelocToApply(); + } case Triple::mipsel: case Triple::mips: switch (RelocType) { @@ -311,6 +319,12 @@ return RelocToApply(Res, 4); } + /// Lanai ELF + RelocToApply visitELF_Lanai_32(RelocationRef R, uint64_t Value) { + uint32_t Res = Value & 0xFFFFFFFF; + return RelocToApply(Res, 4); + } + /// MIPS ELF RelocToApply visitELF_MIPS_32(RelocationRef R, uint64_t Value) { uint32_t Res = Value & 0xFFFFFFFF; Index: include/llvm/Support/ELF.h =================================================================== --- include/llvm/Support/ELF.h +++ include/llvm/Support/ELF.h @@ -315,6 +315,11 @@ // such numbers for an official value for WebAssembly. As soon as one is // allocated, this enum will be updated to use it. EM_WEBASSEMBLY = 0x4157, // WebAssembly architecture + + // A request has been made to the maintainer of the official registry for + // an official value for Lanai. As soon as one is allocated, this enum will be + // updated to use it. + EM_LANAI = 0x8123 // Lanai 32-bit processor }; // Object file classes. @@ -589,6 +594,11 @@ #include "ELFRelocs/Hexagon.def" }; +// ELF Relocation type for Lanai. +enum { +#include "ELFRelocs/Lanai.def" +}; + // ELF Relocation types for S390/zSeries enum { #include "ELFRelocs/SystemZ.def" Index: include/llvm/Support/ELFRelocs/Lanai.def =================================================================== --- include/llvm/Support/ELFRelocs/Lanai.def +++ include/llvm/Support/ELFRelocs/Lanai.def @@ -0,0 +1,12 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC(R_LANAI_NONE, 0) +ELF_RELOC(R_LANAI_21, 1) +ELF_RELOC(R_LANAI_21_F, 2) +ELF_RELOC(R_LANAI_25, 3) +ELF_RELOC(R_LANAI_32, 4) +ELF_RELOC(R_LANAI_HI16, 5) +ELF_RELOC(R_LANAI_LO16, 6) Index: lib/MC/MCExpr.cpp =================================================================== --- lib/MC/MCExpr.cpp +++ lib/MC/MCExpr.cpp @@ -289,6 +289,8 @@ case VK_Mips_CALL_LO16: return "CALL_LO16"; case VK_Mips_PCREL_HI16: return "PCREL_HI16"; case VK_Mips_PCREL_LO16: return "PCREL_LO16"; + case VK_Lanai_ABS_HI: return "hi"; + case VK_Lanai_ABS_LO: return "lo"; case VK_COFF_IMGREL32: return "IMGREL"; case VK_Hexagon_PCREL: return "PCREL"; case VK_Hexagon_LO16: return "LO16"; @@ -311,6 +313,8 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) { return StringSwitch(Name.lower()) .Case("got", VK_GOT) + .Case("lo", VK_Lanai_ABS_LO) + .Case("hi", VK_Lanai_ABS_HI) .Case("gotoff", VK_GOTOFF) .Case("gotpcrel", VK_GOTPCREL) .Case("gottpoff", VK_GOTTPOFF) Index: lib/MC/MCObjectFileInfo.cpp =================================================================== --- lib/MC/MCObjectFileInfo.cpp +++ lib/MC/MCObjectFileInfo.cpp @@ -356,6 +356,11 @@ TTypeEncoding = dwarf::DW_EH_PE_absptr; } break; + case Triple::lanai: + LSDAEncoding = dwarf::DW_EH_PE_absptr; + PersonalityEncoding = dwarf::DW_EH_PE_absptr; + TTypeEncoding = dwarf::DW_EH_PE_absptr; + break; case Triple::mips: case Triple::mipsel: case Triple::mips64: Index: lib/Object/ELF.cpp =================================================================== --- lib/Object/ELF.cpp +++ lib/Object/ELF.cpp @@ -61,6 +61,13 @@ break; } break; + case ELF::EM_LANAI: + switch (Type) { +#include "llvm/Support/ELFRelocs/Lanai.def" + default: + break; + } + break; case ELF::EM_PPC: switch (Type) { #include "llvm/Support/ELFRelocs/PowerPC.def"