LLVM: lib/Target/WebAssembly/WebAssemblyMemIntrinsicResults.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

41using namespace llvm;

42

43#define DEBUG_TYPE "wasm-mem-intrinsic-results"

44

45namespace {

47public:

48 static char ID;

50

52 return "WebAssembly Memory Intrinsic Results";

53 }

54

66 }

67

69

70private:

71};

72}

73

74char WebAssemblyMemIntrinsicResults::ID = 0;

76 "Optimize memory intrinsic result values for WebAssembly",

77 false, false)

78

80 return new WebAssemblyMemIntrinsicResults();

81}

82

83

85 unsigned FromReg, unsigned ToReg,

89 bool Changed = false;

90

93

96

98

102

103

105 continue;

106

107

110 if (WhereVNI && WhereVNI != FromVNI)

111 continue;

112

113

115 if (ToVNI && ToVNI != FromVNI)

116 continue;

117

118 Changed = true;

119 LLVM_DEBUG(dbgs() << "Setting operand " << O << " in " << *Where << " from "

120 << MI << "\n");

121 O.setReg(ToReg);

122

123

124 if (!O.isUndef()) {

125 MI.getOperand(0).setIsDead(false);

126

128 }

129 }

130

131 if (Changed) {

132

134

135

137

138

143 }

144

145 return Changed;

146}

147

155 return false;

156

161 if (!CallReturnsInput)

162 return false;

163

166 return false;

167

168 Register FromReg = MI.getOperand(2).getReg();

169 Register ToReg = MI.getOperand(0).getReg();

170 if (MRI.getRegClass(FromReg) != MRI.getRegClass(ToReg))

171 report_fatal_error("Memory Intrinsic results: call to builtin function "

172 "with wrong signature, from/to mismatch");

174}

175

176bool WebAssemblyMemIntrinsicResults::runOnMachineFunction(MachineFunction &MF) {

178 dbgs() << "********** Memory Intrinsic Results **********\n"

179 << "********** Function: " << MF.getName() << '\n';

180 });

181

183 auto &MDT = getAnalysis().getDomTree();

186 const auto &LibInfo =

187 getAnalysis().getTLI(MF.getFunction());

188 auto &LIS = getAnalysis().getLIS();

189 bool Changed = false;

190

191

192 MRI.leaveSSA();

193

195 "MemIntrinsicResults expects liveness tracking");

196

197 for (auto &MBB : MF) {

199 for (auto &MI : MBB)

200 switch (MI.getOpcode()) {

201 default:

202 break;

203 case WebAssembly::CALL:

205 break;

206 }

207 }

208

209 return Changed;

210}

unsigned const MachineRegisterInfo * MRI

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This file provides WebAssembly-specific target descriptions.

This file declares WebAssembly-specific per-machine-function information.

static bool optimizeCall(MachineBasicBlock &MBB, MachineInstr &MI, const MachineRegisterInfo &MRI, MachineDominatorTree &MDT, LiveIntervals &LIS, const WebAssemblyTargetLowering &TLI, const TargetLibraryInfo &LibInfo)

static bool replaceDominatedUses(MachineBasicBlock &MBB, MachineInstr &MI, unsigned FromReg, unsigned ToReg, const MachineRegisterInfo &MRI, MachineDominatorTree &MDT, LiveIntervals &LIS)

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.

AnalysisUsage & addRequired()

AnalysisUsage & addPreserved()

Add the specified Pass class to the set of analyses preserved by this 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.

LiveInterval - This class represents the liveness of a register, or stack slot.

SlotIndex getInstructionIndex(const MachineInstr &Instr) const

Returns the base index of the given instruction.

LiveInterval & getInterval(Register Reg)

bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr * > *dead=nullptr)

After removing some uses of a register, shrink its live range to just the remaining uses.

void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs)

Extend the live range LR to reach all points in Indices.

bool liveAt(SlotIndex index) const

VNInfo * getVNInfoAt(SlotIndex Idx) const

getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.

const MachineFunction * getParent() const

Return the MachineFunction containing this basic block.

StringRef getName() const

Return the name of the corresponding LLVM basic block, or an empty string.

Analysis pass which computes a MachineDominatorTree.

DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...

bool dominates(const MachineInstr *A, const MachineInstr *B) const

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.

Function & getFunction()

Return the LLVM function that this machine code represents.

Representation of each machine instruction.

MachineOperand class - Representation of each machine instruction operand.

bool isSymbol() const

isSymbol - Tests if this is a MO_ExternalSymbol operand.

const char * getSymbolName() const

MachineRegisterInfo - Keep track of information for virtual and physical registers,...

virtual StringRef getPassName() const

getPassName - Return a nice clean name for a pass.

Wrapper class representing virtual and physical registers.

SlotIndex - An opaque wrapper around machine indexes.

SlotIndex getDeadSlot() const

Returns the dead def kill slot for the current instruction.

SlotIndex getRegSlot(bool EC=false) const

Returns the register use/def slot in the current instruction for a normal or early-clobber def.

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

Provides information about what library functions are available for the current target.

bool getLibFunc(StringRef funcName, LibFunc &F) const

Searches for a particular function name.

const char * getLibcallName(RTLIB::Libcall Call) const

Get the libcall routine name for the specified libcall.

VNInfo - Value Number Information.

const WebAssemblyRegisterInfo * getRegisterInfo() const override

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

This is an optimization pass for GlobalISel generic memory operations.

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...

FunctionPass * createWebAssemblyMemIntrinsicResults()

raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

void report_fatal_error(Error Err, bool gen_crash_diag=true)

Report a serious error, calling any installed error handler.