Summary: WebAssembly is unique among upstream targets in that it does not at any point use physical registers to store values. Instead, it uses virtual registers to model positions in its value stack. This means that some target-independent lowering activities that would use physical registers need to use virtual registers instead for WebAssembly and similar downstream targets. This CL generalizes the existing `usesPhysRegsForPEI` lowering hook to `usesPhysRegsForValues` in preparation for using it in more places. One such place is in InstrEmitter for instructions that have variadic defs. On register machines, it only makes sense for these defs to be physical registers, but for WebAssembly they must be virtual registers like any other values. This CL changes InstrEmitter to check the new target lowering hook to determine whether variadic defs should be physical or virtual registers. These changes are necessary to support a generalized CALL instruction for WebAssembly that is capable of returning an arbitrary number of arguments. Fully implementing that instruction will require additional changes that are described in comments here but left for a follow up commit. Reviewers: aheejin, dschuff, qcolombet Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71484
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
//===-- WebAssemblyUtilities - WebAssembly Utility Functions ---*- C++ -*-====//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file
|
|
/// This file contains the declaration of the WebAssembly-specific
|
|
/// utility functions.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H
|
|
#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYUTILITIES_H
|
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
|
|
|
namespace llvm {
|
|
|
|
class WebAssemblyFunctionInfo;
|
|
|
|
namespace WebAssembly {
|
|
|
|
bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
|
|
bool mayThrow(const MachineInstr &MI);
|
|
|
|
// Exception-related function names
|
|
extern const char *const ClangCallTerminateFn;
|
|
extern const char *const CxaBeginCatchFn;
|
|
extern const char *const CxaRethrowFn;
|
|
extern const char *const StdTerminateFn;
|
|
extern const char *const PersonalityWrapperFn;
|
|
|
|
/// Return the "bottom" block of an entity, which can be either a MachineLoop or
|
|
/// WebAssemblyException. This differs from MachineLoop::getBottomBlock in that
|
|
/// it works even if the entity is discontiguous.
|
|
template <typename T> MachineBasicBlock *getBottom(const T *Unit) {
|
|
MachineBasicBlock *Bottom = Unit->getHeader();
|
|
for (MachineBasicBlock *MBB : Unit->blocks())
|
|
if (MBB->getNumber() > Bottom->getNumber())
|
|
Bottom = MBB;
|
|
return Bottom;
|
|
}
|
|
|
|
/// Returns the operand number of a callee, assuming the argument is a call
|
|
/// instruction.
|
|
const MachineOperand &getCalleeOp(const MachineInstr &MI);
|
|
|
|
} // end namespace WebAssembly
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif
|