LLVM  14.0.0git
Macros | Functions
WebAssemblyExplicitLocals.cpp File Reference
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "Utils/WebAssemblyUtilities.h"
#include "WebAssembly.h"
#include "WebAssemblyDebugValueManager.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblySubtarget.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 void checkFrameBase (WebAssemblyFunctionInfo &MFI, unsigned Local, unsigned Reg)
 
static unsigned getLocalId (DenseMap< unsigned, unsigned > &Reg2Local, WebAssemblyFunctionInfo &MFI, 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 getLocalGetOpcode (const TargetRegisterClass *RC)
 Get the appropriate local.get opcode for the given register class. More...
 
static unsigned getLocalSetOpcode (const TargetRegisterClass *RC)
 Get the appropriate local.set opcode for the given register class. More...
 
static unsigned getLocalTeeOpcode (const TargetRegisterClass *RC)
 Get the appropriate local.tee 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, const WebAssemblyFunctionInfo &MFI)
 Given a MachineOperand of a stackified vreg, return the instruction at the start of the expression tree. More...
 

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 local.get and local.set 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

◆ checkFrameBase()

static void checkFrameBase ( WebAssemblyFunctionInfo MFI,
unsigned  Local,
unsigned  Reg 
)
static

◆ findStartOfTree()

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

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

Definition at line 184 of file WebAssemblyExplicitLocals.cpp.

References assert(), llvm::tgtok::Def, llvm::MachineOperand::getReg(), llvm::MachineRegisterInfo::getVRegDef(), llvm::WebAssemblyFunctionInfo::isVRegStackified(), MRI, and Reg.

◆ getDropOpcode()

static unsigned getDropOpcode ( const TargetRegisterClass RC)
static

Get the appropriate drop opcode for the given register class.

Definition at line 88 of file WebAssemblyExplicitLocals.cpp.

References llvm_unreachable.

◆ getLocalGetOpcode()

static unsigned getLocalGetOpcode ( const TargetRegisterClass RC)
static

Get the appropriate local.get opcode for the given register class.

Definition at line 107 of file WebAssemblyExplicitLocals.cpp.

References llvm_unreachable.

◆ getLocalId()

static unsigned getLocalId ( DenseMap< unsigned, unsigned > &  Reg2Local,
WebAssemblyFunctionInfo MFI,
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 76 of file WebAssemblyExplicitLocals.cpp.

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

◆ getLocalSetOpcode()

static unsigned getLocalSetOpcode ( const TargetRegisterClass RC)
static

Get the appropriate local.set opcode for the given register class.

Definition at line 126 of file WebAssemblyExplicitLocals.cpp.

References llvm_unreachable.

◆ getLocalTeeOpcode()

static unsigned getLocalTeeOpcode ( const TargetRegisterClass RC)
static

Get the appropriate local.tee opcode for the given register class.

Definition at line 145 of file WebAssemblyExplicitLocals.cpp.

References llvm_unreachable.

◆ INITIALIZE_PASS()

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

Definition at line 55 of file WebAssemblyExplicitLocals.cpp.

◆ typeForRegClass()

static MVT typeForRegClass ( const TargetRegisterClass RC)
static

Get the type associated with the given register class.

Definition at line 164 of file WebAssemblyExplicitLocals.cpp.

References llvm::MVT::externref, llvm::MVT::f32, llvm::MVT::f64, llvm::MVT::funcref, llvm::MVT::i32, llvm::MVT::i64, llvm_unreachable, and llvm::MVT::v16i8.