llvm.org GIT mirror llvm / e98bc0b
Add XCOFF triple object format type for AIX This patch adds an XCOFF triple object format type into LLVM. This XCOFF triple object file type will be used later by object file and assembly generation for the AIX platform. Differential Revision: https://reviews.llvm.org/D58930 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355989 91177308-0d34-0410-b5e6-96231b3b80d8 Jason Liu 5 months ago
8 changed file(s) with 41 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
218218 ELF,
219219 MachO,
220220 Wasm,
221 XCOFF,
221222 };
222223
223224 private:
597598 !isAndroid();
598599 }
599600
601 /// Tests whether the OS is AIX.
602 bool isOSAIX() const {
603 return getOS() == Triple::AIX;
604 }
605
600606 /// Tests whether the OS uses the ELF binary format.
601607 bool isOSBinFormatELF() const {
602608 return getObjectFormat() == Triple::ELF;
615621 /// Tests whether the OS uses the Wasm binary format.
616622 bool isOSBinFormatWasm() const {
617623 return getObjectFormat() == Triple::Wasm;
624 }
625
626 /// Tests whether the OS uses the XCOFF binary format.
627 bool isOSBinFormatXCOFF() const {
628 return getObjectFormat() == Triple::XCOFF;
618629 }
619630
620631 /// Tests whether the target is the PS4 CPU
379379 return EHFrameSection;
380380 }
381381
382 enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
382 enum Environment { IsMachO, IsELF, IsCOFF, IsWasm, IsXCOFF };
383383 Environment getObjectFileType() const { return Env; }
384384
385385 bool isPositionIndependent() const { return PositionIndependent; }
160160 return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
161161 case MCObjectFileInfo::IsWasm:
162162 return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
163 case MCObjectFileInfo::IsXCOFF:
164 // TODO: Need to implement class MCSymbolXCOFF.
165 break;
163166 }
164167 }
165168 return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
800800 Env = IsWasm;
801801 initWasmMCObjectFileInfo(TT);
802802 break;
803 case Triple::XCOFF:
804 Env = IsXCOFF;
805 // TODO: Initialize MCObjectFileInfo for XCOFF format when
806 // MCSectionXCOFF is ready.
807 break;
803808 case Triple::UnknownObjectFormat:
804809 report_fatal_error("Cannot initialize MC for unknown object file format.");
805810 break;
815820 case Triple::MachO:
816821 case Triple::COFF:
817822 case Triple::Wasm:
823 case Triple::XCOFF:
818824 case Triple::UnknownObjectFormat:
819825 report_fatal_error("Cannot get DWARF comdat section for this object file "
820826 "format: not implemented.");
708708 break;
709709 case MCObjectFileInfo::IsWasm:
710710 PlatformParser.reset(createWasmAsmParser());
711 break;
712 case MCObjectFileInfo::IsXCOFF:
713 // TODO: Need to implement createXCOFFAsmParser for XCOFF format.
711714 break;
712715 }
713716
533533
534534 static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
535535 return StringSwitch(EnvironmentName)
536 // "xcoff" must come before "coff" because of the order-dependendent
537 // pattern matching.
538 .EndsWith("xcoff", Triple::XCOFF)
536539 .EndsWith("coff", Triple::COFF)
537540 .EndsWith("elf", Triple::ELF)
538541 .EndsWith("macho", Triple::MachO)
621624 case Triple::ELF: return "elf";
622625 case Triple::MachO: return "macho";
623626 case Triple::Wasm: return "wasm";
627 case Triple::XCOFF: return "xcoff";
624628 }
625629 llvm_unreachable("unknown object format type");
626630 }
685689 case Triple::ppc64:
686690 if (T.isOSDarwin())
687691 return Triple::MachO;
692 else if (T.isOSAIX())
693 return Triple::XCOFF;
688694 return Triple::ELF;
689695
690696 case Triple::wasm32:
55925592 break;
55935593 case MCObjectFileInfo::IsWasm:
55945594 CurrentFormat = WASM;
5595 break;
5596 case MCObjectFileInfo::IsXCOFF:
5597 llvm_unreachable("unexpected object format");
55955598 break;
55965599 }
55975600
12571257 EXPECT_EQ(Triple::Wasm,
12581258 Triple("wasm64-unknown-wasi-musl-wasm").getObjectFormat());
12591259
1260 EXPECT_EQ(Triple::XCOFF, Triple("powerpc-ibm-aix").getObjectFormat());
1261 EXPECT_EQ(Triple::XCOFF, Triple("powerpc64-ibm-aix").getObjectFormat());
1262 EXPECT_EQ(Triple::XCOFF, Triple("powerpc---xcoff").getObjectFormat());
1263 EXPECT_EQ(Triple::XCOFF, Triple("powerpc64---xcoff").getObjectFormat());
1264
12601265 Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
12611266 EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
12621267
12751280
12761281 T.setObjectFormat(Triple::MachO);
12771282 EXPECT_EQ(Triple::MachO, T.getObjectFormat());
1283
1284 T.setObjectFormat(Triple::XCOFF);
1285 EXPECT_EQ(Triple::XCOFF, T.getObjectFormat());
12781286 }
12791287
12801288 TEST(TripleTest, NormalizeWindows) {