Index: llvm/include/llvm/ADT/Triple.h =================================================================== --- llvm/include/llvm/ADT/Triple.h +++ llvm/include/llvm/ADT/Triple.h @@ -56,6 +56,7 @@ avr, // AVR: Atmel AVR microcontroller bpfel, // eBPF or extended BPF or 64-bit BPF (little endian) bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian) + csky, // CSKY: csky hexagon, // Hexagon: hexagon mips, // MIPS: mips, mipsallegrex, mipsr6 mipsel, // MIPSEL: mipsel, mipsallegrexe, mipsr6el @@ -755,6 +756,11 @@ return getArch() == Triple::wasm32 || getArch() == Triple::wasm64; } + // Tests whether the target is CSKY + bool isCSKY() const { + return getArch() == Triple::csky; + } + /// Tests whether the target supports comdat bool supportsCOMDAT() const { return !(isOSBinFormatMachO() || isOSBinFormatXCOFF()); Index: llvm/lib/Support/Triple.cpp =================================================================== --- llvm/lib/Support/Triple.cpp +++ llvm/lib/Support/Triple.cpp @@ -36,6 +36,7 @@ case avr: return "avr"; case bpfeb: return "bpfeb"; case bpfel: return "bpfel"; + case csky: return "csky"; case hexagon: return "hexagon"; case hsail64: return "hsail64"; case hsail: return "hsail"; @@ -151,6 +152,7 @@ case riscv64: return "riscv"; case ve: return "ve"; + case csky: return "csky"; } } @@ -319,6 +321,7 @@ .Case("renderscript32", renderscript32) .Case("renderscript64", renderscript64) .Case("ve", ve) + .Case("csky", csky) .Default(UnknownArch); } @@ -448,6 +451,7 @@ .Case("ve", Triple::ve) .Case("wasm32", Triple::wasm32) .Case("wasm64", Triple::wasm64) + .Case("csky", Triple::csky) .Default(Triple::UnknownArch); // Some architectures require special parsing logic just to compute the @@ -678,6 +682,7 @@ case Triple::avr: case Triple::bpfeb: case Triple::bpfel: + case Triple::csky: case Triple::hexagon: case Triple::hsail64: case Triple::hsail: @@ -1251,6 +1256,7 @@ case llvm::Triple::arc: case llvm::Triple::arm: case llvm::Triple::armeb: + case llvm::Triple::csky: case llvm::Triple::hexagon: case llvm::Triple::hsail: case llvm::Triple::kalimba: @@ -1334,6 +1340,7 @@ case Triple::arc: case Triple::arm: case Triple::armeb: + case Triple::csky: case Triple::hexagon: case Triple::hsail: case Triple::kalimba: @@ -1385,6 +1392,7 @@ case Triple::UnknownArch: case Triple::arc: case Triple::avr: + case Triple::csky: case Triple::hexagon: case Triple::kalimba: case Triple::lanai: @@ -1478,6 +1486,7 @@ case Triple::x86_64: case Triple::xcore: case Triple::ve: + case Triple::csky: // ARM is intentionally unsupported here, changing the architecture would // drop any arch suffixes. @@ -1541,6 +1550,7 @@ case Triple::arm: case Triple::avr: case Triple::bpfel: + case Triple::csky: case Triple::hexagon: case Triple::hsail64: case Triple::hsail: Index: llvm/unittests/ADT/TripleTest.cpp =================================================================== --- llvm/unittests/ADT/TripleTest.cpp +++ llvm/unittests/ADT/TripleTest.cpp @@ -303,6 +303,18 @@ EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("csky-unknown-unknown"); + EXPECT_EQ(Triple::csky, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::UnknownOS, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + + T = Triple("csky-unknown-linux"); + EXPECT_EQ(Triple::csky, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("riscv32-unknown-unknown"); EXPECT_EQ(Triple::riscv32, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); @@ -882,6 +894,12 @@ EXPECT_FALSE(T.isArch32Bit()); EXPECT_TRUE(T.isArch64Bit()); EXPECT_TRUE(T.isRISCV()); + + T.setArch(Triple::csky); + EXPECT_FALSE(T.isArch16Bit()); + EXPECT_TRUE(T.isArch32Bit()); + EXPECT_FALSE(T.isArch64Bit()); + EXPECT_TRUE(T.isCSKY()); } TEST(TripleTest, BitWidthArchVariants) { @@ -981,6 +999,10 @@ EXPECT_EQ(Triple::riscv32, T.get32BitArchVariant().getArch()); EXPECT_EQ(Triple::riscv64, T.get64BitArchVariant().getArch()); + T.setArch(Triple::csky); + EXPECT_EQ(Triple::csky, T.get32BitArchVariant().getArch()); + EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch()); + T.setArch(Triple::thumbeb); EXPECT_EQ(Triple::thumbeb, T.get32BitArchVariant().getArch()); EXPECT_EQ(Triple::aarch64_be, T.get64BitArchVariant().getArch()); @@ -1134,6 +1156,10 @@ T.setArch(Triple::le64); EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch()); EXPECT_EQ(Triple::le64, T.getLittleEndianArchVariant().getArch()); + + T.setArch(Triple::csky); + EXPECT_EQ(Triple::UnknownArch, T.getBigEndianArchVariant().getArch()); + EXPECT_EQ(Triple::csky, T.getLittleEndianArchVariant().getArch()); } TEST(TripleTest, getOSVersion) { @@ -1360,6 +1386,9 @@ EXPECT_EQ(Triple::XCOFF, Triple("powerpc---xcoff").getObjectFormat()); EXPECT_EQ(Triple::XCOFF, Triple("powerpc64---xcoff").getObjectFormat()); + EXPECT_EQ(Triple::ELF, Triple("csky-unknown-unknown").getObjectFormat()); + EXPECT_EQ(Triple::ELF, Triple("csky-unknown-linux").getObjectFormat()); + Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf")); EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());