LLVM  7.0.0svn
Macros | Functions | Variables
WebAssemblyExplicitLocals.cpp File Reference

This file converts any remaining registers into WebAssembly locals. More...

#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "WebAssembly.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblySubtarget.h"
#include "WebAssemblyUtilities.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Include dependency graph for WebAssemblyExplicitLocals.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "wasm-explicit-locals"
 

Functions

 INITIALIZE_PASS (WebAssemblyExplicitLocals, DEBUG_TYPE, "Convert registers to WebAssembly locals", false, false) FunctionPass *llvm
 
static unsigned getLocalId (DenseMap< unsigned, unsigned > &Reg2Local, unsigned &CurLocal, unsigned Reg)
 Return a local id number for the given register, assigning it a new one if it doesn't yet have one. More...
 
static unsigned getDropOpcode (const TargetRegisterClass *RC)
 Get the appropriate drop opcode for the given register class. More...
 
static unsigned getGetLocalOpcode (const TargetRegisterClass *RC)
 Get the appropriate get_local opcode for the given register class. More...
 
static unsigned getSetLocalOpcode (const TargetRegisterClass *RC)
 Get the appropriate set_local opcode for the given register class. More...
 
static unsigned getTeeLocalOpcode (const TargetRegisterClass *RC)
 Get the appropriate tee_local opcode for the given register class. More...
 
static MVT typeForRegClass (const TargetRegisterClass *RC)
 Get the type associated with the given register class. More...
 
static MachineInstrFindStartOfTree (MachineOperand &MO, MachineRegisterInfo &MRI, WebAssemblyFunctionInfo &MFI)
 Given a MachineOperand of a stackified vreg, return the instruction at the start of the expression tree. More...
 

Variables

static cl::opt< boolDisableWebAssemblyExplicitLocals ("disable-wasm-explicit-locals", cl::ReallyHidden, cl::desc("WebAssembly: Disable emission of get_local/set_local."), cl::init(false))
 

Detailed Description

This file converts any remaining registers into WebAssembly locals.

After register stackification and register coloring, convert non-stackified registers into locals, inserting explicit get_local and set_local instructions.

Definition in file WebAssemblyExplicitLocals.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "wasm-explicit-locals"

Definition at line 32 of file WebAssemblyExplicitLocals.cpp.

Function Documentation

◆ FindStartOfTree()

static MachineInstr* FindStartOfTree ( MachineOperand MO,
MachineRegisterInfo MRI,
WebAssemblyFunctionInfo MFI 
)
static

Given a MachineOperand of a stackified vreg, return the instruction at the start of the expression tree.

Definition at line 165 of file WebAssemblyExplicitLocals.cpp.

References llvm::MachineInstrBuilder::addReg(), assert(), llvm::MachineFunction::begin(), llvm::BuildMI(), llvm::MachineOperand::CreateImm(), llvm::MachineRegisterInfo::createVirtualRegister(), llvm::dbgs(), llvm::tgtok::Def, DisableWebAssemblyExplicitLocals, E, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::MachineInstr::eraseFromParent(), llvm::MachineInstr::explicit_uses(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::MachineInstr::getDebugLoc(), llvm::MachineInstr::getDesc(), getDropOpcode(), getGetLocalOpcode(), llvm::MachineOperand::getImm(), llvm::MachineFunction::getInfo(), getLocalId(), llvm::MachineFunction::getName(), llvm::MCInstrDesc::getNumDefs(), llvm::MachineRegisterInfo::getNumVirtRegs(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::WebAssemblyFunctionInfo::getParams(), llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineFunction::getRegInfo(), getSetLocalOpcode(), llvm::MachineFunction::getSubtarget(), getTeeLocalOpcode(), llvm::MachineRegisterInfo::getVRegDef(), I, llvm::TargetRegisterInfo::index2VirtReg(), llvm::ISD::INLINEASM, llvm::WebAssembly::isArgument(), llvm::WebAssembly::isCopy(), llvm::MachineInstr::isDebugInstr(), llvm::MachineInstr::isLabel(), llvm::WebAssembly::isTee(), llvm::WebAssemblyFunctionInfo::isVRegStackified(), LLVM_DEBUG, MI, MRI, Reg, llvm::MachineRegisterInfo::removeRegOperandFromUseList(), llvm::MachineRegisterInfo::replaceRegWith(), llvm::reverse(), llvm::MachineOperand::setIsDead(), llvm::MachineOperand::setIsKill(), llvm::WebAssemblyFunctionInfo::setLocal(), llvm::WebAssemblyFunctionInfo::setNumLocals(), llvm::MachineOperand::setReg(), llvm::WebAssemblyFunctionInfo::stackifyVReg(), TII, typeForRegClass(), llvm::MachineRegisterInfo::use_empty(), and llvm::TargetRegisterInfo::virtReg2Index().

◆ getDropOpcode()

static unsigned getDropOpcode ( const TargetRegisterClass RC)
static

Get the appropriate drop opcode for the given register class.

Definition at line 81 of file WebAssemblyExplicitLocals.cpp.

References llvm_unreachable.

Referenced by FindStartOfTree().

◆ getGetLocalOpcode()

static unsigned getGetLocalOpcode ( const TargetRegisterClass RC)
static

Get the appropriate get_local opcode for the given register class.

Definition at line 98 of file WebAssemblyExplicitLocals.cpp.

References llvm_unreachable.

Referenced by FindStartOfTree().

◆ getLocalId()

static unsigned getLocalId ( DenseMap< unsigned, unsigned > &  Reg2Local,
unsigned CurLocal,
unsigned  Reg 
)
static

Return a local id number for the given register, assigning it a new one if it doesn't yet have one.

Definition at line 72 of file WebAssemblyExplicitLocals.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), and P.

Referenced by FindStartOfTree().

◆ getSetLocalOpcode()

static unsigned getSetLocalOpcode ( const TargetRegisterClass RC)
static

Get the appropriate set_local opcode for the given register class.

Definition at line 115 of file WebAssemblyExplicitLocals.cpp.

References llvm_unreachable.

Referenced by FindStartOfTree().

◆ getTeeLocalOpcode()

static unsigned getTeeLocalOpcode ( const TargetRegisterClass RC)
static

Get the appropriate tee_local opcode for the given register class.

Definition at line 132 of file WebAssemblyExplicitLocals.cpp.

References llvm_unreachable.

Referenced by FindStartOfTree().

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( WebAssemblyExplicitLocals  ,
DEBUG_TYPE  ,
"Convert registers to WebAssembly locals"  ,
false  ,
false   
)

Definition at line 63 of file WebAssemblyExplicitLocals.cpp.

◆ typeForRegClass()

static MVT typeForRegClass ( const TargetRegisterClass RC)
static

Get the type associated with the given register class.

Definition at line 149 of file WebAssemblyExplicitLocals.cpp.

References llvm::MVT::ExceptRef, llvm::MVT::f32, llvm::MVT::f64, llvm::MVT::i32, llvm::MVT::i64, and llvm_unreachable.

Referenced by FindStartOfTree().

Variable Documentation

◆ DisableWebAssemblyExplicitLocals

cl::opt<bool> DisableWebAssemblyExplicitLocals("disable-wasm-explicit-locals", cl::ReallyHidden, cl::desc("WebAssembly: Disable emission of get_local/set_local."), cl::init(false))
static

Referenced by FindStartOfTree().