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

1

2

3

4

5

6

7

8

9

10

11

12

13

20using namespace llvm;

21

22

27 "_Unwind_Wasm_CallPersonality";

28

29

32 if (MI.getNumOperands() == 0)

33 return false;

36 return false;

39}

40

42 switch (MI.getOpcode()) {

43 case WebAssembly::THROW:

44 case WebAssembly::THROW_S:

45 case WebAssembly::THROW_REF:

46 case WebAssembly::THROW_REF_S:

47 case WebAssembly::RETHROW:

48 case WebAssembly::RETHROW_S:

49 return true;

50 }

52 return true;

53 if (MI.isCall())

54 return false;

55

58

60

61

62

63

64

66 if (strcmp(Name, "memcpy") == 0 || strcmp(Name, "memmove") == 0 ||

67 strcmp(Name, "memset") == 0)

68 return false;

69 return true;

70 }

71

73 if (F)

74 return true;

75 if (F->doesNotThrow())

76 return false;

77

80 return false;

81

82

83

84 return true;

85}

86

88 switch (MI.getOpcode()) {

89 case WebAssembly::CALL:

90 case WebAssembly::CALL_S:

91 case WebAssembly::RET_CALL:

92 case WebAssembly::RET_CALL_S:

93 return MI.getOperand(MI.getNumExplicitDefs());

94 case WebAssembly::CALL_INDIRECT:

95 case WebAssembly::CALL_INDIRECT_S:

96 case WebAssembly::RET_CALL_INDIRECT:

97 case WebAssembly::RET_CALL_INDIRECT_S:

98 return MI.getOperand(MI.getNumExplicitOperands() - 1);

99 default:

101 }

102}

103

106 StringRef Name = "__indirect_function_table";

107 auto *Sym = static_cast<MCSymbolWasm *>(Ctx.lookupSymbol(Name));

108 if (Sym) {

109 if (!Sym->isFunctionTable())

110 Ctx.reportError(SMLoc(), "symbol is not a wasm funcref table");

111 } else {

113 Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name));

115

116 }

117

120 return Sym;

121}

122

125 StringRef Name = "__funcref_call_table";

126 auto *Sym = static_cast<MCSymbolWasm *>(Ctx.lookupSymbol(Name));

127 if (Sym) {

128 if (!Sym->isFunctionTable())

129 Ctx.reportError(SMLoc(), "symbol is not a wasm funcref table");

130 } else {

131 Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name));

132

133

134

136

140 Sym->setTableType(TableType);

141 }

142

145 return Sym;

146}

147

148

151 auto Pos = EHPad->begin();

152

153

154 while (Pos != EHPad->end() &&

155 (Pos->isLabel() || Pos->isDebugInstr() || isMarker(Pos->getOpcode())))

156 Pos++;

158 return &*Pos;

159 return nullptr;

160}

161

163 assert(RC != nullptr);

164 switch (RC->getID()) {

165 case WebAssembly::I32RegClassID:

166 return WebAssembly::COPY_I32;

167 case WebAssembly::I64RegClassID:

168 return WebAssembly::COPY_I64;

169 case WebAssembly::F32RegClassID:

170 return WebAssembly::COPY_F32;

171 case WebAssembly::F64RegClassID:

172 return WebAssembly::COPY_F64;

173 case WebAssembly::V128RegClassID:

174 return WebAssembly::COPY_V128;

175 case WebAssembly::FUNCREFRegClassID:

176 return WebAssembly::COPY_FUNCREF;

177 case WebAssembly::EXTERNREFRegClassID:

178 return WebAssembly::COPY_EXTERNREF;

179 case WebAssembly::EXNREFRegClassID:

180 return WebAssembly::COPY_EXNREF;

181 default:

183 }

184}

185

190 return Subtarget->hasMultivalue() && TM.usesMultivalueABI();

191}

192

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

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

This file declares the WebAssembly-specific subclass of TargetMachine.

This file contains the declaration of the WebAssembly-specific utility functions.

Context object for machine code objects.

void setFunctionTable(bool is64)

void setWeak(bool isWeak)

void setOmitFromLinkingSection()

bool isEHPad() const

Returns true if the block is a landing pad.

Representation of each machine instruction.

MachineOperand class - Representation of each machine instruction operand.

const GlobalValue * getGlobal() const

bool isReg() const

isReg - Tests if this is a MO_Register operand.

bool isSymbol() const

isSymbol - Tests if this is a MO_ExternalSymbol operand.

bool isGlobal() const

isGlobal - Tests if this is a MO_GlobalAddress operand.

const char * getSymbolName() const

Register getReg() const

getReg - Returns the register number.

Wrapper class representing virtual and physical registers.

constexpr bool isVirtual() const

Return true if the specified register number is in the virtual register namespace.

Represents a location in source code.

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

unsigned getID() const

Return the register class ID number.

LLVM_ABI bool isArch64Bit() const

Test whether the architecture is 64-bit.

This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...

bool isVRegStackified(Register VReg) const

bool hasCallIndirectOverlong() const

const Triple & getTargetTriple() const

const WebAssemblyTargetLowering * getTargetLowering() const override

bool hasMultivalue() const

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

const char *const StdTerminateFn

Definition WebAssemblyUtilities.cpp:25

const char *const CxaBeginCatchFn

Definition WebAssemblyUtilities.cpp:23

bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI)

Test whether MI is a child of some other node in an expression tree.

Definition WebAssemblyUtilities.cpp:30

bool isCallIndirect(unsigned Opc)

bool canLowerMultivalueReturn(const WebAssemblySubtarget *Subtarget)

Returns true if multivalue returns of a function can be lowered directly, i.e., not indirectly via a ...

Definition WebAssemblyUtilities.cpp:186

const char *const CxaRethrowFn

Definition WebAssemblyUtilities.cpp:24

MCSymbolWasm * getOrCreateFunctionTableSymbol(MCContext &Ctx, const WebAssemblySubtarget *Subtarget)

Returns the __indirect_function_table, for use in call_indirect and in function bitcasts.

Definition WebAssemblyUtilities.cpp:104

bool isMarker(unsigned Opc)

unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC)

Returns the appropriate copy opcode for the given register class.

Definition WebAssemblyUtilities.cpp:162

const MachineOperand & getCalleeOp(const MachineInstr &MI)

Returns the operand number of a callee, assuming the argument is a call instruction.

Definition WebAssemblyUtilities.cpp:87

MachineInstr * findCatch(MachineBasicBlock *EHPad)

Find a catch instruction from an EH pad.

Definition WebAssemblyUtilities.cpp:149

bool isCatch(unsigned Opc)

MCSymbolWasm * getOrCreateFuncrefCallTableSymbol(MCContext &Ctx, const WebAssemblySubtarget *Subtarget)

Returns the __funcref_call_table, for use in funcref calls when lowered to table.set + call_indirect.

Definition WebAssemblyUtilities.cpp:123

const char *const PersonalityWrapperFn

Definition WebAssemblyUtilities.cpp:26

bool canLowerReturn(size_t ResultSize, const WebAssemblySubtarget *Subtarget)

Returns true if the function's return value(s) can be lowered directly, i.e., not indirectly via a po...

Definition WebAssemblyUtilities.cpp:193

bool mayThrow(const MachineInstr &MI)

Definition WebAssemblyUtilities.cpp:41

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.