#include "MCTargetDesc/PPCInstPrinter.h"
#include "MCTargetDesc/PPCMCExpr.h"
#include "MCTargetDesc/PPCMCTargetDesc.h"
#include "MCTargetDesc/PPCPredicates.h"
#include "PPC.h"
#include "PPCInstrInfo.h"
#include "PPCMachineFunctionInfo.h"
#include "PPCSubtarget.h"
#include "PPCTargetMachine.h"
#include "PPCTargetStreamer.h"
#include "TargetInfo/PowerPCTargetInfo.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Module.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstBuilder.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionXCOFF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolELF.h"
#include "llvm/MC/MCSymbolXCOFF.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <memory>
#include <new>
usingnamespacellvm;
usingnamespacellvm::XCOFF;
#define DEBUG_TYPE …
STATISTIC(NumTOCEntries, "Number of Total TOC Entries Emitted.");
STATISTIC(NumTOCConstPool, "Number of Constant Pool TOC Entries.");
STATISTIC(NumTOCGlobalInternal,
"Number of Internal Linkage Global TOC Entries.");
STATISTIC(NumTOCGlobalExternal,
"Number of External Linkage Global TOC Entries.");
STATISTIC(NumTOCJumpTable, "Number of Jump Table TOC Entries.");
STATISTIC(NumTOCThreadLocal, "Number of Thread Local TOC Entries.");
STATISTIC(NumTOCBlockAddress, "Number of Block Address TOC Entries.");
STATISTIC(NumTOCEHBlock, "Number of EH Block TOC Entries.");
static cl::opt<bool> EnableSSPCanaryBitInTB(
"aix-ssp-tb-bit", cl::init(false),
cl::desc("Enable Passing SSP Canary info in Trackback on AIX"), cl::Hidden);
namespace llvm {
template <>
struct DenseMapInfo<std::pair<const MCSymbol *, MCSymbolRefExpr::VariantKind>> { … };
}
namespace {
enum { … };
class PPCAsmPrinter : public AsmPrinter { … };
class PPCLinuxAsmPrinter : public PPCAsmPrinter { … };
class PPCAIXAsmPrinter : public PPCAsmPrinter { … };
}
void PPCAsmPrinter::PrintSymbolOperand(const MachineOperand &MO,
raw_ostream &O) { … }
void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
raw_ostream &O) { … }
bool PPCAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
const char *ExtraCode, raw_ostream &O) { … }
bool PPCAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
const char *ExtraCode,
raw_ostream &O) { … }
static void collectTOCStats(PPCAsmPrinter::TOCEntryType Type) { … }
static CodeModel::Model getCodeModel(const PPCSubtarget &S,
const TargetMachine &TM,
const MachineOperand &MO) { … }
static void setOptionalCodeModel(MCSymbolXCOFF *XSym, CodeModel::Model CM) { … }
MCSymbol *
PPCAsmPrinter::lookUpOrCreateTOCEntry(const MCSymbol *Sym, TOCEntryType Type,
MCSymbolRefExpr::VariantKind Kind) { … }
void PPCAsmPrinter::LowerSTACKMAP(StackMaps &SM, const MachineInstr &MI) { … }
void PPCAsmPrinter::LowerPATCHPOINT(StackMaps &SM, const MachineInstr &MI) { … }
static MCSymbol *createMCSymbolForTlsGetAddr(MCContext &Ctx, unsigned MIOpc) { … }
void PPCAsmPrinter::EmitAIXTlsCallHelper(const MachineInstr *MI) { … }
void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI,
MCSymbolRefExpr::VariantKind VK) { … }
static MCSymbol *getMCSymbolForTOCPseudoMO(const MachineOperand &MO,
AsmPrinter &AP) { … }
static PPCAsmPrinter::TOCEntryType
getTOCEntryTypeForMO(const MachineOperand &MO) { … }
void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) { … }
const MCExpr *
PPCAsmPrinter::getAdjustedFasterLocalExpr(const MachineOperand &MO,
int64_t Offset) { … }
void PPCLinuxAsmPrinter::emitGNUAttributes(Module &M) { … }
void PPCLinuxAsmPrinter::emitInstruction(const MachineInstr *MI) { … }
void PPCLinuxAsmPrinter::emitStartOfAsmFile(Module &M) { … }
void PPCLinuxAsmPrinter::emitFunctionEntryLabel() { … }
void PPCLinuxAsmPrinter::emitEndOfAsmFile(Module &M) { … }
void PPCLinuxAsmPrinter::emitFunctionBodyStart() { … }
void PPCLinuxAsmPrinter::emitFunctionBodyEnd() { … }
void PPCAIXAsmPrinter::emitLinkage(const GlobalValue *GV,
MCSymbol *GVSym) const { … }
void PPCAIXAsmPrinter::SetupMachineFunction(MachineFunction &MF) { … }
uint16_t PPCAIXAsmPrinter::getNumberOfVRSaved() { … }
void PPCAIXAsmPrinter::emitFunctionBodyEnd() { … }
void PPCAIXAsmPrinter::emitTracebackTable() { … }
static bool isSpecialLLVMGlobalArrayToSkip(const GlobalVariable *GV) { … }
static bool isSpecialLLVMGlobalArrayForStaticInit(const GlobalVariable *GV) { … }
uint64_t PPCAIXAsmPrinter::getAliasOffset(const Constant *C) { … }
static void tocDataChecks(unsigned PointerSize, const GlobalVariable *GV) { … }
void PPCAIXAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) { … }
void PPCAIXAsmPrinter::emitGlobalVariableHelper(const GlobalVariable *GV) { … }
void PPCAIXAsmPrinter::emitFunctionDescriptor() { … }
void PPCAIXAsmPrinter::emitFunctionEntryLabel() { … }
void PPCAIXAsmPrinter::emitPGORefs(Module &M) { … }
void PPCAIXAsmPrinter::emitEndOfAsmFile(Module &M) { … }
bool PPCAIXAsmPrinter::doInitialization(Module &M) { … }
void PPCAIXAsmPrinter::emitInstruction(const MachineInstr *MI) { … }
bool PPCAIXAsmPrinter::doFinalization(Module &M) { … }
static unsigned mapToSinitPriority(int P) { … }
static std::string convertToSinitPriority(int Priority) { … }
void PPCAIXAsmPrinter::emitXXStructorList(const DataLayout &DL,
const Constant *List, bool IsCtor) { … }
void PPCAIXAsmPrinter::emitTTypeReference(const GlobalValue *GV,
unsigned Encoding) { … }
static AsmPrinter *
createPPCAsmPrinterPass(TargetMachine &tm,
std::unique_ptr<MCStreamer> &&Streamer) { … }
void PPCAIXAsmPrinter::emitModuleCommandLines(Module &M) { … }
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmPrinter() { … }