blob: 0630797fe8143f5bc429ff6e4f2ceed7414d9e3f [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001// WebAssemblyTargetMachine.h - Define TargetMachine for WebAssembly -*- C++ -*-
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Dan Gohman10e730a2015-06-29 23:51:55 +00006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// This file declares the WebAssembly-specific subclass of
Dan Gohman10e730a2015-06-29 23:51:55 +000011/// TargetMachine.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYTARGETMACHINE_H
17
18#include "WebAssemblySubtarget.h"
19#include "llvm/Target/TargetMachine.h"
20
21namespace llvm {
22
Matthias Braunbb8507e2017-10-12 22:57:28 +000023class WebAssemblyTargetMachine final : public LLVMTargetMachine {
Dan Gohman10e730a2015-06-29 23:51:55 +000024 std::unique_ptr<TargetLoweringObjectFile> TLOF;
25 mutable StringMap<std::unique_ptr<WebAssemblySubtarget>> SubtargetMap;
Thomas Livelyf3b4f992019-02-28 18:39:08 +000026 mutable FeatureBitset UsedFeatures;
Dan Gohman10e730a2015-06-29 23:51:55 +000027
28public:
29 WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
30 StringRef FS, const TargetOptions &Options,
Daniel Jasper314ed202017-08-03 05:15:53 +000031 Optional<Reloc::Model> RM,
32 Optional<CodeModel::Model> CM, CodeGenOpt::Level OL,
33 bool JIT);
Dan Gohman10e730a2015-06-29 23:51:55 +000034
35 ~WebAssemblyTargetMachine() override;
Thomas Livelyf3b4f992019-02-28 18:39:08 +000036
37 const WebAssemblySubtarget *getSubtargetImpl(std::string CPU,
38 std::string FS) const;
Dan Gohman10e730a2015-06-29 23:51:55 +000039 const WebAssemblySubtarget *
40 getSubtargetImpl(const Function &F) const override;
41
42 // Pass Pipeline Configuration
43 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
44
45 TargetLoweringObjectFile *getObjFileLowering() const override {
46 return TLOF.get();
47 }
48
Thomas Livelyf3b4f992019-02-28 18:39:08 +000049 FeatureBitset getUsedFeatures() const { return UsedFeatures; }
50
Sanjoy Das26d11ca2017-12-22 18:21:59 +000051 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
Derek Schuff1aaf87e2016-05-17 08:49:59 +000052
53 bool usesPhysRegsForPEI() const override { return false; }
Dan Gohman10e730a2015-06-29 23:51:55 +000054};
55
56} // end namespace llvm
57
58#endif