#include "BPFTargetMachine.h"
#include "BPF.h"
#include "BPFTargetTransformInfo.h"
#include "MCTargetDesc/BPFMCAsmInfo.h"
#include "TargetInfo/BPFTargetInfo.h"
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
#include "llvm/CodeGen/GlobalISel/Legalizer.h"
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/PassManager.h"
#include "llvm/InitializePasses.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/SimplifyCFG.h"
#include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
#include <optional>
usingnamespacellvm;
static cl::
opt<bool> DisableMIPeephole("disable-bpf-peephole", cl::Hidden,
cl::desc("Disable machine peepholes for BPF"));
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFTarget() { … }
static std::string computeDataLayout(const Triple &TT) { … }
static Reloc::Model getEffectiveRelocModel(std::optional<Reloc::Model> RM) { … }
BPFTargetMachine::BPFTargetMachine(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)
: … { … }
namespace {
class BPFPassConfig : public TargetPassConfig { … };
}
TargetPassConfig *BPFTargetMachine::createPassConfig(PassManagerBase &PM) { … }
static Expected<bool> parseBPFPreserveStaticOffsetOptions(StringRef Params) { … }
void BPFTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { … }
void BPFPassConfig::addIRPasses() { … }
TargetTransformInfo
BPFTargetMachine::getTargetTransformInfo(const Function &F) const { … }
bool BPFPassConfig::addInstSelector() { … }
void BPFPassConfig::addMachineSSAOptimization() { … }
void BPFPassConfig::addPreEmitPass() { … }
bool BPFPassConfig::addIRTranslator() { … }
bool BPFPassConfig::addLegalizeMachineIR() { … }
bool BPFPassConfig::addRegBankSelect() { … }
bool BPFPassConfig::addGlobalInstructionSelect() { … }