LLVM  4.0.0
WebAssemblyUtilities.cpp
Go to the documentation of this file.
1 //===-- WebAssemblyUtilities.cpp - WebAssembly Utility Functions ----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file implements several utility functions for WebAssembly.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #include "WebAssemblyUtilities.h"
18 using namespace llvm;
19 
21  switch (MI.getOpcode()) {
22  case WebAssembly::ARGUMENT_I32:
23  case WebAssembly::ARGUMENT_I64:
24  case WebAssembly::ARGUMENT_F32:
25  case WebAssembly::ARGUMENT_F64:
26  case WebAssembly::ARGUMENT_v16i8:
27  case WebAssembly::ARGUMENT_v8i16:
28  case WebAssembly::ARGUMENT_v4i32:
29  case WebAssembly::ARGUMENT_v4f32:
30  return true;
31  default:
32  return false;
33  }
34 }
35 
37  switch (MI.getOpcode()) {
38  case WebAssembly::COPY_I32:
39  case WebAssembly::COPY_I64:
40  case WebAssembly::COPY_F32:
41  case WebAssembly::COPY_F64:
42  return true;
43  default:
44  return false;
45  }
46 }
47 
49  switch (MI.getOpcode()) {
50  case WebAssembly::TEE_I32:
51  case WebAssembly::TEE_I64:
52  case WebAssembly::TEE_F32:
53  case WebAssembly::TEE_F64:
54  return true;
55  default:
56  return false;
57  }
58 }
59 
60 /// Test whether MI is a child of some other node in an expression tree.
62  const WebAssemblyFunctionInfo &MFI) {
63  if (MI.getNumOperands() == 0)
64  return false;
65  const MachineOperand &MO = MI.getOperand(0);
66  if (!MO.isReg() || MO.isImplicit() || !MO.isDef())
67  return false;
68  unsigned Reg = MO.getReg();
70  MFI.isVRegStackified(Reg);
71 }
bool isImplicit() const
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool isVRegStackified(unsigned VReg) const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Reg
All possible values of the reg field in the ModR/M byte.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Definition: MachineInstr.h:277
bool isCopy(const MachineInstr &MI)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:273
This file contains the declaration of the WebAssembly-specific utility functions. ...
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:279
bool isTee(const MachineInstr &MI)
bool isArgument(const MachineInstr &MI)
MachineOperand class - Representation of each machine instruction operand.
Representation of each machine instruction.
Definition: MachineInstr.h:52
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
This file declares WebAssembly-specific per-machine-function information.
unsigned getReg() const
getReg - Returns the register number.
IRTranslator LLVM IR MI
bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI)
Test whether MI is a child of some other node in an expression tree.