1 //===-- WebAssemblyWasmObjectWriter.cpp - WebAssembly Wasm Writer ---------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file handles Wasm-specific object emission, converting LLVM's
12 /// internal fixups into the appropriate relocations.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
17 #include "llvm/MC/MCFixup.h"
18 #include "llvm/MC/MCWasmObjectWriter.h"
19 #include "llvm/Support/ErrorHandling.h"
20 using namespace llvm;
21 
22 namespace {
23 class WebAssemblyWasmObjectWriter final : public MCWasmObjectTargetWriter {
24 public:
25   explicit WebAssemblyWasmObjectWriter(bool Is64Bit);
26 
27 private:
28   unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
29                         const MCFixup &Fixup, bool IsPCRel) const override;
30 };
31 } // end anonymous namespace
32 
33 WebAssemblyWasmObjectWriter::WebAssemblyWasmObjectWriter(bool Is64Bit)
34     : MCWasmObjectTargetWriter(Is64Bit) {}
35 
36 unsigned WebAssemblyWasmObjectWriter::getRelocType(MCContext &Ctx,
37                                                    const MCValue &Target,
38                                                    const MCFixup &Fixup,
39                                                    bool IsPCRel) const {
40   llvm_unreachable("Relocations not yet implemented");
41   return 0;
42 }
43 
44 MCObjectWriter *llvm::createWebAssemblyWasmObjectWriter(raw_pwrite_stream &OS,
45                                                         bool Is64Bit) {
46   MCWasmObjectTargetWriter *MOTW = new WebAssemblyWasmObjectWriter(Is64Bit);
47   return createWasmObjectWriter(MOTW, OS);
48 }
49