LLVM: lib/Target/AArch64/AArch64MCInstLower.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

33using namespace llvm;

35

37

40

45

47 unsigned TargetFlags) const {

48 const Triple &TheTriple = Printer.TM.getTargetTriple();

50 return Printer.getSymbolPreferLocal(*GV);

51

53 "Windows is the only supported COFF target");

54

55 bool IsIndirect =

57 if (!IsIndirect) {

58

59

60

61

64 return Printer.getSymbol(GV);

65

66 StringRef Name = Printer.getSymbol(GV)->getName();

67

69 "__os_arm64x_check_icall_cfg", "__os_arm64x_dispatch_call_no_redirect",

70 "__os_arm64x_check_icall"};

72 return Printer.getSymbol(GV);

73

74 if (std::optionalstd::string MangledName =

76 MCSymbol *MangledSym = Ctx.getOrCreateSymbol(MangledName.value());

77 if (cast<Function>(GV)->hasMetadata("arm64ec_hasguestexit")) {

78 Printer.OutStreamer->emitSymbolAttribute(Printer.getSymbol(GV),

80 Printer.OutStreamer->emitAssignment(

82 Printer.OutStreamer->emitSymbolAttribute(MangledSym, MCSA_WeakAntiDep);

83 Printer.OutStreamer->emitAssignment(

85 }

86

88 return MangledSym;

89 }

90

91 return Printer.getSymbol(GV);

92 }

93

95

100

101

102

103

104

105

106

107

108

109

110

111 Name = "__imp_";

112 Printer.TM.getNameWithPrefix(Name, GV,

113 Printer.getObjFileLowering().getMangler());

114 MCSymbol *ExtraSym = Ctx.getOrCreateSymbol(Name);

115 Printer.OutStreamer->emitSymbolAttribute(ExtraSym, MCSA_Global);

116

117 Name = "__imp_aux_";

119 Name = "__imp_";

121 Name = ".refptr.";

122 }

123 Printer.TM.getNameWithPrefix(Name, GV,

124 Printer.getObjFileLowering().getMangler());

125

126 MCSymbol *MCSym = Ctx.getOrCreateSymbol(Name);

127

133

134 if (!StubSym.getPointer())

136 }

137

138 return MCSym;

139}

140

143 return Printer.GetExternalSymbolSymbol(MO.getSymbolName());

144}

145

148

149

157 else

158 llvm_unreachable("Unexpected target flags with MO_GOT on GV operand");

165 else

166 llvm_unreachable("Unexpected target flags with MO_TLS on GV operand");

167 } else {

173 }

174

180}

181

185

197 } else {

199 Model = Printer.TM.getTLSModel(GV);

203 }

204 } else {

207 "unexpected external TLS symbol");

208

209

211 }

212 switch (Model) {

215 break;

218 break;

221 break;

223

224

225

226

231 break;

232 }

233 }

236 } else {

237

238

240 }

241

257

260

265

268}

269

273

280

283 } else {

285

291 }

292

301

302

303

304

310 }

311

316

319}

320

323 if (Printer.TM.getTargetTriple().isOSBinFormatMachO())

325 if (Printer.TM.getTargetTriple().isOSBinFormatCOFF())

327

328 assert(Printer.TM.getTargetTriple().isOSBinFormatELF() && "Invalid target");

330}

331

335 default:

338

340 return false;

342 break;

344

345 return false;

348 break;

352 break;

355 break;

358 break;

361 break;

364 break;

367 break;

370 MO, Printer.GetBlockAddressSymbol(MO.getBlockAddress()));

371 break;

372 }

373 return true;

374}

375

378

383 }

384

386 case AArch64::CATCHRET:

390 break;

391 case AArch64::CLEANUPRET:

395 break;

396 }

397}

cl::opt< bool > EnableAArch64ELFLocalDynamicTLSGeneration("aarch64-elf-ldtls-generation", cl::Hidden, cl::desc("Allow AArch64 Local Dynamic TLS code generation"), cl::init(false))

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...

bool hasELFSignedGOT() const

MCSymbol * GetExternalSymbolSymbol(const MachineOperand &MO) const

Definition AArch64MCInstLower.cpp:142

MCOperand lowerSymbolOperandCOFF(const MachineOperand &MO, MCSymbol *Sym) const

Definition AArch64MCInstLower.cpp:270

MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const

Definition AArch64MCInstLower.cpp:321

MCSymbol * GetGlobalValueSymbol(const GlobalValue *GV, unsigned TargetFlags) const

Definition AArch64MCInstLower.cpp:46

MCOperand lowerSymbolOperandELF(const MachineOperand &MO, MCSymbol *Sym) const

Definition AArch64MCInstLower.cpp:182

AArch64MCInstLower(MCContext &ctx, AsmPrinter &printer)

Definition AArch64MCInstLower.cpp:38

