27#define DEBUG_TYPE "wasm-lower-br_unless"
32 return "WebAssembly Lower br_unless";
48char WebAssemblyLowerBrUnless::ID = 0;
50 "Lowers br_unless into inverted br_if",
false,
false)
53 return new WebAssemblyLowerBrUnless();
56bool WebAssemblyLowerBrUnless::runOnMachineFunction(
MachineFunction &MF) {
58 "********** Function: "
65 for (
auto &
MBB : MF) {
67 if (
MI.getOpcode() != WebAssembly::BR_UNLESS)
71 bool Inverted =
false;
74 if (MFI.isVRegStackified(
Cond)) {
77 switch (
Def->getOpcode()) {
78 using namespace WebAssembly;
80 Def->setDesc(
TII.get(NE_I32));
84 Def->setDesc(
TII.get(EQ_I32));
88 Def->setDesc(
TII.get(LE_S_I32));
92 Def->setDesc(
TII.get(LT_S_I32));
96 Def->setDesc(
TII.get(GE_S_I32));
100 Def->setDesc(
TII.get(GT_S_I32));
104 Def->setDesc(
TII.get(LE_U_I32));
108 Def->setDesc(
TII.get(LT_U_I32));
112 Def->setDesc(
TII.get(GE_U_I32));
116 Def->setDesc(
TII.get(GT_U_I32));
120 Def->setDesc(
TII.get(NE_I64));
124 Def->setDesc(
TII.get(EQ_I64));
128 Def->setDesc(
TII.get(LE_S_I64));
132 Def->setDesc(
TII.get(LT_S_I64));
136 Def->setDesc(
TII.get(GE_S_I64));
140 Def->setDesc(
TII.get(GT_S_I64));
144 Def->setDesc(
TII.get(LE_U_I64));
148 Def->setDesc(
TII.get(LT_U_I64));
152 Def->setDesc(
TII.get(GE_U_I64));
156 Def->setDesc(
TII.get(GT_U_I64));
160 Def->setDesc(
TII.get(NE_F32));
164 Def->setDesc(
TII.get(EQ_F32));
168 Def->setDesc(
TII.get(NE_F64));
172 Def->setDesc(
TII.get(EQ_F64));
177 Cond =
Def->getOperand(1).getReg();
178 Def->eraseFromParent();
190 Register Tmp =
MRI.createVirtualRegister(&WebAssembly::I32RegClass);
193 MFI.stackifyVReg(
MRI, Tmp);
202 .
add(
MI.getOperand(0))
unsigned const MachineRegisterInfo * MRI
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file provides WebAssembly-specific target descriptions.
This file declares WebAssembly-specific per-machine-function information.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
Represent the analysis usage information of a pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
NodeAddr< DefNode * > Def
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createWebAssemblyLowerBrUnless()