#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "WebAssembly.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblySubtarget.h"
#include "WebAssemblyUtilities.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::opt<bool> DisableWebAssemblyFallthroughReturnOpt(
"disable-wasm-fallthrough-return-opt", cl::Hidden,
cl::desc("WebAssembly: Disable fallthrough-return optimizations."),
cl::init(false));
namespace {
class WebAssemblyPeephole final : public MachineFunctionPass { … };
}
char WebAssemblyPeephole::ID = …;
INITIALIZE_PASS(…)
FunctionPass *llvm::createWebAssemblyPeephole() { … }
static bool maybeRewriteToDrop(unsigned OldReg, unsigned NewReg,
MachineOperand &MO, WebAssemblyFunctionInfo &MFI,
MachineRegisterInfo &MRI) { … }
static bool maybeRewriteToFallthrough(MachineInstr &MI, MachineBasicBlock &MBB,
const MachineFunction &MF,
WebAssemblyFunctionInfo &MFI,
MachineRegisterInfo &MRI,
const WebAssemblyInstrInfo &TII) { … }
bool WebAssemblyPeephole::runOnMachineFunction(MachineFunction &MF) { … }