28 #define DEBUG_TYPE "wasm-lower-br_unless" 33 return "WebAssembly Lower br_unless";
51 "Lowers br_unless into inverted br_if",
false,
false)
54 return new WebAssemblyLowerBrUnless();
57 bool WebAssemblyLowerBrUnless::runOnMachineFunction(
MachineFunction &MF) {
59 "********** Function: " 66 for (
auto &MBB : MF) {
67 for (
auto MII = MBB.begin(); MII != MBB.end();) {
69 if (MI->
getOpcode() != WebAssembly::BR_UNLESS)
73 bool Inverted =
false;
76 if (MFI.isVRegStackified(Cond)) {
79 switch (Def->getOpcode()) {
80 using namespace WebAssembly;
82 Def->setDesc(TII.get(NE_I32));
86 Def->setDesc(TII.get(EQ_I32));
90 Def->setDesc(TII.get(LE_S_I32));
94 Def->setDesc(TII.get(LT_S_I32));
98 Def->setDesc(TII.get(GE_S_I32));
102 Def->setDesc(TII.get(GT_S_I32));
106 Def->setDesc(TII.get(LE_U_I32));
110 Def->setDesc(TII.get(LT_U_I32));
114 Def->setDesc(TII.get(GE_U_I32));
118 Def->setDesc(TII.get(GT_U_I32));
122 Def->setDesc(TII.get(NE_I64));
126 Def->setDesc(TII.get(EQ_I64));
130 Def->setDesc(TII.get(LE_S_I64));
134 Def->setDesc(TII.get(LT_S_I64));
138 Def->setDesc(TII.get(GE_S_I64));
142 Def->setDesc(TII.get(GT_S_I64));
146 Def->setDesc(TII.get(LE_U_I64));
150 Def->setDesc(TII.get(LT_U_I64));
154 Def->setDesc(TII.get(GE_U_I64));
158 Def->setDesc(TII.get(GT_U_I64));
162 Def->setDesc(TII.get(NE_F32));
166 Def->setDesc(TII.get(EQ_F32));
170 Def->setDesc(TII.get(NE_F64));
174 Def->setDesc(TII.get(EQ_F64));
179 Cond = Def->getOperand(1).getReg();
180 Def->eraseFromParent();
192 unsigned Tmp =
MRI.createVirtualRegister(&WebAssembly::I32RegClass);
195 MFI.stackifyVReg(Tmp);
FunctionPass * createWebAssemblyLowerBrUnless()
This class represents lattice values for constants.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
unsigned getReg() const
getReg - Returns the register number.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
This file provides WebAssembly-specific target descriptions.
Represent the analysis usage information of a pass.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
FunctionPass class - This class is used to implement most global optimizations.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Representation of each machine instruction.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
INITIALIZE_PASS(WebAssemblyLowerBrUnless, DEBUG_TYPE, "Lowers br_unless into inverted br_if", false, false) FunctionPass *llvm
This file declares WebAssembly-specific per-machine-function information.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
const MachineOperand & getOperand(unsigned i) const