#include "X86TargetMachine.h"
#include "MCTargetDesc/X86MCTargetDesc.h"
#include "TargetInfo/X86TargetInfo.h"
#include "X86.h"
#include "X86MachineFunctionInfo.h"
#include "X86MacroFusion.h"
#include "X86Subtarget.h"
#include "X86TargetObjectFile.h"
#include "X86TargetTransformInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/CodeGen/ExecutionDomainFix.h"
#include "llvm/CodeGen/GlobalISel/CSEInfo.h"
#include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
#include "llvm/CodeGen/GlobalISel/Legalizer.h"
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
#include "llvm/CodeGen/MIRParser/MIParser.h"
#include "llvm/CodeGen/MIRYamlMapping.h"
#include "llvm/CodeGen/MachineScheduler.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/RegAllocRegistry.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Pass.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/CFGuard.h"
#include <memory>
#include <optional>
#include <string>
usingnamespacellvm;
static cl::opt<bool> EnableMachineCombinerPass("x86-machine-combiner",
cl::desc("Enable the machine combiner pass"),
cl::init(true), cl::Hidden);
static cl::opt<bool>
EnableTileRAPass("x86-tile-ra",
cl::desc("Enable the tile register allocation pass"),
cl::init(true), cl::Hidden);
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86Target() { … }
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) { … }
static std::string computeDataLayout(const Triple &TT) { … }
static Reloc::Model getEffectiveRelocModel(const Triple &TT, bool JIT,
std::optional<Reloc::Model> RM) { … }
static CodeModel::Model
getEffectiveX86CodeModel(const Triple &TT, std::optional<CodeModel::Model> CM,
bool JIT) { … }
X86TargetMachine::X86TargetMachine(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)
: … { … }
X86TargetMachine::~X86TargetMachine() = default;
const X86Subtarget *
X86TargetMachine::getSubtargetImpl(const Function &F) const { … }
yaml::MachineFunctionInfo *X86TargetMachine::createDefaultFuncInfoYAML() const { … }
yaml::MachineFunctionInfo *
X86TargetMachine::convertFuncInfoToYAML(const MachineFunction &MF) const { … }
bool X86TargetMachine::parseMachineFunctionInfo(
const yaml::MachineFunctionInfo &MFI, PerFunctionMIParsingState &PFS,
SMDiagnostic &Error, SMRange &SourceRange) const { … }
bool X86TargetMachine::isNoopAddrSpaceCast(unsigned SrcAS,
unsigned DestAS) const { … }
TargetTransformInfo
X86TargetMachine::getTargetTransformInfo(const Function &F) const { … }
namespace {
class X86PassConfig : public TargetPassConfig { … };
class X86ExecutionDomainFix : public ExecutionDomainFix { … };
char X86ExecutionDomainFix::ID;
}
INITIALIZE_PASS_BEGIN(X86ExecutionDomainFix, "x86-execution-domain-fix",
"X86 Execution Domain Fix", false, false)
INITIALIZE_PASS_DEPENDENCY(ReachingDefAnalysis)
INITIALIZE_PASS_END(X86ExecutionDomainFix, "x86-execution-domain-fix",
"X86 Execution Domain Fix", false, false)
TargetPassConfig *X86TargetMachine::createPassConfig(PassManagerBase &PM) { … }
MachineFunctionInfo *X86TargetMachine::createMachineFunctionInfo(
BumpPtrAllocator &Allocator, const Function &F,
const TargetSubtargetInfo *STI) const { … }
void X86PassConfig::addIRPasses() { … }
bool X86PassConfig::addInstSelector() { … }
bool X86PassConfig::addIRTranslator() { … }
bool X86PassConfig::addLegalizeMachineIR() { … }
bool X86PassConfig::addRegBankSelect() { … }
bool X86PassConfig::addGlobalInstructionSelect() { … }
bool X86PassConfig::addILPOpts() { … }
bool X86PassConfig::addPreISel() { … }
void X86PassConfig::addPreRegAlloc() { … }
void X86PassConfig::addMachineSSAOptimization() { … }
void X86PassConfig::addPostRegAlloc() { … }
void X86PassConfig::addPreSched2() { … }
void X86PassConfig::addPreEmitPass() { … }
void X86PassConfig::addPreEmitPass2() { … }
bool X86PassConfig::addPostFastRegAllocRewrite() { … }
std::unique_ptr<CSEConfigBase> X86PassConfig::getCSEConfig() const { … }
static bool onlyAllocateTileRegisters(const TargetRegisterInfo &TRI,
const MachineRegisterInfo &MRI,
const Register Reg) { … }
bool X86PassConfig::addRegAssignAndRewriteOptimized() { … }