#include "WebAssemblyTargetMachine.h"
#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "TargetInfo/WebAssemblyTargetInfo.h"
#include "WebAssembly.h"
#include "WebAssemblyISelLowering.h"
#include "WebAssemblyMachineFunctionInfo.h"
#include "WebAssemblyTargetObjectFile.h"
#include "WebAssemblyTargetTransformInfo.h"
#include "WebAssemblyUtilities.h"
#include "llvm/CodeGen/MIRParser/MIParser.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/RegAllocRegistry.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/Function.h"
#include "llvm/InitializePasses.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/LowerAtomicPass.h"
#include "llvm/Transforms/Utils.h"
#include <optional>
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::opt<bool> WasmDisableExplicitLocals(
"wasm-disable-explicit-locals", cl::Hidden,
cl::desc("WebAssembly: output implicit locals in"
" instruction output for test purposes only."),
cl::init(false));
static cl::opt<bool> WasmDisableFixIrreducibleControlFlowPass(
"wasm-disable-fix-irreducible-control-flow-pass", cl::Hidden,
cl::desc("webassembly: disables the fix "
" irreducible control flow optimization pass"),
cl::init(false));
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() { … }
static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM,
const Triple &TT) { … }
WebAssemblyTargetMachine::WebAssemblyTargetMachine(
const Target &T, const Triple &TT, StringRef CPU, StringRef FS,
const TargetOptions &Options, std::optional<Reloc::Model> RM,
std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, bool JIT)
: … { … }
WebAssemblyTargetMachine::~WebAssemblyTargetMachine() = default;
const WebAssemblySubtarget *WebAssemblyTargetMachine::getSubtargetImpl() const { … }
const WebAssemblySubtarget *
WebAssemblyTargetMachine::getSubtargetImpl(std::string CPU,
std::string FS) const { … }
const WebAssemblySubtarget *
WebAssemblyTargetMachine::getSubtargetImpl(const Function &F) const { … }
namespace {
class CoalesceFeaturesAndStripAtomics final : public ModulePass { … };
char CoalesceFeaturesAndStripAtomics::ID = …;
class WebAssemblyPassConfig final : public TargetPassConfig { … };
}
MachineFunctionInfo *WebAssemblyTargetMachine::createMachineFunctionInfo(
BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const { … }
TargetTransformInfo
WebAssemblyTargetMachine::getTargetTransformInfo(const Function &F) const { … }
TargetPassConfig *
WebAssemblyTargetMachine::createPassConfig(PassManagerBase &PM) { … }
FunctionPass *WebAssemblyPassConfig::createTargetRegisterAllocator(bool) { … }
WasmEnableEH;
WasmEnableEmEH;
WasmEnableEmSjLj;
WasmEnableExnref;
WasmEnableSjLj;
static void basicCheckForEHAndSjLj(TargetMachine *TM) { … }
void WebAssemblyPassConfig::addIRPasses() { … }
void WebAssemblyPassConfig::addISelPrepare() { … }
bool WebAssemblyPassConfig::addInstSelector() { … }
void WebAssemblyPassConfig::addOptimizedRegAlloc() { … }
void WebAssemblyPassConfig::addPostRegAlloc() { … }
void WebAssemblyPassConfig::addPreEmitPass() { … }
bool WebAssemblyPassConfig::addPreISel() { … }
yaml::MachineFunctionInfo *
WebAssemblyTargetMachine::createDefaultFuncInfoYAML() const { … }
yaml::MachineFunctionInfo *WebAssemblyTargetMachine::convertFuncInfoToYAML(
const MachineFunction &MF) const { … }
bool WebAssemblyTargetMachine::parseMachineFunctionInfo(
const yaml::MachineFunctionInfo &MFI, PerFunctionMIParsingState &PFS,
SMDiagnostic &Error, SMRange &SourceRange) const { … }