From 98f658e2a0fc7e5ba03d078399afe6d342b57353 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 17 Dec 2015 04:55:44 +0000 Subject: [PATCH] [WebAssembly] Convert WebAssemblyTargetObjectFile to TargetLoweringObjectFileELF git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255877 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/WebAssembly/CMakeLists.txt | 1 + .../WebAssembly/WebAssemblyTargetMachine.cpp | 4 +- .../WebAssemblyTargetObjectFile.cpp | 24 +++++++++++ .../WebAssembly/WebAssemblyTargetObjectFile.h | 43 ++----------------- 4 files changed, 30 insertions(+), 42 deletions(-) create mode 100644 lib/Target/WebAssembly/WebAssemblyTargetObjectFile.cpp diff --git a/lib/Target/WebAssembly/CMakeLists.txt b/lib/Target/WebAssembly/CMakeLists.txt index f3a21557f7b..284a7d91bc6 100644 --- a/lib/Target/WebAssembly/CMakeLists.txt +++ b/lib/Target/WebAssembly/CMakeLists.txt @@ -33,6 +33,7 @@ add_llvm_target(WebAssemblyCodeGen WebAssemblyStoreResults.cpp WebAssemblySubtarget.cpp WebAssemblyTargetMachine.cpp + WebAssemblyTargetObjectFile.cpp WebAssemblyTargetTransformInfo.cpp ) diff --git a/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 38568fc4773..c774c120bb5 100644 --- a/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -15,11 +15,11 @@ #include "WebAssembly.h" #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" #include "WebAssemblyTargetMachine.h" +#include "WebAssemblyTargetObjectFile.h" #include "WebAssemblyTargetTransformInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/RegAllocRegistry.h" -#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/IR/Function.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/TargetRegistry.h" @@ -48,7 +48,7 @@ WebAssemblyTargetMachine::WebAssemblyTargetMachine( : LLVMTargetMachine(T, TT.isArch64Bit() ? "e-p:64:64-i64:64-n32:64-S128" : "e-p:32:32-i64:64-n32:64-S128", TT, CPU, FS, Options, RM, CM, OL), - TLOF(make_unique()) { + TLOF(make_unique()) { // WebAssembly type-checks expressions, but a noreturn function with a return // type that doesn't match the context will cause a check failure. So we lower // LLVM 'unreachable' to ISD::TRAP and then lower that to WebAssembly's diff --git a/lib/Target/WebAssembly/WebAssemblyTargetObjectFile.cpp b/lib/Target/WebAssembly/WebAssemblyTargetObjectFile.cpp new file mode 100644 index 00000000000..74e33b93e00 --- /dev/null +++ b/lib/Target/WebAssembly/WebAssemblyTargetObjectFile.cpp @@ -0,0 +1,24 @@ +//===-- WebAssemblyTargetObjectFile.cpp - WebAssembly Object Info ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief This file defines the functions of the WebAssembly-specific subclass +/// of TargetLoweringObjectFile. +/// +//===----------------------------------------------------------------------===// + +#include "WebAssemblyTargetObjectFile.h" +#include "WebAssemblyTargetMachine.h" +using namespace llvm; + +void WebAssemblyTargetObjectFile::Initialize(MCContext &Ctx, + const TargetMachine &TM) { + TargetLoweringObjectFileELF::Initialize(Ctx, TM); + InitializeELF(TM.Options.UseInitArray); +} diff --git a/lib/Target/WebAssembly/WebAssemblyTargetObjectFile.h b/lib/Target/WebAssembly/WebAssemblyTargetObjectFile.h index b5382340a61..39e50c9c575 100644 --- a/lib/Target/WebAssembly/WebAssemblyTargetObjectFile.h +++ b/lib/Target/WebAssembly/WebAssemblyTargetObjectFile.h @@ -16,50 +16,13 @@ #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETOBJECTFILE_H #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETOBJECTFILE_H -#include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" namespace llvm { -class GlobalVariable; - -class WebAssemblyTargetObjectFile final : public TargetLoweringObjectFile { +class WebAssemblyTargetObjectFile final : public TargetLoweringObjectFileELF { public: - WebAssemblyTargetObjectFile() { - TextSection = nullptr; - DataSection = nullptr; - BSSSection = nullptr; - ReadOnlySection = nullptr; - - StaticCtorSection = nullptr; - StaticDtorSection = nullptr; - LSDASection = nullptr; - EHFrameSection = nullptr; - DwarfAbbrevSection = nullptr; - DwarfInfoSection = nullptr; - DwarfLineSection = nullptr; - DwarfFrameSection = nullptr; - DwarfPubTypesSection = nullptr; - DwarfDebugInlineSection = nullptr; - DwarfStrSection = nullptr; - DwarfLocSection = nullptr; - DwarfARangesSection = nullptr; - DwarfRangesSection = nullptr; - } - - MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind, - const Constant *C) const override { - return ReadOnlySection; - } - - MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler &Mang, - const TargetMachine &TM) const override { - return DataSection; - } - - MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, - Mangler &Mang, - const TargetMachine &TM) const override; + void Initialize(MCContext &Ctx, const TargetMachine &TM) override; }; } // end namespace llvm -- 2.34.1