[llvm] r355989 - Add XCOFF triple object format type for AIX
Jason Liu via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 15:01:10 PDT 2019
Author: jasonliu
Date: Tue Mar 12 15:01:10 2019
New Revision: 355989
URL: http://llvm.org/viewvc/llvm-project?rev=355989&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/ADT/Triple.h
llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
llvm/trunk/lib/MC/MCContext.cpp
llvm/trunk/lib/MC/MCObjectFileInfo.cpp
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/lib/Support/Triple.cpp
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/trunk/unittests/ADT/TripleTest.cpp
Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=355989&r1=355988&r2=355989&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Tue Mar 12 15:01:10 2019
@@ -219,6 +219,7 @@ public:
ELF,
MachO,
Wasm,
+ XCOFF,
};
private:
@@ -598,6 +599,11 @@ public:
!isAndroid();
}
+ /// Tests whether the OS is AIX.
+ bool isOSAIX() const {
+ return getOS() == Triple::AIX;
+ }
+
/// Tests whether the OS uses the ELF binary format.
bool isOSBinFormatELF() const {
return getObjectFormat() == Triple::ELF;
@@ -618,6 +624,11 @@ public:
return getObjectFormat() == Triple::Wasm;
}
+ /// Tests whether the OS uses the XCOFF binary format.
+ bool isOSBinFormatXCOFF() const {
+ return getObjectFormat() == Triple::XCOFF;
+ }
+
/// Tests whether the target is the PS4 CPU
bool isPS4CPU() const {
return getArch() == Triple::x86_64 &&
Modified: llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectFileInfo.h?rev=355989&r1=355988&r2=355989&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectFileInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectFileInfo.h Tue Mar 12 15:01:10 2019
@@ -380,7 +380,7 @@ public:
return EHFrameSection;
}
- enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
+ enum Environment { IsMachO, IsELF, IsCOFF, IsWasm, IsXCOFF };
Environment getObjectFileType() const { return Env; }
bool isPositionIndependent() const { return PositionIndependent; }
Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=355989&r1=355988&r2=355989&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Tue Mar 12 15:01:10 2019
@@ -161,6 +161,9 @@ MCSymbol *MCContext::createSymbolImpl(co
return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
case MCObjectFileInfo::IsWasm:
return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
+ case MCObjectFileInfo::IsXCOFF:
+ // TODO: Need to implement class MCSymbolXCOFF.
+ break;
}
}
return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=355989&r1=355988&r2=355989&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Tue Mar 12 15:01:10 2019
@@ -801,6 +801,11 @@ void MCObjectFileInfo::InitMCObjectFileI
Env = IsWasm;
initWasmMCObjectFileInfo(TT);
break;
+ case Triple::XCOFF:
+ Env = IsXCOFF;
+ // TODO: Initialize MCObjectFileInfo for XCOFF format when
+ // MCSectionXCOFF is ready.
+ break;
case Triple::UnknownObjectFormat:
report_fatal_error("Cannot initialize MC for unknown object file format.");
break;
@@ -816,6 +821,7 @@ MCSection *MCObjectFileInfo::getDwarfCom
case Triple::MachO:
case Triple::COFF:
case Triple::Wasm:
+ case Triple::XCOFF:
case Triple::UnknownObjectFormat:
report_fatal_error("Cannot get DWARF comdat section for this object file "
"format: not implemented.");
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=355989&r1=355988&r2=355989&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Mar 12 15:01:10 2019
@@ -710,6 +710,9 @@ AsmParser::AsmParser(SourceMgr &SM, MCCo
case MCObjectFileInfo::IsWasm:
PlatformParser.reset(createWasmAsmParser());
break;
+ case MCObjectFileInfo::IsXCOFF:
+ // TODO: Need to implement createXCOFFAsmParser for XCOFF format.
+ break;
}
PlatformParser->Initialize(*this);
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=355989&r1=355988&r2=355989&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Tue Mar 12 15:01:10 2019
@@ -534,6 +534,9 @@ static Triple::EnvironmentType parseEnvi
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
return StringSwitch<Triple::ObjectFormatType>(EnvironmentName)
+ // "xcoff" must come before "coff" because of the order-dependendent
+ // pattern matching.
+ .EndsWith("xcoff", Triple::XCOFF)
.EndsWith("coff", Triple::COFF)
.EndsWith("elf", Triple::ELF)
.EndsWith("macho", Triple::MachO)
@@ -622,6 +625,7 @@ static StringRef getObjectFormatTypeName
case Triple::ELF: return "elf";
case Triple::MachO: return "macho";
case Triple::Wasm: return "wasm";
+ case Triple::XCOFF: return "xcoff";
}
llvm_unreachable("unknown object format type");
}
@@ -686,6 +690,8 @@ static Triple::ObjectFormatType getDefau
case Triple::ppc64:
if (T.isOSDarwin())
return Triple::MachO;
+ else if (T.isOSAIX())
+ return Triple::XCOFF;
return Triple::ELF;
case Triple::wasm32:
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=355989&r1=355988&r2=355989&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Tue Mar 12 15:01:10 2019
@@ -5594,6 +5594,9 @@ bool ARMAsmParser::parsePrefix(ARMMCExpr
case MCObjectFileInfo::IsWasm:
CurrentFormat = WASM;
break;
+ case MCObjectFileInfo::IsXCOFF:
+ llvm_unreachable("unexpected object format");
+ break;
}
if (~Prefix->SupportedFormats & CurrentFormat) {
Modified: llvm/trunk/unittests/ADT/TripleTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TripleTest.cpp?rev=355989&r1=355988&r2=355989&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/TripleTest.cpp (original)
+++ llvm/trunk/unittests/ADT/TripleTest.cpp Tue Mar 12 15:01:10 2019
@@ -1258,6 +1258,11 @@ TEST(TripleTest, FileFormat) {
EXPECT_EQ(Triple::Wasm,
Triple("wasm64-unknown-wasi-musl-wasm").getObjectFormat());
+ EXPECT_EQ(Triple::XCOFF, Triple("powerpc-ibm-aix").getObjectFormat());
+ EXPECT_EQ(Triple::XCOFF, Triple("powerpc64-ibm-aix").getObjectFormat());
+ EXPECT_EQ(Triple::XCOFF, Triple("powerpc---xcoff").getObjectFormat());
+ EXPECT_EQ(Triple::XCOFF, Triple("powerpc64---xcoff").getObjectFormat());
+
Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
@@ -1276,6 +1281,9 @@ TEST(TripleTest, FileFormat) {
T.setObjectFormat(Triple::MachO);
EXPECT_EQ(Triple::MachO, T.getObjectFormat());
+
+ T.setObjectFormat(Triple::XCOFF);
+ EXPECT_EQ(Triple::XCOFF, T.getObjectFormat());
}
TEST(TripleTest, NormalizeWindows) {
More information about the llvm-commits
mailing list