summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@google.com>2018-10-03 22:22:48 +0000
committerDerek Schuff <dschuff@google.com>2018-10-03 22:22:48 +0000
commit77a7a38006eed3dda8f63b1a352f3f60398bda41 (patch)
treefeb6080c3570ffc594004af3e1514a1bfa55fd12 /llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
parent3ed33eade06d583f2a93fe253975bc07a39fbd9e (diff)
downloadbcm5719-llvm-77a7a38006eed3dda8f63b1a352f3f60398bda41.tar.gz
bcm5719-llvm-77a7a38006eed3dda8f63b1a352f3f60398bda41.zip
[WebAssembly] Refactor WasmSignature and use it for MCSymbolWasm
MCContext does not destroy MCSymbols on shutdown. So, rather than putting SmallVectors (which may heap-allocate) inside MCSymbolWasm, use unowned pointer to a WasmSignature instead. The signatures are now owned by the AsmPrinter. Also uses WasmSignature instead of param and result vectors in TargetStreamer, and leaves some TODOs for further simplification. Differential Revision: https://reviews.llvm.org/D52580 llvm-svn: 343733
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
index e511e574050..073706e567e 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp
@@ -43,20 +43,34 @@ void llvm::ComputeLegalValueVTs(const Function &F, const TargetMachine &TM,
}
}
-void llvm::ComputeSignatureVTs(const Function &F, const TargetMachine &TM,
+void llvm::ComputeSignatureVTs(const FunctionType *Ty, const Function &F,
+ const TargetMachine &TM,
SmallVectorImpl<MVT> &Params,
SmallVectorImpl<MVT> &Results) {
- ComputeLegalValueVTs(F, TM, F.getReturnType(), Results);
+ ComputeLegalValueVTs(F, TM, Ty->getReturnType(), Results);
+ MVT PtrVT = MVT::getIntegerVT(TM.createDataLayout().getPointerSizeInBits());
if (Results.size() > 1) {
// WebAssembly currently can't lower returns of multiple values without
// demoting to sret (see WebAssemblyTargetLowering::CanLowerReturn). So
// replace multiple return values with a pointer parameter.
Results.clear();
- Params.push_back(
- MVT::getIntegerVT(TM.createDataLayout().getPointerSizeInBits()));
+ Params.push_back(PtrVT);
}
- for (auto &Arg : F.args())
- ComputeLegalValueVTs(F, TM, Arg.getType(), Params);
+ for (auto *Param : Ty->params())
+ ComputeLegalValueVTs(F, TM, Param, Params);
+ if (Ty->isVarArg())
+ Params.push_back(PtrVT);
+}
+
+std::unique_ptr<wasm::WasmSignature>
+llvm::SignatureFromMVTs(const SmallVectorImpl<MVT> &Results,
+ const SmallVectorImpl<MVT> &Params) {
+ auto Sig = make_unique<wasm::WasmSignature>();
+ for (MVT Ty : Results)
+ Sig->Returns.push_back(WebAssembly::toValType(Ty));
+ for (MVT Ty : Params)
+ Sig->Params.push_back(WebAssembly::toValType(Ty));
+ return Sig;
}
OpenPOWER on IntegriCloud