diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-03-26 17:35:35 +0000 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2019-03-26 17:35:35 +0000 |
commit | 52221d56bcf3d087bb88d44b56c682fd27f59a13 (patch) | |
tree | da2b6ddee3ba76afab43eab9d9721b710f774c1f /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | |
parent | 222718fdd20545e90f46e93d76b58eeb3dd63773 (diff) | |
download | llvm-52221d56bcf3d087bb88d44b56c682fd27f59a13.zip llvm-52221d56bcf3d087bb88d44b56c682fd27f59a13.tar.gz llvm-52221d56bcf3d087bb88d44b56c682fd27f59a13.tar.bz2 |
[WebAssembly] Support WebAssemblyFunctionInfo serialization
Summary:
The framework for supporting target-specific MachineFunctionInfo was
added in r356215. This adds serialization support for
WebAssemblyFunctionInfo on top of that. This patch only adds the
framework and does not actually serialize anything at this point; we
have to add YAML mapping later for the fields in WebAssemblyFunctionInfo
we want to serialize if necessary.
Reviewers: dschuff, arsenm
Subscribers: sunfish, wdng, sbc100, jgravelle-google, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59737
llvm-svn: 357009
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 414f055..6d9fd00 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -14,8 +14,10 @@ #include "WebAssemblyTargetMachine.h" #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" #include "WebAssembly.h" +#include "WebAssemblyMachineFunctionInfo.h" #include "WebAssemblyTargetObjectFile.h" #include "WebAssemblyTargetTransformInfo.h" +#include "llvm/CodeGen/MIRParser/MIParser.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/RegAllocRegistry.h" @@ -367,3 +369,24 @@ void WebAssemblyPassConfig::addPreEmitPass() { // Create a mapping from LLVM CodeGen virtual registers to wasm registers. addPass(createWebAssemblyRegNumbering()); } + +yaml::MachineFunctionInfo * +WebAssemblyTargetMachine::createDefaultFuncInfoYAML() const { + return new yaml::WebAssemblyFunctionInfo(); +} + +yaml::MachineFunctionInfo *WebAssemblyTargetMachine::convertFuncInfoToYAML( + const MachineFunction &MF) const { + const auto *MFI = MF.getInfo<WebAssemblyFunctionInfo>(); + return new yaml::WebAssemblyFunctionInfo(*MFI); +} + +bool WebAssemblyTargetMachine::parseMachineFunctionInfo( + const yaml::MachineFunctionInfo &MFI, PerFunctionMIParsingState &PFS, + SMDiagnostic &Error, SMRange &SourceRange) const { + const auto &YamlMFI = + reinterpret_cast<const yaml::WebAssemblyFunctionInfo &>(MFI); + MachineFunction &MF = PFS.MF; + MF.getInfo<WebAssemblyFunctionInfo>()->initializeBaseYamlFields(YamlMFI); + return false; +} |