mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-21 03:05:26 -04:00
[WebAssembly] Add skeleton MC support for the Wasm container format
This just adds the basic skeleton for supporting a new object file format. All of the actual encoding will be implemented in followup patches. Differential Revision: https://reviews.llvm.org/D26722 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295803 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -30,8 +30,10 @@
|
||||
#include "llvm/MC/MCSectionCOFF.h"
|
||||
#include "llvm/MC/MCSectionELF.h"
|
||||
#include "llvm/MC/MCSectionMachO.h"
|
||||
#include "llvm/MC/MCSectionWasm.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCSymbolELF.h"
|
||||
#include "llvm/MC/MCSymbolWasm.h"
|
||||
#include "llvm/MC/MCValue.h"
|
||||
#include "llvm/ProfileData/InstrProf.h"
|
||||
#include "llvm/Support/COFF.h"
|
||||
@@ -1155,3 +1157,53 @@ void TargetLoweringObjectFileCOFF::emitLinkerFlagsForGlobal(
|
||||
raw_ostream &OS, const GlobalValue *GV) const {
|
||||
emitLinkerFlagsForGlobalCOFF(OS, GV, getTargetTriple(), getMangler());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Wasm
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal(
|
||||
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
|
||||
llvm_unreachable("getExplicitSectionGlobal not yet implemented");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MCSection *TargetLoweringObjectFileWasm::SelectSectionForGlobal(
|
||||
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
|
||||
if (Kind.isText())
|
||||
return TextSection;
|
||||
assert(!Kind.isMetadata() && "metadata sections not yet implemented");
|
||||
return DataSection;
|
||||
}
|
||||
|
||||
bool TargetLoweringObjectFileWasm::shouldPutJumpTableInFunctionSection(
|
||||
bool UsesLabelDifference, const Function &F) const {
|
||||
// We can always create relative relocations, so use another section
|
||||
// that can be marked non-executable.
|
||||
return false;
|
||||
}
|
||||
|
||||
const MCExpr *TargetLoweringObjectFileWasm::lowerRelativeReference(
|
||||
const GlobalValue *LHS, const GlobalValue *RHS,
|
||||
const TargetMachine &TM) const {
|
||||
// We may only use a PLT-relative relocation to refer to unnamed_addr
|
||||
// functions.
|
||||
if (!LHS->hasGlobalUnnamedAddr() || !LHS->getValueType()->isFunctionTy())
|
||||
return nullptr;
|
||||
|
||||
// Basic sanity checks.
|
||||
if (LHS->getType()->getPointerAddressSpace() != 0 ||
|
||||
RHS->getType()->getPointerAddressSpace() != 0 || LHS->isThreadLocal() ||
|
||||
RHS->isThreadLocal())
|
||||
return nullptr;
|
||||
|
||||
return MCBinaryExpr::createSub(
|
||||
MCSymbolRefExpr::create(TM.getSymbol(LHS), MCSymbolRefExpr::VK_None,
|
||||
getContext()),
|
||||
MCSymbolRefExpr::create(TM.getSymbol(RHS), getContext()), getContext());
|
||||
}
|
||||
|
||||
void
|
||||
TargetLoweringObjectFileWasm::InitializeWasm() {
|
||||
// TODO: Initialize StaticCtorSection and StaticDtorSection.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user