30#define DEBUG_TYPE "wasm-lower-br_unless"
35 return "WebAssembly Lower br_unless";
51char WebAssemblyLowerBrUnlessLegacy::ID = 0;
53 "Lowers br_unless into inverted br_if",
false,
false)
56 return new WebAssemblyLowerBrUnlessLegacy();
61 "********** Function: "
68 for (
auto &
MBB : MF) {
70 if (
MI.getOpcode() != WebAssembly::BR_UNLESS)
74 bool Inverted =
false;
77 if (MFI.isVRegStackified(
Cond)) {
80 switch (Def->getOpcode()) {
83 Def->setDesc(
TII.get(NE_I32));
87 Def->setDesc(
TII.get(EQ_I32));
91 Def->setDesc(
TII.get(LE_S_I32));
95 Def->setDesc(
TII.get(LT_S_I32));
99 Def->setDesc(
TII.get(GE_S_I32));
103 Def->setDesc(
TII.get(GT_S_I32));
107 Def->setDesc(
TII.get(LE_U_I32));
111 Def->setDesc(
TII.get(LT_U_I32));
115 Def->setDesc(
TII.get(GE_U_I32));
119 Def->setDesc(
TII.get(GT_U_I32));
123 Def->setDesc(
TII.get(NE_I64));
127 Def->setDesc(
TII.get(EQ_I64));
131 Def->setDesc(
TII.get(LE_S_I64));
135 Def->setDesc(
TII.get(LT_S_I64));
139 Def->setDesc(
TII.get(GE_S_I64));
143 Def->setDesc(
TII.get(GT_S_I64));
147 Def->setDesc(
TII.get(LE_U_I64));
151 Def->setDesc(
TII.get(LT_U_I64));
155 Def->setDesc(
TII.get(GE_U_I64));
159 Def->setDesc(
TII.get(GT_U_I64));
163 Def->setDesc(
TII.get(NE_F32));
167 Def->setDesc(
TII.get(EQ_F32));
171 Def->setDesc(
TII.get(NE_F64));
175 Def->setDesc(
TII.get(EQ_F64));
180 Cond = Def->getOperand(1).getReg();
181 Def->eraseFromParent();
193 Register Tmp = MRI.createVirtualRegister(&WebAssembly::I32RegClass);
196 MFI.stackifyVReg(MRI, Tmp);
205 .
add(
MI.getOperand(0))
214bool WebAssemblyLowerBrUnlessLegacy::runOnMachineFunction(
MachineFunction &MF) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
const SmallVectorImpl< MachineOperand > & Cond
static bool lowerBrUnless(MachineFunction &MF)
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.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
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.
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 & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
Representation of each machine instruction.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Wrapper class representing virtual and physical registers.
Represent a constant reference to a string, i.e.
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Pass manager infrastructure for declaring and invalidating analyses.
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...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createWebAssemblyLowerBrUnlessLegacyPass()