Index: include/llvm/ADT/Triple.h =================================================================== --- include/llvm/ADT/Triple.h +++ include/llvm/ADT/Triple.h @@ -76,6 +76,7 @@ tcele, // TCE little endian (http://tce.cs.tut.fi/): tcele thumb, // Thumb (little endian): thumb, thumbv.* thumbeb, // Thumb (big endian): thumbeb + m680x0, // m680x0: Motorola 680x0 family x86, // X86: i[3-9]86 x86_64, // X86-64: amd64, x86_64 xcore, // XCore: xcore Index: include/llvm/BinaryFormat/ELF.h =================================================================== --- include/llvm/BinaryFormat/ELF.h +++ include/llvm/BinaryFormat/ELF.h @@ -725,6 +725,11 @@ #include "ELFRelocs/BPF.def" }; +// ELF Relocation types for M680x0 +enum { +#include "ELFRelocs/m680x0.def" +}; + #undef ELF_RELOC // Section header. Index: include/llvm/BinaryFormat/ELFRelocs/m680x0.def =================================================================== --- /dev/null +++ include/llvm/BinaryFormat/ELFRelocs/m680x0.def @@ -0,0 +1,50 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC (R_M680x0_NONE, 0) /* No reloc */ +ELF_RELOC (R_M680x0_32, 1) /* Direct 32 bit */ +ELF_RELOC (R_M680x0_16, 2) /* Direct 16 bit */ +ELF_RELOC (R_M680x0_8, 3) /* Direct 8 bit */ +ELF_RELOC (R_M680x0_PC32, 4) /* PC relative 32 bit */ +ELF_RELOC (R_M680x0_PC16, 5) /* PC relative 16 bit */ +ELF_RELOC (R_M680x0_PC8, 6) /* PC relative 8 bit */ +ELF_RELOC (R_M680x0_GOTPCREL32, 7) /* 32 bit PC relative GOT entry */ +ELF_RELOC (R_M680x0_GOTPCREL16, 8) /* 16 bit PC relative GOT entry */ +ELF_RELOC (R_M680x0_GOTPCREL8, 9) /* 8 bit PC relative GOT entry */ +ELF_RELOC (R_M680x0_GOTOFF32, 10) /* 32 bit GOT offset */ +ELF_RELOC (R_M680x0_GOTOFF16, 11) /* 16 bit GOT offset */ +ELF_RELOC (R_M680x0_GOTOFF8, 12) /* 8 bit GOT offset */ +ELF_RELOC (R_M680x0_PLT32, 13) /* 32 bit PC relative PLT address */ +ELF_RELOC (R_M680x0_PLT16, 14) /* 16 bit PC relative PLT address */ +ELF_RELOC (R_M680x0_PLT8, 15) /* 8 bit PC relative PLT address */ +ELF_RELOC (R_M680x0_PLTOFF32, 16) /* 32 bit PLT offset */ +ELF_RELOC (R_M680x0_PLTOFF16, 17) /* 16 bit PLT offset */ +ELF_RELOC (R_M680x0_PLTOFF8, 18) /* 8 bit PLT offset */ +ELF_RELOC (R_M680x0_COPY, 19) /* Copy symbol at runtime */ +ELF_RELOC (R_M680x0_GLOB_DAT, 20) /* Create GOT entry */ +ELF_RELOC (R_M680x0_JMP_SLOT, 21) /* Create PLT entry */ +ELF_RELOC (R_M680x0_RELATIVE, 22) /* Adjust by program base */ +/* These are GNU extensions to enable C++ vtable garbage collection. */ +ELF_RELOC (R_M680x0_GNU_VTINHERIT, 23) +ELF_RELOC (R_M680x0_GNU_VTENTRY, 24) +/* TLS static relocations. */ +ELF_RELOC (R_M680x0_TLS_GD32, 25) +ELF_RELOC (R_M680x0_TLS_GD16, 26) +ELF_RELOC (R_M680x0_TLS_GD8, 27) +ELF_RELOC (R_M680x0_TLS_LDM32, 28) +ELF_RELOC (R_M680x0_TLS_LDM16, 29) +ELF_RELOC (R_M680x0_TLS_LDM8, 30) +ELF_RELOC (R_M680x0_TLS_LDO32, 31) +ELF_RELOC (R_M680x0_TLS_LDO16, 32) +ELF_RELOC (R_M680x0_TLS_LDO8, 33) +ELF_RELOC (R_M680x0_TLS_IE32, 34) +ELF_RELOC (R_M680x0_TLS_IE16, 35) +ELF_RELOC (R_M680x0_TLS_IE8, 36) +ELF_RELOC (R_M680x0_TLS_LE32, 37) +ELF_RELOC (R_M680x0_TLS_LE16, 38) +ELF_RELOC (R_M680x0_TLS_LE8, 39) +ELF_RELOC (R_M680x0_TLS_DTPMOD32, 40) +ELF_RELOC (R_M680x0_TLS_DTPREL32, 41) +ELF_RELOC (R_M680x0_TLS_TPREL32, 42) Index: include/llvm/MC/MCExpr.h =================================================================== --- include/llvm/MC/MCExpr.h +++ include/llvm/MC/MCExpr.h @@ -172,6 +172,7 @@ VK_GOT, VK_GOTOFF, VK_GOTREL, + VK_GOTPC, VK_GOTPCREL, VK_GOTTPOFF, VK_INDNTPOFF, Index: include/llvm/Object/ELFObjectFile.h =================================================================== --- include/llvm/Object/ELFObjectFile.h +++ include/llvm/Object/ELFObjectFile.h @@ -1005,6 +1005,8 @@ switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) { case ELF::ELFCLASS32: switch (EF.getHeader()->e_machine) { + case ELF::EM_68K: + return "ELF32-M680x0"; case ELF::EM_386: return "ELF32-i386"; case ELF::EM_IAMCU: @@ -1067,6 +1069,8 @@ template Triple::ArchType ELFObjectFile::getArch() const { bool IsLittleEndian = ELFT::TargetEndianness == support::little; switch (EF.getHeader()->e_machine) { + case ELF::EM_68K: + return Triple::m680x0; case ELF::EM_386: case ELF::EM_IAMCU: return Triple::x86; Index: include/llvm/module.modulemap =================================================================== --- include/llvm/module.modulemap +++ include/llvm/module.modulemap @@ -58,6 +58,7 @@ textual header "BinaryFormat/ELFRelocs/Sparc.def" textual header "BinaryFormat/ELFRelocs/SystemZ.def" textual header "BinaryFormat/ELFRelocs/x86_64.def" + textual header "BinaryFormat/ELFRelocs/m680x0.def" textual header "BinaryFormat/WasmRelocs.def" textual header "BinaryFormat/MsgPack.def" } Index: lib/MC/MCExpr.cpp =================================================================== --- lib/MC/MCExpr.cpp +++ lib/MC/MCExpr.cpp @@ -197,6 +197,7 @@ case VK_GOT: return "GOT"; case VK_GOTOFF: return "GOTOFF"; case VK_GOTREL: return "GOTREL"; + case VK_GOTPC: return "GOTPC"; case VK_GOTPCREL: return "GOTPCREL"; case VK_GOTTPOFF: return "GOTTPOFF"; case VK_INDNTPOFF: return "INDNTPOFF"; @@ -323,6 +324,7 @@ .Case("got", VK_GOT) .Case("gotoff", VK_GOTOFF) .Case("gotrel", VK_GOTREL) + .Case("gotpc", VK_GOTPC) .Case("gotpcrel", VK_GOTPCREL) .Case("gottpoff", VK_GOTTPOFF) .Case("indntpoff", VK_INDNTPOFF) Index: lib/Object/ELF.cpp =================================================================== --- lib/Object/ELF.cpp +++ lib/Object/ELF.cpp @@ -23,6 +23,13 @@ StringRef llvm::object::getELFRelocationTypeName(uint32_t Machine, uint32_t Type) { switch (Machine) { + case ELF::EM_68K: + switch (Type) { +#include "llvm/BinaryFormat/ELFRelocs/m680x0.def" + default: + break; + } + break; case ELF::EM_X86_64: switch (Type) { #include "llvm/BinaryFormat/ELFRelocs/x86_64.def" Index: lib/ObjectYAML/ELFYAML.cpp =================================================================== --- lib/ObjectYAML/ELFYAML.cpp +++ lib/ObjectYAML/ELFYAML.cpp @@ -644,6 +644,9 @@ case ELF::EM_BPF: #include "llvm/BinaryFormat/ELFRelocs/BPF.def" break; + case ELF::EM_68K: +#include "llvm/BinaryFormat/ELFRelocs/m680x0.def" + break; default: llvm_unreachable("Unsupported architecture"); } Index: lib/Support/Triple.cpp =================================================================== --- lib/Support/Triple.cpp +++ lib/Support/Triple.cpp @@ -51,6 +51,7 @@ case tcele: return "tcele"; case thumb: return "thumb"; case thumbeb: return "thumbeb"; + case m680x0: return "m680x0"; case x86: return "i386"; case x86_64: return "x86_64"; case xcore: return "xcore"; @@ -118,6 +119,8 @@ case systemz: return "s390"; + case m680x0: return "m680x0"; + case x86: case x86_64: return "x86"; @@ -290,6 +293,7 @@ .Case("tcele", tcele) .Case("thumb", thumb) .Case("thumbeb", thumbeb) + .Case("m680x0", m680x0) .Case("x86", x86) .Case("x86-64", x86_64) .Case("xcore", xcore) @@ -387,6 +391,7 @@ .Cases("powerpc", "ppc", "ppc32", Triple::ppc) .Cases("powerpc64", "ppu", "ppc64", Triple::ppc64) .Cases("powerpc64le", "ppc64le", Triple::ppc64le) + .Case("m680x0", Triple::m680x0) .Case("xscale", Triple::arm) .Case("xscaleeb", Triple::armeb) .Case("aarch64", Triple::aarch64) @@ -624,6 +629,7 @@ case Triple::aarch64: case Triple::arm: case Triple::thumb: + case Triple::m680x0: case Triple::x86: case Triple::x86_64: if (T.isOSDarwin()) @@ -1213,6 +1219,7 @@ case llvm::Triple::tcele: case llvm::Triple::thumb: case llvm::Triple::thumbeb: + case llvm::Triple::m680x0: case llvm::Triple::x86: case llvm::Triple::xcore: case llvm::Triple::amdil: @@ -1299,6 +1306,7 @@ case Triple::thumb: case Triple::thumbeb: case Triple::x86: + case Triple::m680x0: case Triple::xcore: case Triple::lanai: case Triple::shave: @@ -1341,6 +1349,7 @@ case Triple::tce: case Triple::tcele: case Triple::xcore: + case Triple::m680x0: case Triple::sparcel: case Triple::shave: T.setArch(UnknownArch); @@ -1456,6 +1465,7 @@ case Triple::ppc: case Triple::sparcv9: case Triple::systemz: + case Triple::m680x0: // ARM is intentionally unsupported here, changing the architecture would // drop any arch suffixes. Index: unittests/ADT/TripleTest.cpp =================================================================== --- unittests/ADT/TripleTest.cpp +++ unittests/ADT/TripleTest.cpp @@ -379,6 +379,24 @@ EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("m680x0"); + EXPECT_EQ(Triple::m680x0, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::UnknownOS, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + + T = Triple("m680x0-unknown-unknown"); + EXPECT_EQ(Triple::m680x0, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::UnknownOS, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + + T = Triple("m680x0-unknown-linux"); + EXPECT_EQ(Triple::m680x0, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("huh"); EXPECT_EQ(Triple::UnknownArch, T.getArch()); } @@ -696,6 +714,11 @@ EXPECT_FALSE(T.isArch16Bit()); EXPECT_FALSE(T.isArch32Bit()); EXPECT_TRUE(T.isArch64Bit()); + + T.setArch(Triple::m680x0); + EXPECT_FALSE(T.isArch16Bit()); + EXPECT_TRUE(T.isArch32Bit()); + EXPECT_FALSE(T.isArch64Bit()); } TEST(TripleTest, BitWidthArchVariants) { @@ -842,6 +865,10 @@ T.setArch(Triple::xcore); EXPECT_EQ(Triple::xcore, T.get32BitArchVariant().getArch()); EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch()); + + T.setArch(Triple::m680x0); + EXPECT_EQ(Triple::m680x0, T.get32BitArchVariant().getArch()); + EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch()); } TEST(TripleTest, EndianArchVariants) { @@ -948,6 +975,10 @@ T.setArch(Triple::le64); EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch()); EXPECT_EQ(Triple::le64, T.getLittleEndianArchVariant().getArch()); + + T.setArch(Triple::m680x0); + EXPECT_EQ(Triple::m680x0, T.getBigEndianArchVariant().getArch()); + EXPECT_EQ(Triple::UnknownArch, T.getLittleEndianArchVariant().getArch()); } TEST(TripleTest, getOSVersion) { @@ -1078,6 +1109,9 @@ EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-unknown-wasm").getObjectFormat()); + EXPECT_EQ(Triple::ELF, Triple("m680x0-unknown-linux").getObjectFormat()); + EXPECT_EQ(Triple::ELF, Triple("m680x0-unknown-unknown").getObjectFormat()); + Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf")); EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());