LLVM 23.0.0git
SystemZAsmPrinter.cpp
Go to the documentation of this file.
1//===-- SystemZAsmPrinter.cpp - SystemZ LLVM assembly printer -------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Streams SystemZ assembly language and associated data, in the form of
10// MCInsts and MCExprs respectively.
11//
12//===----------------------------------------------------------------------===//
13
14#include "SystemZAsmPrinter.h"
20#include "SystemZMCInstLower.h"
28#include "llvm/IR/Mangler.h"
29#include "llvm/IR/Module.h"
31#include "llvm/MC/MCExpr.h"
34#include "llvm/MC/MCStreamer.h"
37#include "llvm/Support/Chrono.h"
41
42using namespace llvm;
43
44// Return an RI instruction like MI with opcode Opcode, but with the
45// GR64 register operands turned into GR32s.
46static MCInst lowerRILow(const MachineInstr *MI, unsigned Opcode) {
47 if (MI->isCompare())
48 return MCInstBuilder(Opcode)
49 .addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
50 .addImm(MI->getOperand(1).getImm());
51 else
52 return MCInstBuilder(Opcode)
53 .addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
54 .addReg(SystemZMC::getRegAsGR32(MI->getOperand(1).getReg()))
55 .addImm(MI->getOperand(2).getImm());
56}
57
58// Return an RI instruction like MI with opcode Opcode, but with the
59// GR64 register operands turned into GRH32s.
60static MCInst lowerRIHigh(const MachineInstr *MI, unsigned Opcode) {
61 if (MI->isCompare())
62 return MCInstBuilder(Opcode)
63 .addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
64 .addImm(MI->getOperand(1).getImm());
65 else
66 return MCInstBuilder(Opcode)
67 .addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
68 .addReg(SystemZMC::getRegAsGRH32(MI->getOperand(1).getReg()))
69 .addImm(MI->getOperand(2).getImm());
70}
71
72// Return an RI instruction like MI with opcode Opcode, but with the
73// R2 register turned into a GR64.
74static MCInst lowerRIEfLow(const MachineInstr *MI, unsigned Opcode) {
75 return MCInstBuilder(Opcode)
76 .addReg(MI->getOperand(0).getReg())
77 .addReg(MI->getOperand(1).getReg())
78 .addReg(SystemZMC::getRegAsGR64(MI->getOperand(2).getReg()))
79 .addImm(MI->getOperand(3).getImm())
80 .addImm(MI->getOperand(4).getImm())
81 .addImm(MI->getOperand(5).getImm());
82}
83
84static const MCSymbolRefExpr *getTLSGetOffset(MCContext &Context) {
85 StringRef Name = "__tls_get_offset";
86 return MCSymbolRefExpr::create(Context.getOrCreateSymbol(Name),
87 SystemZ::S_PLT, Context);
88}
89
91 StringRef Name = "_GLOBAL_OFFSET_TABLE_";
92 return MCSymbolRefExpr::create(Context.getOrCreateSymbol(Name),
93 Context);
94}
95
96// MI is an instruction that accepts an optional alignment hint,
97// and which was already lowered to LoweredMI. If the alignment
98// of the original memory operand is known, update LoweredMI to
99// an instruction with the corresponding hint set.
100static void lowerAlignmentHint(const MachineInstr *MI, MCInst &LoweredMI,
101 unsigned Opcode) {
102 if (MI->memoperands_empty())
103 return;
104
105 Align Alignment = Align(16);
106 for (MachineInstr::mmo_iterator MMOI = MI->memoperands_begin(),
107 EE = MI->memoperands_end(); MMOI != EE; ++MMOI)
108 if ((*MMOI)->getAlign() < Alignment)
109 Alignment = (*MMOI)->getAlign();
110
111 unsigned AlignmentHint = 0;
112 if (Alignment >= Align(16))
113 AlignmentHint = 4;
114 else if (Alignment >= Align(8))
115 AlignmentHint = 3;
116 if (AlignmentHint == 0)
117 return;
118
119 LoweredMI.setOpcode(Opcode);
120 LoweredMI.addOperand(MCOperand::createImm(AlignmentHint));
121}
122
123// MI loads the high part of a vector from memory. Return an instruction
124// that uses replicating vector load Opcode to do the same thing.
125static MCInst lowerSubvectorLoad(const MachineInstr *MI, unsigned Opcode) {
126 return MCInstBuilder(Opcode)
127 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
128 .addReg(MI->getOperand(1).getReg())
129 .addImm(MI->getOperand(2).getImm())
130 .addReg(MI->getOperand(3).getReg());
131}
132
133// MI stores the high part of a vector to memory. Return an instruction
134// that uses elemental vector store Opcode to do the same thing.
135static MCInst lowerSubvectorStore(const MachineInstr *MI, unsigned Opcode) {
136 return MCInstBuilder(Opcode)
137 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
138 .addReg(MI->getOperand(1).getReg())
139 .addImm(MI->getOperand(2).getImm())
140 .addReg(MI->getOperand(3).getReg())
141 .addImm(0);
142}
143
144// MI extracts the first element of the source vector.
145static MCInst lowerVecEltExtraction(const MachineInstr *MI, unsigned Opcode) {
146 return MCInstBuilder(Opcode)
147 .addReg(SystemZMC::getRegAsGR64(MI->getOperand(0).getReg()))
148 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(1).getReg()))
149 .addReg(0)
150 .addImm(0);
151}
152
153// MI inserts value into the first element of the destination vector.
154static MCInst lowerVecEltInsertion(const MachineInstr *MI, unsigned Opcode) {
155 return MCInstBuilder(Opcode)
156 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
157 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
158 .addReg(MI->getOperand(1).getReg())
159 .addReg(0)
160 .addImm(0);
161}
162
164 SM.reset();
165
166 // In HLASM, the only way to represent aliases is to use the
167 // extra-label-at-definition strategy. This is similar to the AIX
168 // implementation with the additional caveat that all symbol attributes must
169 // be emitted before the label is emitted.
170 if (TM.getTargetTriple().isOSzOS()) {
171 // Construct an aliasing list for each GlobalObject.
172 for (const auto &Alias : M.aliases()) {
173 const GlobalObject *Aliasee = Alias.getAliaseeObject();
174 if (!Aliasee)
175 OutContext.reportError(
176 {}, "Alias without a base object is not yet supported on z/OS.");
177
178 bool IsFunc = isa<Function>(Aliasee->stripPointerCasts());
179 if (IsFunc) {
180 if (Alias.hasWeakLinkage() || Alias.hasLinkOnceLinkage())
181 OutContext.reportError({},
182 "Weak alias/reference not supported on z/OS");
183
184 GOAliasMap[Aliasee].push_back(&Alias);
185 } else
186 OutContext.reportError(
187 {}, "Only aliases to functions is supported in GOFF.");
188 }
189 }
191}
192
193// The XPLINK ABI requires that a no-op encoding the call type is emitted after
194// each call to a subroutine. This information can be used by the called
195// function to determine its entry point, e.g. for generating a backtrace. The
196// call type is encoded as a register number in the bcr instruction. See
197// enumeration CallType for the possible values.
198void SystemZAsmPrinter::emitCallInformation(CallType CT) {
200 MCInstBuilder(SystemZ::BCRAsm)
201 .addImm(0)
202 .addReg(SystemZMC::GR64Regs[static_cast<unsigned>(CT)]));
203}
204
205uint32_t SystemZAsmPrinter::AssociatedDataAreaTable::insert(const MCSymbol *Sym,
206 unsigned SlotKind) {
207 auto Key = std::make_pair(Sym, SlotKind);
208 auto It = Displacements.find(Key);
209
210 if (It != Displacements.end())
211 return (*It).second;
212
213 // Determine length of descriptor.
215 switch (SlotKind) {
217 Length = 2 * PointerSize;
218 break;
219 default:
220 Length = PointerSize;
221 break;
222 }
223
224 uint32_t Displacement = NextDisplacement;
225 Displacements[std::make_pair(Sym, SlotKind)] = NextDisplacement;
226 NextDisplacement += Length;
227
228 return Displacement;
229}
230
231uint32_t
232SystemZAsmPrinter::AssociatedDataAreaTable::insert(const MachineOperand MO) {
233 MCSymbol *Sym;
235 const GlobalValue *GV = MO.getGlobal();
236 Sym = MO.getParent()->getMF()->getTarget().getSymbol(GV);
237 assert(Sym && "No symbol");
238 } else if (MO.getType() == MachineOperand::MO_ExternalSymbol) {
239 const char *SymName = MO.getSymbolName();
240 Sym = MO.getParent()->getMF()->getContext().getOrCreateSymbol(SymName);
241 assert(Sym && "No symbol");
242 } else
243 llvm_unreachable("Unexpected operand type");
244
245 unsigned ADAslotType = MO.getTargetFlags();
246 return insert(Sym, ADAslotType);
247}
248
250 SystemZ_MC::verifyInstructionPredicates(MI->getOpcode(),
251 getSubtargetInfo().getFeatureBits());
252
253 SystemZMCInstLower Lower(MF->getContext(), *this);
254 MCInst LoweredMI;
255 switch (MI->getOpcode()) {
256 case SystemZ::Return:
257 LoweredMI = MCInstBuilder(SystemZ::BR)
258 .addReg(SystemZ::R14D);
259 break;
260
261 case SystemZ::Return_XPLINK:
262 LoweredMI = MCInstBuilder(SystemZ::B)
263 .addReg(SystemZ::R7D)
264 .addImm(2)
265 .addReg(0);
266 break;
267
268 case SystemZ::CondReturn:
269 LoweredMI = MCInstBuilder(SystemZ::BCR)
270 .addImm(MI->getOperand(0).getImm())
271 .addImm(MI->getOperand(1).getImm())
272 .addReg(SystemZ::R14D);
273 break;
274
275 case SystemZ::CondReturn_XPLINK:
276 LoweredMI = MCInstBuilder(SystemZ::BC)
277 .addImm(MI->getOperand(0).getImm())
278 .addImm(MI->getOperand(1).getImm())
279 .addReg(SystemZ::R7D)
280 .addImm(2)
281 .addReg(0);
282 break;
283
284 case SystemZ::CRBReturn:
285 LoweredMI = MCInstBuilder(SystemZ::CRB)
286 .addReg(MI->getOperand(0).getReg())
287 .addReg(MI->getOperand(1).getReg())
288 .addImm(MI->getOperand(2).getImm())
289 .addReg(SystemZ::R14D)
290 .addImm(0);
291 break;
292
293 case SystemZ::CGRBReturn:
294 LoweredMI = MCInstBuilder(SystemZ::CGRB)
295 .addReg(MI->getOperand(0).getReg())
296 .addReg(MI->getOperand(1).getReg())
297 .addImm(MI->getOperand(2).getImm())
298 .addReg(SystemZ::R14D)
299 .addImm(0);
300 break;
301
302 case SystemZ::CIBReturn:
303 LoweredMI = MCInstBuilder(SystemZ::CIB)
304 .addReg(MI->getOperand(0).getReg())
305 .addImm(MI->getOperand(1).getImm())
306 .addImm(MI->getOperand(2).getImm())
307 .addReg(SystemZ::R14D)
308 .addImm(0);
309 break;
310
311 case SystemZ::CGIBReturn:
312 LoweredMI = MCInstBuilder(SystemZ::CGIB)
313 .addReg(MI->getOperand(0).getReg())
314 .addImm(MI->getOperand(1).getImm())
315 .addImm(MI->getOperand(2).getImm())
316 .addReg(SystemZ::R14D)
317 .addImm(0);
318 break;
319
320 case SystemZ::CLRBReturn:
321 LoweredMI = MCInstBuilder(SystemZ::CLRB)
322 .addReg(MI->getOperand(0).getReg())
323 .addReg(MI->getOperand(1).getReg())
324 .addImm(MI->getOperand(2).getImm())
325 .addReg(SystemZ::R14D)
326 .addImm(0);
327 break;
328
329 case SystemZ::CLGRBReturn:
330 LoweredMI = MCInstBuilder(SystemZ::CLGRB)
331 .addReg(MI->getOperand(0).getReg())
332 .addReg(MI->getOperand(1).getReg())
333 .addImm(MI->getOperand(2).getImm())
334 .addReg(SystemZ::R14D)
335 .addImm(0);
336 break;
337
338 case SystemZ::CLIBReturn:
339 LoweredMI = MCInstBuilder(SystemZ::CLIB)
340 .addReg(MI->getOperand(0).getReg())
341 .addImm(MI->getOperand(1).getImm())
342 .addImm(MI->getOperand(2).getImm())
343 .addReg(SystemZ::R14D)
344 .addImm(0);
345 break;
346
347 case SystemZ::CLGIBReturn:
348 LoweredMI = MCInstBuilder(SystemZ::CLGIB)
349 .addReg(MI->getOperand(0).getReg())
350 .addImm(MI->getOperand(1).getImm())
351 .addImm(MI->getOperand(2).getImm())
352 .addReg(SystemZ::R14D)
353 .addImm(0);
354 break;
355
356 case SystemZ::CallBRASL_XPLINK64:
358 .addReg(SystemZ::R7D)
359 .addExpr(Lower.getExpr(MI->getOperand(0),
361 emitCallInformation(CallType::BRASL7);
362 return;
363
364 case SystemZ::CallBASR_XPLINK64:
366 .addReg(SystemZ::R7D)
367 .addReg(MI->getOperand(0).getReg()));
368 emitCallInformation(CallType::BASR76);
369 return;
370
371 case SystemZ::CallBASR_STACKEXT:
373 .addReg(SystemZ::R3D)
374 .addReg(MI->getOperand(0).getReg()));
375 emitCallInformation(CallType::BASR33);
376 return;
377
378 case SystemZ::ADA_ENTRY_VALUE:
379 case SystemZ::ADA_ENTRY: {
380 const SystemZSubtarget &Subtarget = MF->getSubtarget<SystemZSubtarget>();
381 const SystemZInstrInfo *TII = Subtarget.getInstrInfo();
382 uint32_t Disp = ADATable.insert(MI->getOperand(1));
383 Register TargetReg = MI->getOperand(0).getReg();
384
385 Register ADAReg = MI->getOperand(2).getReg();
386 Disp += MI->getOperand(3).getImm();
387 bool LoadAddr = MI->getOpcode() == SystemZ::ADA_ENTRY;
388
389 unsigned Op0 = LoadAddr ? SystemZ::LA : SystemZ::LG;
390 unsigned Op = TII->getOpcodeForOffset(Op0, Disp);
391
392 Register IndexReg = 0;
393 if (!Op) {
394 if (TargetReg != ADAReg) {
395 IndexReg = TargetReg;
396 // Use TargetReg to store displacement.
399 MCInstBuilder(SystemZ::LLILF).addReg(TargetReg).addImm(Disp));
400 } else
402 .addReg(TargetReg)
403 .addReg(TargetReg)
404 .addImm(Disp));
405 Disp = 0;
406 Op = Op0;
407 }
409 .addReg(TargetReg)
410 .addReg(ADAReg)
411 .addImm(Disp)
412 .addReg(IndexReg));
413
414 return;
415 }
416 case SystemZ::CallBRASL:
417 LoweredMI = MCInstBuilder(SystemZ::BRASL)
418 .addReg(SystemZ::R14D)
419 .addExpr(Lower.getExpr(MI->getOperand(0), SystemZ::S_PLT));
420 break;
421
422 case SystemZ::CallBASR:
423 LoweredMI = MCInstBuilder(SystemZ::BASR)
424 .addReg(SystemZ::R14D)
425 .addReg(MI->getOperand(0).getReg());
426 break;
427
428 case SystemZ::CallJG:
429 LoweredMI = MCInstBuilder(SystemZ::JG)
430 .addExpr(Lower.getExpr(MI->getOperand(0), SystemZ::S_PLT));
431 break;
432
433 case SystemZ::CallBRCL:
434 LoweredMI = MCInstBuilder(SystemZ::BRCL)
435 .addImm(MI->getOperand(0).getImm())
436 .addImm(MI->getOperand(1).getImm())
437 .addExpr(Lower.getExpr(MI->getOperand(2), SystemZ::S_PLT));
438 break;
439
440 case SystemZ::CallBR:
441 LoweredMI = MCInstBuilder(SystemZ::BR)
442 .addReg(MI->getOperand(0).getReg());
443 break;
444
445 case SystemZ::CallBCR:
446 LoweredMI = MCInstBuilder(SystemZ::BCR)
447 .addImm(MI->getOperand(0).getImm())
448 .addImm(MI->getOperand(1).getImm())
449 .addReg(MI->getOperand(2).getReg());
450 break;
451
452 case SystemZ::CRBCall:
453 LoweredMI = MCInstBuilder(SystemZ::CRB)
454 .addReg(MI->getOperand(0).getReg())
455 .addReg(MI->getOperand(1).getReg())
456 .addImm(MI->getOperand(2).getImm())
457 .addReg(MI->getOperand(3).getReg())
458 .addImm(0);
459 break;
460
461 case SystemZ::CGRBCall:
462 LoweredMI = MCInstBuilder(SystemZ::CGRB)
463 .addReg(MI->getOperand(0).getReg())
464 .addReg(MI->getOperand(1).getReg())
465 .addImm(MI->getOperand(2).getImm())
466 .addReg(MI->getOperand(3).getReg())
467 .addImm(0);
468 break;
469
470 case SystemZ::CIBCall:
471 LoweredMI = MCInstBuilder(SystemZ::CIB)
472 .addReg(MI->getOperand(0).getReg())
473 .addImm(MI->getOperand(1).getImm())
474 .addImm(MI->getOperand(2).getImm())
475 .addReg(MI->getOperand(3).getReg())
476 .addImm(0);
477 break;
478
479 case SystemZ::CGIBCall:
480 LoweredMI = MCInstBuilder(SystemZ::CGIB)
481 .addReg(MI->getOperand(0).getReg())
482 .addImm(MI->getOperand(1).getImm())
483 .addImm(MI->getOperand(2).getImm())
484 .addReg(MI->getOperand(3).getReg())
485 .addImm(0);
486 break;
487
488 case SystemZ::CLRBCall:
489 LoweredMI = MCInstBuilder(SystemZ::CLRB)
490 .addReg(MI->getOperand(0).getReg())
491 .addReg(MI->getOperand(1).getReg())
492 .addImm(MI->getOperand(2).getImm())
493 .addReg(MI->getOperand(3).getReg())
494 .addImm(0);
495 break;
496
497 case SystemZ::CLGRBCall:
498 LoweredMI = MCInstBuilder(SystemZ::CLGRB)
499 .addReg(MI->getOperand(0).getReg())
500 .addReg(MI->getOperand(1).getReg())
501 .addImm(MI->getOperand(2).getImm())
502 .addReg(MI->getOperand(3).getReg())
503 .addImm(0);
504 break;
505
506 case SystemZ::CLIBCall:
507 LoweredMI = MCInstBuilder(SystemZ::CLIB)
508 .addReg(MI->getOperand(0).getReg())
509 .addImm(MI->getOperand(1).getImm())
510 .addImm(MI->getOperand(2).getImm())
511 .addReg(MI->getOperand(3).getReg())
512 .addImm(0);
513 break;
514
515 case SystemZ::CLGIBCall:
516 LoweredMI = MCInstBuilder(SystemZ::CLGIB)
517 .addReg(MI->getOperand(0).getReg())
518 .addImm(MI->getOperand(1).getImm())
519 .addImm(MI->getOperand(2).getImm())
520 .addReg(MI->getOperand(3).getReg())
521 .addImm(0);
522 break;
523
524 case SystemZ::TLS_GDCALL:
525 LoweredMI =
526 MCInstBuilder(SystemZ::BRASL)
527 .addReg(SystemZ::R14D)
528 .addExpr(getTLSGetOffset(MF->getContext()))
529 .addExpr(Lower.getExpr(MI->getOperand(0), SystemZ::S_TLSGD));
530 break;
531
532 case SystemZ::TLS_LDCALL:
533 LoweredMI =
534 MCInstBuilder(SystemZ::BRASL)
535 .addReg(SystemZ::R14D)
536 .addExpr(getTLSGetOffset(MF->getContext()))
537 .addExpr(Lower.getExpr(MI->getOperand(0), SystemZ::S_TLSLDM));
538 break;
539
540 case SystemZ::GOT:
541 LoweredMI = MCInstBuilder(SystemZ::LARL)
542 .addReg(MI->getOperand(0).getReg())
543 .addExpr(getGlobalOffsetTable(MF->getContext()));
544 break;
545
546 case SystemZ::IILF64:
547 LoweredMI = MCInstBuilder(SystemZ::IILF)
548 .addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
549 .addImm(MI->getOperand(2).getImm());
550 break;
551
552 case SystemZ::IIHF64:
553 LoweredMI = MCInstBuilder(SystemZ::IIHF)
554 .addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
555 .addImm(MI->getOperand(2).getImm());
556 break;
557
558 case SystemZ::RISBHH:
559 case SystemZ::RISBHL:
560 LoweredMI = lowerRIEfLow(MI, SystemZ::RISBHG);
561 break;
562
563 case SystemZ::RISBLH:
564 case SystemZ::RISBLL:
565 LoweredMI = lowerRIEfLow(MI, SystemZ::RISBLG);
566 break;
567
568 case SystemZ::VLVGP32:
569 LoweredMI = MCInstBuilder(SystemZ::VLVGP)
570 .addReg(MI->getOperand(0).getReg())
571 .addReg(SystemZMC::getRegAsGR64(MI->getOperand(1).getReg()))
572 .addReg(SystemZMC::getRegAsGR64(MI->getOperand(2).getReg()));
573 break;
574
575 case SystemZ::VLR16:
576 case SystemZ::VLR32:
577 case SystemZ::VLR64:
578 LoweredMI = MCInstBuilder(SystemZ::VLR)
579 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
580 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(1).getReg()));
581 break;
582
583 case SystemZ::VL:
584 Lower.lower(MI, LoweredMI);
585 lowerAlignmentHint(MI, LoweredMI, SystemZ::VLAlign);
586 break;
587
588 case SystemZ::VST:
589 Lower.lower(MI, LoweredMI);
590 lowerAlignmentHint(MI, LoweredMI, SystemZ::VSTAlign);
591 break;
592
593 case SystemZ::VLM:
594 Lower.lower(MI, LoweredMI);
595 lowerAlignmentHint(MI, LoweredMI, SystemZ::VLMAlign);
596 break;
597
598 case SystemZ::VSTM:
599 Lower.lower(MI, LoweredMI);
600 lowerAlignmentHint(MI, LoweredMI, SystemZ::VSTMAlign);
601 break;
602
603 case SystemZ::VL16:
604 LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPH);
605 break;
606
607 case SystemZ::VL32:
608 LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPF);
609 break;
610
611 case SystemZ::VL64:
612 LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPG);
613 break;
614
615 case SystemZ::VST16:
616 LoweredMI = lowerSubvectorStore(MI, SystemZ::VSTEH);
617 break;
618
619 case SystemZ::VST32:
620 LoweredMI = lowerSubvectorStore(MI, SystemZ::VSTEF);
621 break;
622
623 case SystemZ::VST64:
624 LoweredMI = lowerSubvectorStore(MI, SystemZ::VSTEG);
625 break;
626
627 case SystemZ::LFER:
628 LoweredMI = lowerVecEltExtraction(MI, SystemZ::VLGVF);
629 break;
630
631 case SystemZ::LFER_16:
632 LoweredMI = lowerVecEltExtraction(MI, SystemZ::VLGVH);
633 break;
634
635 case SystemZ::LEFR:
636 LoweredMI = lowerVecEltInsertion(MI, SystemZ::VLVGF);
637 break;
638
639 case SystemZ::LEFR_16:
640 LoweredMI = lowerVecEltInsertion(MI, SystemZ::VLVGH);
641 break;
642
643#define LOWER_LOW(NAME) \
644 case SystemZ::NAME##64: LoweredMI = lowerRILow(MI, SystemZ::NAME); break
645
646 LOWER_LOW(IILL);
647 LOWER_LOW(IILH);
648 LOWER_LOW(TMLL);
649 LOWER_LOW(TMLH);
650 LOWER_LOW(NILL);
651 LOWER_LOW(NILH);
652 LOWER_LOW(NILF);
653 LOWER_LOW(OILL);
654 LOWER_LOW(OILH);
655 LOWER_LOW(OILF);
656 LOWER_LOW(XILF);
657
658#undef LOWER_LOW
659
660#define LOWER_HIGH(NAME) \
661 case SystemZ::NAME##64: LoweredMI = lowerRIHigh(MI, SystemZ::NAME); break
662
663 LOWER_HIGH(IIHL);
664 LOWER_HIGH(IIHH);
665 LOWER_HIGH(TMHL);
666 LOWER_HIGH(TMHH);
667 LOWER_HIGH(NIHL);
668 LOWER_HIGH(NIHH);
669 LOWER_HIGH(NIHF);
670 LOWER_HIGH(OIHL);
671 LOWER_HIGH(OIHH);
672 LOWER_HIGH(OIHF);
673 LOWER_HIGH(XIHF);
674
675#undef LOWER_HIGH
676
677 case SystemZ::Serialize:
678 if (MF->getSubtarget<SystemZSubtarget>().hasFastSerialization())
679 LoweredMI = MCInstBuilder(SystemZ::BCRAsm)
680 .addImm(14).addReg(SystemZ::R0D);
681 else
682 LoweredMI = MCInstBuilder(SystemZ::BCRAsm)
683 .addImm(15).addReg(SystemZ::R0D);
684 break;
685
686 // We want to emit "j .+2" for traps, jumping to the relative immediate field
687 // of the jump instruction, which is an illegal instruction. We cannot emit a
688 // "." symbol, so create and emit a temp label before the instruction and use
689 // that instead.
690 case SystemZ::Trap: {
691 MCSymbol *DotSym = OutContext.createTempSymbol();
692 OutStreamer->emitLabel(DotSym);
693
695 const MCConstantExpr *ConstExpr = MCConstantExpr::create(2, OutContext);
696 LoweredMI = MCInstBuilder(SystemZ::J)
697 .addExpr(MCBinaryExpr::createAdd(Expr, ConstExpr, OutContext));
698 }
699 break;
700
701 // Conditional traps will create a branch on condition instruction that jumps
702 // to the relative immediate field of the jump instruction. (eg. "jo .+2")
703 case SystemZ::CondTrap: {
704 MCSymbol *DotSym = OutContext.createTempSymbol();
705 OutStreamer->emitLabel(DotSym);
706
708 const MCConstantExpr *ConstExpr = MCConstantExpr::create(2, OutContext);
709 LoweredMI = MCInstBuilder(SystemZ::BRC)
710 .addImm(MI->getOperand(0).getImm())
711 .addImm(MI->getOperand(1).getImm())
712 .addExpr(MCBinaryExpr::createAdd(Expr, ConstExpr, OutContext));
713 }
714 break;
715
716 case TargetOpcode::FENTRY_CALL:
717 LowerFENTRY_CALL(*MI, Lower);
718 return;
719
720 case TargetOpcode::STACKMAP:
721 LowerSTACKMAP(*MI);
722 return;
723
724 case TargetOpcode::PATCHPOINT:
725 LowerPATCHPOINT(*MI, Lower);
726 return;
727
728 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
729 LowerPATCHABLE_FUNCTION_ENTER(*MI, Lower);
730 return;
731
732 case TargetOpcode::PATCHABLE_RET:
733 LowerPATCHABLE_RET(*MI, Lower);
734 return;
735
736 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
737 llvm_unreachable("PATCHABLE_FUNCTION_EXIT should never be emitted");
738
739 case TargetOpcode::PATCHABLE_TAIL_CALL:
740 // TODO: Define a trampoline `__xray_FunctionTailExit` and differentiate a
741 // normal function exit from a tail exit.
742 llvm_unreachable("Tail call is handled in the normal case. See comments "
743 "around this assert.");
744
745 case SystemZ::EXRL_Pseudo: {
746 unsigned TargetInsOpc = MI->getOperand(0).getImm();
747 Register LenMinus1Reg = MI->getOperand(1).getReg();
748 Register DestReg = MI->getOperand(2).getReg();
749 int64_t DestDisp = MI->getOperand(3).getImm();
750 Register SrcReg = MI->getOperand(4).getReg();
751 int64_t SrcDisp = MI->getOperand(5).getImm();
752
753 SystemZTargetStreamer *TS = getTargetStreamer();
754 MCInst ET = MCInstBuilder(TargetInsOpc)
755 .addReg(DestReg)
756 .addImm(DestDisp)
757 .addImm(1)
758 .addReg(SrcReg)
759 .addImm(SrcDisp);
760 SystemZTargetStreamer::MCInstSTIPair ET_STI(ET, &MF->getSubtarget());
761 auto [It, Inserted] = TS->EXRLTargets2Sym.try_emplace(ET_STI);
762 if (Inserted)
763 It->second = OutContext.createTempSymbol();
764 MCSymbol *DotSym = It->second;
768 MCInstBuilder(SystemZ::EXRL).addReg(LenMinus1Reg).addExpr(Dot));
769 return;
770 }
771
772 case SystemZ::FENCE:
773 OutStreamer->emitRawComment("FENCE");
774 return;
775
776 // EH_SjLj_Setup is a dummy terminator instruction of size 0.
777 // It is used to handle the clobber register for builtin setjmp.
778 case SystemZ::EH_SjLj_Setup:
779 return;
780
781 case SystemZ::LOAD_TLS_BLOCK_ADDR:
782 lowerLOAD_TLS_BLOCK_ADDR(*MI, Lower);
783 return;
784 case SystemZ::LOAD_GLOBAL_STACKGUARD_ADDR:
785 lowerLOAD_GLOBAL_STACKGUARD_ADDR(*MI, Lower);
786 return;
787
788 default:
789 Lower.lower(MI, LoweredMI);
790 break;
791 }
792 EmitToStreamer(*OutStreamer, LoweredMI);
793}
794
795// Emit the largest nop instruction smaller than or equal to NumBytes
796// bytes. Return the size of nop emitted.
798 unsigned NumBytes, const MCSubtargetInfo &STI) {
799 if (NumBytes < 2) {
800 llvm_unreachable("Zero nops?");
801 return 0;
802 }
803 else if (NumBytes < 4) {
804 OutStreamer.emitInstruction(
805 MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R0D), STI);
806 return 2;
807 }
808 else if (NumBytes < 6) {
809 OutStreamer.emitInstruction(
810 MCInstBuilder(SystemZ::BCAsm).addImm(0).addReg(0).addImm(0).addReg(0),
811 STI);
812 return 4;
813 }
814 else {
817 OutStreamer.emitLabel(DotSym);
818 OutStreamer.emitInstruction(
819 MCInstBuilder(SystemZ::BRCLAsm).addImm(0).addExpr(Dot), STI);
820 return 6;
821 }
822}
823
824void SystemZAsmPrinter::LowerFENTRY_CALL(const MachineInstr &MI,
825 SystemZMCInstLower &Lower) {
826 MCContext &Ctx = MF->getContext();
827 if (MF->getFunction().hasFnAttribute("mrecord-mcount")) {
828 MCSymbol *DotSym = OutContext.createTempSymbol();
829 OutStreamer->pushSection();
830 OutStreamer->switchSection(
831 Ctx.getELFSection("__mcount_loc", ELF::SHT_PROGBITS, ELF::SHF_ALLOC));
832 OutStreamer->emitSymbolValue(DotSym, 8);
833 OutStreamer->popSection();
834 OutStreamer->emitLabel(DotSym);
835 }
836
837 if (MF->getFunction().hasFnAttribute("mnop-mcount")) {
839 return;
840 }
841
842 MCSymbol *fentry = Ctx.getOrCreateSymbol("__fentry__");
843 const MCSymbolRefExpr *Op =
845 OutStreamer->emitInstruction(
846 MCInstBuilder(SystemZ::BRASL).addReg(SystemZ::R0D).addExpr(Op),
848}
849
850void SystemZAsmPrinter::LowerSTACKMAP(const MachineInstr &MI) {
851 auto *TII = MF->getSubtarget<SystemZSubtarget>().getInstrInfo();
852
853 unsigned NumNOPBytes = MI.getOperand(1).getImm();
854
855 auto &Ctx = OutStreamer->getContext();
856 MCSymbol *MILabel = Ctx.createTempSymbol();
857 OutStreamer->emitLabel(MILabel);
858
859 SM.recordStackMap(*MILabel, MI);
860 assert(NumNOPBytes % 2 == 0 && "Invalid number of NOP bytes requested!");
861
862 // Scan ahead to trim the shadow.
863 unsigned ShadowBytes = 0;
864 const MachineBasicBlock &MBB = *MI.getParent();
866 ++MII;
867 while (ShadowBytes < NumNOPBytes) {
868 if (MII == MBB.end() ||
869 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
870 MII->getOpcode() == TargetOpcode::STACKMAP)
871 break;
872 ShadowBytes += TII->getInstSizeInBytes(*MII);
873 if (MII->isCall())
874 break;
875 ++MII;
876 }
877
878 // Emit nops.
879 while (ShadowBytes < NumNOPBytes)
880 ShadowBytes += EmitNop(OutContext, *OutStreamer, NumNOPBytes - ShadowBytes,
882}
883
884// Lower a patchpoint of the form:
885// [<def>], <id>, <numBytes>, <target>, <numArgs>
886void SystemZAsmPrinter::LowerPATCHPOINT(const MachineInstr &MI,
887 SystemZMCInstLower &Lower) {
888 auto &Ctx = OutStreamer->getContext();
889 MCSymbol *MILabel = Ctx.createTempSymbol();
890 OutStreamer->emitLabel(MILabel);
891
892 SM.recordPatchPoint(*MILabel, MI);
893 PatchPointOpers Opers(&MI);
894
895 unsigned EncodedBytes = 0;
896 const MachineOperand &CalleeMO = Opers.getCallTarget();
897
898 if (CalleeMO.isImm()) {
899 uint64_t CallTarget = CalleeMO.getImm();
900 if (CallTarget) {
901 unsigned ScratchIdx = -1;
902 unsigned ScratchReg = 0;
903 do {
904 ScratchIdx = Opers.getNextScratchIdx(ScratchIdx + 1);
905 ScratchReg = MI.getOperand(ScratchIdx).getReg();
906 } while (ScratchReg == SystemZ::R0D);
907
908 // Materialize the call target address
909 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::LLILF)
910 .addReg(ScratchReg)
911 .addImm(CallTarget & 0xFFFFFFFF));
912 EncodedBytes += 6;
913 if (CallTarget >> 32) {
914 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::IIHF)
915 .addReg(ScratchReg)
916 .addImm(CallTarget >> 32));
917 EncodedBytes += 6;
918 }
919
920 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BASR)
921 .addReg(SystemZ::R14D)
922 .addReg(ScratchReg));
923 EncodedBytes += 2;
924 }
925 } else if (CalleeMO.isGlobal()) {
926 const MCExpr *Expr = Lower.getExpr(CalleeMO, SystemZ::S_PLT);
927 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BRASL)
928 .addReg(SystemZ::R14D)
929 .addExpr(Expr));
930 EncodedBytes += 6;
931 }
932
933 // Emit padding.
934 unsigned NumBytes = Opers.getNumPatchBytes();
935 assert(NumBytes >= EncodedBytes &&
936 "Patchpoint can't request size less than the length of a call.");
937 assert((NumBytes - EncodedBytes) % 2 == 0 &&
938 "Invalid number of NOP bytes requested!");
939 while (EncodedBytes < NumBytes)
940 EncodedBytes += EmitNop(OutContext, *OutStreamer, NumBytes - EncodedBytes,
942}
943
944void SystemZAsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(
945 const MachineInstr &MI, SystemZMCInstLower &Lower) {
946
947 const MachineFunction &MF = *(MI.getParent()->getParent());
948 const Function &F = MF.getFunction();
949
950 // If patchable-function-entry is set, emit in-function nops here.
951 if (F.hasFnAttribute("patchable-function-entry")) {
952 // get M-N from function attribute (CodeGenFunction subtracts N
953 // from M to yield the correct patchable-function-entry).
954 unsigned Num = F.getFnAttributeAsParsedInteger("patchable-function-entry");
955 // Emit M-N 2-byte nops. Use getNop() here instead of emitNops()
956 // to keep it aligned with the common code implementation emitting
957 // the prefix nops.
958 for (unsigned I = 0; I < Num; ++I)
959 EmitToStreamer(*OutStreamer, MF.getSubtarget().getInstrInfo()->getNop());
960 return;
961 }
962 // Otherwise, emit xray sled.
963 // .begin:
964 // j .end # -> stmg %r2, %r15, 16(%r15)
965 // nop
966 // llilf %2, FuncID
967 // brasl %r14, __xray_FunctionEntry@GOT
968 // .end:
969 //
970 // Update compiler-rt/lib/xray/xray_s390x.cpp accordingly when number
971 // of instructions change.
972 bool HasVectorFeature =
973 TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureVector) &&
974 !TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureSoftFloat);
975 MCSymbol *FuncEntry = OutContext.getOrCreateSymbol(
976 HasVectorFeature ? "__xray_FunctionEntryVec" : "__xray_FunctionEntry");
977 MCSymbol *BeginOfSled = OutContext.createTempSymbol("xray_sled_", true);
978 MCSymbol *EndOfSled = OutContext.createTempSymbol();
979 OutStreamer->emitLabel(BeginOfSled);
981 MCInstBuilder(SystemZ::J)
982 .addExpr(MCSymbolRefExpr::create(EndOfSled, OutContext)));
985 MCInstBuilder(SystemZ::LLILF).addReg(SystemZ::R2D).addImm(0));
986 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BRASL)
987 .addReg(SystemZ::R14D)
989 FuncEntry, SystemZ::S_PLT, OutContext)));
990 OutStreamer->emitLabel(EndOfSled);
991 recordSled(BeginOfSled, MI, SledKind::FUNCTION_ENTER, 2);
992}
993
994void SystemZAsmPrinter::LowerPATCHABLE_RET(const MachineInstr &MI,
995 SystemZMCInstLower &Lower) {
996 unsigned OpCode = MI.getOperand(0).getImm();
997 MCSymbol *FallthroughLabel = nullptr;
998 if (OpCode == SystemZ::CondReturn) {
999 FallthroughLabel = OutContext.createTempSymbol();
1000 int64_t Cond0 = MI.getOperand(1).getImm();
1001 int64_t Cond1 = MI.getOperand(2).getImm();
1002 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BRC)
1003 .addImm(Cond0)
1004 .addImm(Cond1 ^ Cond0)
1005 .addExpr(MCSymbolRefExpr::create(
1006 FallthroughLabel, OutContext)));
1007 }
1008 // .begin:
1009 // br %r14 # -> stmg %r2, %r15, 24(%r15)
1010 // nop
1011 // nop
1012 // llilf %2,FuncID
1013 // j __xray_FunctionExit@GOT
1014 //
1015 // Update compiler-rt/lib/xray/xray_s390x.cpp accordingly when number
1016 // of instructions change.
1017 bool HasVectorFeature =
1018 TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureVector) &&
1019 !TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureSoftFloat);
1020 MCSymbol *FuncExit = OutContext.getOrCreateSymbol(
1021 HasVectorFeature ? "__xray_FunctionExitVec" : "__xray_FunctionExit");
1022 MCSymbol *BeginOfSled = OutContext.createTempSymbol("xray_sled_", true);
1023 OutStreamer->emitLabel(BeginOfSled);
1025 MCInstBuilder(SystemZ::BR).addReg(SystemZ::R14D));
1028 MCInstBuilder(SystemZ::LLILF).addReg(SystemZ::R2D).addImm(0));
1029 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::J)
1030 .addExpr(MCSymbolRefExpr::create(
1031 FuncExit, SystemZ::S_PLT, OutContext)));
1032 if (FallthroughLabel)
1033 OutStreamer->emitLabel(FallthroughLabel);
1034 recordSled(BeginOfSled, MI, SledKind::FUNCTION_EXIT, 2);
1035}
1036
1037void SystemZAsmPrinter::lowerLOAD_TLS_BLOCK_ADDR(const MachineInstr &MI,
1038 SystemZMCInstLower &Lower) {
1039 Register AddrReg = MI.getOperand(0).getReg();
1040 const MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo();
1041
1042 // EAR can only load the low subregister so use a shift for %a0 to produce
1043 // the GR containing %a0 and %a1.
1044 const Register Reg32 =
1045 MRI.getTargetRegisterInfo()->getSubReg(AddrReg, SystemZ::subreg_l32);
1046
1047 // ear <reg>, %a0
1049 MCInstBuilder(SystemZ::EAR).addReg(Reg32).addReg(SystemZ::A0));
1050
1051 // sllg <reg>, <reg>, 32
1052 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::SLLG)
1053 .addReg(AddrReg)
1054 .addReg(AddrReg)
1055 .addReg(0)
1056 .addImm(32));
1057
1058 // ear <reg>, %a1
1060 MCInstBuilder(SystemZ::EAR).addReg(Reg32).addReg(SystemZ::A1));
1061}
1062
1063void SystemZAsmPrinter::lowerLOAD_GLOBAL_STACKGUARD_ADDR(
1064 const MachineInstr &MI, SystemZMCInstLower &Lower) {
1065 Register AddrReg = MI.getOperand(0).getReg();
1066 const MachineFunction &MF = *(MI.getParent()->getParent());
1067 const Module *M = MF.getFunction().getParent();
1068 const TargetLowering *TLI = MF.getSubtarget().getTargetLowering();
1069
1070 // Obtain the global value (assert if stack guard variable can't be found).
1071 const GlobalVariable *GV = cast<GlobalVariable>(
1072 TLI->getSDagStackGuard(*M, TLI->getLibcallLoweringInfo()));
1073
1074 // If configured, emit the `__stack_protector_loc` entry
1075 if (M->hasStackProtectorGuardRecord()) {
1076 MCSymbol *Sym = OutContext.createTempSymbol();
1077 OutStreamer->pushSection();
1078 OutStreamer->switchSection(OutContext.getELFSection(
1079 "__stack_protector_loc", ELF::SHT_PROGBITS, ELF::SHF_ALLOC));
1080 OutStreamer->emitSymbolValue(Sym, getDataLayout().getPointerSize());
1081 OutStreamer->popSection();
1082 OutStreamer->emitLabel(Sym);
1083 }
1084 // Emit the address load.
1085 if (M->getPICLevel() == PICLevel::NotPIC) {
1086 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::LARL)
1087 .addReg(AddrReg)
1088 .addExpr(MCSymbolRefExpr::create(
1089 getSymbol(GV), OutContext)));
1090 } else {
1092 MCInstBuilder(SystemZ::LGRL)
1093 .addReg(AddrReg)
1094 .addExpr(MCSymbolRefExpr::create(
1096 }
1097}
1098
1099// The *alignment* of 128-bit vector types is different between the software
1100// and hardware vector ABIs. If the there is an externally visible use of a
1101// vector type in the module it should be annotated with an attribute.
1102void SystemZAsmPrinter::emitAttributes(Module &M) {
1103 if (M.getModuleFlag("s390x-visible-vector-ABI")) {
1104 bool HasVectorFeature =
1105 TM.getMCSubtargetInfo().hasFeature(SystemZ::FeatureVector);
1106 OutStreamer->emitGNUAttribute(8, HasVectorFeature ? 2 : 1);
1107 }
1108}
1109
1110// Convert a SystemZ-specific constant pool modifier into the associated
1111// specifier.
1113 switch (Modifier) {
1114 case SystemZCP::TLSGD:
1115 return SystemZ::S_TLSGD;
1116 case SystemZCP::TLSLDM:
1117 return SystemZ::S_TLSLDM;
1118 case SystemZCP::DTPOFF:
1119 return SystemZ::S_DTPOFF;
1120 case SystemZCP::NTPOFF:
1121 return SystemZ::S_NTPOFF;
1122 }
1123 llvm_unreachable("Invalid SystemCPModifier!");
1124}
1125
1128 auto *ZCPV = static_cast<SystemZConstantPoolValue*>(MCPV);
1129
1130 const MCExpr *Expr = MCSymbolRefExpr::create(
1131 getSymbol(ZCPV->getGlobalValue()),
1132 getSpecifierFromModifier(ZCPV->getModifier()), OutContext);
1133 uint64_t Size = getDataLayout().getTypeAllocSize(ZCPV->getType());
1134
1135 OutStreamer->emitValue(Expr, Size);
1136}
1137
1138// Emit the ctor or dtor list taking into account the init priority.
1140 const Constant *List, bool IsCtor) {
1141 if (!TM.getTargetTriple().isOSBinFormatGOFF())
1142 return AsmPrinter::emitXXStructorList(DL, List, IsCtor);
1143
1144 SmallVector<Structor, 8> Structors;
1145 preprocessXXStructorList(DL, List, Structors);
1146 if (Structors.empty())
1147 return;
1148
1149 const Align Align = llvm::Align(4);
1150 const TargetLoweringObjectFileGOFF &Obj =
1151 static_cast<const TargetLoweringObjectFileGOFF &>(getObjFileLowering());
1152 for (Structor &S : Structors) {
1153 MCSectionGOFF *Section =
1154 static_cast<MCSectionGOFF *>(Obj.getStaticXtorSection(S.Priority));
1155 OutStreamer->switchSection(Section);
1156 if (OutStreamer->getCurrentSection() != OutStreamer->getPreviousSection())
1158
1159 // The priority is provided as an input to getStaticXtorSection(), and is
1160 // recalculated within that function as `Prio` going to going into the
1161 // PR section.
1162 // This priority retrieved via the `SortKey` below is the recalculated
1163 // Priority.
1164 uint32_t XtorPriority = Section->getPRAttributes().SortKey;
1165
1166 const GlobalValue *GV = dyn_cast<GlobalValue>(S.Func->stripPointerCasts());
1167 assert(GV && "C++ xxtor pointer was not a GlobalValue!");
1168 MCSymbolGOFF *Symbol = static_cast<MCSymbolGOFF *>(getSymbol(GV));
1169
1170 // @@SQINIT entry: { unsigned prio; void (*ctor)(); void (*dtor)(); }
1171
1172 unsigned PointerSizeInBytes = DL.getPointerSize();
1173
1174 auto &Ctx = OutStreamer->getContext();
1175 const MCExpr *ADAFuncRefExpr;
1176 unsigned SlotKind = SystemZII::MO_ADA_DIRECT_FUNC_DESC;
1177
1178 MCSectionGOFF *ADASection =
1179 static_cast<MCSectionGOFF *>(Obj.getADASection());
1180 assert(ADASection && "ADA section must exist for GOFF targets!");
1181 const MCSymbol *ADASym = ADASection->getBeginSymbol();
1182 assert(ADASym && "ADA symbol should already be set!");
1183
1184 ADAFuncRefExpr = MCBinaryExpr::createAdd(
1187 MCConstantExpr::create(ADATable.insert(Symbol, SlotKind), Ctx), Ctx);
1188
1189 emitInt32(XtorPriority);
1190 if (IsCtor) {
1191 OutStreamer->emitValue(ADAFuncRefExpr, PointerSizeInBytes);
1192 OutStreamer->emitIntValue(0, PointerSizeInBytes);
1193 } else {
1194 OutStreamer->emitIntValue(0, PointerSizeInBytes);
1195 OutStreamer->emitValue(ADAFuncRefExpr, PointerSizeInBytes);
1196 }
1197 }
1198}
1199
1200static void printFormattedRegName(const MCAsmInfo *MAI, unsigned RegNo,
1201 raw_ostream &OS) {
1202 const char *RegName;
1203 if (MAI->getAssemblerDialect() == AD_HLASM) {
1205 // Skip register prefix so that only register number is left
1206 assert(isalpha(RegName[0]) && isdigit(RegName[1]));
1207 OS << (RegName + 1);
1208 } else {
1210 OS << '%' << RegName;
1211 }
1212}
1213
1214static void printReg(unsigned Reg, const MCAsmInfo *MAI, raw_ostream &OS) {
1215 if (!Reg)
1216 OS << '0';
1217 else
1219}
1220
1221static void printOperand(const MCOperand &MCOp, const MCAsmInfo *MAI,
1222 raw_ostream &OS) {
1223 if (MCOp.isReg())
1224 printReg(MCOp.getReg(), MAI, OS);
1225 else if (MCOp.isImm())
1226 OS << MCOp.getImm();
1227 else if (MCOp.isExpr())
1228 MAI->printExpr(OS, *MCOp.getExpr());
1229 else
1230 llvm_unreachable("Invalid operand");
1231}
1232
1233static void printAddress(const MCAsmInfo *MAI, unsigned Base,
1234 const MCOperand &DispMO, unsigned Index,
1235 raw_ostream &OS) {
1236 printOperand(DispMO, MAI, OS);
1237 if (Base || Index) {
1238 OS << '(';
1239 if (Index) {
1240 printFormattedRegName(MAI, Index, OS);
1241 if (Base)
1242 OS << ',';
1243 }
1244 if (Base)
1246 OS << ')';
1247 }
1248}
1249
1251 const char *ExtraCode,
1252 raw_ostream &OS) {
1253 const MCRegisterInfo &MRI = TM.getMCRegisterInfo();
1254 const MachineOperand &MO = MI->getOperand(OpNo);
1255 MCOperand MCOp;
1256 if (ExtraCode) {
1257 if (ExtraCode[0] == 'N' && !ExtraCode[1] && MO.isReg() &&
1258 SystemZ::GR128BitRegClass.contains(MO.getReg()))
1259 MCOp =
1260 MCOperand::createReg(MRI.getSubReg(MO.getReg(), SystemZ::subreg_l64));
1261 else
1262 return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS);
1263 } else {
1264 SystemZMCInstLower Lower(MF->getContext(), *this);
1265 MCOp = Lower.lowerOperand(MO);
1266 }
1267 printOperand(MCOp, &MAI, OS);
1268 return false;
1269}
1270
1272 unsigned OpNo,
1273 const char *ExtraCode,
1274 raw_ostream &OS) {
1275 if (ExtraCode && ExtraCode[0] && !ExtraCode[1]) {
1276 switch (ExtraCode[0]) {
1277 case 'A':
1278 // Unlike EmitMachineNode(), EmitSpecialNode(INLINEASM) does not call
1279 // setMemRefs(), so MI->memoperands() is empty and the alignment
1280 // information is not available.
1281 return false;
1282 case 'O':
1283 OS << MI->getOperand(OpNo + 1).getImm();
1284 return false;
1285 case 'R':
1286 ::printReg(MI->getOperand(OpNo).getReg(), &MAI, OS);
1287 return false;
1288 }
1289 }
1290 printAddress(&MAI, MI->getOperand(OpNo).getReg(),
1291 MCOperand::createImm(MI->getOperand(OpNo + 1).getImm()),
1292 MI->getOperand(OpNo + 2).getReg(), OS);
1293 return false;
1294}
1295
1297 auto TT = OutContext.getTargetTriple();
1298 if (TT.isOSzOS()) {
1299 auto *ZOS = static_cast<SystemZTargetzOSStreamer *>(getTargetStreamer());
1300 emitADASection();
1301 emitIDRLSection(M);
1302 // On z/OS, we need to associate an external data reference with an ED
1303 // symbol, for which we use the the ED of the ADA. We also need to mark the
1304 // reference as being to data, otherwise we cannot bind with code generated
1305 // by XL.
1306 for (auto &GO : M.global_objects()) {
1307 if (auto *GV = dyn_cast<GlobalVariable>(&GO)) {
1308 if (!GV->hasInitializer()) {
1309 MCSymbol *Sym = getSymbol(GV);
1310 ZOS->emitADA(Sym, OutContext.getObjectFileInfo()->getADASection());
1311 OutStreamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeObject);
1312 }
1313 }
1314 }
1315 }
1316 emitAttributes(M);
1317}
1318
1319void SystemZAsmPrinter::emitADASection() {
1320 OutStreamer->pushSection();
1321
1322 const unsigned PointerSize = getDataLayout().getPointerSize();
1323 OutStreamer->switchSection(getObjFileLowering().getADASection());
1324
1325 auto *ZOS = static_cast<SystemZTargetzOSStreamer *>(getTargetStreamer());
1326 unsigned EmittedBytes = 0;
1327 for (auto &Entry : ADATable.getTable()) {
1328 const MCSymbol *Sym;
1329 unsigned SlotKind;
1330 std::tie(Sym, SlotKind) = Entry.first;
1331 unsigned Offset = Entry.second;
1332 assert(Offset == EmittedBytes && "Offset not as expected");
1333 (void)EmittedBytes;
1334#define EMIT_COMMENT(Str) \
1335 OutStreamer->AddComment(Twine("Offset ") \
1336 .concat(utostr(Offset)) \
1337 .concat(" " Str " ") \
1338 .concat(Sym->getName()));
1339 switch (SlotKind) {
1341 // Language Environment DLL logic requires function descriptors, for
1342 // imported functions, that are placed in the ADA to be 8 byte aligned.
1343 EMIT_COMMENT("function descriptor of");
1344 OutStreamer->emitValue(
1347 PointerSize);
1348 OutStreamer->emitValue(
1351 PointerSize);
1352 EmittedBytes += PointerSize * 2;
1353 break;
1355 EMIT_COMMENT("pointer to data symbol");
1356 OutStreamer->emitValue(
1359 PointerSize);
1360 EmittedBytes += PointerSize;
1361 break;
1364 Twine(Sym->getName()).concat("@indirect"));
1365 OutStreamer->emitSymbolAttribute(Alias, MCSA_IndirectSymbol);
1366 OutStreamer->emitSymbolAttribute(Alias, MCSA_ELF_TypeFunction);
1367 OutStreamer->emitSymbolAttribute(Alias, MCSA_Global);
1368 OutStreamer->emitSymbolAttribute(Alias, MCSA_Extern);
1369 MCSymbolGOFF *GOFFSym =
1370 static_cast<llvm::MCSymbolGOFF *>(const_cast<llvm::MCSymbol *>(Sym));
1371 ZOS->emitExternalName(Alias, GOFFSym->getExternalName());
1372 EMIT_COMMENT("pointer to function descriptor");
1373 OutStreamer->emitValue(
1376 PointerSize);
1377 EmittedBytes += PointerSize;
1378 break;
1379 }
1380 default:
1381 llvm_unreachable("Unexpected slot kind");
1382 }
1383#undef EMIT_COMMENT
1384 }
1385 OutStreamer->popSection();
1386}
1387
1388static std::string getProductID(Module &M) {
1389 std::string ProductID;
1390 if (auto *MD = M.getModuleFlag("zos_product_id"))
1391 ProductID = cast<MDString>(MD)->getString().str();
1392 if (ProductID.empty())
1393 ProductID = "LLVM";
1394 return ProductID;
1395}
1396
1398 if (auto *VersionVal = mdconst::extract_or_null<ConstantInt>(
1399 M.getModuleFlag("zos_product_major_version")))
1400 return VersionVal->getZExtValue();
1401 return LLVM_VERSION_MAJOR;
1402}
1403
1405 if (auto *ReleaseVal = mdconst::extract_or_null<ConstantInt>(
1406 M.getModuleFlag("zos_product_minor_version")))
1407 return ReleaseVal->getZExtValue();
1408 return LLVM_VERSION_MINOR;
1409}
1410
1412 if (auto *PatchVal = mdconst::extract_or_null<ConstantInt>(
1413 M.getModuleFlag("zos_product_patchlevel")))
1414 return PatchVal->getZExtValue();
1415 return LLVM_VERSION_PATCH;
1416}
1417
1418static time_t getTranslationTime(Module &M) {
1419 std::time_t Time = 0;
1421 M.getModuleFlag("zos_translation_time"))) {
1422 long SecondsSinceEpoch = Val->getSExtValue();
1423 Time = static_cast<time_t>(SecondsSinceEpoch);
1424 }
1425 return Time;
1426}
1427
1428void SystemZAsmPrinter::emitIDRLSection(Module &M) {
1429 OutStreamer->pushSection();
1430 OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
1431 constexpr unsigned IDRLDataLength = 30;
1432 std::time_t Time = getTranslationTime(M);
1433
1434 uint32_t ProductVersion = getProductVersion(M);
1435 uint32_t ProductRelease = getProductRelease(M);
1436
1437 std::string ProductID = getProductID(M);
1438
1439 SmallString<IDRLDataLength + 1> TempStr;
1440 raw_svector_ostream O(TempStr);
1441 O << formatv("{0,-10}{1,0-2:d}{2,0-2:d}{3:%Y%m%d%H%M%S}{4,0-2}",
1442 ProductID.substr(0, 10).c_str(), ProductVersion, ProductRelease,
1443 llvm::sys::toUtcTime(Time), "0");
1444 SmallString<IDRLDataLength> Data;
1446
1447 OutStreamer->emitInt8(0); // Reserved.
1448 OutStreamer->emitInt8(3); // Format.
1449 OutStreamer->emitInt16(IDRLDataLength); // Length.
1450 OutStreamer->emitBytes(Data.str());
1451 OutStreamer->popSection();
1452}
1453
1455 if (TM.getTargetTriple().isOSzOS()) {
1456 // Emit symbol for the end of function if the z/OS target streamer
1457 // is used. This is needed to calculate the size of the function.
1458 auto *ZOS = static_cast<SystemZTargetzOSStreamer *>(getTargetStreamer());
1459 OutStreamer->emitLabel(ZOS->DeferredPPA1.back().FnEnd);
1460 }
1461}
1462
1463// Determine the end of the prolog and the instructions which updates the stack
1464// register, and attach symbols to those instructions.
1466 MCSymbol *&EndOfPrologSym,
1467 MCSymbol *&StackUpdateSym) {
1468 EndOfPrologSym = nullptr;
1469 StackUpdateSym = nullptr;
1470
1471 // Scan the basic block for the FENCE instruction which marks the end
1472 // of the prologue. We know
1473 // the prologue is spread at most across the first 3 basic blocks. Also record
1474 // the first instruction updating the stack pointer.
1477 MachineInstr *EndOfPrologMI = nullptr;
1478 MachineInstr *StackUpdateMI = nullptr;
1479 unsigned BBCount = 1;
1480
1481 for (auto &MBB : *MF) {
1482 for (auto &I : MBB) {
1483 if (I.getOpcode() == SystemZ::FENCE)
1484 EndOfPrologMI = &I;
1485 else if (!StackUpdateMI) {
1486 unsigned Opcode = I.getOpcode();
1487 // TODO: We can instead emit a pseudo instruction in
1488 // SystemZFrameLowering to represent a stack adjustment instruction, and
1489 // check for that here, instead of having to check for multiple
1490 // instructions.
1491 if ((Opcode == SystemZ::AGHI || Opcode == SystemZ::AGFI) &&
1492 I.getOperand(0).getReg() == Regs.getStackPointerRegister())
1493 StackUpdateMI = &I;
1494 }
1495 }
1496
1497 // Prologue can be a max of 3 BBs if we need to call stack extension code
1498 if (EndOfPrologMI || BBCount == 3)
1499 break;
1500
1501 ++BBCount;
1502 }
1503
1504 // Leaf functions do not have a prologue.
1505 if (EndOfPrologMI == nullptr)
1506 return;
1507
1508#ifdef EXPENSIVE_CHECKS
1509 // Check that the prolog length is valid.
1510 auto *TII = STI.getInstrInfo();
1511 size_t Size = 0;
1512
1513 for (auto &MBB : *MF) {
1514 bool TerminateLoop = false;
1515 for (auto &I : MBB) {
1516 Size += TII->getInstSizeInBytes(I);
1517 if (&I == EndOfPrologMI) {
1518 TerminateLoop = true;
1519 break;
1520 }
1521 }
1522 if (TerminateLoop)
1523 break;
1524 }
1525 if (Size > 128)
1527 Twine(MF->getName()).concat(": Prolog exceeds 128 bytes"));
1528#endif
1529
1530 // Attach a temporary symbol to mark the end of the prolog.
1531 EndOfPrologSym = MF->getContext().createTempSymbol("end_of_prologue");
1532 EndOfPrologMI->setPostInstrSymbol(*MF, EndOfPrologSym);
1533
1534 if (StackUpdateMI) {
1535 StackUpdateSym = MF->getContext().createTempSymbol("stack_update");
1536 StackUpdateMI->setPreInstrSymbol(*MF, StackUpdateSym);
1537 }
1538}
1539
1540void SystemZAsmPrinter::calculatePPA1() {
1541 auto *ZOS = static_cast<SystemZTargetzOSStreamer *>(getTargetStreamer());
1542 assert(ZOS->PPA2Sym != nullptr && "PPA2 Symbol not defined");
1543
1544 SystemZTargetzOSStreamer::PPA1Info Info;
1545
1546 const TargetRegisterInfo *TRI = MF->getRegInfo().getTargetRegisterInfo();
1547 const SystemZSubtarget &Subtarget = MF->getSubtarget<SystemZSubtarget>();
1548
1549 const SystemZMachineFunctionInfo *ZFI =
1550 MF->getInfo<SystemZMachineFunctionInfo>();
1551 const auto *ZFL = static_cast<const SystemZXPLINKFrameLowering *>(
1552 Subtarget.getFrameLowering());
1553 const MachineFrameInfo &MFFrame = MF->getFrameInfo();
1554
1555 // Get saved GPR/FPR/VPR masks.
1556 const std::vector<CalleeSavedInfo> &CSI = MFFrame.getCalleeSavedInfo();
1557 uint16_t SavedGPRMask = 0;
1558 uint16_t SavedFPRMask = 0;
1559 uint8_t SavedVRMask = 0;
1560 int64_t OffsetFPR = 0;
1561 int64_t OffsetVR = 0;
1562 const int64_t TopOfStack =
1563 MFFrame.getOffsetAdjustment() + MFFrame.getStackSize();
1564
1565 // Loop over the spilled registers. The CalleeSavedInfo can't be used because
1566 // it does not contain all spilled registers.
1567 for (unsigned I = ZFI->getSpillGPRRegs().LowGPR,
1568 E = ZFI->getSpillGPRRegs().HighGPR;
1569 I && E && I <= E; ++I) {
1570 unsigned V = TRI->getEncodingValue((Register)I);
1571 assert(V < 16 && "GPR index out of range");
1572 SavedGPRMask |= 1 << (15 - V);
1573 }
1574
1575 for (auto &CS : CSI) {
1576 unsigned Reg = CS.getReg();
1577 unsigned I = TRI->getEncodingValue(Reg);
1578
1579 if (SystemZ::FP64BitRegClass.contains(Reg)) {
1580 assert(I < 16 && "FPR index out of range");
1581 SavedFPRMask |= 1 << (15 - I);
1582 int64_t Temp = MFFrame.getObjectOffset(CS.getFrameIdx());
1583 if (Temp < OffsetFPR)
1584 OffsetFPR = Temp;
1585 } else if (SystemZ::VR128BitRegClass.contains(Reg)) {
1586 assert(I >= 16 && I <= 23 && "VPR index out of range");
1587 unsigned BitNum = I - 16;
1588 SavedVRMask |= 1 << (7 - BitNum);
1589 int64_t Temp = MFFrame.getObjectOffset(CS.getFrameIdx());
1590 if (Temp < OffsetVR)
1591 OffsetVR = Temp;
1592 }
1593 }
1594
1595 // Adjust the offset.
1596 OffsetFPR += (OffsetFPR < 0) ? TopOfStack : 0;
1597 OffsetVR += (OffsetVR < 0) ? TopOfStack : 0;
1598
1599 // Get alloca register.
1600 uint8_t FrameReg = TRI->getEncodingValue(TRI->getFrameRegister(*MF));
1601 uint8_t AllocaReg = ZFL->hasFP(*MF) ? FrameReg : 0;
1602 assert(AllocaReg < 16 && "Can't have alloca register larger than 15");
1603
1604 MCSymbol *PersonalityRoutine = nullptr;
1605 MCSymbol *GCCEH = nullptr;
1606 uint64_t PersonalityADADisp = 0;
1607 uint64_t GCCEHADADisp = 0;
1608 if (!MF->getLandingPads().empty()) {
1609 const Function *Per = dyn_cast<Function>(
1610 MF->getFunction().getPersonalityFn()->stripPointerCasts());
1611 PersonalityRoutine = Per ? MF->getTarget().getSymbol(Per) : nullptr;
1612 assert(PersonalityRoutine && "Missing personality routine");
1613
1614 GCCEH = MF->getContext().getOrCreateSymbol(Twine("GCC_except_table") +
1615 Twine(MF->getFunctionNumber()));
1616 PersonalityADADisp = ADATable.insert(PersonalityRoutine,
1618 GCCEHADADisp = ADATable.insert(GCCEH, SystemZII::MO_ADA_DATA_SYMBOL_ADDR);
1619 }
1620
1621 // Get the name of the function, with suffix _.
1622 std::string N(MF->getFunction().hasName()
1623 ? Twine(MF->getFunction().getName()).concat("_").str()
1624 : "");
1625
1626 // Calculate the lables for the prolog size and the stack update symbol.
1627 MCSymbol *EndOfPrologSym;
1628 MCSymbol *StackUpdateSym;
1629 determinePrologueStackUpdateSym(MF, EndOfPrologSym, StackUpdateSym);
1630
1631 // Save the calculated values.
1632 if (MF->getFunction().hasFnAttribute("zos-ppa1-name"))
1633 Info.Name =
1634 MF->getFunction().getFnAttribute("zos-ppa1-name").getValueAsString();
1635 else if (MF->getFunction().hasName())
1636 Info.Name = MF->getFunction().getName();
1637
1638 Info.PPA1 = OutContext.createTempSymbol(Twine("PPA1_").concat(N), true);
1639 Info.EPMarker = OutContext.createTempSymbol(Twine("EPM_").concat(N), true);
1640 Info.FnEnd = OutContext.createTempSymbol(Twine(N).concat("end_"));
1641 Info.Fn = CurrentFnSym;
1642 Info.EndOfProlog = EndOfPrologSym;
1643 Info.StackUpdate = StackUpdateSym;
1644 Info.PersonalityADADisp = PersonalityADADisp;
1645 Info.GCCEHADADisp = GCCEHADADisp;
1646 Info.OffsetFPR = OffsetFPR;
1647 Info.OffsetVR = OffsetVR;
1648 Info.CallFrameSize = MFFrame.getMaxCallFrameSize();
1649 Info.SizeOfFnParams = ZFI->getSizeOfFnParams();
1650 Info.SavedGPRMask = SavedGPRMask;
1651 Info.SavedFPRMask = SavedFPRMask;
1652 Info.SavedVRMask = SavedVRMask;
1653 Info.FrameReg = FrameReg;
1654 Info.AllocaReg = AllocaReg;
1655 Info.IsVarArg = MF->getFunction().isVarArg();
1656 Info.HasStackProtector = MFFrame.hasStackProtectorIndex();
1657
1658 ZOS->DeferredPPA1.push_back(Info);
1659}
1660
1662 if (TM.getTargetTriple().isOSzOS())
1663 emitPPA2(M);
1665}
1666
1667void SystemZAsmPrinter::emitPPA2(Module &M) {
1668 auto *ZOS = static_cast<SystemZTargetzOSStreamer *>(getTargetStreamer());
1669 OutStreamer->pushSection();
1670 OutStreamer->switchSection(getObjFileLowering().getTextSection());
1671 MCContext &OutContext = OutStreamer->getContext();
1672 // Make CELQSTRT symbol.
1673 const char *StartSymbolName = "CELQSTRT";
1674 MCSymbol *CELQSTRT = OutContext.getOrCreateSymbol(StartSymbolName);
1675 OutStreamer->emitSymbolAttribute(CELQSTRT, MCSA_OSLinkage);
1676 OutStreamer->emitSymbolAttribute(CELQSTRT, MCSA_Global);
1677
1678 // Create symbol and assign to streamer field for use in PPA1.
1679 ZOS->PPA2Sym = OutContext.createTempSymbol("PPA2", false);
1680 MCSymbol *PPA2Sym = ZOS->PPA2Sym;
1681 MCSymbol *DateVersionSym = OutContext.createTempSymbol("DVS", false);
1682
1683 std::time_t Time = getTranslationTime(M);
1684 SmallString<14> CompilationTimeEBCDIC, CompilationTime;
1685 CompilationTime = formatv("{0:%Y%m%d%H%M%S}", llvm::sys::toUtcTime(Time));
1686
1687 uint32_t ProductVersion = getProductVersion(M),
1688 ProductRelease = getProductRelease(M),
1689 ProductPatch = getProductPatch(M);
1690
1691 SmallString<6> VersionEBCDIC, Version;
1692 Version = formatv("{0,0-2:d}{1,0-2:d}{2,0-2:d}", ProductVersion,
1693 ProductRelease, ProductPatch);
1694
1695 ConverterEBCDIC::convertToEBCDIC(CompilationTime, CompilationTimeEBCDIC);
1697
1698 enum class PPA2MemberId : uint8_t {
1699 // See z/OS Language Environment Vendor Interfaces v2r5, p.23, for
1700 // complete list. Only the C runtime is supported by this backend.
1701 LE_C_Runtime = 3,
1702 };
1703 enum class PPA2MemberSubId : uint8_t {
1704 // List of languages using the LE C runtime implementation.
1705 C = 0x00,
1706 CXX = 0x01,
1707 Swift = 0x03,
1708 Go = 0x60,
1709 LLVMBasedLang = 0xe7,
1710 };
1711 // PPA2 Flags
1712 enum class PPA2Flags : uint8_t {
1713 CompileForBinaryFloatingPoint = 0x80,
1714 CompiledWithXPLink = 0x01,
1715 CompiledUnitASCII = 0x04,
1716 HasServiceInfo = 0x20,
1717 };
1718
1719 PPA2MemberSubId MemberSubId = PPA2MemberSubId::LLVMBasedLang;
1720 if (auto *MD = M.getModuleFlag("zos_cu_language")) {
1721 StringRef Language = cast<MDString>(MD)->getString();
1722 MemberSubId = StringSwitch<PPA2MemberSubId>(Language)
1723 .Case("C", PPA2MemberSubId::C)
1724 .Case("C++", PPA2MemberSubId::CXX)
1725 .Case("Swift", PPA2MemberSubId::Swift)
1726 .Case("Go", PPA2MemberSubId::Go)
1727 .Default(PPA2MemberSubId::LLVMBasedLang);
1728 }
1729
1730 // Emit PPA2 section.
1731 OutStreamer->emitLabel(PPA2Sym);
1732 OutStreamer->emitInt8(static_cast<uint8_t>(PPA2MemberId::LE_C_Runtime));
1733 OutStreamer->emitInt8(static_cast<uint8_t>(MemberSubId));
1734 OutStreamer->emitInt8(0x22); // Member defined, c370_plist+c370_env
1735 OutStreamer->emitInt8(0x04); // Control level 4 (XPLink)
1736 OutStreamer->emitAbsoluteSymbolDiff(CELQSTRT, PPA2Sym, 4);
1737 OutStreamer->emitInt32(0x00000000);
1738 OutStreamer->emitAbsoluteSymbolDiff(DateVersionSym, PPA2Sym, 4);
1739 OutStreamer->emitInt32(
1740 0x00000000); // Offset to main entry point, always 0 (so says TR).
1741 uint8_t Flgs = static_cast<uint8_t>(PPA2Flags::CompileForBinaryFloatingPoint);
1742 Flgs |= static_cast<uint8_t>(PPA2Flags::CompiledWithXPLink);
1743
1744 bool IsASCII = true;
1745 if (auto *MD = M.getModuleFlag("zos_le_char_mode")) {
1746 const StringRef &CharMode = cast<MDString>(MD)->getString();
1747 if (CharMode == "ebcdic")
1748 IsASCII = false;
1749 else if (CharMode != "ascii")
1750 OutContext.reportError(
1751 {}, "Only ascii or ebcdic are allowed for zos_le_char_mode");
1752 }
1753 if (IsASCII)
1754 Flgs |= static_cast<uint8_t>(
1755 PPA2Flags::CompiledUnitASCII); // Setting bit for ASCII char. mode.
1756
1757 OutStreamer->emitInt8(Flgs);
1758 OutStreamer->emitInt8(0x00); // Reserved.
1759 // No MD5 signature before timestamp.
1760 // No FLOAT(AFP(VOLATILE)).
1761 // Remaining 5 flag bits reserved.
1762 OutStreamer->emitInt16(0x0000); // 16 Reserved flag bits.
1763
1764 // Emit date and version section.
1765 OutStreamer->emitLabel(DateVersionSym);
1766 OutStreamer->emitBytes(CompilationTimeEBCDIC.str());
1767 OutStreamer->emitBytes(VersionEBCDIC.str());
1768
1769 OutStreamer->emitInt16(0x0000); // Service level string length.
1770
1771 // The binder requires that the offset to the PPA2 be emitted in a different,
1772 // specially-named section.
1773 OutStreamer->switchSection(getObjFileLowering().getPPA2ListSection());
1774 // Emit 8 byte alignment.
1775 // Emit pointer to PPA2 label.
1776 OutStreamer->AddComment("A(PPA2-CELQSTRT)");
1777 OutStreamer->emitAbsoluteSymbolDiff(PPA2Sym, CELQSTRT, 8);
1778 OutStreamer->popSection();
1779}
1780
1782 const GlobalAlias &GA) {
1783 if (!TM.getTargetTriple().isOSzOS())
1784 return AsmPrinter::emitGlobalAlias(M, GA);
1785
1786 // Aliased function labels have already been emitted for z/OS
1787}
1788
1790 const Constant *BaseCV,
1791 uint64_t Offset) {
1792 const Triple &TargetTriple = TM.getTargetTriple();
1793
1794 if (TargetTriple.isOSzOS()) {
1795 const GlobalAlias *GA = dyn_cast<GlobalAlias>(CV);
1797 const Function *FV = dyn_cast<Function>(CV);
1798 bool IsFunc = !GV && (FV || (GA && isa<Function>(GA->getAliaseeObject())));
1799
1800 MCSymbol *Sym = NULL;
1801
1802 if (GA)
1803 Sym = getSymbol(GA);
1804 else if (IsFunc)
1805 Sym = getSymbol(FV);
1806 else if (GV)
1807 Sym = getSymbol(GV);
1808
1809 if (IsFunc) {
1810 OutStreamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeFunction);
1811 if (FV->hasExternalLinkage())
1814 // Trigger creation of function descriptor in ADA for internal
1815 // functions.
1816 unsigned Disp = ADATable.insert(Sym, SystemZII::MO_ADA_DIRECT_FUNC_DESC);
1820 getObjFileLowering().getADASection()->getBeginSymbol(),
1821 OutContext),
1824 }
1825 if (Sym) {
1826 OutStreamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeObject);
1828 }
1829 }
1830 return AsmPrinter::lowerConstant(CV);
1831}
1832
1834 const SystemZSubtarget &Subtarget = MF->getSubtarget<SystemZSubtarget>();
1835
1836 if (Subtarget.getTargetTriple().isOSzOS()) {
1837 auto *ZOS = static_cast<SystemZTargetzOSStreamer *>(getTargetStreamer());
1838 calculatePPA1();
1839
1840 // EntryPoint Marker
1841 const MachineFrameInfo &MFFrame = MF->getFrameInfo();
1842 bool IsUsingAlloca = MFFrame.hasVarSizedObjects();
1843 uint32_t DSASize = MFFrame.getStackSize();
1844 bool IsLeaf = DSASize == 0 && MFFrame.getCalleeSavedInfo().empty();
1845
1846 // Set Flags.
1847 uint8_t Flags = 0;
1848 if (IsLeaf)
1849 Flags |= 0x08;
1850 if (IsUsingAlloca)
1851 Flags |= 0x04;
1852
1853 // Combine into top 27 bits of DSASize and bottom 5 bits of Flags.
1854 uint32_t DSAAndFlags = DSASize & 0xFFFFFFE0; // (x/32) << 5
1855 DSAAndFlags |= Flags;
1856
1857 // Emit entry point marker section.
1858 OutStreamer->AddComment("XPLINK Routine Layout Entry");
1859 OutStreamer->emitLabel(ZOS->DeferredPPA1.back().EPMarker);
1860 OutStreamer->AddComment("Eyecatcher 0x00C300C500C500");
1861 OutStreamer->emitIntValueInHex(0x00C300C500C500, 7); // Eyecatcher.
1862 OutStreamer->AddComment("Mark Type C'1'");
1863 OutStreamer->emitInt8(0xF1); // Mark Type.
1864 OutStreamer->AddComment("Offset to PPA1");
1865 OutStreamer->emitAbsoluteSymbolDiff(ZOS->DeferredPPA1.back().PPA1,
1866 ZOS->DeferredPPA1.back().EPMarker, 4);
1867 if (OutStreamer->isVerboseAsm()) {
1868 OutStreamer->AddComment("DSA Size 0x" + Twine::utohexstr(DSASize));
1869 OutStreamer->AddComment("Entry Flags");
1870 if (Flags & 0x08)
1871 OutStreamer->AddComment(" Bit 1: 1 = Leaf function");
1872 else
1873 OutStreamer->AddComment(" Bit 1: 0 = Non-leaf function");
1874 if (Flags & 0x04)
1875 OutStreamer->AddComment(" Bit 2: 1 = Uses alloca");
1876 else
1877 OutStreamer->AddComment(" Bit 2: 0 = Does not use alloca");
1878 }
1879 OutStreamer->emitInt32(DSAAndFlags);
1880
1881 ZOS->emitADA(CurrentFnSym, getObjFileLowering().getADASection());
1882 }
1883
1885
1886 if (Subtarget.getTargetTriple().isOSzOS()) {
1887 const Function *F = &MF->getFunction();
1888 // Emit aliasing label for function entry point label.
1889 for (const GlobalAlias *Alias : GOAliasMap[F]) {
1890 MCSymbol *Sym = getSymbol(Alias);
1891 OutStreamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeFunction);
1892 emitVisibility(Sym, Alias->getVisibility());
1893 emitLinkage(Alias, Sym);
1894 OutStreamer->emitLabel(Sym);
1895 }
1896 }
1897}
1898
1899char SystemZAsmPrinter::ID = 0;
1900
1901INITIALIZE_PASS(SystemZAsmPrinter, "systemz-asm-printer",
1902 "SystemZ Assembly Printer", false, false)
1903
1904// Force static initialization.
1905extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void
1906LLVMInitializeSystemZAsmPrinter() {
1908}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
#define X(NUM, ENUM, NAME)
Definition ELF.h:856
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
This file provides utility functions for converting between EBCDIC-1047 and UTF-8.
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
#define RegName(no)
This file contains the MCSymbolGOFF class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Machine Check Debug Module
Register Reg
Register const TargetRegisterInfo * TRI
Promote Memory to Register
Definition Mem2Reg.cpp:110
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:484
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
This file contains some functions that are useful when dealing with strings.
static MCInst lowerVecEltExtraction(const MachineInstr *MI, unsigned Opcode)
static uint8_t getSpecifierFromModifier(SystemZCP::SystemZCPModifier Modifier)
#define LOWER_LOW(NAME)
static void lowerAlignmentHint(const MachineInstr *MI, MCInst &LoweredMI, unsigned Opcode)
#define EMIT_COMMENT(Str)
static void determinePrologueStackUpdateSym(MachineFunction *MF, MCSymbol *&EndOfPrologSym, MCSymbol *&StackUpdateSym)
static const MCSymbolRefExpr * getGlobalOffsetTable(MCContext &Context)
#define LOWER_HIGH(NAME)
static void printFormattedRegName(const MCAsmInfo *MAI, unsigned RegNo, raw_ostream &OS)
static MCInst lowerRILow(const MachineInstr *MI, unsigned Opcode)
static uint32_t getProductVersion(Module &M)
static std::string getProductID(Module &M)
static MCInst lowerRIHigh(const MachineInstr *MI, unsigned Opcode)
static void printAddress(const MCAsmInfo *MAI, unsigned Base, const MCOperand &DispMO, unsigned Index, raw_ostream &OS)
static time_t getTranslationTime(Module &M)
static const MCSymbolRefExpr * getTLSGetOffset(MCContext &Context)
static MCInst lowerSubvectorStore(const MachineInstr *MI, unsigned Opcode)
static unsigned EmitNop(MCContext &OutContext, MCStreamer &OutStreamer, unsigned NumBytes, const MCSubtargetInfo &STI)
static MCInst lowerVecEltInsertion(const MachineInstr *MI, unsigned Opcode)
static uint32_t getProductRelease(Module &M)
static MCInst lowerSubvectorLoad(const MachineInstr *MI, unsigned Opcode)
static uint32_t getProductPatch(Module &M)
static MCInst lowerRIEfLow(const MachineInstr *MI, unsigned Opcode)
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
MCSymbol * getSymbol(const GlobalValue *GV) const
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:94
virtual void emitGlobalAlias(const Module &M, const GlobalAlias &GA)
Align emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
MachineFunction * MF
The current machine function.
Definition AsmPrinter.h:109
virtual const MCExpr * lowerConstant(const Constant *CV, const Constant *BaseCV=nullptr, uint64_t Offset=0)
Lower the specified LLVM Constant to an MCExpr.
virtual void emitStartOfAsmFile(Module &)
This virtual method can be overridden by targets that want to emit something at the start of their fi...
Definition AsmPrinter.h:614
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
virtual void emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const
This emits linkage information about GVSym based on GV, if this is supported by the target.
MCSymbol * CurrentFnSym
The symbol for the current function.
Definition AsmPrinter.h:128
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition AsmPrinter.h:101
virtual void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor)
This method emits llvm.global_ctors or llvm.global_dtors list.
void emitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition=true) const
This emits visibility information about symbol, if this is supported by the target.
void emitInt32(int Value) const
Emit a long directive and value.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition AsmPrinter.h:106
const MCAsmInfo & MAI
Target Asm Printer information.
Definition AsmPrinter.h:97
void preprocessXXStructorList(const DataLayout &DL, const Constant *List, SmallVector< Structor, 8 > &Structors)
This method gathers an array of Structors and then sorts them out by Priority.
unsigned getPointerSize() const
Return the pointer size from the TargetMachine.
const DataLayout & getDataLayout() const
Return information about data layout.
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
This is an important base class in LLVM.
Definition Constant.h:43
const Constant * stripPointerCasts() const
Definition Constant.h:233
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
LLVM_ABI TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
LLVM_ABI unsigned getPointerSize(unsigned AS=0) const
The pointer representation size in bytes, rounded up to a whole number of bytes.
LLVM_ABI const GlobalObject * getAliaseeObject() const
Definition Globals.cpp:730
bool hasExternalLinkage() const
LLVM_ABI const GlobalObject * getAliaseeObject() const
Definition Globals.cpp:521
bool hasInitializer() const
Definitions have initializers, declarations don't.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:66
unsigned getAssemblerDialect() const
Definition MCAsmInfo.h:576
void printExpr(raw_ostream &, const MCExpr &) const
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:342
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition MCExpr.cpp:212
Context object for machine code objects.
Definition MCContext.h:83
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition MCContext.h:550
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
MCInstBuilder & addReg(MCRegister Reg)
Add a new register operand.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
MCInstBuilder & addExpr(const MCExpr *Val)
Add a new MCExpr operand.
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
void addOperand(const MCOperand Op)
Definition MCInst.h:215
void setOpcode(unsigned Op)
Definition MCInst.h:201
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:40
int64_t getImm() const
Definition MCInst.h:84
static MCOperand createReg(MCRegister Reg)
Definition MCInst.h:138
static MCOperand createImm(int64_t Val)
Definition MCInst.h:145
bool isImm() const
Definition MCInst.h:66
bool isReg() const
Definition MCInst.h:65
MCRegister getReg() const
Returns the register number.
Definition MCInst.h:73
const MCExpr * getExpr() const
Definition MCInst.h:118
bool isExpr() const
Definition MCInst.h:69
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
MCRegister getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo.
MCSymbol * getBeginSymbol()
Definition MCSection.h:646
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.cpp:743
Streaming machine code generation interface.
Definition MCStreamer.h:222
Generic base class for all target subtargets.
StringRef getExternalName() const
Represent a reference to a symbol from inside an expression.
Definition MCExpr.h:190
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:213
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
StringRef getName() const
getName - Get the symbol name.
Definition MCSymbol.h:188
MachineInstrBundleIterator< const MachineInstr > const_iterator
Abstract base class for all machine specific constantpool value subclasses.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
uint64_t getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
int64_t getOffsetAdjustment() const
Return the correction for frame offsets.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
bool hasStackProtectorIndex() const
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MCContext & getContext() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Representation of each machine instruction.
ArrayRef< MachineMemOperand * >::iterator mmo_iterator
LLVM_ABI void setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just prior to the instruction itself.
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
int64_t getImm() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
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.
@ MO_GlobalAddress
Address of a global value.
@ MO_ExternalSymbol
Name of external global symbol.
const TargetRegisterInfo * getTargetRegisterInfo() const
iterator find(const KeyT &Key)
Definition MapVector.h:156
iterator end()
Definition MapVector.h:69
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Wrapper class representing virtual and physical registers.
Definition Register.h:20
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
StringRef str() const
Explicit conversion to StringRef.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override
void emitFunctionBodyEnd() override
Targets can override this to emit stuff after the last basic block in the function.
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
void emitInstruction(const MachineInstr *MI) override
Targets should implement this to emit instructions.
void emitGlobalAlias(const Module &M, const GlobalAlias &GA) override
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
void emitFunctionEntryLabel() override
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
const MCExpr * lowerConstant(const Constant *CV, const Constant *BaseCV=nullptr, uint64_t Offset=0) override
Lower the specified LLVM Constant to an MCExpr.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
void emitXXStructorList(const DataLayout &DL, const Constant *List, bool IsCtor) override
This method emits llvm.global_ctors or llvm.global_dtors list.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
A SystemZ-specific constant pool value.
static const char * getRegisterName(MCRegister Reg)
static const char * getRegisterName(MCRegister Reg)
const SystemZInstrInfo * getInstrInfo() const override
const TargetFrameLowering * getFrameLowering() const override
SystemZCallingConventionRegisters * getSpecialRegisters() const
std::pair< MCInst, const MCSubtargetInfo * > MCInstSTIPair
XPLINK64 calling convention specific use registers Particular to z/OS when in 64 bit mode.
const LibcallLoweringInfo & getLibcallLoweringInfo() const
virtual Value * getSDagStackGuard(const Module &M, const LibcallLoweringInfo &Libcalls) const
Return the variable that's previously inserted by insertSSPDeclarations, if any, otherwise return nul...
MCSymbol * getSymbol(const GlobalValue *GV) const
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
bool isOSzOS() const
Definition Triple.h:706
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
Twine concat(const Twine &Suffix) const
Definition Twine.h:497
static Twine utohexstr(uint64_t Val)
Definition Twine.h:385
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Language[]
Key for Kernel::Metadata::mLanguage.
@ Swift
Calling convention for Swift.
Definition CallingConv.h:69
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
LLVM_ABI std::error_code convertToEBCDIC(StringRef Source, SmallVectorImpl< char > &Result)
@ SHF_ALLOC
Definition ELF.h:1256
@ SHT_PROGBITS
Definition ELF.h:1155
unsigned getRegAsGR32(unsigned Reg)
const unsigned GR64Regs[16]
unsigned getRegAsGRH32(unsigned Reg)
unsigned getRegAsVR128(unsigned Reg)
unsigned getRegAsGR64(unsigned Reg)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
Definition Metadata.h:683
UtcTime< std::chrono::seconds > toUtcTime(std::time_t T)
Convert a std::time_t to a UtcTime.
Definition Chrono.h:44
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheSystemZTarget()
@ Offset
Definition DWP.cpp:573
@ Length
Definition DWP.cpp:573
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
@ ZOS
z/OS MVS Exception Handling.
Definition CodeGen.h:61
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
Definition STLExtras.h:1151
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
@ MCSA_OSLinkage
symbol uses OS linkage (GOFF)
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
@ MCSA_Global
.type _foo, @gnu_unique_object
@ MCSA_Extern
.extern (XCOFF)
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
llvm.global_ctors and llvm.global_dtors are arrays of Structor structs.
Definition AsmPrinter.h:547
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...