27#define DEBUG_TYPE "wasm-set-p2align-operands"
36 return "WebAssembly Set p2align Operands";
50char WebAssemblySetP2AlignOperandsLegacy::ID = 0;
52 "Set the p2align operands for WebAssembly loads and stores",
56 return new WebAssemblySetP2AlignOperandsLegacy();
60 assert(
MI.getOperand(OperandNo).getImm() == 0 &&
61 "ISel should set p2align operands to 0");
63 "Load and store instructions have exactly one mem operand");
64 assert((*
MI.memoperands_begin())->getSize() ==
66 "Default p2align value should be natural");
67 assert(
MI.getDesc().operands()[OperandNo].OperandType ==
69 "Load and store instructions should have a p2align operand");
73 P2Align = std::min(P2Align,
76 MI.getOperand(OperandNo).setImm(P2Align);
81 dbgs() <<
"********** Set p2align Operands **********\n"
82 <<
"********** Function: " << MF.
getName() <<
'\n';
87 for (
auto &
MBB : MF) {
88 for (
auto &
MI :
MBB) {
89 int16_t P2AlignOpNum = WebAssembly::getNamedOperandIdx(
90 MI.getOpcode(), WebAssembly::OpName::p2align);
91 if (P2AlignOpNum != -1) {
101bool WebAssemblySetP2AlignOperandsLegacy::runOnMachineFunction(
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file contains the WebAssembly implementation of the TargetInstrInfo class.
This file provides WebAssembly-specific target descriptions.
static void rewriteP2Align(MachineInstr &MI, unsigned OperandNo)
static bool setP2AlignOperands(MachineFunction &MF)
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
Represent the analysis usage information of a pass.
AnalysisUsage & addPreservedID(const void *ID)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this 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.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
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.
Represent a constant reference to a string, i.e.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Pass manager infrastructure for declaring and invalidating analyses.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
unsigned GetDefaultP2Align(unsigned Opc)
@ OPERAND_P2ALIGN
p2align immediate for load and store address alignment.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
FunctionPass * createWebAssemblySetP2AlignOperandsLegacyPass()
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.
unsigned Log2(Align A)
Returns the log2 of the alignment.