WebAssemblyTargetMachine.h revision 285163
1// WebAssemblyTargetMachine.h - Define TargetMachine for WebAssembly -*- C++ -*-
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 declares the WebAssembly-specific subclass of
12/// TargetMachine.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H
17#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H
18
19#include "WebAssemblySubtarget.h"
20#include "llvm/Target/TargetMachine.h"
21
22namespace llvm {
23
24class WebAssemblyTargetMachine final : public LLVMTargetMachine {
25  std::unique_ptr<TargetLoweringObjectFile> TLOF;
26  mutable StringMap<std::unique_ptr<WebAssemblySubtarget>> SubtargetMap;
27
28public:
29  WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
30                           StringRef FS, const TargetOptions &Options,
31                           Reloc::Model RM, CodeModel::Model CM,
32                           CodeGenOpt::Level OL);
33
34  ~WebAssemblyTargetMachine() override;
35  const WebAssemblySubtarget *
36  getSubtargetImpl(const Function &F) const override;
37
38  // Pass Pipeline Configuration
39  TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
40
41  TargetLoweringObjectFile *getObjFileLowering() const override {
42    return TLOF.get();
43  }
44
45  /// \brief Get the TargetIRAnalysis for this target.
46  TargetIRAnalysis getTargetIRAnalysis() override;
47};
48
49} // end namespace llvm
50
51#endif
52