mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-19 00:14:20 +00:00
[WebAssembly] Add triple support for the new wasm object format
Differential Revision: https://reviews.llvm.org/D26701 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ecf1f1111b
commit
c67238a892
@ -206,6 +206,7 @@ public:
|
||||
COFF,
|
||||
ELF,
|
||||
MachO,
|
||||
Wasm,
|
||||
};
|
||||
|
||||
private:
|
||||
@ -576,6 +577,11 @@ public:
|
||||
return getObjectFormat() == Triple::MachO;
|
||||
}
|
||||
|
||||
/// Tests whether the OS uses the Wasm binary format.
|
||||
bool isOSBinFormatWasm() const {
|
||||
return getObjectFormat() == Triple::Wasm;
|
||||
}
|
||||
|
||||
/// Tests whether the target is the PS4 CPU
|
||||
bool isPS4CPU() const {
|
||||
return getArch() == Triple::x86_64 &&
|
||||
|
@ -843,6 +843,9 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
|
||||
Env = IsELF;
|
||||
initELFMCObjectFileInfo(TT);
|
||||
break;
|
||||
case Triple::Wasm:
|
||||
report_fatal_error("Cannot initialize MC for wasm object file format yet.");
|
||||
break;
|
||||
case Triple::UnknownObjectFormat:
|
||||
report_fatal_error("Cannot initialize MC for unknown object file format.");
|
||||
break;
|
||||
|
@ -794,7 +794,7 @@ bool needsComdatForCounter(const Function &F, const Module &M) {
|
||||
return true;
|
||||
|
||||
Triple TT(M.getTargetTriple());
|
||||
if (!TT.isOSBinFormatELF())
|
||||
if (!TT.isOSBinFormatELF() && !TT.isOSBinFormatWasm())
|
||||
return false;
|
||||
|
||||
// See createPGOFuncNameVar for more details. To avoid link errors, profile
|
||||
|
@ -510,6 +510,7 @@ static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) {
|
||||
.EndsWith("coff", Triple::COFF)
|
||||
.EndsWith("elf", Triple::ELF)
|
||||
.EndsWith("macho", Triple::MachO)
|
||||
.EndsWith("wasm", Triple::Wasm)
|
||||
.Default(Triple::UnknownObjectFormat);
|
||||
}
|
||||
|
||||
@ -581,6 +582,7 @@ static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
|
||||
case Triple::COFF: return "coff";
|
||||
case Triple::ELF: return "elf";
|
||||
case Triple::MachO: return "macho";
|
||||
case Triple::Wasm: return "wasm";
|
||||
}
|
||||
llvm_unreachable("unknown object format type");
|
||||
}
|
||||
|
@ -1853,7 +1853,8 @@ bool AddressSanitizerModule::InstrumentGlobals(IRBuilder<> &IRB, Module &M) {
|
||||
GlobalValue *InstrumentedGlobal = NewGlobal;
|
||||
|
||||
bool CanUsePrivateAliases =
|
||||
TargetTriple.isOSBinFormatELF() || TargetTriple.isOSBinFormatMachO();
|
||||
TargetTriple.isOSBinFormatELF() || TargetTriple.isOSBinFormatMachO() ||
|
||||
TargetTriple.isOSBinFormatWasm();
|
||||
if (CanUsePrivateAliases && ClUsePrivateAliasForGlobals) {
|
||||
// Create local alias for NewGlobal to avoid crash on ODR between
|
||||
// instrumented and non-instrumented libraries.
|
||||
|
@ -888,6 +888,9 @@ TEST(TripleTest, FileFormat) {
|
||||
EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
|
||||
EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
|
||||
|
||||
EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-unknown-wasm").getObjectFormat());
|
||||
EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-unknown-wasm").getObjectFormat());
|
||||
|
||||
Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
|
||||
EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user