#include "AArch64.h"
#include "AArch64MCInstLower.h"
#include "AArch64MachineFunctionInfo.h"
#include "AArch64RegisterInfo.h"
#include "AArch64Subtarget.h"
#include "AArch64TargetObjectFile.h"
#include "MCTargetDesc/AArch64AddressingModes.h"
#include "MCTargetDesc/AArch64InstPrinter.h"
#include "MCTargetDesc/AArch64MCExpr.h"
#include "MCTargetDesc/AArch64MCTargetDesc.h"
#include "MCTargetDesc/AArch64TargetStreamer.h"
#include "TargetInfo/AArch64TargetInfo.h"
#include "Utils/AArch64BaseInfo.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/FaultMaps.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/StackMaps.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Module.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstBuilder.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <map>
#include <memory>
usingnamespacellvm;
enum PtrauthCheckMode { … };
static cl::opt<PtrauthCheckMode> PtrauthAuthChecks(
"aarch64-ptrauth-auth-checks", cl::Hidden,
cl::values(clEnumValN(Unchecked, "none", "don't test for failure"),
clEnumValN(Poison, "poison", "poison on failure"),
clEnumValN(Trap, "trap", "trap on failure")),
cl::desc("Check pointer authentication auth/resign failures"),
cl::init(Default));
#define DEBUG_TYPE …
namespace {
class AArch64AsmPrinter : public AsmPrinter { … };
}
void AArch64AsmPrinter::emitStartOfAsmFile(Module &M) { … }
void AArch64AsmPrinter::emitFunctionHeaderComment() { … }
void AArch64AsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI)
{ … }
void AArch64AsmPrinter::LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI) { … }
void AArch64AsmPrinter::emitSled(const MachineInstr &MI, SledKind Kind) { … }
void AArch64AsmPrinter::LowerPATCHABLE_EVENT_CALL(const MachineInstr &MI,
bool Typed) { … }
void AArch64AsmPrinter::LowerKCFI_CHECK(const MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerHWASAN_CHECK_MEMACCESS(const MachineInstr &MI) { … }
void AArch64AsmPrinter::emitHwasanMemaccessSymbols(Module &M) { … }
static void emitAuthenticatedPointer(MCStreamer &OutStreamer,
MCSymbol *StubLabel,
const MCExpr *StubAuthPtrRef) { … }
void AArch64AsmPrinter::emitEndOfAsmFile(Module &M) { … }
void AArch64AsmPrinter::emitLOHs() { … }
void AArch64AsmPrinter::emitFunctionBodyEnd() { … }
MCSymbol *AArch64AsmPrinter::GetCPISymbol(unsigned CPID) const { … }
void AArch64AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNum,
raw_ostream &O) { … }
bool AArch64AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode,
raw_ostream &O) { … }
bool AArch64AsmPrinter::printAsmRegInClass(const MachineOperand &MO,
const TargetRegisterClass *RC,
unsigned AltName, raw_ostream &O) { … }
bool AArch64AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
const char *ExtraCode, raw_ostream &O) { … }
bool AArch64AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
unsigned OpNum,
const char *ExtraCode,
raw_ostream &O) { … }
void AArch64AsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
raw_ostream &OS) { … }
void AArch64AsmPrinter::emitJumpTableInfo() { … }
std::tuple<const MCSymbol *, uint64_t, const MCSymbol *,
codeview::JumpTableEntrySize>
AArch64AsmPrinter::getCodeViewJumpTableInfo(int JTI,
const MachineInstr *BranchInstr,
const MCSymbol *BranchLabel) const { … }
void AArch64AsmPrinter::emitFunctionEntryLabel() { … }
void AArch64AsmPrinter::emitXXStructor(const DataLayout &DL,
const Constant *CV) { … }
void AArch64AsmPrinter::emitGlobalAlias(const Module &M,
const GlobalAlias &GA) { … }
void AArch64AsmPrinter::LowerJumpTableDest(llvm::MCStreamer &OutStreamer,
const llvm::MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerHardenedBRJumpTable(const MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerMOPS(llvm::MCStreamer &OutStreamer,
const llvm::MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerSTACKMAP(MCStreamer &OutStreamer, StackMaps &SM,
const MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerPATCHPOINT(MCStreamer &OutStreamer, StackMaps &SM,
const MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerSTATEPOINT(MCStreamer &OutStreamer, StackMaps &SM,
const MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerFAULTING_OP(const MachineInstr &FaultingMI) { … }
void AArch64AsmPrinter::emitFMov0(const MachineInstr &MI) { … }
unsigned AArch64AsmPrinter::emitPtrauthDiscriminator(uint16_t Disc,
unsigned AddrDisc,
unsigned &InstsEmitted) { … }
void AArch64AsmPrinter::emitPtrauthAuthResign(const MachineInstr *MI) { … }
void AArch64AsmPrinter::emitPtrauthBranch(const MachineInstr *MI) { … }
const MCExpr *
AArch64AsmPrinter::lowerConstantPtrAuth(const ConstantPtrAuth &CPA) { … }
void AArch64AsmPrinter::LowerLOADauthptrstatic(const MachineInstr &MI) { … }
void AArch64AsmPrinter::LowerMOVaddrPAC(const MachineInstr &MI) { … }
const MCExpr *
AArch64AsmPrinter::lowerBlockAddressConstant(const BlockAddress &BA) { … }
#include "AArch64GenMCPseudoLowering.inc"
void AArch64AsmPrinter::emitInstruction(const MachineInstr *MI) { … }
void AArch64AsmPrinter::emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI,
MCSymbol *LazyPointer) { … }
void AArch64AsmPrinter::emitMachOIFuncStubHelperBody(Module &M,
const GlobalIFunc &GI,
MCSymbol *LazyPointer) { … }
const MCExpr *AArch64AsmPrinter::lowerConstant(const Constant *CV) { … }
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64AsmPrinter() { … }