mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-03 16:21:41 +00:00
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 llvm-svn: 355989
This commit is contained in:
parent
14e47fc8be
commit
65a0422be5
@ -219,6 +219,7 @@ public:
|
|||||||
ELF,
|
ELF,
|
||||||
MachO,
|
MachO,
|
||||||
Wasm,
|
Wasm,
|
||||||
|
XCOFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -598,6 +599,11 @@ public:
|
|||||||
!isAndroid();
|
!isAndroid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tests whether the OS is AIX.
|
||||||
|
bool isOSAIX() const {
|
||||||
|
return getOS() == Triple::AIX;
|
||||||
|
}
|
||||||
|
|
||||||
/// Tests whether the OS uses the ELF binary format.
|
/// Tests whether the OS uses the ELF binary format.
|
||||||
bool isOSBinFormatELF() const {
|
bool isOSBinFormatELF() const {
|
||||||
return getObjectFormat() == Triple::ELF;
|
return getObjectFormat() == Triple::ELF;
|
||||||
@ -618,6 +624,11 @@ public:
|
|||||||
return getObjectFormat() == Triple::Wasm;
|
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
|
/// Tests whether the target is the PS4 CPU
|
||||||
bool isPS4CPU() const {
|
bool isPS4CPU() const {
|
||||||
return getArch() == Triple::x86_64 &&
|
return getArch() == Triple::x86_64 &&
|
||||||
|
@ -380,7 +380,7 @@ public:
|
|||||||
return EHFrameSection;
|
return EHFrameSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
|
enum Environment { IsMachO, IsELF, IsCOFF, IsWasm, IsXCOFF };
|
||||||
Environment getObjectFileType() const { return Env; }
|
Environment getObjectFileType() const { return Env; }
|
||||||
|
|
||||||
bool isPositionIndependent() const { return PositionIndependent; }
|
bool isPositionIndependent() const { return PositionIndependent; }
|
||||||
|
@ -161,6 +161,9 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
|
|||||||
return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
|
return new (Name, *this) MCSymbolMachO(Name, IsTemporary);
|
||||||
case MCObjectFileInfo::IsWasm:
|
case MCObjectFileInfo::IsWasm:
|
||||||
return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
|
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,
|
return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name,
|
||||||
|
@ -801,6 +801,11 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
|
|||||||
Env = IsWasm;
|
Env = IsWasm;
|
||||||
initWasmMCObjectFileInfo(TT);
|
initWasmMCObjectFileInfo(TT);
|
||||||
break;
|
break;
|
||||||
|
case Triple::XCOFF:
|
||||||
|
Env = IsXCOFF;
|
||||||
|
// TODO: Initialize MCObjectFileInfo for XCOFF format when
|
||||||
|
// MCSectionXCOFF is ready.
|
||||||
|
break;
|
||||||
case Triple::UnknownObjectFormat:
|
case Triple::UnknownObjectFormat:
|
||||||
report_fatal_error("Cannot initialize MC for unknown object file format.");
|
report_fatal_error("Cannot initialize MC for unknown object file format.");
|
||||||
break;
|
break;
|
||||||
@ -816,6 +821,7 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name,
|
|||||||
case Triple::MachO:
|
case Triple::MachO:
|
||||||
case Triple::COFF:
|
case Triple::COFF:
|
||||||
case Triple::Wasm:
|
case Triple::Wasm:
|
||||||
|
case Triple::XCOFF:
|
||||||
case Triple::UnknownObjectFormat:
|
case Triple::UnknownObjectFormat:
|
||||||
report_fatal_error("Cannot get DWARF comdat section for this object file "
|
report_fatal_error("Cannot get DWARF comdat section for this object file "
|
||||||
"format: not implemented.");
|
"format: not implemented.");
|
||||||
|
@ -710,6 +710,9 @@ AsmParser::AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
|
|||||||
case MCObjectFileInfo::IsWasm:
|
case MCObjectFileInfo::IsWasm:
|
||||||
PlatformParser.reset(createWasmAsmParser());
|
PlatformParser.reset(createWasmAsmParser());
|
||||||
break;
|
break;
|
||||||
|
case MCObjectFileInfo::IsXCOFF:
|
||||||
|
// TODO: Need to implement createXCOFFAsmParser for XCOFF format.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlatformParser->Initialize(*this);
|
PlatformParser->Initialize(*this);
|
||||||
|
@ -534,6 +534,9 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
|
|||||||
|
|
||||||
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
|
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
|
||||||
return StringSwitch<Triple::ObjectFormatType>(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("coff", Triple::COFF)
|
||||||
.EndsWith("elf", Triple::ELF)
|
.EndsWith("elf", Triple::ELF)
|
||||||
.EndsWith("macho", Triple::MachO)
|
.EndsWith("macho", Triple::MachO)
|
||||||
@ -622,6 +625,7 @@ static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
|
|||||||
case Triple::ELF: return "elf";
|
case Triple::ELF: return "elf";
|
||||||
case Triple::MachO: return "macho";
|
case Triple::MachO: return "macho";
|
||||||
case Triple::Wasm: return "wasm";
|
case Triple::Wasm: return "wasm";
|
||||||
|
case Triple::XCOFF: return "xcoff";
|
||||||
}
|
}
|
||||||
llvm_unreachable("unknown object format type");
|
llvm_unreachable("unknown object format type");
|
||||||
}
|
}
|
||||||
@ -686,6 +690,8 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
|
|||||||
case Triple::ppc64:
|
case Triple::ppc64:
|
||||||
if (T.isOSDarwin())
|
if (T.isOSDarwin())
|
||||||
return Triple::MachO;
|
return Triple::MachO;
|
||||||
|
else if (T.isOSAIX())
|
||||||
|
return Triple::XCOFF;
|
||||||
return Triple::ELF;
|
return Triple::ELF;
|
||||||
|
|
||||||
case Triple::wasm32:
|
case Triple::wasm32:
|
||||||
|
@ -5594,6 +5594,9 @@ bool ARMAsmParser::parsePrefix(ARMMCExpr::VariantKind &RefKind) {
|
|||||||
case MCObjectFileInfo::IsWasm:
|
case MCObjectFileInfo::IsWasm:
|
||||||
CurrentFormat = WASM;
|
CurrentFormat = WASM;
|
||||||
break;
|
break;
|
||||||
|
case MCObjectFileInfo::IsXCOFF:
|
||||||
|
llvm_unreachable("unexpected object format");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (~Prefix->SupportedFormats & CurrentFormat) {
|
if (~Prefix->SupportedFormats & CurrentFormat) {
|
||||||
|
@ -1258,6 +1258,11 @@ TEST(TripleTest, FileFormat) {
|
|||||||
EXPECT_EQ(Triple::Wasm,
|
EXPECT_EQ(Triple::Wasm,
|
||||||
Triple("wasm64-unknown-wasi-musl-wasm").getObjectFormat());
|
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"));
|
Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
|
||||||
EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
|
EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
|
||||||
|
|
||||||
@ -1276,6 +1281,9 @@ TEST(TripleTest, FileFormat) {
|
|||||||
|
|
||||||
T.setObjectFormat(Triple::MachO);
|
T.setObjectFormat(Triple::MachO);
|
||||||
EXPECT_EQ(Triple::MachO, T.getObjectFormat());
|
EXPECT_EQ(Triple::MachO, T.getObjectFormat());
|
||||||
|
|
||||||
|
T.setObjectFormat(Triple::XCOFF);
|
||||||
|
EXPECT_EQ(Triple::XCOFF, T.getObjectFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TripleTest, NormalizeWindows) {
|
TEST(TripleTest, NormalizeWindows) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user