Compare commits
1 Commits
3d-grid
...
openmp-off
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cfb51ae02 |
@@ -249,6 +249,7 @@ static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) {
|
|||||||
case Triple::Wasm:
|
case Triple::Wasm:
|
||||||
case Triple::DXContainer:
|
case Triple::DXContainer:
|
||||||
case Triple::SPIRV:
|
case Triple::SPIRV:
|
||||||
|
case Triple::MetalLib:
|
||||||
case Triple::UnknownObjectFormat:
|
case Triple::UnknownObjectFormat:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5077,6 +5077,7 @@ std::string CGObjCCommonMac::GetSectionName(StringRef Section,
|
|||||||
case llvm::Triple::Wasm:
|
case llvm::Triple::Wasm:
|
||||||
case llvm::Triple::GOFF:
|
case llvm::Triple::GOFF:
|
||||||
case llvm::Triple::SPIRV:
|
case llvm::Triple::SPIRV:
|
||||||
|
case llvm::Triple::MetalLib:
|
||||||
case llvm::Triple::XCOFF:
|
case llvm::Triple::XCOFF:
|
||||||
case llvm::Triple::DXContainer:
|
case llvm::Triple::DXContainer:
|
||||||
llvm::report_fatal_error(
|
llvm::report_fatal_error(
|
||||||
|
|||||||
@@ -5806,6 +5806,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
|
|||||||
case llvm::Triple::GOFF:
|
case llvm::Triple::GOFF:
|
||||||
case llvm::Triple::SPIRV:
|
case llvm::Triple::SPIRV:
|
||||||
case llvm::Triple::XCOFF:
|
case llvm::Triple::XCOFF:
|
||||||
|
case llvm::Triple::MetalLib:
|
||||||
llvm_unreachable("unimplemented");
|
llvm_unreachable("unimplemented");
|
||||||
case llvm::Triple::COFF:
|
case llvm::Triple::COFF:
|
||||||
case llvm::Triple::ELF:
|
case llvm::Triple::ELF:
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class MCSectionELF;
|
|||||||
class MCSectionGOFF;
|
class MCSectionGOFF;
|
||||||
class MCSectionMachO;
|
class MCSectionMachO;
|
||||||
class MCSectionSPIRV;
|
class MCSectionSPIRV;
|
||||||
|
class MCSectionMetalLib;
|
||||||
class MCSectionWasm;
|
class MCSectionWasm;
|
||||||
class MCSectionXCOFF;
|
class MCSectionXCOFF;
|
||||||
class MCStreamer;
|
class MCStreamer;
|
||||||
@@ -87,7 +88,8 @@ public:
|
|||||||
IsSPIRV,
|
IsSPIRV,
|
||||||
IsWasm,
|
IsWasm,
|
||||||
IsXCOFF,
|
IsXCOFF,
|
||||||
IsDXContainer
|
IsDXContainer,
|
||||||
|
IsMetalLib
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -135,6 +137,7 @@ private:
|
|||||||
SpecificBumpPtrAllocator<MCSectionMachO> MachOAllocator;
|
SpecificBumpPtrAllocator<MCSectionMachO> MachOAllocator;
|
||||||
SpecificBumpPtrAllocator<MCSectionGOFF> GOFFAllocator;
|
SpecificBumpPtrAllocator<MCSectionGOFF> GOFFAllocator;
|
||||||
SpecificBumpPtrAllocator<MCSectionSPIRV> SPIRVAllocator;
|
SpecificBumpPtrAllocator<MCSectionSPIRV> SPIRVAllocator;
|
||||||
|
SpecificBumpPtrAllocator<MCSectionSPIRV> MetalLibAllocator;
|
||||||
SpecificBumpPtrAllocator<MCSectionWasm> WasmAllocator;
|
SpecificBumpPtrAllocator<MCSectionWasm> WasmAllocator;
|
||||||
SpecificBumpPtrAllocator<MCSectionXCOFF> XCOFFAllocator;
|
SpecificBumpPtrAllocator<MCSectionXCOFF> XCOFFAllocator;
|
||||||
SpecificBumpPtrAllocator<MCInst> MCInstAllocator;
|
SpecificBumpPtrAllocator<MCInst> MCInstAllocator;
|
||||||
@@ -641,6 +644,8 @@ public:
|
|||||||
|
|
||||||
MCSectionSPIRV *getSPIRVSection();
|
MCSectionSPIRV *getSPIRVSection();
|
||||||
|
|
||||||
|
MCSectionMetalLib *getMetalLibSection();
|
||||||
|
|
||||||
MCSectionWasm *getWasmSection(const Twine &Section, SectionKind K,
|
MCSectionWasm *getWasmSection(const Twine &Section, SectionKind K,
|
||||||
unsigned Flags = 0) {
|
unsigned Flags = 0) {
|
||||||
return getWasmSection(Section, K, Flags, nullptr);
|
return getWasmSection(Section, K, Flags, nullptr);
|
||||||
|
|||||||
48
llvm/include/llvm/MC/MCMetalLibStreamer.h
Normal file
48
llvm/include/llvm/MC/MCMetalLibStreamer.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
//===- MCMetalLibStreamer.h - MetalLib Object File Interface ------*- C++ ===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Overrides MCObjectStreamer to disable all unnecessary features with stubs.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_MC_MCMetalLibSTREAMER_H
|
||||||
|
#define LLVM_MC_MCMetalLibSTREAMER_H
|
||||||
|
|
||||||
|
#include "llvm/MC/MCAsmBackend.h"
|
||||||
|
#include "llvm/MC/MCCodeEmitter.h"
|
||||||
|
#include "llvm/MC/MCObjectStreamer.h"
|
||||||
|
#include "llvm/MC/MCObjectWriter.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
class MCInst;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
|
class MCMetalLibStreamer : public MCObjectStreamer {
|
||||||
|
public:
|
||||||
|
MCMetalLibStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
|
||||||
|
std::unique_ptr<MCObjectWriter> OW,
|
||||||
|
std::unique_ptr<MCCodeEmitter> Emitter)
|
||||||
|
: MCObjectStreamer(Context, std::move(TAB), std::move(OW),
|
||||||
|
std::move(Emitter)) {}
|
||||||
|
|
||||||
|
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
|
Align ByteAlignment) override {}
|
||||||
|
void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
|
||||||
|
uint64_t Size = 0, Align ByteAlignment = Align(1),
|
||||||
|
SMLoc Loc = SMLoc()) override {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace llvm
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -459,6 +459,7 @@ private:
|
|||||||
void initGOFFMCObjectFileInfo(const Triple &T);
|
void initGOFFMCObjectFileInfo(const Triple &T);
|
||||||
void initCOFFMCObjectFileInfo(const Triple &T);
|
void initCOFFMCObjectFileInfo(const Triple &T);
|
||||||
void initSPIRVMCObjectFileInfo(const Triple &T);
|
void initSPIRVMCObjectFileInfo(const Triple &T);
|
||||||
|
void initMetalLibMCObjectFileInfo(const Triple &T);
|
||||||
void initWasmMCObjectFileInfo(const Triple &T);
|
void initWasmMCObjectFileInfo(const Triple &T);
|
||||||
void initXCOFFMCObjectFileInfo(const Triple &T);
|
void initXCOFFMCObjectFileInfo(const Triple &T);
|
||||||
void initDXContainerObjectFileInfo(const Triple &T);
|
void initDXContainerObjectFileInfo(const Triple &T);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
SV_XCOFF,
|
SV_XCOFF,
|
||||||
SV_SPIRV,
|
SV_SPIRV,
|
||||||
SV_DXContainer,
|
SV_DXContainer,
|
||||||
|
SV_MetalLib,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Express the state of bundle locked groups while emitting code.
|
/// Express the state of bundle locked groups while emitting code.
|
||||||
|
|||||||
41
llvm/include/llvm/MC/MCSectionMetalLib.h
Normal file
41
llvm/include/llvm/MC/MCSectionMetalLib.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
//===- MCSectionMetalLib.h - MetalLib Machine Code Sections -----*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file declares the MCSectionMetalLib class.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_MC_MCSECTIONMetalLib_H
|
||||||
|
#define LLVM_MC_MCSECTIONMetalLib_H
|
||||||
|
|
||||||
|
#include "llvm/MC/MCSection.h"
|
||||||
|
#include "llvm/MC/SectionKind.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
class MCSymbol;
|
||||||
|
|
||||||
|
class MCSectionMetalLib final : public MCSection {
|
||||||
|
friend class MCContext;
|
||||||
|
|
||||||
|
MCSectionMetalLib(SectionKind K, MCSymbol *Begin)
|
||||||
|
: MCSection(SV_MetalLib, "", K, Begin) {}
|
||||||
|
// TODO: Add StringRef Name to MCSectionMetalLib.
|
||||||
|
|
||||||
|
public:
|
||||||
|
~MCSectionMetalLib() = default;
|
||||||
|
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
|
||||||
|
raw_ostream &OS,
|
||||||
|
const MCExpr *Subsection) const override {}
|
||||||
|
bool useCodeAlign() const override { return false; }
|
||||||
|
bool isVirtualSection() const override { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end namespace llvm
|
||||||
|
|
||||||
|
#endif // LLVM_MC_MCSECTIONMetalLib_H
|
||||||
@@ -120,6 +120,11 @@ MCStreamer *createDXContainerStreamer(MCContext &Ctx,
|
|||||||
std::unique_ptr<MCObjectWriter> &&OW,
|
std::unique_ptr<MCObjectWriter> &&OW,
|
||||||
std::unique_ptr<MCCodeEmitter> &&CE,
|
std::unique_ptr<MCCodeEmitter> &&CE,
|
||||||
bool RelaxAll);
|
bool RelaxAll);
|
||||||
|
MCStreamer *createMetalLibStreamer(MCContext &Ctx,
|
||||||
|
std::unique_ptr<MCAsmBackend> &&TAB,
|
||||||
|
std::unique_ptr<MCObjectWriter> &&OW,
|
||||||
|
std::unique_ptr<MCCodeEmitter> &&CE,
|
||||||
|
bool RelaxAll);
|
||||||
|
|
||||||
MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx);
|
MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx);
|
||||||
|
|
||||||
@@ -227,6 +232,12 @@ public:
|
|||||||
std::unique_ptr<MCObjectWriter> &&OW,
|
std::unique_ptr<MCObjectWriter> &&OW,
|
||||||
std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll);
|
std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll);
|
||||||
|
|
||||||
|
using MetalLibStreamerCtorTy =
|
||||||
|
MCStreamer *(*)(const Triple &T, MCContext &Ctx,
|
||||||
|
std::unique_ptr<MCAsmBackend> &&TAB,
|
||||||
|
std::unique_ptr<MCObjectWriter> &&OW,
|
||||||
|
std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll);
|
||||||
|
|
||||||
using NullTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S);
|
using NullTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S);
|
||||||
using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)(
|
using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)(
|
||||||
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
|
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
|
||||||
@@ -333,6 +344,7 @@ private:
|
|||||||
XCOFFStreamerCtorTy XCOFFStreamerCtorFn = nullptr;
|
XCOFFStreamerCtorTy XCOFFStreamerCtorFn = nullptr;
|
||||||
SPIRVStreamerCtorTy SPIRVStreamerCtorFn = nullptr;
|
SPIRVStreamerCtorTy SPIRVStreamerCtorFn = nullptr;
|
||||||
DXContainerStreamerCtorTy DXContainerStreamerCtorFn = nullptr;
|
DXContainerStreamerCtorTy DXContainerStreamerCtorFn = nullptr;
|
||||||
|
MetalLibStreamerCtorTy MetalLibStreamerCtorFn = nullptr;
|
||||||
|
|
||||||
/// Construction function for this target's null TargetStreamer, if
|
/// Construction function for this target's null TargetStreamer, if
|
||||||
/// registered (default = nullptr).
|
/// registered (default = nullptr).
|
||||||
@@ -621,6 +633,13 @@ public:
|
|||||||
S = createDXContainerStreamer(Ctx, std::move(TAB), std::move(OW),
|
S = createDXContainerStreamer(Ctx, std::move(TAB), std::move(OW),
|
||||||
std::move(Emitter), RelaxAll);
|
std::move(Emitter), RelaxAll);
|
||||||
break;
|
break;
|
||||||
|
case Triple::MetalLib:
|
||||||
|
if (MetalLibStreamerCtorFn)
|
||||||
|
S = MetalLibStreamerCtorFn(T, Ctx, std::move(TAB), std::move(OW),
|
||||||
|
std::move(Emitter), RelaxAll);
|
||||||
|
else
|
||||||
|
S = createMetalLibStreamer(Ctx, std::move(TAB), std::move(OW),
|
||||||
|
std::move(Emitter), RelaxAll);
|
||||||
}
|
}
|
||||||
if (ObjectTargetStreamerCtorFn)
|
if (ObjectTargetStreamerCtorFn)
|
||||||
ObjectTargetStreamerCtorFn(*S, STI);
|
ObjectTargetStreamerCtorFn(*S, STI);
|
||||||
|
|||||||
@@ -106,7 +106,9 @@ public:
|
|||||||
renderscript32, // 32-bit RenderScript
|
renderscript32, // 32-bit RenderScript
|
||||||
renderscript64, // 64-bit RenderScript
|
renderscript64, // 64-bit RenderScript
|
||||||
ve, // NEC SX-Aurora Vector Engine
|
ve, // NEC SX-Aurora Vector Engine
|
||||||
LastArchType = ve
|
air, // 32-bit Apple IR
|
||||||
|
air64, // 64-bit Apple IR
|
||||||
|
LastArchType = air64
|
||||||
};
|
};
|
||||||
enum SubArchType {
|
enum SubArchType {
|
||||||
NoSubArch,
|
NoSubArch,
|
||||||
@@ -288,6 +290,7 @@ public:
|
|||||||
SPIRV,
|
SPIRV,
|
||||||
Wasm,
|
Wasm,
|
||||||
XCOFF,
|
XCOFF,
|
||||||
|
MetalLib,
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -5106,6 +5106,9 @@ static const char *getSectionNameForBitcode(const Triple &T) {
|
|||||||
case Triple::DXContainer:
|
case Triple::DXContainer:
|
||||||
llvm_unreachable("DXContainer is not yet implemented");
|
llvm_unreachable("DXContainer is not yet implemented");
|
||||||
break;
|
break;
|
||||||
|
case Triple::MetalLib:
|
||||||
|
llvm_unreachable("MetalLib is not yet implemented");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
llvm_unreachable("Unimplemented ObjectFormatType");
|
llvm_unreachable("Unimplemented ObjectFormatType");
|
||||||
}
|
}
|
||||||
@@ -5131,6 +5134,9 @@ static const char *getSectionNameForCommandline(const Triple &T) {
|
|||||||
case Triple::DXContainer:
|
case Triple::DXContainer:
|
||||||
llvm_unreachable("DXC is not yet implemented");
|
llvm_unreachable("DXC is not yet implemented");
|
||||||
break;
|
break;
|
||||||
|
case Triple::MetalLib:
|
||||||
|
llvm_unreachable("Metal is not yet implemented");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
llvm_unreachable("Unimplemented ObjectFormatType");
|
llvm_unreachable("Unimplemented ObjectFormatType");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ add_llvm_component_library(LLVMMC
|
|||||||
MCSectionXCOFF.cpp
|
MCSectionXCOFF.cpp
|
||||||
MCStreamer.cpp
|
MCStreamer.cpp
|
||||||
MCSPIRVStreamer.cpp
|
MCSPIRVStreamer.cpp
|
||||||
|
MCMetalLibStreamer.cpp
|
||||||
MCSubtargetInfo.cpp
|
MCSubtargetInfo.cpp
|
||||||
MCSymbol.cpp
|
MCSymbol.cpp
|
||||||
MCSymbolELF.cpp
|
MCSymbolELF.cpp
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "llvm/MC/MCSectionGOFF.h"
|
#include "llvm/MC/MCSectionGOFF.h"
|
||||||
#include "llvm/MC/MCSectionMachO.h"
|
#include "llvm/MC/MCSectionMachO.h"
|
||||||
#include "llvm/MC/MCSectionSPIRV.h"
|
#include "llvm/MC/MCSectionSPIRV.h"
|
||||||
|
#include "llvm/MC/MCSectionMetalLib.h"
|
||||||
#include "llvm/MC/MCSectionWasm.h"
|
#include "llvm/MC/MCSectionWasm.h"
|
||||||
#include "llvm/MC/MCSectionXCOFF.h"
|
#include "llvm/MC/MCSectionXCOFF.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
@@ -109,6 +110,9 @@ MCContext::MCContext(const Triple &TheTriple, const MCAsmInfo *mai,
|
|||||||
case Triple::SPIRV:
|
case Triple::SPIRV:
|
||||||
Env = IsSPIRV;
|
Env = IsSPIRV;
|
||||||
break;
|
break;
|
||||||
|
case Triple::MetalLib:
|
||||||
|
Env = IsMetalLib;
|
||||||
|
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;
|
||||||
@@ -253,6 +257,7 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
|
|||||||
return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
|
return new (Name, *this) MCSymbolWasm(Name, IsTemporary);
|
||||||
case MCContext::IsXCOFF:
|
case MCContext::IsXCOFF:
|
||||||
return createXCOFFSymbolImpl(Name, IsTemporary);
|
return createXCOFFSymbolImpl(Name, IsTemporary);
|
||||||
|
case MCContext::IsMetalLib:
|
||||||
case MCContext::IsDXContainer:
|
case MCContext::IsDXContainer:
|
||||||
break;
|
break;
|
||||||
case MCContext::IsSPIRV:
|
case MCContext::IsSPIRV:
|
||||||
@@ -852,6 +857,21 @@ MCSectionSPIRV *MCContext::getSPIRVSection() {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCSectionMetalLib *MCContext::getMetalLibSection() {
|
||||||
|
MCSymbol *Begin = nullptr;
|
||||||
|
MCSectionMetalLib *Result = new (MetalLibAllocator.Allocate())
|
||||||
|
MCSectionMetalLib(SectionKind::getText(), Begin);
|
||||||
|
|
||||||
|
auto *F = new MCDataFragment();
|
||||||
|
Result->getFragmentList().insert(Result->begin(), F);
|
||||||
|
F->setParent(Result);
|
||||||
|
|
||||||
|
if (Begin)
|
||||||
|
Begin->setFragment(F);
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
MCSectionDXContainer *MCContext::getDXContainerSection(StringRef Section,
|
MCSectionDXContainer *MCContext::getDXContainerSection(StringRef Section,
|
||||||
SectionKind K) {
|
SectionKind K) {
|
||||||
// Do the lookup, if we have a hit, return it.
|
// Do the lookup, if we have a hit, return it.
|
||||||
|
|||||||
44
llvm/lib/MC/MCMetalLibStreamer.cpp
Normal file
44
llvm/lib/MC/MCMetalLibStreamer.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
//===- lib/MC/MCMetalLibStreamer.cpp - MetalLib Object Output -*- C++ -*---===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file assembles .s files and emits MetalLib .o object files.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/MC/MCMetalLibStreamer.h"
|
||||||
|
#include "llvm/MC/MCAssembler.h"
|
||||||
|
#include "llvm/MC/TargetRegistry.h"
|
||||||
|
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
void MCMetalLibStreamer::emitInstToData(const MCInst &Inst,
|
||||||
|
const MCSubtargetInfo &STI) {
|
||||||
|
MCAssembler &Assembler = getAssembler();
|
||||||
|
SmallVector<MCFixup, 0> Fixups;
|
||||||
|
SmallString<256> Code;
|
||||||
|
Assembler.getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
|
||||||
|
|
||||||
|
// Append the encoded instruction to the current data fragment (or create a
|
||||||
|
// new such fragment if the current fragment is not a data fragment).
|
||||||
|
MCDataFragment *DF = getOrCreateDataFragment();
|
||||||
|
|
||||||
|
DF->setHasInstructions(STI);
|
||||||
|
DF->getContents().append(Code.begin(), Code.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
MCStreamer *llvm::createMetalLibStreamer(MCContext &Context,
|
||||||
|
std::unique_ptr<MCAsmBackend> &&MAB,
|
||||||
|
std::unique_ptr<MCObjectWriter> &&OW,
|
||||||
|
std::unique_ptr<MCCodeEmitter> &&CE,
|
||||||
|
bool RelaxAll) {
|
||||||
|
MCMetalLibStreamer *S = new MCMetalLibStreamer(Context, std::move(MAB),
|
||||||
|
std::move(OW), std::move(CE));
|
||||||
|
if (RelaxAll)
|
||||||
|
S->getAssembler().setRelaxAll(true);
|
||||||
|
return S;
|
||||||
|
}
|
||||||
@@ -829,6 +829,11 @@ void MCObjectFileInfo::initSPIRVMCObjectFileInfo(const Triple &T) {
|
|||||||
TextSection = Ctx->getSPIRVSection();
|
TextSection = Ctx->getSPIRVSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCObjectFileInfo::initMetalLibMCObjectFileInfo(const Triple &T) {
|
||||||
|
// Put everything in a single binary section.
|
||||||
|
TextSection = Ctx->getSPIRVSection();
|
||||||
|
}
|
||||||
|
|
||||||
void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
|
void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
|
||||||
TextSection = Ctx->getWasmSection(".text", SectionKind::getText());
|
TextSection = Ctx->getWasmSection(".text", SectionKind::getText());
|
||||||
DataSection = Ctx->getWasmSection(".data", SectionKind::getData());
|
DataSection = Ctx->getWasmSection(".data", SectionKind::getData());
|
||||||
@@ -1079,6 +1084,9 @@ void MCObjectFileInfo::initMCObjectFileInfo(MCContext &MCCtx, bool PIC,
|
|||||||
case MCContext::IsDXContainer:
|
case MCContext::IsDXContainer:
|
||||||
initDXContainerObjectFileInfo(TheTriple);
|
initDXContainerObjectFileInfo(TheTriple);
|
||||||
break;
|
break;
|
||||||
|
case MCContext::IsMetalLib:
|
||||||
|
initMetalLibMCObjectFileInfo(TheTriple);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1097,6 +1105,7 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name,
|
|||||||
case Triple::SPIRV:
|
case Triple::SPIRV:
|
||||||
case Triple::XCOFF:
|
case Triple::XCOFF:
|
||||||
case Triple::DXContainer:
|
case Triple::DXContainer:
|
||||||
|
case Triple::MetalLib:
|
||||||
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.");
|
||||||
|
|||||||
@@ -800,6 +800,10 @@ AsmParser::AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
|
|||||||
report_fatal_error(
|
report_fatal_error(
|
||||||
"Need to implement createSPIRVAsmParser for SPIRV format.");
|
"Need to implement createSPIRVAsmParser for SPIRV format.");
|
||||||
break;
|
break;
|
||||||
|
case MCContext::IsMetalLib:
|
||||||
|
report_fatal_error(
|
||||||
|
"Need to implement createMetalLibAsmParser for SPIRV format.");
|
||||||
|
break;
|
||||||
case MCContext::IsWasm:
|
case MCContext::IsWasm:
|
||||||
PlatformParser.reset(createWasmAsmParser());
|
PlatformParser.reset(createWasmAsmParser());
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ StringRef Triple::getArchTypeName(ArchType Kind) {
|
|||||||
case x86_64: return "x86_64";
|
case x86_64: return "x86_64";
|
||||||
case xcore: return "xcore";
|
case xcore: return "xcore";
|
||||||
case xtensa: return "xtensa";
|
case xtensa: return "xtensa";
|
||||||
|
case air: return "air";
|
||||||
|
case air64: return "air64";
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm_unreachable("Invalid ArchType!");
|
llvm_unreachable("Invalid ArchType!");
|
||||||
@@ -308,6 +310,7 @@ StringRef Triple::getObjectFormatTypeName(ObjectFormatType Kind) {
|
|||||||
case XCOFF: return "xcoff";
|
case XCOFF: return "xcoff";
|
||||||
case DXContainer: return "dxcontainer";
|
case DXContainer: return "dxcontainer";
|
||||||
case SPIRV: return "spirv";
|
case SPIRV: return "spirv";
|
||||||
|
case MetalLib: return "metallib";
|
||||||
}
|
}
|
||||||
llvm_unreachable("unknown object format type");
|
llvm_unreachable("unknown object format type");
|
||||||
}
|
}
|
||||||
@@ -873,6 +876,9 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
|
|||||||
|
|
||||||
case Triple::dxil:
|
case Triple::dxil:
|
||||||
return Triple::DXContainer;
|
return Triple::DXContainer;
|
||||||
|
case Triple::air:
|
||||||
|
case Triple::air64:
|
||||||
|
return Triple::MetalLib;
|
||||||
}
|
}
|
||||||
llvm_unreachable("unknown architecture");
|
llvm_unreachable("unknown architecture");
|
||||||
}
|
}
|
||||||
@@ -1431,6 +1437,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
|
|||||||
case llvm::Triple::x86:
|
case llvm::Triple::x86:
|
||||||
case llvm::Triple::xcore:
|
case llvm::Triple::xcore:
|
||||||
case llvm::Triple::xtensa:
|
case llvm::Triple::xtensa:
|
||||||
|
case llvm::Triple::air:
|
||||||
return 32;
|
return 32;
|
||||||
|
|
||||||
case llvm::Triple::aarch64:
|
case llvm::Triple::aarch64:
|
||||||
@@ -1456,6 +1463,7 @@ static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
|
|||||||
case llvm::Triple::ve:
|
case llvm::Triple::ve:
|
||||||
case llvm::Triple::wasm64:
|
case llvm::Triple::wasm64:
|
||||||
case llvm::Triple::x86_64:
|
case llvm::Triple::x86_64:
|
||||||
|
case llvm::Triple::air64:
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
llvm_unreachable("Invalid architecture value");
|
llvm_unreachable("Invalid architecture value");
|
||||||
@@ -1522,6 +1530,7 @@ Triple Triple::get32BitArchVariant() const {
|
|||||||
case Triple::x86:
|
case Triple::x86:
|
||||||
case Triple::xcore:
|
case Triple::xcore:
|
||||||
case Triple::xtensa:
|
case Triple::xtensa:
|
||||||
|
case Triple::air:
|
||||||
// Already 32-bit.
|
// Already 32-bit.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1549,6 +1558,7 @@ Triple Triple::get32BitArchVariant() const {
|
|||||||
break;
|
break;
|
||||||
case Triple::wasm64: T.setArch(Triple::wasm32); break;
|
case Triple::wasm64: T.setArch(Triple::wasm32); break;
|
||||||
case Triple::x86_64: T.setArch(Triple::x86); break;
|
case Triple::x86_64: T.setArch(Triple::x86); break;
|
||||||
|
case Triple::air64: T.setArch(Triple::air); break;
|
||||||
}
|
}
|
||||||
return T;
|
return T;
|
||||||
}
|
}
|
||||||
@@ -1599,6 +1609,7 @@ Triple Triple::get64BitArchVariant() const {
|
|||||||
case Triple::ve:
|
case Triple::ve:
|
||||||
case Triple::wasm64:
|
case Triple::wasm64:
|
||||||
case Triple::x86_64:
|
case Triple::x86_64:
|
||||||
|
case Triple::air64:
|
||||||
// Already 64-bit.
|
// Already 64-bit.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1629,6 +1640,7 @@ Triple Triple::get64BitArchVariant() const {
|
|||||||
case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
|
case Triple::thumbeb: T.setArch(Triple::aarch64_be); break;
|
||||||
case Triple::wasm32: T.setArch(Triple::wasm64); break;
|
case Triple::wasm32: T.setArch(Triple::wasm64); break;
|
||||||
case Triple::x86: T.setArch(Triple::x86_64); break;
|
case Triple::x86: T.setArch(Triple::x86_64); break;
|
||||||
|
case Triple::air: T.setArch(Triple::air64); break;
|
||||||
}
|
}
|
||||||
return T;
|
return T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1920,6 +1920,7 @@ StringRef ModuleAddressSanitizer::getGlobalMetadataSection() const {
|
|||||||
case Triple::SPIRV:
|
case Triple::SPIRV:
|
||||||
case Triple::XCOFF:
|
case Triple::XCOFF:
|
||||||
case Triple::DXContainer:
|
case Triple::DXContainer:
|
||||||
|
case Triple::MetalLib:
|
||||||
report_fatal_error(
|
report_fatal_error(
|
||||||
"ModuleAddressSanitizer not implemented for object file format");
|
"ModuleAddressSanitizer not implemented for object file format");
|
||||||
case Triple::UnknownObjectFormat:
|
case Triple::UnknownObjectFormat:
|
||||||
|
|||||||
@@ -71,11 +71,11 @@ set(OPENMP_TEST_OPENMP_FLAGS ${OPENMP_TEST_COMPILER_OPENMP_FLAGS} CACHE STRING
|
|||||||
"OpenMP compiler flag to use for testing OpenMP runtime libraries.")
|
"OpenMP compiler flag to use for testing OpenMP runtime libraries.")
|
||||||
|
|
||||||
set(ENABLE_LIBOMPTARGET ON)
|
set(ENABLE_LIBOMPTARGET ON)
|
||||||
# Currently libomptarget cannot be compiled on Windows or MacOS X.
|
# Currently libomptarget cannot be compiled on Windows.
|
||||||
# Since the device plugins are only supported on Linux anyway,
|
# Since the device plugins are only supported on Linux anyway, there is no point
|
||||||
# there is no point in trying to compile libomptarget on other OSes.
|
# in trying to compile libomptarget on other OSes.
|
||||||
# 32-bit systems are not supported either.
|
# 32-bit systems are not supported either.
|
||||||
if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP17_FLAG OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if (WIN32 OR NOT OPENMP_HAVE_STD_CPP17_FLAG OR NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
set(ENABLE_LIBOMPTARGET OFF)
|
set(ENABLE_LIBOMPTARGET OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -97,8 +97,8 @@ add_subdirectory(runtime)
|
|||||||
|
|
||||||
if (OPENMP_ENABLE_LIBOMPTARGET)
|
if (OPENMP_ENABLE_LIBOMPTARGET)
|
||||||
# Check that the library can actually be built.
|
# Check that the library can actually be built.
|
||||||
if (APPLE OR WIN32)
|
if (WIN32)
|
||||||
message(FATAL_ERROR "libomptarget cannot be built on Windows and MacOS X!")
|
message(FATAL_ERROR "libomptarget cannot be built on Windows!")
|
||||||
elseif (NOT OPENMP_HAVE_STD_CPP17_FLAG)
|
elseif (NOT OPENMP_HAVE_STD_CPP17_FLAG)
|
||||||
message(FATAL_ERROR "Host compiler must support C++17 to build libomptarget!")
|
message(FATAL_ERROR "Host compiler must support C++17 to build libomptarget!")
|
||||||
elseif (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
elseif (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
|||||||
@@ -105,9 +105,13 @@ set(LIBOMPTARGET_LLVM_LIBRARY_DIR "${LLVM_LIBRARY_DIR}" CACHE STRING
|
|||||||
"Path to folder containing llvm library libomptarget.so")
|
"Path to folder containing llvm library libomptarget.so")
|
||||||
|
|
||||||
# Build offloading plugins and device RTLs if they are available.
|
# Build offloading plugins and device RTLs if they are available.
|
||||||
add_subdirectory(plugins)
|
# FIXME: For now let's disable building other stuff on macOS.
|
||||||
add_subdirectory(plugins-nextgen)
|
if (NOT APPLE)
|
||||||
add_subdirectory(DeviceRTL)
|
add_subdirectory(plugins)
|
||||||
|
add_subdirectory(plugins-nextgen)
|
||||||
|
add_subdirectory(DeviceRTL)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
|
|
||||||
# Add tests.
|
# Add tests.
|
||||||
|
|||||||
Reference in New Issue
Block a user