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"
27#include "llvm/IR/Mangler.h"
28#include "llvm/IR/Module.h"
30#include "llvm/MC/MCExpr.h"
33#include "llvm/MC/MCStreamer.h"
36#include "llvm/Support/Chrono.h"
40
41using namespace llvm;
42
43// Return an RI instruction like MI with opcode Opcode, but with the
44// GR64 register operands turned into GR32s.
45static MCInst lowerRILow(const MachineInstr *MI, unsigned Opcode) {
46 if (MI->isCompare())
47 return MCInstBuilder(Opcode)
48 .addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
49 .addImm(MI->getOperand(1).getImm());
50 else
51 return MCInstBuilder(Opcode)
52 .addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
53 .addReg(SystemZMC::getRegAsGR32(MI->getOperand(1).getReg()))
54 .addImm(MI->getOperand(2).getImm());
55}
56
57// Return an RI instruction like MI with opcode Opcode, but with the
58// GR64 register operands turned into GRH32s.
59static MCInst lowerRIHigh(const MachineInstr *MI, unsigned Opcode) {
60 if (MI->isCompare())
61 return MCInstBuilder(Opcode)
62 .addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
63 .addImm(MI->getOperand(1).getImm());
64 else
65 return MCInstBuilder(Opcode)
66 .addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
67 .addReg(SystemZMC::getRegAsGRH32(MI->getOperand(1).getReg()))
68 .addImm(MI->getOperand(2).getImm());
69}
70
71// Return an RI instruction like MI with opcode Opcode, but with the
72// R2 register turned into a GR64.
73static MCInst lowerRIEfLow(const MachineInstr *MI, unsigned Opcode) {
74 return MCInstBuilder(Opcode)
75 .addReg(MI->getOperand(0).getReg())
76 .addReg(MI->getOperand(1).getReg())
77 .addReg(SystemZMC::getRegAsGR64(MI->getOperand(2).getReg()))
78 .addImm(MI->getOperand(3).getImm())
79 .addImm(MI->getOperand(4).getImm())
80 .addImm(MI->getOperand(5).getImm());
81}
82
83static const MCSymbolRefExpr *getTLSGetOffset(MCContext &Context) {
84 StringRef Name = "__tls_get_offset";
85 return MCSymbolRefExpr::create(Context.getOrCreateSymbol(Name),
86 SystemZ::S_PLT, Context);
87}
88
90 StringRef Name = "_GLOBAL_OFFSET_TABLE_";
91 return MCSymbolRefExpr::create(Context.getOrCreateSymbol(Name),
92 Context);
93}
94
95// MI is an instruction that accepts an optional alignment hint,
96// and which was already lowered to LoweredMI. If the alignment
97// of the original memory operand is known, update LoweredMI to
98// an instruction with the corresponding hint set.
99static void lowerAlignmentHint(const MachineInstr *MI, MCInst &LoweredMI,
100 unsigned Opcode) {
101 if (MI->memoperands_empty())
102 return;
103
104 Align Alignment = Align(16);
105 for (MachineInstr::mmo_iterator MMOI = MI->memoperands_begin(),
106 EE = MI->memoperands_end(); MMOI != EE; ++MMOI)
107 if ((*MMOI)->getAlign() < Alignment)
108 Alignment = (*MMOI)->getAlign();
109
110 unsigned AlignmentHint = 0;
111 if (Alignment >= Align(16))
112 AlignmentHint = 4;
113 else if (Alignment >= Align(8))
114 AlignmentHint = 3;
115 if (AlignmentHint == 0)
116 return;
117
118 LoweredMI.setOpcode(Opcode);
119 LoweredMI.addOperand(MCOperand::createImm(AlignmentHint));
120}
121
122// MI loads the high part of a vector from memory. Return an instruction
123// that uses replicating vector load Opcode to do the same thing.
124static MCInst lowerSubvectorLoad(const MachineInstr *MI, unsigned Opcode) {
125 return MCInstBuilder(Opcode)
126 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
127 .addReg(MI->getOperand(1).getReg())
128 .addImm(MI->getOperand(2).getImm())
129 .addReg(MI->getOperand(3).getReg());
130}
131
132// MI stores the high part of a vector to memory. Return an instruction
133// that uses elemental vector store Opcode to do the same thing.
134static MCInst lowerSubvectorStore(const MachineInstr *MI, unsigned Opcode) {
135 return MCInstBuilder(Opcode)
136 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
137 .addReg(MI->getOperand(1).getReg())
138 .addImm(MI->getOperand(2).getImm())
139 .addReg(MI->getOperand(3).getReg())
140 .addImm(0);
141}
142
143// MI extracts the first element of the source vector.
144static MCInst lowerVecEltExtraction(const MachineInstr *MI, unsigned Opcode) {
145 return MCInstBuilder(Opcode)
146 .addReg(SystemZMC::getRegAsGR64(MI->getOperand(0).getReg()))
147 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(1).getReg()))
148 .addReg(0)
149 .addImm(0);
150}
151
152// MI inserts value into the first element of the destination vector.
153static MCInst lowerVecEltInsertion(const MachineInstr *MI, unsigned Opcode) {
154 return MCInstBuilder(Opcode)
155 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
156 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
157 .addReg(MI->getOperand(1).getReg())
158 .addReg(0)
159 .addImm(0);
160}
161
163 SM.reset();
164
165 // In HLASM, the only way to represent aliases is to use the
166 // extra-label-at-definition strategy. This is similar to the AIX
167 // implementation with the additional caveat that all symbol attributes must
168 // be emitted before the label is emitted.
169 if (TM.getTargetTriple().isOSzOS()) {
170 // Construct an aliasing list for each GlobalObject.
171 for (const auto &Alias : M.aliases()) {
172 const GlobalObject *Aliasee = Alias.getAliaseeObject();
173 if (!Aliasee)
174 OutContext.reportError(
175 {}, "Alias without a base object is not yet supported on z/OS.");
176
177 bool IsFunc = isa<Function>(Aliasee->stripPointerCasts());
178 if (IsFunc) {
179 if (Alias.hasWeakLinkage() || Alias.hasLinkOnceLinkage())
180 OutContext.reportError({},
181 "Weak alias/reference not supported on z/OS");
182
183 GOAliasMap[Aliasee].push_back(&Alias);
184 } else
185 OutContext.reportError(
186 {}, "Only aliases to functions is supported in GOFF.");
187 }
188 }
190}
191
192// The XPLINK ABI requires that a no-op encoding the call type is emitted after
193// each call to a subroutine. This information can be used by the called
194// function to determine its entry point, e.g. for generating a backtrace. The
195// call type is encoded as a register number in the bcr instruction. See
196// enumeration CallType for the possible values.
197void SystemZAsmPrinter::emitCallInformation(CallType CT) {
199 MCInstBuilder(SystemZ::BCRAsm)
200 .addImm(0)
201 .addReg(SystemZMC::GR64Regs[static_cast<unsigned>(CT)]));
202}
203
204uint32_t SystemZAsmPrinter::AssociatedDataAreaTable::insert(const MCSymbol *Sym,
205 unsigned SlotKind) {
206 auto Key = std::make_pair(Sym, SlotKind);
207 auto It = Displacements.find(Key);
208
209 if (It != Displacements.end())
210 return (*It).second;
211
212 // Determine length of descriptor.
214 switch (SlotKind) {
216 Length = 2 * PointerSize;
217 break;
218 default:
219 Length = PointerSize;
220 break;
221 }
222
223 uint32_t Displacement = NextDisplacement;
224 Displacements[std::make_pair(Sym, SlotKind)] = NextDisplacement;
225 NextDisplacement += Length;
226
227 return Displacement;
228}
229
230uint32_t
231SystemZAsmPrinter::AssociatedDataAreaTable::insert(const MachineOperand MO) {
232 MCSymbol *Sym;
234 const GlobalValue *GV = MO.getGlobal();
235 Sym = MO.getParent()->getMF()->getTarget().getSymbol(GV);
236 assert(Sym && "No symbol");
237 } else if (MO.getType() == MachineOperand::MO_ExternalSymbol) {
238 const char *SymName = MO.getSymbolName();
239 Sym = MO.getParent()->getMF()->getContext().getOrCreateSymbol(SymName);
240 assert(Sym && "No symbol");
241 } else
242 llvm_unreachable("Unexpected operand type");
243
244 unsigned ADAslotType = MO.getTargetFlags();
245 return insert(Sym, ADAslotType);
246}
247
249 SystemZ_MC::verifyInstructionPredicates(MI->getOpcode(),
250 getSubtargetInfo().getFeatureBits());
251
252 SystemZMCInstLower Lower(MF->getContext(), *this);
253 MCInst LoweredMI;
254 switch (MI->getOpcode()) {
255 case SystemZ::Return:
256 LoweredMI = MCInstBuilder(SystemZ::BR)
257 .addReg(SystemZ::R14D);
258 break;
259
260 case SystemZ::Return_XPLINK:
261 LoweredMI = MCInstBuilder(SystemZ::B)
262 .addReg(SystemZ::R7D)
263 .addImm(2)
264 .addReg(0);
265 break;
266
267 case SystemZ::CondReturn:
268 LoweredMI = MCInstBuilder(SystemZ::BCR)
269 .addImm(MI->getOperand(0).getImm())
270 .addImm(MI->getOperand(1).getImm())
271 .addReg(SystemZ::R14D);
272 break;
273
274 case SystemZ::CondReturn_XPLINK:
275 LoweredMI = MCInstBuilder(SystemZ::BC)
276 .addImm(MI->getOperand(0).getImm())
277 .addImm(MI->getOperand(1).getImm())
278 .addReg(SystemZ::R7D)
279 .addImm(2)
280 .addReg(0);
281 break;
282
283 case SystemZ::CRBReturn:
284 LoweredMI = MCInstBuilder(SystemZ::CRB)
285 .addReg(MI->getOperand(0).getReg())
286 .addReg(MI->getOperand(1).getReg())
287 .addImm(MI->getOperand(2).getImm())
288 .addReg(SystemZ::R14D)
289 .addImm(0);
290 break;
291
292 case SystemZ::CGRBReturn:
293 LoweredMI = MCInstBuilder(SystemZ::CGRB)
294 .addReg(MI->getOperand(0).getReg())
295 .addReg(MI->getOperand(1).getReg())
296 .addImm(MI->getOperand(2).getImm())
297 .addReg(SystemZ::R14D)
298 .addImm(0);
299 break;
300
301 case SystemZ::CIBReturn:
302 LoweredMI = MCInstBuilder(SystemZ::CIB)
303 .addReg(MI->getOperand(0).getReg())
304 .addImm(MI->getOperand(1).getImm())
305 .addImm(MI->getOperand(2).getImm())
306 .addReg(SystemZ::R14D)
307 .addImm(0);
308 break;
309
310 case SystemZ::CGIBReturn:
311 LoweredMI = MCInstBuilder(SystemZ::CGIB)
312 .addReg(MI->getOperand(0).getReg())
313 .addImm(MI->getOperand(1).getImm())
314 .addImm(MI->getOperand(2).getImm())
315 .addReg(SystemZ::R14D)
316 .addImm(0);
317 break;
318
319 case SystemZ::CLRBReturn:
320 LoweredMI = MCInstBuilder(SystemZ::CLRB)
321 .addReg(MI->getOperand(0).getReg())
322 .addReg(MI->getOperand(1).getReg())
323 .addImm(MI->getOperand(2).getImm())
324 .addReg(SystemZ::R14D)
325 .addImm(0);
326 break;
327
328 case SystemZ::CLGRBReturn:
329 LoweredMI = MCInstBuilder(SystemZ::CLGRB)
330 .addReg(MI->getOperand(0).getReg())
331 .addReg(MI->getOperand(1).getReg())
332 .addImm(MI->getOperand(2).getImm())
333 .addReg(SystemZ::R14D)
334 .addImm(0);
335 break;
336
337 case SystemZ::CLIBReturn:
338 LoweredMI = MCInstBuilder(SystemZ::CLIB)
339 .addReg(MI->getOperand(0).getReg())
340 .addImm(MI->getOperand(1).getImm())
341 .addImm(MI->getOperand(2).getImm())
342 .addReg(SystemZ::R14D)
343 .addImm(0);
344 break;
345
346 case SystemZ::CLGIBReturn:
347 LoweredMI = MCInstBuilder(SystemZ::CLGIB)
348 .addReg(MI->getOperand(0).getReg())
349 .addImm(MI->getOperand(1).getImm())
350 .addImm(MI->getOperand(2).getImm())
351 .addReg(SystemZ::R14D)
352 .addImm(0);
353 break;
354
355 case SystemZ::CallBRASL_XPLINK64:
357 .addReg(SystemZ::R7D)
358 .addExpr(Lower.getExpr(MI->getOperand(0),
360 emitCallInformation(CallType::BRASL7);
361 return;
362
363 case SystemZ::CallBASR_XPLINK64:
365 .addReg(SystemZ::R7D)
366 .addReg(MI->getOperand(0).getReg()));
367 emitCallInformation(CallType::BASR76);
368 return;
369
370 case SystemZ::CallBASR_STACKEXT:
372 .addReg(SystemZ::R3D)
373 .addReg(MI->getOperand(0).getReg()));
374 emitCallInformation(CallType::BASR33);
375 return;
376
377 case SystemZ::ADA_ENTRY_VALUE:
378 case SystemZ::ADA_ENTRY: {
379 const SystemZSubtarget &Subtarget = MF->getSubtarget<SystemZSubtarget>();
380 const SystemZInstrInfo *TII = Subtarget.getInstrInfo();
381 uint32_t Disp = ADATable.insert(MI->getOperand(1));
382 Register TargetReg = MI->getOperand(0).getReg();
383
384 Register ADAReg = MI->getOperand(2).getReg();
385 Disp += MI->getOperand(3).getImm();
386 bool LoadAddr = MI->getOpcode() == SystemZ::ADA_ENTRY;
387
388 unsigned Op0 = LoadAddr ? SystemZ::LA : SystemZ::LG;
389 unsigned Op = TII->getOpcodeForOffset(Op0, Disp);
390
391 Register IndexReg = 0;
392 if (!Op) {
393 if (TargetReg != ADAReg) {
394 IndexReg = TargetReg;
395 // Use TargetReg to store displacement.
398 MCInstBuilder(SystemZ::LLILF).addReg(TargetReg).addImm(Disp));
399 } else
401 .addReg(TargetReg)
402 .addReg(TargetReg)
403 .addImm(Disp));
404 Disp = 0;
405 Op = Op0;
406 }
408 .addReg(TargetReg)
409 .addReg(ADAReg)
410 .addImm(Disp)
411 .addReg(IndexReg));
412
413 return;
414 }
415 case SystemZ::CallBRASL:
416 LoweredMI = MCInstBuilder(SystemZ::BRASL)
417 .addReg(SystemZ::R14D)
418 .addExpr(Lower.getExpr(MI->getOperand(0), SystemZ::S_PLT));
419 break;
420
421 case SystemZ::CallBASR:
422 LoweredMI = MCInstBuilder(SystemZ::BASR)
423 .addReg(SystemZ::R14D)
424 .addReg(MI->getOperand(0).getReg());
425 break;
426
427 case SystemZ::CallJG:
428 LoweredMI = MCInstBuilder(SystemZ::JG)
429 .addExpr(Lower.getExpr(MI->getOperand(0), SystemZ::S_PLT));
430 break;
431
432 case SystemZ::CallBRCL:
433 LoweredMI = MCInstBuilder(SystemZ::BRCL)
434 .addImm(MI->getOperand(0).getImm())
435 .addImm(MI->getOperand(1).getImm())
436 .addExpr(Lower.getExpr(MI->getOperand(2), SystemZ::S_PLT));
437 break;
438
439 case SystemZ::CallBR:
440 LoweredMI = MCInstBuilder(SystemZ::BR)
441 .addReg(MI->getOperand(0).getReg());
442 break;
443
444 case SystemZ::CallBCR:
445 LoweredMI = MCInstBuilder(SystemZ::BCR)
446 .addImm(MI->getOperand(0).getImm())
447 .addImm(MI->getOperand(1).getImm())
448 .addReg(MI->getOperand(2).getReg());
449 break;
450
451 case SystemZ::CRBCall:
452 LoweredMI = MCInstBuilder(SystemZ::CRB)
453 .addReg(MI->getOperand(0).getReg())
454 .addReg(MI->getOperand(1).getReg())
455 .addImm(MI->getOperand(2).getImm())
456 .addReg(MI->getOperand(3).getReg())
457 .addImm(0);
458 break;
459
460 case SystemZ::CGRBCall:
461 LoweredMI = MCInstBuilder(SystemZ::CGRB)
462 .addReg(MI->getOperand(0).getReg())
463 .addReg(MI->getOperand(1).getReg())
464 .addImm(MI->getOperand(2).getImm())
465 .addReg(MI->getOperand(3).getReg())
466 .addImm(0);
467 break;
468
469 case SystemZ::CIBCall:
470 LoweredMI = MCInstBuilder(SystemZ::CIB)
471 .addReg(MI->getOperand(0).getReg())
472 .addImm(MI->getOperand(1).getImm())
473 .addImm(MI->getOperand(2).getImm())
474 .addReg(MI->getOperand(3).getReg())
475 .addImm(0);
476 break;
477
478 case SystemZ::CGIBCall:
479 LoweredMI = MCInstBuilder(SystemZ::CGIB)
480 .addReg(MI->getOperand(0).getReg())
481 .addImm(MI->getOperand(1).getImm())
482 .addImm(MI->getOperand(2).getImm())
483 .addReg(MI->getOperand(3).getReg())
484 .addImm(0);
485 break;
486
487 case SystemZ::CLRBCall:
488 LoweredMI = MCInstBuilder(SystemZ::CLRB)
489 .addReg(MI->getOperand(0).getReg())
490 .addReg(MI->getOperand(1).getReg())
491 .addImm(MI->getOperand(2).getImm())
492 .addReg(MI->getOperand(3).getReg())
493 .addImm(0);
494 break;
495
496 case SystemZ::CLGRBCall:
497 LoweredMI = MCInstBuilder(SystemZ::CLGRB)
498 .addReg(MI->getOperand(0).getReg())
499 .addReg(MI->getOperand(1).getReg())
500 .addImm(MI->getOperand(2).getImm())
501 .addReg(MI->getOperand(3).getReg())
502 .addImm(0);
503 break;
504
505 case SystemZ::CLIBCall:
506 LoweredMI = MCInstBuilder(SystemZ::CLIB)
507 .addReg(MI->getOperand(0).getReg())
508 .addImm(MI->getOperand(1).getImm())
509 .addImm(MI->getOperand(2).getImm())
510 .addReg(MI->getOperand(3).getReg())
511 .addImm(0);
512 break;
513
514 case SystemZ::CLGIBCall:
515 LoweredMI = MCInstBuilder(SystemZ::CLGIB)
516 .addReg(MI->getOperand(0).getReg())
517 .addImm(MI->getOperand(1).getImm())
518 .addImm(MI->getOperand(2).getImm())
519 .addReg(MI->getOperand(3).getReg())
520 .addImm(0);
521 break;
522
523 case SystemZ::TLS_GDCALL:
524 LoweredMI =
525 MCInstBuilder(SystemZ::BRASL)
526 .addReg(SystemZ::R14D)
527 .addExpr(getTLSGetOffset(MF->getContext()))
528 .addExpr(Lower.getExpr(MI->getOperand(0), SystemZ::S_TLSGD));
529 break;
530
531 case SystemZ::TLS_LDCALL:
532 LoweredMI =
533 MCInstBuilder(SystemZ::BRASL)
534 .addReg(SystemZ::R14D)
535 .addExpr(getTLSGetOffset(MF->getContext()))
536 .addExpr(Lower.getExpr(MI->getOperand(0), SystemZ::S_TLSLDM));
537 break;
538
539 case SystemZ::GOT:
540 LoweredMI = MCInstBuilder(SystemZ::LARL)
541 .addReg(MI->getOperand(0).getReg())
542 .addExpr(getGlobalOffsetTable(MF->getContext()));
543 break;
544
545 case SystemZ::IILF64:
546 LoweredMI = MCInstBuilder(SystemZ::IILF)
547 .addReg(SystemZMC::getRegAsGR32(MI->getOperand(0).getReg()))
548 .addImm(MI->getOperand(2).getImm());
549 break;
550
551 case SystemZ::IIHF64:
552 LoweredMI = MCInstBuilder(SystemZ::IIHF)
553 .addReg(SystemZMC::getRegAsGRH32(MI->getOperand(0).getReg()))
554 .addImm(MI->getOperand(2).getImm());
555 break;
556
557 case SystemZ::RISBHH:
558 case SystemZ::RISBHL:
559 LoweredMI = lowerRIEfLow(MI, SystemZ::RISBHG);
560 break;
561
562 case SystemZ::RISBLH:
563 case SystemZ::RISBLL:
564 LoweredMI = lowerRIEfLow(MI, SystemZ::RISBLG);
565 break;
566
567 case SystemZ::VLVGP32:
568 LoweredMI = MCInstBuilder(SystemZ::VLVGP)
569 .addReg(MI->getOperand(0).getReg())
570 .addReg(SystemZMC::getRegAsGR64(MI->getOperand(1).getReg()))
571 .addReg(SystemZMC::getRegAsGR64(MI->getOperand(2).getReg()));
572 break;
573
574 case SystemZ::VLR16:
575 case SystemZ::VLR32:
576 case SystemZ::VLR64:
577 LoweredMI = MCInstBuilder(SystemZ::VLR)
578 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(0).getReg()))
579 .addReg(SystemZMC::getRegAsVR128(MI->getOperand(1).getReg()));
580 break;
581
582 case SystemZ::VL:
583 Lower.lower(MI, LoweredMI);
584 lowerAlignmentHint(MI, LoweredMI, SystemZ::VLAlign);
585 break;
586
587 case SystemZ::VST:
588 Lower.lower(MI, LoweredMI);
589 lowerAlignmentHint(MI, LoweredMI, SystemZ::VSTAlign);
590 break;
591
592 case SystemZ::VLM:
593 Lower.lower(MI, LoweredMI);
594 lowerAlignmentHint(MI, LoweredMI, SystemZ::VLMAlign);
595 break;
596
597 case SystemZ::VSTM:
598 Lower.lower(MI, LoweredMI);
599 lowerAlignmentHint(MI, LoweredMI, SystemZ::VSTMAlign);
600 break;
601
602 case SystemZ::VL16:
603 LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPH);
604 break;
605
606 case SystemZ::VL32:
607 LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPF);
608 break;
609
610 case SystemZ::VL64:
611 LoweredMI = lowerSubvectorLoad(MI, SystemZ::VLREPG);
612 break;
613
614 case SystemZ::VST16:
615 LoweredMI = lowerSubvectorStore(MI, SystemZ::VSTEH);
616 break;
617
618 case SystemZ::VST32:
619 LoweredMI = lowerSubvectorStore(MI, SystemZ::VSTEF);
620 break;
621
622 case SystemZ::VST64:
623 LoweredMI = lowerSubvectorStore(MI, SystemZ::VSTEG);
624 break;
625
626 case SystemZ::LFER:
627 LoweredMI = lowerVecEltExtraction(MI, SystemZ::VLGVF);
628 break;
629
630 case SystemZ::LFER_16:
631 LoweredMI = lowerVecEltExtraction(MI, SystemZ::VLGVH);
632 break;
633
634 case SystemZ::LEFR:
635 LoweredMI = lowerVecEltInsertion(MI, SystemZ::VLVGF);
636 break;
637
638 case SystemZ::LEFR_16:
639 LoweredMI = lowerVecEltInsertion(MI, SystemZ::VLVGH);
640 break;
641
642#define LOWER_LOW(NAME) \
643 case SystemZ::NAME##64: LoweredMI = lowerRILow(MI, SystemZ::NAME); break
644
645 LOWER_LOW(IILL);
646 LOWER_LOW(IILH);
647 LOWER_LOW(TMLL);
648 LOWER_LOW(TMLH);
649 LOWER_LOW(NILL);
650 LOWER_LOW(NILH);
651 LOWER_LOW(NILF);
652 LOWER_LOW(OILL);
653 LOWER_LOW(OILH);
654 LOWER_LOW(OILF);
655 LOWER_LOW(XILF);
656
657#undef LOWER_LOW
658
659#define LOWER_HIGH(NAME) \
660 case SystemZ::NAME##64: LoweredMI = lowerRIHigh(MI, SystemZ::NAME); break
661
662 LOWER_HIGH(IIHL);
663 LOWER_HIGH(IIHH);
664 LOWER_HIGH(TMHL);
665 LOWER_HIGH(TMHH);
666 LOWER_HIGH(NIHL);
667 LOWER_HIGH(NIHH);
668 LOWER_HIGH(NIHF);
669 LOWER_HIGH(OIHL);
670 LOWER_HIGH(OIHH);
671 LOWER_HIGH(OIHF);
672 LOWER_HIGH(XIHF);
673
674#undef LOWER_HIGH
675
676 case SystemZ::Serialize:
677 if (MF->getSubtarget<SystemZSubtarget>().hasFastSerialization())
678 LoweredMI = MCInstBuilder(SystemZ::BCRAsm)
679 .addImm(14).addReg(SystemZ::R0D);
680 else
681 LoweredMI = MCInstBuilder(SystemZ::BCRAsm)
682 .addImm(15).addReg(SystemZ::R0D);
683 break;
684
685 // We want to emit "j .+2" for traps, jumping to the relative immediate field
686 // of the jump instruction, which is an illegal instruction. We cannot emit a
687 // "." symbol, so create and emit a temp label before the instruction and use
688 // that instead.
689 case SystemZ::Trap: {
690 MCSymbol *DotSym = OutContext.createTempSymbol();
691 OutStreamer->emitLabel(DotSym);
692
694 const MCConstantExpr *ConstExpr = MCConstantExpr::create(2, OutContext);
695 LoweredMI = MCInstBuilder(SystemZ::J)
696 .addExpr(MCBinaryExpr::createAdd(Expr, ConstExpr, OutContext));
697 }
698 break;
699
700 // Conditional traps will create a branch on condition instruction that jumps
701 // to the relative immediate field of the jump instruction. (eg. "jo .+2")
702 case SystemZ::CondTrap: {
703 MCSymbol *DotSym = OutContext.createTempSymbol();
704 OutStreamer->emitLabel(DotSym);
705
707 const MCConstantExpr *ConstExpr = MCConstantExpr::create(2, OutContext);
708 LoweredMI = MCInstBuilder(SystemZ::BRC)
709 .addImm(MI->getOperand(0).getImm())
710 .addImm(MI->getOperand(1).getImm())
711 .addExpr(MCBinaryExpr::createAdd(Expr, ConstExpr, OutContext));
712 }
713 break;
714
715 case TargetOpcode::FENTRY_CALL:
716 LowerFENTRY_CALL(*MI, Lower);
717 return;
718
719 case TargetOpcode::STACKMAP:
720 LowerSTACKMAP(*MI);
721 return;
722
723 case TargetOpcode::PATCHPOINT:
724 LowerPATCHPOINT(*MI, Lower);
725 return;
726
727 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
728 LowerPATCHABLE_FUNCTION_ENTER(*MI, Lower);
729 return;
730
731 case TargetOpcode::PATCHABLE_RET:
732 LowerPATCHABLE_RET(*MI, Lower);
733 return;
734
735 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
736 llvm_unreachable("PATCHABLE_FUNCTION_EXIT should never be emitted");
737
738 case TargetOpcode::PATCHABLE_TAIL_CALL:
739 // TODO: Define a trampoline `__xray_FunctionTailExit` and differentiate a
740 // normal function exit from a tail exit.
741 llvm_unreachable("Tail call is handled in the normal case. See comments "
742 "around this assert.");
743
744 case SystemZ::EXRL_Pseudo: {
745 unsigned TargetInsOpc = MI->getOperand(0).getImm();
746 Register LenMinus1Reg = MI->getOperand(1).getReg();
747 Register DestReg = MI->getOperand(2).getReg();
748 int64_t DestDisp = MI->getOperand(3).getImm();
749 Register SrcReg = MI->getOperand(4).getReg();
750 int64_t SrcDisp = MI->getOperand(5).getImm();
751
752 SystemZTargetStreamer *TS = getTargetStreamer();
753 MCInst ET = MCInstBuilder(TargetInsOpc)
754 .addReg(DestReg)
755 .addImm(DestDisp)
756 .addImm(1)
757 .addReg(SrcReg)
758 .addImm(SrcDisp);
759 SystemZTargetStreamer::MCInstSTIPair ET_STI(ET, &MF->getSubtarget());
760 auto [It, Inserted] = TS->EXRLTargets2Sym.try_emplace(ET_STI);
761 if (Inserted)
762 It->second = OutContext.createTempSymbol();
763 MCSymbol *DotSym = It->second;
767 MCInstBuilder(SystemZ::EXRL).addReg(LenMinus1Reg).addExpr(Dot));
768 return;
769 }
770
771 // EH_SjLj_Setup is a dummy terminator instruction of size 0.
772 // It is used to handle the clobber register for builtin setjmp.
773 case SystemZ::EH_SjLj_Setup:
774 return;
775
776 default:
777 Lower.lower(MI, LoweredMI);
778 break;
779 }
780 EmitToStreamer(*OutStreamer, LoweredMI);
781}
782
783// Emit the largest nop instruction smaller than or equal to NumBytes
784// bytes. Return the size of nop emitted.
786 unsigned NumBytes, const MCSubtargetInfo &STI) {
787 if (NumBytes < 2) {
788 llvm_unreachable("Zero nops?");
789 return 0;
790 }
791 else if (NumBytes < 4) {
792 OutStreamer.emitInstruction(
793 MCInstBuilder(SystemZ::BCRAsm).addImm(0).addReg(SystemZ::R0D), STI);
794 return 2;
795 }
796 else if (NumBytes < 6) {
797 OutStreamer.emitInstruction(
798 MCInstBuilder(SystemZ::BCAsm).addImm(0).addReg(0).addImm(0).addReg(0),
799 STI);
800 return 4;
801 }
802 else {
805 OutStreamer.emitLabel(DotSym);
806 OutStreamer.emitInstruction(
807 MCInstBuilder(SystemZ::BRCLAsm).addImm(0).addExpr(Dot), STI);
808 return 6;
809 }
810}
811
812void SystemZAsmPrinter::LowerFENTRY_CALL(const MachineInstr &MI,
813 SystemZMCInstLower &Lower) {
814 MCContext &Ctx = MF->getContext();
815 if (MF->getFunction().hasFnAttribute("mrecord-mcount")) {
816 MCSymbol *DotSym = OutContext.createTempSymbol();
817 OutStreamer->pushSection();
818 OutStreamer->switchSection(
819 Ctx.getELFSection("__mcount_loc", ELF::SHT_PROGBITS, ELF::SHF_ALLOC));
820 OutStreamer->emitSymbolValue(DotSym, 8);
821 OutStreamer->popSection();
822 OutStreamer->emitLabel(DotSym);
823 }
824
825 if (MF->getFunction().hasFnAttribute("mnop-mcount")) {
827 return;
828 }
829
830 MCSymbol *fentry = Ctx.getOrCreateSymbol("__fentry__");
831 const MCSymbolRefExpr *Op =
833 OutStreamer->emitInstruction(
834 MCInstBuilder(SystemZ::BRASL).addReg(SystemZ::R0D).addExpr(Op),
836}
837
838void SystemZAsmPrinter::LowerSTACKMAP(const MachineInstr &MI) {
839 auto *TII = MF->getSubtarget<SystemZSubtarget>().getInstrInfo();
840
841 unsigned NumNOPBytes = MI.getOperand(1).getImm();
842
843 auto &Ctx = OutStreamer->getContext();
844 MCSymbol *MILabel = Ctx.createTempSymbol();
845 OutStreamer->emitLabel(MILabel);
846
847 SM.recordStackMap(*MILabel, MI);
848 assert(NumNOPBytes % 2 == 0 && "Invalid number of NOP bytes requested!");
849
850 // Scan ahead to trim the shadow.
851 unsigned ShadowBytes = 0;
852 const MachineBasicBlock &MBB = *MI.getParent();
854 ++MII;
855 while (ShadowBytes < NumNOPBytes) {
856 if (MII == MBB.end() ||
857 MII->getOpcode() == TargetOpcode::PATCHPOINT ||
858 MII->getOpcode() == TargetOpcode::STACKMAP)
859 break;
860 ShadowBytes += TII->getInstSizeInBytes(*MII);
861 if (MII->isCall())
862 break;
863 ++MII;
864 }
865
866 // Emit nops.
867 while (ShadowBytes < NumNOPBytes)
868 ShadowBytes += EmitNop(OutContext, *OutStreamer, NumNOPBytes - ShadowBytes,
870}
871
872// Lower a patchpoint of the form:
873// [<def>], <id>, <numBytes>, <target>, <numArgs>
874void SystemZAsmPrinter::LowerPATCHPOINT(const MachineInstr &MI,
875 SystemZMCInstLower &Lower) {
876 auto &Ctx = OutStreamer->getContext();
877 MCSymbol *MILabel = Ctx.createTempSymbol();
878 OutStreamer->emitLabel(MILabel);
879
880 SM.recordPatchPoint(*MILabel, MI);
881 PatchPointOpers Opers(&MI);
882
883 unsigned EncodedBytes = 0;
884 const MachineOperand &CalleeMO = Opers.getCallTarget();
885
886 if (CalleeMO.isImm()) {
887 uint64_t CallTarget = CalleeMO.getImm();
888 if (CallTarget) {
889 unsigned ScratchIdx = -1;
890 unsigned ScratchReg = 0;
891 do {
892 ScratchIdx = Opers.getNextScratchIdx(ScratchIdx + 1);
893 ScratchReg = MI.getOperand(ScratchIdx).getReg();
894 } while (ScratchReg == SystemZ::R0D);
895
896 // Materialize the call target address
897 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::LLILF)
898 .addReg(ScratchReg)
899 .addImm(CallTarget & 0xFFFFFFFF));
900 EncodedBytes += 6;
901 if (CallTarget >> 32) {
902 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::IIHF)
903 .addReg(ScratchReg)
904 .addImm(CallTarget >> 32));
905 EncodedBytes += 6;
906 }
907
908 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BASR)
909 .addReg(SystemZ::R14D)
910 .addReg(ScratchReg));
911 EncodedBytes += 2;
912 }
913 } else if (CalleeMO.isGlobal()) {
914 const MCExpr *Expr = Lower.getExpr(CalleeMO, SystemZ::S_PLT);
915 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BRASL)
916 .addReg(SystemZ::R14D)
917 .addExpr(Expr));
918 EncodedBytes += 6;
919 }
920
921 // Emit padding.
922 unsigned NumBytes = Opers.getNumPatchBytes();
923 assert(NumBytes >= EncodedBytes &&
924 "Patchpoint can't request size less than the length of a call.");
925 assert((NumBytes - EncodedBytes) % 2 == 0 &&
926 "Invalid number of NOP bytes requested!");
927 while (EncodedBytes < NumBytes)
928 EncodedBytes += EmitNop(OutContext, *OutStreamer, NumBytes - EncodedBytes,
930}
931
932void SystemZAsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(
933 const MachineInstr &MI, SystemZMCInstLower &Lower) {
934
935 const MachineFunction &MF = *(MI.getParent()->getParent());
936 const Function &F = MF.getFunction();
937
938 // If patchable-function-entry is set, emit in-function nops here.
939 if (F.hasFnAttribute("patchable-function-entry")) {
940 unsigned Num;
941 // get M-N from function attribute (CodeGenFunction subtracts N
942 // from M to yield the correct patchable-function-entry).
943 if (F.getFnAttribute("patchable-function-entry")
944 .getValueAsString()
945 .getAsInteger(10, Num))
946 return;
947 // Emit M-N 2-byte nops. Use getNop() here instead of emitNops()
948 // to keep it aligned with the common code implementation emitting
949 // the prefix nops.
950 for (unsigned I = 0; I < Num; ++I)
951 EmitToStreamer(*OutStreamer, MF.getSubtarget().getInstrInfo()->getNop());
952 return;
953 }
954 // Otherwise, emit xray sled.
955 // .begin:
956 // j .end # -> stmg %r2, %r15, 16(%r15)
957 // nop
958 // llilf %2, FuncID
959 // brasl %r14, __xray_FunctionEntry@GOT
960 // .end:
961 //
962 // Update compiler-rt/lib/xray/xray_s390x.cpp accordingly when number
963 // of instructions change.
964 bool HasVectorFeature =
965 TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureVector) &&
966 !TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureSoftFloat);
967 MCSymbol *FuncEntry = OutContext.getOrCreateSymbol(
968 HasVectorFeature ? "__xray_FunctionEntryVec" : "__xray_FunctionEntry");
969 MCSymbol *BeginOfSled = OutContext.createTempSymbol("xray_sled_", true);
970 MCSymbol *EndOfSled = OutContext.createTempSymbol();
971 OutStreamer->emitLabel(BeginOfSled);
973 MCInstBuilder(SystemZ::J)
974 .addExpr(MCSymbolRefExpr::create(EndOfSled, OutContext)));
977 MCInstBuilder(SystemZ::LLILF).addReg(SystemZ::R2D).addImm(0));
978 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BRASL)
979 .addReg(SystemZ::R14D)
981 FuncEntry, SystemZ::S_PLT, OutContext)));
982 OutStreamer->emitLabel(EndOfSled);
983 recordSled(BeginOfSled, MI, SledKind::FUNCTION_ENTER, 2);
984}
985
986void SystemZAsmPrinter::LowerPATCHABLE_RET(const MachineInstr &MI,
987 SystemZMCInstLower &Lower) {
988 unsigned OpCode = MI.getOperand(0).getImm();
989 MCSymbol *FallthroughLabel = nullptr;
990 if (OpCode == SystemZ::CondReturn) {
991 FallthroughLabel = OutContext.createTempSymbol();
992 int64_t Cond0 = MI.getOperand(1).getImm();
993 int64_t Cond1 = MI.getOperand(2).getImm();
994 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::BRC)
995 .addImm(Cond0)
996 .addImm(Cond1 ^ Cond0)
998 FallthroughLabel, OutContext)));
999 }
1000 // .begin:
1001 // br %r14 # -> stmg %r2, %r15, 24(%r15)
1002 // nop
1003 // nop
1004 // llilf %2,FuncID
1005 // j __xray_FunctionExit@GOT
1006 //
1007 // Update compiler-rt/lib/xray/xray_s390x.cpp accordingly when number
1008 // of instructions change.
1009 bool HasVectorFeature =
1010 TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureVector) &&
1011 !TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureSoftFloat);
1012 MCSymbol *FuncExit = OutContext.getOrCreateSymbol(
1013 HasVectorFeature ? "__xray_FunctionExitVec" : "__xray_FunctionExit");
1014 MCSymbol *BeginOfSled = OutContext.createTempSymbol("xray_sled_", true);
1015 OutStreamer->emitLabel(BeginOfSled);
1017 MCInstBuilder(SystemZ::BR).addReg(SystemZ::R14D));
1020 MCInstBuilder(SystemZ::LLILF).addReg(SystemZ::R2D).addImm(0));
1021 EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::J)
1022 .addExpr(MCSymbolRefExpr::create(
1023 FuncExit, SystemZ::S_PLT, OutContext)));
1024 if (FallthroughLabel)
1025 OutStreamer->emitLabel(FallthroughLabel);
1026 recordSled(BeginOfSled, MI, SledKind::FUNCTION_EXIT, 2);
1027}
1028
1029// The *alignment* of 128-bit vector types is different between the software
1030// and hardware vector ABIs. If the there is an externally visible use of a
1031// vector type in the module it should be annotated with an attribute.
1032void SystemZAsmPrinter::emitAttributes(Module &M) {
1033 if (M.getModuleFlag("s390x-visible-vector-ABI")) {
1034 bool HasVectorFeature =
1035 TM.getMCSubtargetInfo()->hasFeature(SystemZ::FeatureVector);
1036 OutStreamer->emitGNUAttribute(8, HasVectorFeature ? 2 : 1);
1037 }
1038}
1039
1040// Convert a SystemZ-specific constant pool modifier into the associated
1041// specifier.
1043 switch (Modifier) {
1044 case SystemZCP::TLSGD:
1045 return SystemZ::S_TLSGD;
1046 case SystemZCP::TLSLDM:
1047 return SystemZ::S_TLSLDM;
1048 case SystemZCP::DTPOFF:
1049 return SystemZ::S_DTPOFF;
1050 case SystemZCP::NTPOFF:
1051 return SystemZ::S_NTPOFF;
1052 }
1053 llvm_unreachable("Invalid SystemCPModifier!");
1054}
1055
1058 auto *ZCPV = static_cast<SystemZConstantPoolValue*>(MCPV);
1059
1060 const MCExpr *Expr = MCSymbolRefExpr::create(
1061 getSymbol(ZCPV->getGlobalValue()),
1062 getSpecifierFromModifier(ZCPV->getModifier()), OutContext);
1063 uint64_t Size = getDataLayout().getTypeAllocSize(ZCPV->getType());
1064
1065 OutStreamer->emitValue(Expr, Size);
1066}
1067
1068// Emit the ctor or dtor list taking into account the init priority.
1070 const Constant *List, bool IsCtor) {
1071 if (!TM.getTargetTriple().isOSBinFormatGOFF())
1072 return AsmPrinter::emitXXStructorList(DL, List, IsCtor);
1073
1074 SmallVector<Structor, 8> Structors;
1075 preprocessXXStructorList(DL, List, Structors);
1076 if (Structors.empty())
1077 return;
1078
1079 const Align Align = llvm::Align(4);
1080 const TargetLoweringObjectFileGOFF &Obj =
1081 static_cast<const TargetLoweringObjectFileGOFF &>(getObjFileLowering());
1082 for (Structor &S : Structors) {
1083 MCSectionGOFF *Section =
1084 static_cast<MCSectionGOFF *>(Obj.getStaticXtorSection(S.Priority));
1085 OutStreamer->switchSection(Section);
1086 if (OutStreamer->getCurrentSection() != OutStreamer->getPreviousSection())
1088
1089 // The priority is provided as an input to getStaticXtorSection(), and is
1090 // recalculated within that function as `Prio` going to going into the
1091 // PR section.
1092 // This priority retrieved via the `SortKey` below is the recalculated
1093 // Priority.
1094 uint32_t XtorPriority = Section->getPRAttributes().SortKey;
1095
1096 const GlobalValue *GV = dyn_cast<GlobalValue>(S.Func->stripPointerCasts());
1097 assert(GV && "C++ xxtor pointer was not a GlobalValue!");
1098 MCSymbolGOFF *Symbol = static_cast<MCSymbolGOFF *>(getSymbol(GV));
1099
1100 // @@SQINIT entry: { unsigned prio; void (*ctor)(); void (*dtor)(); }
1101
1102 unsigned PointerSizeInBytes = DL.getPointerSize();
1103
1104 auto &Ctx = OutStreamer->getContext();
1105 const MCExpr *ADAFuncRefExpr;
1106 unsigned SlotKind = SystemZII::MO_ADA_DIRECT_FUNC_DESC;
1107
1108 MCSectionGOFF *ADASection =
1109 static_cast<MCSectionGOFF *>(Obj.getADASection());
1110 assert(ADASection && "ADA section must exist for GOFF targets!");
1111 const MCSymbol *ADASym = ADASection->getBeginSymbol();
1112 assert(ADASym && "ADA symbol should already be set!");
1113
1114 ADAFuncRefExpr = MCBinaryExpr::createAdd(
1117 MCConstantExpr::create(ADATable.insert(Symbol, SlotKind), Ctx), Ctx);
1118
1119 emitInt32(XtorPriority);
1120 if (IsCtor) {
1121 OutStreamer->emitValue(ADAFuncRefExpr, PointerSizeInBytes);
1122 OutStreamer->emitIntValue(0, PointerSizeInBytes);
1123 } else {
1124 OutStreamer->emitIntValue(0, PointerSizeInBytes);
1125 OutStreamer->emitValue(ADAFuncRefExpr, PointerSizeInBytes);
1126 }
1127 }
1128}
1129
1130static void printFormattedRegName(const MCAsmInfo *MAI, unsigned RegNo,
1131 raw_ostream &OS) {
1132 const char *RegName;
1133 if (MAI->getAssemblerDialect() == AD_HLASM) {
1135 // Skip register prefix so that only register number is left
1136 assert(isalpha(RegName[0]) && isdigit(RegName[1]));
1137 OS << (RegName + 1);
1138 } else {
1140 OS << '%' << RegName;
1141 }
1142}
1143
1144static void printReg(unsigned Reg, const MCAsmInfo *MAI, raw_ostream &OS) {
1145 if (!Reg)
1146 OS << '0';
1147 else
1149}
1150
1151static void printOperand(const MCOperand &MCOp, const MCAsmInfo *MAI,
1152 raw_ostream &OS) {
1153 if (MCOp.isReg())
1154 printReg(MCOp.getReg(), MAI, OS);
1155 else if (MCOp.isImm())
1156 OS << MCOp.getImm();
1157 else if (MCOp.isExpr())
1158 MAI->printExpr(OS, *MCOp.getExpr());
1159 else
1160 llvm_unreachable("Invalid operand");
1161}
1162
1163static void printAddress(const MCAsmInfo *MAI, unsigned Base,
1164 const MCOperand &DispMO, unsigned Index,
1165 raw_ostream &OS) {
1166 printOperand(DispMO, MAI, OS);
1167 if (Base || Index) {
1168 OS << '(';
1169 if (Index) {
1170 printFormattedRegName(MAI, Index, OS);
1171 if (Base)
1172 OS << ',';
1173 }
1174 if (Base)
1176 OS << ')';
1177 }
1178}
1179
1181 const char *ExtraCode,
1182 raw_ostream &OS) {
1183 const MCRegisterInfo &MRI = *TM.getMCRegisterInfo();
1184 const MachineOperand &MO = MI->getOperand(OpNo);
1185 MCOperand MCOp;
1186 if (ExtraCode) {
1187 if (ExtraCode[0] == 'N' && !ExtraCode[1] && MO.isReg() &&
1188 SystemZ::GR128BitRegClass.contains(MO.getReg()))
1189 MCOp =
1190 MCOperand::createReg(MRI.getSubReg(MO.getReg(), SystemZ::subreg_l64));
1191 else
1192 return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, OS);
1193 } else {
1194 SystemZMCInstLower Lower(MF->getContext(), *this);
1195 MCOp = Lower.lowerOperand(MO);
1196 }
1197 printOperand(MCOp, MAI, OS);
1198 return false;
1199}
1200
1202 unsigned OpNo,
1203 const char *ExtraCode,
1204 raw_ostream &OS) {
1205 if (ExtraCode && ExtraCode[0] && !ExtraCode[1]) {
1206 switch (ExtraCode[0]) {
1207 case 'A':
1208 // Unlike EmitMachineNode(), EmitSpecialNode(INLINEASM) does not call
1209 // setMemRefs(), so MI->memoperands() is empty and the alignment
1210 // information is not available.
1211 return false;
1212 case 'O':
1213 OS << MI->getOperand(OpNo + 1).getImm();
1214 return false;
1215 case 'R':
1216 ::printReg(MI->getOperand(OpNo).getReg(), MAI, OS);
1217 return false;
1218 }
1219 }
1220 printAddress(MAI, MI->getOperand(OpNo).getReg(),
1221 MCOperand::createImm(MI->getOperand(OpNo + 1).getImm()),
1222 MI->getOperand(OpNo + 2).getReg(), OS);
1223 return false;
1224}
1225
1227 auto TT = OutContext.getTargetTriple();
1228 if (TT.isOSzOS()) {
1229 emitADASection();
1230 emitIDRLSection(M);
1231 }
1232 emitAttributes(M);
1233}
1234
1235void SystemZAsmPrinter::emitADASection() {
1236 OutStreamer->pushSection();
1237
1238 const unsigned PointerSize = getDataLayout().getPointerSize();
1239 OutStreamer->switchSection(getObjFileLowering().getADASection());
1240
1241 unsigned EmittedBytes = 0;
1242 for (auto &Entry : ADATable.getTable()) {
1243 const MCSymbol *Sym;
1244 unsigned SlotKind;
1245 std::tie(Sym, SlotKind) = Entry.first;
1246 unsigned Offset = Entry.second;
1247 assert(Offset == EmittedBytes && "Offset not as expected");
1248 (void)EmittedBytes;
1249#define EMIT_COMMENT(Str) \
1250 OutStreamer->AddComment(Twine("Offset ") \
1251 .concat(utostr(Offset)) \
1252 .concat(" " Str " ") \
1253 .concat(Sym->getName()));
1254 switch (SlotKind) {
1256 // Language Environment DLL logic requires function descriptors, for
1257 // imported functions, that are placed in the ADA to be 8 byte aligned.
1258 EMIT_COMMENT("function descriptor of");
1259 OutStreamer->emitValue(
1262 PointerSize);
1263 OutStreamer->emitValue(
1266 PointerSize);
1267 EmittedBytes += PointerSize * 2;
1268 break;
1270 EMIT_COMMENT("pointer to data symbol");
1271 OutStreamer->emitValue(
1274 PointerSize);
1275 EmittedBytes += PointerSize;
1276 break;
1279 Twine(Sym->getName()).concat("@indirect"));
1280 OutStreamer->emitAssignment(Alias,
1282 OutStreamer->emitSymbolAttribute(Alias, MCSA_IndirectSymbol);
1283
1284 EMIT_COMMENT("pointer to function descriptor");
1285 OutStreamer->emitValue(
1288 PointerSize);
1289 EmittedBytes += PointerSize;
1290 break;
1291 }
1292 default:
1293 llvm_unreachable("Unexpected slot kind");
1294 }
1295#undef EMIT_COMMENT
1296 }
1297 OutStreamer->popSection();
1298}
1299
1300static std::string getProductID(Module &M) {
1301 std::string ProductID;
1302 if (auto *MD = M.getModuleFlag("zos_product_id"))
1303 ProductID = cast<MDString>(MD)->getString().str();
1304 if (ProductID.empty())
1305 ProductID = "LLVM";
1306 return ProductID;
1307}
1308
1310 if (auto *VersionVal = mdconst::extract_or_null<ConstantInt>(
1311 M.getModuleFlag("zos_product_major_version")))
1312 return VersionVal->getZExtValue();
1313 return LLVM_VERSION_MAJOR;
1314}
1315
1317 if (auto *ReleaseVal = mdconst::extract_or_null<ConstantInt>(
1318 M.getModuleFlag("zos_product_minor_version")))
1319 return ReleaseVal->getZExtValue();
1320 return LLVM_VERSION_MINOR;
1321}
1322
1324 if (auto *PatchVal = mdconst::extract_or_null<ConstantInt>(
1325 M.getModuleFlag("zos_product_patchlevel")))
1326 return PatchVal->getZExtValue();
1327 return LLVM_VERSION_PATCH;
1328}
1329
1330static time_t getTranslationTime(Module &M) {
1331 std::time_t Time = 0;
1333 M.getModuleFlag("zos_translation_time"))) {
1334 long SecondsSinceEpoch = Val->getSExtValue();
1335 Time = static_cast<time_t>(SecondsSinceEpoch);
1336 }
1337 return Time;
1338}
1339
1340void SystemZAsmPrinter::emitIDRLSection(Module &M) {
1341 OutStreamer->pushSection();
1342 OutStreamer->switchSection(getObjFileLowering().getIDRLSection());
1343 constexpr unsigned IDRLDataLength = 30;
1344 std::time_t Time = getTranslationTime(M);
1345
1346 uint32_t ProductVersion = getProductVersion(M);
1347 uint32_t ProductRelease = getProductRelease(M);
1348
1349 std::string ProductID = getProductID(M);
1350
1351 SmallString<IDRLDataLength + 1> TempStr;
1352 raw_svector_ostream O(TempStr);
1353 O << formatv("{0,-10}{1,0-2:d}{2,0-2:d}{3:%Y%m%d%H%M%S}{4,0-2}",
1354 ProductID.substr(0, 10).c_str(), ProductVersion, ProductRelease,
1355 llvm::sys::toUtcTime(Time), "0");
1356 SmallString<IDRLDataLength> Data;
1358
1359 OutStreamer->emitInt8(0); // Reserved.
1360 OutStreamer->emitInt8(3); // Format.
1361 OutStreamer->emitInt16(IDRLDataLength); // Length.
1362 OutStreamer->emitBytes(Data.str());
1363 OutStreamer->popSection();
1364}
1365
1367 if (TM.getTargetTriple().isOSzOS()) {
1368 // Emit symbol for the end of function if the z/OS target streamer
1369 // is used. This is needed to calculate the size of the function.
1370 MCSymbol *FnEndSym = createTempSymbol("func_end");
1371 OutStreamer->emitLabel(FnEndSym);
1372
1373 OutStreamer->pushSection();
1374 OutStreamer->switchSection(getObjFileLowering().getTextSection(),
1376 emitPPA1(FnEndSym);
1377 OutStreamer->popSection();
1378
1379 CurrentFnPPA1Sym = nullptr;
1380 CurrentFnEPMarkerSym = nullptr;
1381 }
1382}
1383
1384static void emitPPA1Flags(std::unique_ptr<MCStreamer> &OutStreamer, bool VarArg,
1385 bool StackProtector, bool FPRMask, bool VRMask,
1386 bool EHBlock, bool HasArgAreaLength, bool HasName) {
1387 enum class PPA1Flag1 : uint8_t {
1388 DSA64Bit = (0x80 >> 0),
1389 VarArg = (0x80 >> 7),
1391 };
1392 enum class PPA1Flag2 : uint8_t {
1393 ExternalProcedure = (0x80 >> 0),
1394 STACKPROTECTOR = (0x80 >> 3),
1395 LLVM_MARK_AS_BITMASK_ENUM(ExternalProcedure)
1396 };
1397 enum class PPA1Flag3 : uint8_t {
1398 HasArgAreaLength = (0x80 >> 1),
1399 FPRMask = (0x80 >> 2),
1400 LLVM_MARK_AS_BITMASK_ENUM(HasArgAreaLength)
1401 };
1402 enum class PPA1Flag4 : uint8_t {
1403 EPMOffsetPresent = (0x80 >> 0),
1404 VRMask = (0x80 >> 2),
1405 EHBlock = (0x80 >> 3),
1406 ProcedureNamePresent = (0x80 >> 7),
1407 LLVM_MARK_AS_BITMASK_ENUM(EPMOffsetPresent)
1408 };
1409
1410 // Declare optional section flags that can be modified.
1411 auto Flags1 = PPA1Flag1(0);
1412 auto Flags2 = PPA1Flag2::ExternalProcedure;
1413 auto Flags3 = PPA1Flag3(0);
1414 auto Flags4 = PPA1Flag4::EPMOffsetPresent;
1415
1416 Flags1 |= PPA1Flag1::DSA64Bit;
1417
1418 if (VarArg)
1419 Flags1 |= PPA1Flag1::VarArg;
1420
1421 if (StackProtector)
1422 Flags2 |= PPA1Flag2::STACKPROTECTOR;
1423
1424 if (HasArgAreaLength)
1425 Flags3 |= PPA1Flag3::HasArgAreaLength; // Add emit ArgAreaLength flag.
1426
1427 // SavedGPRMask, SavedFPRMask, and SavedVRMask are precomputed in.
1428 if (FPRMask)
1429 Flags3 |= PPA1Flag3::FPRMask; // Add emit FPR mask flag.
1430
1431 if (VRMask)
1432 Flags4 |= PPA1Flag4::VRMask; // Add emit VR mask flag.
1433
1434 if (EHBlock)
1435 Flags4 |= PPA1Flag4::EHBlock; // Add optional EH block.
1436
1437 if (HasName)
1438 Flags4 |= PPA1Flag4::ProcedureNamePresent; // Add optional name block.
1439
1440 OutStreamer->AddComment("PPA1 Flags 1");
1441 if ((Flags1 & PPA1Flag1::DSA64Bit) == PPA1Flag1::DSA64Bit)
1442 OutStreamer->AddComment(" Bit 0: 1 = 64-bit DSA");
1443 else
1444 OutStreamer->AddComment(" Bit 0: 0 = 32-bit DSA");
1445 if ((Flags1 & PPA1Flag1::VarArg) == PPA1Flag1::VarArg)
1446 OutStreamer->AddComment(" Bit 7: 1 = Vararg function");
1447 OutStreamer->emitInt8(static_cast<uint8_t>(Flags1)); // Flags 1.
1448
1449 OutStreamer->AddComment("PPA1 Flags 2");
1450 if ((Flags2 & PPA1Flag2::ExternalProcedure) == PPA1Flag2::ExternalProcedure)
1451 OutStreamer->AddComment(" Bit 0: 1 = External procedure");
1452 if ((Flags2 & PPA1Flag2::STACKPROTECTOR) == PPA1Flag2::STACKPROTECTOR)
1453 OutStreamer->AddComment(" Bit 3: 1 = STACKPROTECT is enabled");
1454 else
1455 OutStreamer->AddComment(" Bit 3: 0 = STACKPROTECT is not enabled");
1456 OutStreamer->emitInt8(static_cast<uint8_t>(Flags2)); // Flags 2.
1457
1458 OutStreamer->AddComment("PPA1 Flags 3");
1459 if ((Flags3 & PPA1Flag3::HasArgAreaLength) == PPA1Flag3::HasArgAreaLength)
1460 OutStreamer->AddComment(
1461 " Bit 1: 1 = Argument Area Length is in optional area");
1462 if ((Flags3 & PPA1Flag3::FPRMask) == PPA1Flag3::FPRMask)
1463 OutStreamer->AddComment(" Bit 2: 1 = FP Reg Mask is in optional area");
1464 OutStreamer->emitInt8(
1465 static_cast<uint8_t>(Flags3)); // Flags 3 (optional sections).
1466
1467 OutStreamer->AddComment("PPA1 Flags 4");
1468 if ((Flags4 & PPA1Flag4::VRMask) == PPA1Flag4::VRMask)
1469 OutStreamer->AddComment(" Bit 2: 1 = Vector Reg Mask is in optional area");
1470 if ((Flags4 & PPA1Flag4::EHBlock) == PPA1Flag4::EHBlock)
1471 OutStreamer->AddComment(" Bit 3: 1 = C++ EH block");
1472 if ((Flags4 & PPA1Flag4::ProcedureNamePresent) ==
1473 PPA1Flag4::ProcedureNamePresent)
1474 OutStreamer->AddComment(" Bit 7: 1 = Name Length and Name");
1475 OutStreamer->emitInt8(static_cast<uint8_t>(
1476 Flags4)); // Flags 4 (optional sections, always emit these).
1477}
1478
1479static void emitPPA1Name(std::unique_ptr<MCStreamer> &OutStreamer,
1480 StringRef OutName) {
1481 size_t NameSize = OutName.size();
1482 uint16_t OutSize;
1483 if (NameSize < UINT16_MAX) {
1484 OutSize = static_cast<uint16_t>(NameSize);
1485 } else {
1486 OutName = OutName.substr(0, UINT16_MAX);
1487 OutSize = UINT16_MAX;
1488 }
1489 // Emit padding to ensure that the next optional field word-aligned.
1490 uint8_t ExtraZeros = 4 - ((2 + OutSize) % 4);
1491
1492 SmallString<512> OutnameConv;
1493 ConverterEBCDIC::convertToEBCDIC(OutName, OutnameConv);
1494 OutName = OutnameConv.str();
1495
1496 OutStreamer->AddComment("Length of Name");
1497 OutStreamer->emitInt16(OutSize);
1498 OutStreamer->AddComment("Name of Function");
1499 OutStreamer->emitBytes(OutName);
1500 OutStreamer->emitZeros(ExtraZeros);
1501}
1502
1503void SystemZAsmPrinter::emitPPA1(MCSymbol *FnEndSym) {
1504 assert(PPA2Sym != nullptr && "PPA2 Symbol not defined");
1505
1506 const TargetRegisterInfo *TRI = MF->getRegInfo().getTargetRegisterInfo();
1507 const SystemZSubtarget &Subtarget = MF->getSubtarget<SystemZSubtarget>();
1508 const auto TargetHasVector = Subtarget.hasVector();
1509
1510 const SystemZMachineFunctionInfo *ZFI =
1511 MF->getInfo<SystemZMachineFunctionInfo>();
1512 const auto *ZFL = static_cast<const SystemZXPLINKFrameLowering *>(
1513 Subtarget.getFrameLowering());
1514 const MachineFrameInfo &MFFrame = MF->getFrameInfo();
1515
1516 // Get saved GPR/FPR/VPR masks.
1517 const std::vector<CalleeSavedInfo> &CSI = MFFrame.getCalleeSavedInfo();
1518 uint16_t SavedGPRMask = 0;
1519 uint16_t SavedFPRMask = 0;
1520 uint8_t SavedVRMask = 0;
1521 int64_t OffsetFPR = 0;
1522 int64_t OffsetVR = 0;
1523 const int64_t TopOfStack =
1524 MFFrame.getOffsetAdjustment() + MFFrame.getStackSize();
1525
1526 // Loop over the spilled registers. The CalleeSavedInfo can't be used because
1527 // it does not contain all spilled registers.
1528 for (unsigned I = ZFI->getSpillGPRRegs().LowGPR,
1529 E = ZFI->getSpillGPRRegs().HighGPR;
1530 I && E && I <= E; ++I) {
1531 unsigned V = TRI->getEncodingValue((Register)I);
1532 assert(V < 16 && "GPR index out of range");
1533 SavedGPRMask |= 1 << (15 - V);
1534 }
1535
1536 for (auto &CS : CSI) {
1537 unsigned Reg = CS.getReg();
1538 unsigned I = TRI->getEncodingValue(Reg);
1539
1540 if (SystemZ::FP64BitRegClass.contains(Reg)) {
1541 assert(I < 16 && "FPR index out of range");
1542 SavedFPRMask |= 1 << (15 - I);
1543 int64_t Temp = MFFrame.getObjectOffset(CS.getFrameIdx());
1544 if (Temp < OffsetFPR)
1545 OffsetFPR = Temp;
1546 } else if (SystemZ::VR128BitRegClass.contains(Reg)) {
1547 assert(I >= 16 && I <= 23 && "VPR index out of range");
1548 unsigned BitNum = I - 16;
1549 SavedVRMask |= 1 << (7 - BitNum);
1550 int64_t Temp = MFFrame.getObjectOffset(CS.getFrameIdx());
1551 if (Temp < OffsetVR)
1552 OffsetVR = Temp;
1553 }
1554 }
1555
1556 // Adjust the offset.
1557 OffsetFPR += (OffsetFPR < 0) ? TopOfStack : 0;
1558 OffsetVR += (OffsetVR < 0) ? TopOfStack : 0;
1559
1560 // Get alloca register.
1561 uint8_t FrameReg = TRI->getEncodingValue(TRI->getFrameRegister(*MF));
1562 uint8_t AllocaReg = ZFL->hasFP(*MF) ? FrameReg : 0;
1563 assert(AllocaReg < 16 && "Can't have alloca register larger than 15");
1564 (void)AllocaReg;
1565
1566 // Build FPR save area offset.
1567 uint32_t FrameAndFPROffset = 0;
1568 if (SavedFPRMask) {
1569 uint64_t FPRSaveAreaOffset = OffsetFPR;
1570 assert(FPRSaveAreaOffset < 0x10000000 && "Offset out of range");
1571
1572 FrameAndFPROffset = FPRSaveAreaOffset & 0x0FFFFFFF; // Lose top 4 bits.
1573 FrameAndFPROffset |= FrameReg << 28; // Put into top 4 bits.
1574 }
1575
1576 // Build VR save area offset.
1577 uint32_t FrameAndVROffset = 0;
1578 if (TargetHasVector && SavedVRMask) {
1579 uint64_t VRSaveAreaOffset = OffsetVR;
1580 assert(VRSaveAreaOffset < 0x10000000 && "Offset out of range");
1581
1582 FrameAndVROffset = VRSaveAreaOffset & 0x0FFFFFFF; // Lose top 4 bits.
1583 FrameAndVROffset |= FrameReg << 28; // Put into top 4 bits.
1584 }
1585
1586 // Emit PPA1 section.
1587 OutStreamer->AddComment("PPA1");
1588 OutStreamer->emitLabel(CurrentFnPPA1Sym);
1589 OutStreamer->AddComment("Version");
1590 OutStreamer->emitInt8(0x02); // Version.
1591 OutStreamer->AddComment("LE Signature X'CE'");
1592 OutStreamer->emitInt8(0xCE); // CEL signature.
1593 OutStreamer->AddComment("Saved GPR Mask");
1594 OutStreamer->emitInt16(SavedGPRMask);
1595 OutStreamer->AddComment("Offset to PPA2");
1596 OutStreamer->emitAbsoluteSymbolDiff(PPA2Sym, CurrentFnPPA1Sym, 4);
1597
1598 bool NeedEmitEHBlock = !MF->getLandingPads().empty();
1599
1600 // Optional Argument Area Length.
1601 // Note: This represents the length of the argument area that we reserve
1602 // in our stack for setting up arguments for calls to other
1603 // routines. If this optional field is not set, LE will reserve
1604 // 128 bytes for the argument area. This optional field is
1605 // created if greater than 128 bytes is required - to guarantee
1606 // the required space is reserved on stack extension in the new
1607 // extension. This optional field is also created if the
1608 // routine has alloca(). This may reduce stack space
1609 // if alloca() call causes a stack extension.
1610 bool HasArgAreaLength =
1611 (AllocaReg != 0) || (MFFrame.getMaxCallFrameSize() > 128);
1612
1613 bool HasName =
1614 MF->getFunction().hasName() && MF->getFunction().getName().size() > 0;
1615
1616 emitPPA1Flags(OutStreamer, MF->getFunction().isVarArg(),
1617 MFFrame.hasStackProtectorIndex(), SavedFPRMask != 0,
1618 TargetHasVector && SavedVRMask != 0, NeedEmitEHBlock,
1619 HasArgAreaLength, HasName);
1620
1621 OutStreamer->AddComment("Length/4 of Parms");
1622 OutStreamer->emitInt16(
1623 static_cast<uint16_t>(ZFI->getSizeOfFnParams() / 4)); // Parms/4.
1624 OutStreamer->AddComment("Length of Code");
1625 OutStreamer->emitAbsoluteSymbolDiff(FnEndSym, CurrentFnEPMarkerSym, 4);
1626
1627 if (HasArgAreaLength) {
1628 OutStreamer->AddComment("Argument Area Length");
1629 OutStreamer->emitInt32(MFFrame.getMaxCallFrameSize());
1630 }
1631
1632 // Emit saved FPR mask and offset to FPR save area (0x20 of flags 3).
1633 if (SavedFPRMask) {
1634 OutStreamer->AddComment("FPR mask");
1635 OutStreamer->emitInt16(SavedFPRMask);
1636 OutStreamer->AddComment("AR mask");
1637 OutStreamer->emitInt16(0); // AR Mask, unused currently.
1638 OutStreamer->AddComment("FPR Save Area Locator");
1639 OutStreamer->AddComment(Twine(" Bit 0-3: Register R")
1640 .concat(utostr(FrameAndFPROffset >> 28))
1641 .str());
1642 OutStreamer->AddComment(Twine(" Bit 4-31: Offset ")
1643 .concat(utostr(FrameAndFPROffset & 0x0FFFFFFF))
1644 .str());
1645 OutStreamer->emitInt32(FrameAndFPROffset); // Offset to FPR save area with
1646 // register to add value to
1647 // (alloca reg).
1648 }
1649
1650 // Emit saved VR mask to VR save area.
1651 if (TargetHasVector && SavedVRMask) {
1652 OutStreamer->AddComment("VR mask");
1653 OutStreamer->emitInt8(SavedVRMask);
1654 OutStreamer->emitInt8(0); // Reserved.
1655 OutStreamer->emitInt16(0); // Also reserved.
1656 OutStreamer->AddComment("VR Save Area Locator");
1657 OutStreamer->AddComment(Twine(" Bit 0-3: Register R")
1658 .concat(utostr(FrameAndVROffset >> 28))
1659 .str());
1660 OutStreamer->AddComment(Twine(" Bit 4-31: Offset ")
1661 .concat(utostr(FrameAndVROffset & 0x0FFFFFFF))
1662 .str());
1663 OutStreamer->emitInt32(FrameAndVROffset);
1664 }
1665
1666 // Emit C++ EH information block
1667 const Function *Per = nullptr;
1668 if (NeedEmitEHBlock) {
1669 Per = dyn_cast<Function>(
1670 MF->getFunction().getPersonalityFn()->stripPointerCasts());
1671 MCSymbol *PersonalityRoutine =
1672 Per ? MF->getTarget().getSymbol(Per) : nullptr;
1673 assert(PersonalityRoutine && "Missing personality routine");
1674
1675 OutStreamer->AddComment("Version");
1676 OutStreamer->emitInt32(1);
1677 OutStreamer->AddComment("Flags");
1678 OutStreamer->emitInt32(0); // LSDA field is a WAS offset
1679 OutStreamer->AddComment("Personality routine");
1680 OutStreamer->emitInt64(ADATable.insert(
1681 PersonalityRoutine, SystemZII::MO_ADA_INDIRECT_FUNC_DESC));
1682 OutStreamer->AddComment("LSDA location");
1683 MCSymbol *GCCEH = MF->getContext().getOrCreateSymbol(
1684 Twine("GCC_except_table") + Twine(MF->getFunctionNumber()));
1685 OutStreamer->emitInt64(
1686 ADATable.insert(GCCEH, SystemZII::MO_ADA_DATA_SYMBOL_ADDR));
1687 }
1688
1689 // Emit name length and name optional section (0x01 of flags 4)
1690 if (HasName)
1691 emitPPA1Name(OutStreamer, MF->getFunction().getName());
1692
1693 // Emit offset to entry point optional section (0x80 of flags 4).
1694 OutStreamer->emitAbsoluteSymbolDiff(CurrentFnEPMarkerSym, CurrentFnPPA1Sym,
1695 4);
1696}
1697
1699 if (TM.getTargetTriple().isOSzOS())
1700 emitPPA2(M);
1702}
1703
1704void SystemZAsmPrinter::emitPPA2(Module &M) {
1705 OutStreamer->pushSection();
1706 OutStreamer->switchSection(getObjFileLowering().getTextSection(),
1708 MCContext &OutContext = OutStreamer->getContext();
1709 // Make CELQSTRT symbol.
1710 const char *StartSymbolName = "CELQSTRT";
1711 MCSymbol *CELQSTRT = OutContext.getOrCreateSymbol(StartSymbolName);
1712 OutStreamer->emitSymbolAttribute(CELQSTRT, MCSA_OSLinkage);
1713 OutStreamer->emitSymbolAttribute(CELQSTRT, MCSA_Global);
1714
1715 // Create symbol and assign to class field for use in PPA1.
1716 PPA2Sym = OutContext.createTempSymbol("PPA2", false);
1717 MCSymbol *DateVersionSym = OutContext.createTempSymbol("DVS", false);
1718
1719 std::time_t Time = getTranslationTime(M);
1720 SmallString<14> CompilationTimeEBCDIC, CompilationTime;
1721 CompilationTime = formatv("{0:%Y%m%d%H%M%S}", llvm::sys::toUtcTime(Time));
1722
1723 uint32_t ProductVersion = getProductVersion(M),
1724 ProductRelease = getProductRelease(M),
1725 ProductPatch = getProductPatch(M);
1726
1727 SmallString<6> VersionEBCDIC, Version;
1728 Version = formatv("{0,0-2:d}{1,0-2:d}{2,0-2:d}", ProductVersion,
1729 ProductRelease, ProductPatch);
1730
1731 ConverterEBCDIC::convertToEBCDIC(CompilationTime, CompilationTimeEBCDIC);
1733
1734 enum class PPA2MemberId : uint8_t {
1735 // See z/OS Language Environment Vendor Interfaces v2r5, p.23, for
1736 // complete list. Only the C runtime is supported by this backend.
1737 LE_C_Runtime = 3,
1738 };
1739 enum class PPA2MemberSubId : uint8_t {
1740 // List of languages using the LE C runtime implementation.
1741 C = 0x00,
1742 CXX = 0x01,
1743 Swift = 0x03,
1744 Go = 0x60,
1745 LLVMBasedLang = 0xe7,
1746 };
1747 // PPA2 Flags
1748 enum class PPA2Flags : uint8_t {
1749 CompileForBinaryFloatingPoint = 0x80,
1750 CompiledWithXPLink = 0x01,
1751 CompiledUnitASCII = 0x04,
1752 HasServiceInfo = 0x20,
1753 };
1754
1755 PPA2MemberSubId MemberSubId = PPA2MemberSubId::LLVMBasedLang;
1756 if (auto *MD = M.getModuleFlag("zos_cu_language")) {
1757 StringRef Language = cast<MDString>(MD)->getString();
1758 MemberSubId = StringSwitch<PPA2MemberSubId>(Language)
1759 .Case("C", PPA2MemberSubId::C)
1760 .Case("C++", PPA2MemberSubId::CXX)
1761 .Case("Swift", PPA2MemberSubId::Swift)
1762 .Case("Go", PPA2MemberSubId::Go)
1763 .Default(PPA2MemberSubId::LLVMBasedLang);
1764 }
1765
1766 // Emit PPA2 section.
1767 OutStreamer->emitLabel(PPA2Sym);
1768 OutStreamer->emitInt8(static_cast<uint8_t>(PPA2MemberId::LE_C_Runtime));
1769 OutStreamer->emitInt8(static_cast<uint8_t>(MemberSubId));
1770 OutStreamer->emitInt8(0x22); // Member defined, c370_plist+c370_env
1771 OutStreamer->emitInt8(0x04); // Control level 4 (XPLink)
1772 OutStreamer->emitAbsoluteSymbolDiff(CELQSTRT, PPA2Sym, 4);
1773 OutStreamer->emitInt32(0x00000000);
1774 OutStreamer->emitAbsoluteSymbolDiff(DateVersionSym, PPA2Sym, 4);
1775 OutStreamer->emitInt32(
1776 0x00000000); // Offset to main entry point, always 0 (so says TR).
1777 uint8_t Flgs = static_cast<uint8_t>(PPA2Flags::CompileForBinaryFloatingPoint);
1778 Flgs |= static_cast<uint8_t>(PPA2Flags::CompiledWithXPLink);
1779
1780 bool IsASCII = true;
1781 if (auto *MD = M.getModuleFlag("zos_le_char_mode")) {
1782 const StringRef &CharMode = cast<MDString>(MD)->getString();
1783 if (CharMode == "ebcdic")
1784 IsASCII = false;
1785 else if (CharMode != "ascii")
1786 OutContext.reportError(
1787 {}, "Only ascii or ebcdic are allowed for zos_le_char_mode");
1788 }
1789 if (IsASCII)
1790 Flgs |= static_cast<uint8_t>(
1791 PPA2Flags::CompiledUnitASCII); // Setting bit for ASCII char. mode.
1792
1793 OutStreamer->emitInt8(Flgs);
1794 OutStreamer->emitInt8(0x00); // Reserved.
1795 // No MD5 signature before timestamp.
1796 // No FLOAT(AFP(VOLATILE)).
1797 // Remaining 5 flag bits reserved.
1798 OutStreamer->emitInt16(0x0000); // 16 Reserved flag bits.
1799
1800 // Emit date and version section.
1801 OutStreamer->emitLabel(DateVersionSym);
1802 OutStreamer->emitBytes(CompilationTimeEBCDIC.str());
1803 OutStreamer->emitBytes(VersionEBCDIC.str());
1804
1805 OutStreamer->emitInt16(0x0000); // Service level string length.
1806
1807 // The binder requires that the offset to the PPA2 be emitted in a different,
1808 // specially-named section.
1809 OutStreamer->switchSection(getObjFileLowering().getPPA2ListSection());
1810 // Emit 8 byte alignment.
1811 // Emit pointer to PPA2 label.
1812 OutStreamer->AddComment("A(PPA2-CELQSTRT)");
1813 OutStreamer->emitAbsoluteSymbolDiff(PPA2Sym, CELQSTRT, 8);
1814 OutStreamer->popSection();
1815}
1816
1818 const GlobalAlias &GA) {
1819 if (!TM.getTargetTriple().isOSzOS())
1820 return AsmPrinter::emitGlobalAlias(M, GA);
1821
1822 // Aliased function labels have already been emitted for z/OS
1823}
1824
1826 const Constant *BaseCV,
1827 uint64_t Offset) {
1828 const Triple &TargetTriple = TM.getTargetTriple();
1829
1830 if (TargetTriple.isOSzOS()) {
1831 const GlobalAlias *GA = dyn_cast<GlobalAlias>(CV);
1833 const Function *FV = dyn_cast<Function>(CV);
1834 bool IsFunc = !GV && (FV || (GA && isa<Function>(GA->getAliaseeObject())));
1835
1836 MCSymbol *Sym = NULL;
1837
1838 if (GA)
1839 Sym = getSymbol(GA);
1840 else if (IsFunc)
1841 Sym = getSymbol(FV);
1842 else if (GV)
1843 Sym = getSymbol(GV);
1844
1845 if (IsFunc) {
1846 OutStreamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeFunction);
1847 if (FV->hasExternalLinkage())
1850 // Trigger creation of function descriptor in ADA for internal
1851 // functions.
1852 unsigned Disp = ADATable.insert(Sym, SystemZII::MO_ADA_DIRECT_FUNC_DESC);
1856 getObjFileLowering().getADASection()->getBeginSymbol(),
1857 OutContext),
1860 }
1861 if (Sym) {
1862 OutStreamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeObject);
1864 }
1865 }
1866 return AsmPrinter::lowerConstant(CV);
1867}
1868
1870 const SystemZSubtarget &Subtarget = MF->getSubtarget<SystemZSubtarget>();
1871
1872 if (Subtarget.getTargetTriple().isOSzOS()) {
1873 MCContext &OutContext = OutStreamer->getContext();
1874
1875 // Save information for later use.
1876 std::string N(MF->getFunction().hasName()
1877 ? Twine(MF->getFunction().getName()).concat("_").str()
1878 : "");
1879
1880 CurrentFnEPMarkerSym =
1881 OutContext.createTempSymbol(Twine("EPM_").concat(N).str(), true);
1882 CurrentFnPPA1Sym =
1883 OutContext.createTempSymbol(Twine("PPA1_").concat(N).str(), true);
1884
1885 // EntryPoint Marker
1886 const MachineFrameInfo &MFFrame = MF->getFrameInfo();
1887 bool IsUsingAlloca = MFFrame.hasVarSizedObjects();
1888 uint32_t DSASize = MFFrame.getStackSize();
1889 bool IsLeaf = DSASize == 0 && MFFrame.getCalleeSavedInfo().empty();
1890
1891 // Set Flags.
1892 uint8_t Flags = 0;
1893 if (IsLeaf)
1894 Flags |= 0x08;
1895 if (IsUsingAlloca)
1896 Flags |= 0x04;
1897
1898 // Combine into top 27 bits of DSASize and bottom 5 bits of Flags.
1899 uint32_t DSAAndFlags = DSASize & 0xFFFFFFE0; // (x/32) << 5
1900 DSAAndFlags |= Flags;
1901
1902 // Emit entry point marker section.
1903 OutStreamer->AddComment("XPLINK Routine Layout Entry");
1904 OutStreamer->emitLabel(CurrentFnEPMarkerSym);
1905 OutStreamer->AddComment("Eyecatcher 0x00C300C500C500");
1906 OutStreamer->emitIntValueInHex(0x00C300C500C500, 7); // Eyecatcher.
1907 OutStreamer->AddComment("Mark Type C'1'");
1908 OutStreamer->emitInt8(0xF1); // Mark Type.
1909 OutStreamer->AddComment("Offset to PPA1");
1910 OutStreamer->emitAbsoluteSymbolDiff(CurrentFnPPA1Sym, CurrentFnEPMarkerSym,
1911 4);
1912 if (OutStreamer->isVerboseAsm()) {
1913 OutStreamer->AddComment("DSA Size 0x" + Twine::utohexstr(DSASize));
1914 OutStreamer->AddComment("Entry Flags");
1915 if (Flags & 0x08)
1916 OutStreamer->AddComment(" Bit 1: 1 = Leaf function");
1917 else
1918 OutStreamer->AddComment(" Bit 1: 0 = Non-leaf function");
1919 if (Flags & 0x04)
1920 OutStreamer->AddComment(" Bit 2: 1 = Uses alloca");
1921 else
1922 OutStreamer->AddComment(" Bit 2: 0 = Does not use alloca");
1923 }
1924 OutStreamer->emitInt32(DSAAndFlags);
1925 }
1926
1928
1929 if (Subtarget.getTargetTriple().isOSzOS()) {
1930 const Function *F = &MF->getFunction();
1931 // Emit aliasing label for function entry point label.
1932 for (const GlobalAlias *Alias : GOAliasMap[F]) {
1933 MCSymbol *Sym = getSymbol(Alias);
1934 OutStreamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeFunction);
1935 emitVisibility(Sym, Alias->getVisibility());
1936 emitLinkage(Alias, Sym);
1937 OutStreamer->emitLabel(Sym);
1938 }
1939 }
1940}
1941
1942char SystemZAsmPrinter::ID = 0;
1943
1944INITIALIZE_PASS(SystemZAsmPrinter, "systemz-asm-printer",
1945 "SystemZ Assembly Printer", false, false)
1946
1947// Force static initialization.
1948extern "C" LLVM_ABI LLVM_EXTERNAL_VISIBILITY void
1949LLVMInitializeSystemZAsmPrinter() {
1951}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
#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:487
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)
static void emitPPA1Name(std::unique_ptr< MCStreamer > &OutStreamer, StringRef OutName)
#define LOWER_LOW(NAME)
static void lowerAlignmentHint(const MachineInstr *MI, MCInst &LoweredMI, unsigned Opcode)
#define EMIT_COMMENT(Str)
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 void emitPPA1Flags(std::unique_ptr< MCStreamer > &OutStreamer, bool VarArg, bool StackProtector, bool FPRMask, bool VRMask, bool EHBlock, bool HasArgAreaLength, bool HasName)
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)
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
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)
const MCAsmInfo * MAI
Target Asm Printer information.
Definition AsmPrinter.h:97
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:609
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.
void emitAlignment(Align Alignment, const GlobalObject *GV=nullptr, unsigned MaxBytesToEmit=0) const
Emit an alignment directive to the specified power of two boundary.
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition AsmPrinter.h:101
MCSymbol * createTempSymbol(const Twine &Name) const
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
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.
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:219
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:651
bool hasExternalLinkage() const
LLVM_ABI const GlobalObject * getAliaseeObject() const
Definition Globals.cpp:442
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:64
unsigned getAssemblerDialect() const
Definition MCAsmInfo.h:562
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:343
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:553
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...
MCSymbol * getBeginSymbol()
Definition MCSection.h:589
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:221
Generic base class for all target subtargets.
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:214
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.
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 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.
iterator end()
Definition MapVector.h:67
iterator find(const KeyT &Key)
Definition MapVector.h:154
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.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:591
constexpr size_t size() const
size - Get the string size.
Definition StringRef.h:143
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
std::pair< MCInst, const MCSubtargetInfo * > MCInstSTIPair
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:625
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Definition Twine.cpp:17
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:1250
@ SHT_PROGBITS
Definition ELF.h:1149
@ SK_PPA1
Definition GOFF.h:192
@ SK_PPA2
Definition GOFF.h:193
unsigned getRegAsGR32(unsigned Reg)
const unsigned GR64Regs[16]
unsigned getRegAsGRH32(unsigned Reg)
unsigned getRegAsVR128(unsigned Reg)
unsigned getRegAsGR64(unsigned Reg)
constexpr size_t NameSize
Definition XCOFF.h:30
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.
Definition Types.h:26
Target & getTheSystemZTarget()
@ Offset
Definition DWP.cpp:532
@ Length
Definition DWP.cpp:532
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
std::string utostr(uint64_t X, bool isNeg=false)
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
Definition STLExtras.h:1152
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302
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
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
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_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:543
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...