From 23f101f37937a1bd4a29726cab2f76e0fb038b35 Mon Sep 17 00:00:00 2001 From: patrick Date: Sun, 23 Jun 2019 21:36:31 +0000 Subject: Import LLVM 8.0.0 release including clang, lld and lldb. --- .../WebAssembly/WebAssemblyMachineFunctionInfo.cpp | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'gnu/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp') diff --git a/gnu/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp b/gnu/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp index e511e574050..0157af0f851 100644 --- a/gnu/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp +++ b/gnu/llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.cpp @@ -43,20 +43,38 @@ 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 &Params, SmallVectorImpl &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); +} + +void llvm::ValTypesFromMVTs(const ArrayRef &In, + SmallVectorImpl &Out) { + for (MVT Ty : In) + Out.push_back(WebAssembly::toValType(Ty)); +} + +std::unique_ptr +llvm::SignatureFromMVTs(const SmallVectorImpl &Results, + const SmallVectorImpl &Params) { + auto Sig = make_unique(); + ValTypesFromMVTs(Results, Sig->Returns); + ValTypesFromMVTs(Params, Sig->Params); + return Sig; } -- cgit v1.2.3-59-g8ed1b