void Lower(const MachineInstr *MI, MCInst &OutMI) const

Definition AArch64MCInstLower.cpp:376

bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const

Definition AArch64MCInstLower.cpp:332

MCSymbol * GetGlobalAddressSymbol(const MachineOperand &MO) const

Definition AArch64MCInstLower.cpp:42

MCOperand lowerSymbolOperandMachO(const MachineOperand &MO, MCSymbol *Sym) const

Definition AArch64MCInstLower.cpp:146

This class is intended to be used as a driving class for all asm writers.

bool hasExternalLinkage() const

static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())

static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)

Context object for machine code objects.

Base class for the full range of assembler expressions which are needed for parsing.

Instances of this class represent a single low-level machine instruction.

unsigned getOpcode() const

void addOperand(const MCOperand Op)

void setOpcode(unsigned Op)

Instances of this class represent operands of the MCInst class.

static MCOperand createExpr(const MCExpr *Val)

static MCOperand createReg(MCRegister Reg)

static MCOperand createImm(int64_t Val)

static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())

static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

LLVM_ABI MCSymbol * getSymbol() const

Return the MCSymbol for this basic block.

const MachineFunction * getParent() const

Return the MachineFunction containing this basic block.

Ty * getInfo()

getInfo - Keep track of various per-function pieces of information for backends that would like to do...

Representation of each machine instruction.

const MachineBasicBlock * getParent() const

MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation for COFF targets.

StubValueTy & getGVStubEntry(MCSymbol *Sym)

PointerIntPair< MCSymbol *, 1, bool > StubValueTy

MachineOperand class - Representation of each machine instruction operand.

const GlobalValue * getGlobal() const

MachineBasicBlock * getMBB() const

bool isSymbol() const

isSymbol - Tests if this is a MO_ExternalSymbol operand.

bool isJTI() const

isJTI - Tests if this is a MO_JumpTableIndex operand.

const BlockAddress * getBlockAddress() const

MachineInstr * getParent()

getParent - Return the instruction that this operand belongs to.

unsigned getTargetFlags() const

bool isGlobal() const

isGlobal - Tests if this is a MO_GlobalAddress operand.

MachineOperandType getType() const

getType - Returns the MachineOperandType for this operand.

const char * getSymbolName() const

Register getReg() const

getReg - Returns the register number.

MCSymbol * getMCSymbol() const

@ MO_Immediate

Immediate operand.

@ MO_ConstantPoolIndex

Address of indexed Constant in Constant Pool.

@ MO_MCSymbol

MCSymbol reference (for debug/eh info)

@ MO_GlobalAddress

Address of a global value.

@ MO_RegisterMask

Mask of preserved registers.

@ MO_BlockAddress

Address of a basic block.

@ MO_MachineBasicBlock

MachineBasicBlock reference.

@ MO_Register

Register operand.

@ MO_ExternalSymbol

Name of external global symbol.

@ MO_JumpTableIndex

Address of indexed Jump Table for switch.

int64_t getOffset() const

Return the offset from the symbol in this operand.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...

StringRef - Represent a constant reference to a string, i.e.

Triple - Helper class for working with autoconf configuration names.

bool isOSBinFormatCOFF() const

Tests whether the OS uses the COFF binary format.

bool isOSWindows() const

Tests whether the OS is Windows.

bool isWindowsArm64EC() const

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

@ MO_DLLIMPORT

MO_DLLIMPORT - On a symbol operand, this represents that the reference to the symbol is for an import...

@ MO_NC

MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow.

@ MO_G1

MO_G1 - A symbol operand with this flag (granule 1) represents the bits 16-31 of a 64-bit address,...

@ MO_S

MO_S - Indicates that the bits of the symbol operand represented by MO_G0 etc are signed.

@ MO_PAGEOFF

MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page.

@ MO_GOT

MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...

@ MO_PREL

MO_PREL - Indicates that the bits of the symbol operand represented by MO_G0 etc are PC relative.

@ MO_G0

MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address,...

@ MO_ARM64EC_CALLMANGLE

MO_ARM64EC_CALLMANGLE - Operand refers to the Arm64EC-mangled version of a symbol,...

@ MO_PAGE

MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...

@ MO_HI12

MO_HI12 - This flag indicates that a symbol operand represents the bits 13-24 of a 64-bit address,...

@ MO_TLS

MO_TLS - Indicates that the operand being accessed is some kind of thread-local symbol.

@ MO_G2

MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address,...

@ MO_G3

MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address,...

@ MO_COFFSTUB

MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI std::optional< std::string > getArm64ECMangledFunctionName(StringRef Name)

Returns the ARM64EC mangled function name unless the input is already mangled.

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

bool is_contained(R &&Range, const E &Element)

Returns true if Element is found in Range.

@ MCSA_Global

.type _foo, @gnu_unique_object

@ MCSA_WeakAntiDep

.weak_anti_dep (COFF)