WebAssemblyUtilities.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //===-- WebAssemblyUtilities - WebAssembly Utility Functions ---*- C++ -*-====//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. ///
  9. /// \file
  10. /// This file contains the declaration of the WebAssembly-specific
  11. /// utility functions.
  12. ///
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WEBASSEMBLYUTILITIES_H
  15. #define LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WEBASSEMBLYUTILITIES_H
  16. #include "llvm/Support/CommandLine.h"
  17. namespace llvm {
  18. class MachineBasicBlock;
  19. class MachineInstr;
  20. class MachineOperand;
  21. class MCContext;
  22. class MCSymbolWasm;
  23. class TargetRegisterClass;
  24. class WebAssemblyFunctionInfo;
  25. class WebAssemblySubtarget;
  26. namespace WebAssembly {
  27. bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI);
  28. bool mayThrow(const MachineInstr &MI);
  29. // Exception handling / setjmp-longjmp handling command-line options
  30. extern cl::opt<bool> WasmEnableEmEH; // asm.js-style EH
  31. extern cl::opt<bool> WasmEnableEmSjLj; // asm.js-style SjLJ
  32. extern cl::opt<bool> WasmEnableEH; // EH using Wasm EH instructions
  33. extern cl::opt<bool> WasmEnableSjLj; // SjLj using Wasm EH instructions
  34. // Exception-related function names
  35. extern const char *const ClangCallTerminateFn;
  36. extern const char *const CxaBeginCatchFn;
  37. extern const char *const CxaRethrowFn;
  38. extern const char *const StdTerminateFn;
  39. extern const char *const PersonalityWrapperFn;
  40. /// Returns the operand number of a callee, assuming the argument is a call
  41. /// instruction.
  42. const MachineOperand &getCalleeOp(const MachineInstr &MI);
  43. /// Returns the __indirect_function_table, for use in call_indirect and in
  44. /// function bitcasts.
  45. MCSymbolWasm *
  46. getOrCreateFunctionTableSymbol(MCContext &Ctx,
  47. const WebAssemblySubtarget *Subtarget);
  48. /// Returns the __funcref_call_table, for use in funcref calls when lowered to
  49. /// table.set + call_indirect.
  50. MCSymbolWasm *
  51. getOrCreateFuncrefCallTableSymbol(MCContext &Ctx,
  52. const WebAssemblySubtarget *Subtarget);
  53. /// Find a catch instruction from an EH pad. Returns null if no catch
  54. /// instruction found or the catch is in an invalid location.
  55. MachineInstr *findCatch(MachineBasicBlock *EHPad);
  56. /// Returns the appropriate copy opcode for the given register class.
  57. unsigned getCopyOpcodeForRegClass(const TargetRegisterClass *RC);
  58. } // end namespace WebAssembly
  59. } // end namespace llvm
  60. #endif