Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 1 | // WebAssemblyTargetMachine.h - Define TargetMachine for WebAssembly -*- C++ -*- |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // 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 Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// |
| 9 | /// \file |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 10 | /// This file declares the WebAssembly-specific subclass of |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 11 | /// 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 | |
| 21 | namespace llvm { |
| 22 | |
Matthias Braun | bb8507e | 2017-10-12 22:57:28 +0000 | [diff] [blame] | 23 | class WebAssemblyTargetMachine final : public LLVMTargetMachine { |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 24 | std::unique_ptr<TargetLoweringObjectFile> TLOF; |
| 25 | mutable StringMap<std::unique_ptr<WebAssemblySubtarget>> SubtargetMap; |
| 26 | |
| 27 | public: |
| 28 | WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU, |
| 29 | StringRef FS, const TargetOptions &Options, |
Daniel Jasper | 314ed20 | 2017-08-03 05:15:53 +0000 | [diff] [blame] | 30 | Optional<Reloc::Model> RM, |
| 31 | Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, |
| 32 | bool JIT); |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 33 | |
| 34 | ~WebAssemblyTargetMachine() override; |
Thomas Lively | f3b4f99 | 2019-02-28 18:39:08 +0000 | [diff] [blame] | 35 | |
| 36 | const WebAssemblySubtarget *getSubtargetImpl(std::string CPU, |
| 37 | std::string FS) const; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 38 | const WebAssemblySubtarget * |
| 39 | getSubtargetImpl(const Function &F) const override; |
| 40 | |
| 41 | // Pass Pipeline Configuration |
| 42 | TargetPassConfig *createPassConfig(PassManagerBase &PM) override; |
| 43 | |
| 44 | TargetLoweringObjectFile *getObjFileLowering() const override { |
| 45 | return TLOF.get(); |
| 46 | } |
| 47 | |
Sanjoy Das | 26d11ca | 2017-12-22 18:21:59 +0000 | [diff] [blame] | 48 | TargetTransformInfo getTargetTransformInfo(const Function &F) override; |
Derek Schuff | 1aaf87e | 2016-05-17 08:49:59 +0000 | [diff] [blame] | 49 | |
Thomas Lively | 649aba9 | 2020-02-03 14:37:10 -0800 | [diff] [blame^] | 50 | bool usesPhysRegsForPEI() const override { return false; } |
Heejin Ahn | 52221d5 | 2019-03-26 17:35:35 +0000 | [diff] [blame] | 51 | |
| 52 | yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override; |
| 53 | yaml::MachineFunctionInfo * |
| 54 | convertFuncInfoToYAML(const MachineFunction &MF) const override; |
| 55 | bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, |
| 56 | PerFunctionMIParsingState &PFS, |
| 57 | SMDiagnostic &Error, |
| 58 | SMRange &SourceRange) const override; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // end namespace llvm |
| 62 | |
| 63 | #endif |