LLVM 20.0.0git
HexagonMCTargetDesc.cpp
Go to the documentation of this file.
1//===-- HexagonMCTargetDesc.cpp - Hexagon Target Descriptions -------------===//
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// This file provides Hexagon specific target descriptions.
10//
11//===----------------------------------------------------------------------===//
12
14#include "HexagonDepArch.h"
22#include "llvm/ADT/StringRef.h"
25#include "llvm/MC/MCAssembler.h"
27#include "llvm/MC/MCContext.h"
28#include "llvm/MC/MCDwarf.h"
32#include "llvm/MC/MCInstrInfo.h"
34#include "llvm/MC/MCStreamer.h"
40#include <cassert>
41#include <cstdint>
42#include <mutex>
43#include <new>
44#include <string>
45#include <unordered_map>
46
47using namespace llvm;
48
49#define GET_INSTRINFO_MC_DESC
50#define ENABLE_INSTR_PREDICATE_VERIFIER
51#include "HexagonGenInstrInfo.inc"
52
53#define GET_SUBTARGETINFO_MC_DESC
54#include "HexagonGenSubtargetInfo.inc"
55
56#define GET_REGINFO_MC_DESC
57#include "HexagonGenRegisterInfo.inc"
58
60 ("mno-compound",
61 cl::desc("Disable looking for compound instructions for Hexagon"));
62
64 ("mno-pairing",
65 cl::desc("Disable looking for duplex instructions for Hexagon"));
66
67namespace { // These flags are to be deprecated
68cl::opt<bool> MV5("mv5", cl::Hidden, cl::desc("Build for Hexagon V5"),
69 cl::init(false));
70cl::opt<bool> MV55("mv55", cl::Hidden, cl::desc("Build for Hexagon V55"),
71 cl::init(false));
72cl::opt<bool> MV60("mv60", cl::Hidden, cl::desc("Build for Hexagon V60"),
73 cl::init(false));
74cl::opt<bool> MV62("mv62", cl::Hidden, cl::desc("Build for Hexagon V62"),
75 cl::init(false));
76cl::opt<bool> MV65("mv65", cl::Hidden, cl::desc("Build for Hexagon V65"),
77 cl::init(false));
78cl::opt<bool> MV66("mv66", cl::Hidden, cl::desc("Build for Hexagon V66"),
79 cl::init(false));
80cl::opt<bool> MV67("mv67", cl::Hidden, cl::desc("Build for Hexagon V67"),
81 cl::init(false));
82cl::opt<bool> MV67T("mv67t", cl::Hidden, cl::desc("Build for Hexagon V67T"),
83 cl::init(false));
84cl::opt<bool> MV68("mv68", cl::Hidden, cl::desc("Build for Hexagon V68"),
85 cl::init(false));
86cl::opt<bool> MV69("mv69", cl::Hidden, cl::desc("Build for Hexagon V69"),
87 cl::init(false));
88cl::opt<bool> MV71("mv71", cl::Hidden, cl::desc("Build for Hexagon V71"),
89 cl::init(false));
90cl::opt<bool> MV71T("mv71t", cl::Hidden, cl::desc("Build for Hexagon V71T"),
91 cl::init(false));
92cl::opt<bool> MV73("mv73", cl::Hidden, cl::desc("Build for Hexagon V73"),
93 cl::init(false));
94cl::opt<bool> MV75("mv75", cl::Hidden, cl::desc("Build for Hexagon V75"),
95 cl::init(false));
96} // namespace
97
99 "mhvx", cl::desc("Enable Hexagon Vector eXtensions"),
100 cl::values(clEnumValN(Hexagon::ArchEnum::V60, "v60", "Build for HVX v60"),
101 clEnumValN(Hexagon::ArchEnum::V62, "v62", "Build for HVX v62"),
102 clEnumValN(Hexagon::ArchEnum::V65, "v65", "Build for HVX v65"),
103 clEnumValN(Hexagon::ArchEnum::V66, "v66", "Build for HVX v66"),
104 clEnumValN(Hexagon::ArchEnum::V67, "v67", "Build for HVX v67"),
105 clEnumValN(Hexagon::ArchEnum::V68, "v68", "Build for HVX v68"),
106 clEnumValN(Hexagon::ArchEnum::V69, "v69", "Build for HVX v69"),
107 clEnumValN(Hexagon::ArchEnum::V71, "v71", "Build for HVX v71"),
108 clEnumValN(Hexagon::ArchEnum::V73, "v73", "Build for HVX v73"),
109 clEnumValN(Hexagon::ArchEnum::V75, "v75", "Build for HVX v75"),
110 // Sentinel for no value specified.
111 clEnumValN(Hexagon::ArchEnum::Generic, "", "")),
112 // Sentinel for flag not present.
113 cl::init(Hexagon::ArchEnum::NoArch), cl::ValueOptional);
114
115static cl::opt<bool>
117 cl::desc("Disable Hexagon Vector eXtensions"));
118
119static cl::opt<bool>
121 cl::desc("Enable HVX IEEE floating point extensions"));
123 ("mcabac", cl::desc("tbd"), cl::init(false));
124
125static StringRef DefaultArch = "hexagonv60";
126
128 if (MV5)
129 return "hexagonv5";
130 if (MV55)
131 return "hexagonv55";
132 if (MV60)
133 return "hexagonv60";
134 if (MV62)
135 return "hexagonv62";
136 if (MV65)
137 return "hexagonv65";
138 if (MV66)
139 return "hexagonv66";
140 if (MV67)
141 return "hexagonv67";
142 if (MV67T)
143 return "hexagonv67t";
144 if (MV68)
145 return "hexagonv68";
146 if (MV69)
147 return "hexagonv69";
148 if (MV71)
149 return "hexagonv71";
150 if (MV71T)
151 return "hexagonv71t";
152 if (MV73)
153 return "hexagonv73";
154 if (MV75)
155 return "hexagonv75";
156 return "";
157}
158
161 if (!ArchV.empty() && !CPU.empty()) {
162 // Tiny cores have a "t" suffix that is discarded when creating a secondary
163 // non-tiny subtarget. See: addArchSubtarget
164 std::pair<StringRef, StringRef> ArchP = ArchV.split('t');
165 std::pair<StringRef, StringRef> CPUP = CPU.split('t');
166 if (ArchP.first != CPUP.first)
167 report_fatal_error("conflicting architectures specified.");
168 return CPU;
169 }
170 if (ArchV.empty()) {
171 if (CPU.empty())
172 CPU = DefaultArch;
173 return CPU;
174 }
175 return ArchV;
176}
177
178unsigned llvm::HexagonGetLastSlot() { return HexagonItinerariesV5FU::SLOT3; }
179
180unsigned llvm::HexagonConvertUnits(unsigned ItinUnits, unsigned *Lanes) {
181 enum {
182 CVI_NONE = 0,
183 CVI_XLANE = 1 << 0,
184 CVI_SHIFT = 1 << 1,
185 CVI_MPY0 = 1 << 2,
186 CVI_MPY1 = 1 << 3,
187 CVI_ZW = 1 << 4
188 };
189
190 if (ItinUnits == HexagonItinerariesV62FU::CVI_ALL ||
191 ItinUnits == HexagonItinerariesV62FU::CVI_ALL_NOMEM)
192 return (*Lanes = 4, CVI_XLANE);
193 else if (ItinUnits & HexagonItinerariesV62FU::CVI_MPY01 &&
194 ItinUnits & HexagonItinerariesV62FU::CVI_XLSHF)
195 return (*Lanes = 2, CVI_XLANE | CVI_MPY0);
196 else if (ItinUnits & HexagonItinerariesV62FU::CVI_MPY01)
197 return (*Lanes = 2, CVI_MPY0);
198 else if (ItinUnits & HexagonItinerariesV62FU::CVI_XLSHF)
199 return (*Lanes = 2, CVI_XLANE);
200 else if (ItinUnits & HexagonItinerariesV62FU::CVI_XLANE &&
201 ItinUnits & HexagonItinerariesV62FU::CVI_SHIFT &&
202 ItinUnits & HexagonItinerariesV62FU::CVI_MPY0 &&
203 ItinUnits & HexagonItinerariesV62FU::CVI_MPY1)
204 return (*Lanes = 1, CVI_XLANE | CVI_SHIFT | CVI_MPY0 | CVI_MPY1);
205 else if (ItinUnits & HexagonItinerariesV62FU::CVI_XLANE &&
206 ItinUnits & HexagonItinerariesV62FU::CVI_SHIFT)
207 return (*Lanes = 1, CVI_XLANE | CVI_SHIFT);
208 else if (ItinUnits & HexagonItinerariesV62FU::CVI_MPY0 &&
209 ItinUnits & HexagonItinerariesV62FU::CVI_MPY1)
210 return (*Lanes = 1, CVI_MPY0 | CVI_MPY1);
211 else if (ItinUnits == HexagonItinerariesV62FU::CVI_ZW)
212 return (*Lanes = 1, CVI_ZW);
213 else if (ItinUnits == HexagonItinerariesV62FU::CVI_XLANE)
214 return (*Lanes = 1, CVI_XLANE);
215 else if (ItinUnits == HexagonItinerariesV62FU::CVI_SHIFT)
216 return (*Lanes = 1, CVI_SHIFT);
217
218 return (*Lanes = 0, CVI_NONE);
219}
220
221
222namespace llvm {
223namespace HexagonFUnits {
224bool isSlot0Only(unsigned units) {
225 return HexagonItinerariesV62FU::SLOT0 == units;
226}
227} // namespace HexagonFUnits
228} // namespace llvm
229
230namespace {
231
232class HexagonTargetAsmStreamer : public HexagonTargetStreamer {
234
235public:
236 HexagonTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS,
237 MCInstPrinter &IP)
238 : HexagonTargetStreamer(S), OS(OS) {}
239
240 void prettyPrintAsm(MCInstPrinter &InstPrinter, uint64_t Address,
241 const MCInst &Inst, const MCSubtargetInfo &STI,
242 raw_ostream &OS) override {
245 std::string Buffer;
246 {
247 raw_string_ostream TempStream(Buffer);
248 InstPrinter.printInst(&Inst, Address, "", STI, TempStream);
249 }
250 StringRef Contents(Buffer);
251 auto PacketBundle = Contents.rsplit('\n');
252 auto HeadTail = PacketBundle.first.split('\n');
253 StringRef Separator = "\n";
254 StringRef Indent = "\t";
255 OS << "\t{\n";
256 while (!HeadTail.first.empty()) {
257 StringRef InstTxt;
258 auto Duplex = HeadTail.first.split('\v');
259 if (!Duplex.second.empty()) {
260 OS << Indent << Duplex.first << Separator;
261 InstTxt = Duplex.second;
262 } else if (!HeadTail.first.trim().starts_with("immext")) {
263 InstTxt = Duplex.first;
264 }
265 if (!InstTxt.empty())
266 OS << Indent << InstTxt << Separator;
267 HeadTail = HeadTail.second.split('\n');
268 }
269
271 OS << "\n\t} :mem_noshuf" << PacketBundle.second;
272 else
273 OS << "\t}" << PacketBundle.second;
274 }
275
276 void finish() override { finishAttributeSection(); }
277
278 void finishAttributeSection() override {}
279
280 void emitAttribute(unsigned Attribute, unsigned Value) override {
281 OS << "\t.attribute\t" << Attribute << ", " << Twine(Value);
282 if (getStreamer().isVerboseAsm()) {
285 if (!Name.empty())
286 OS << "\t// " << Name;
287 }
288 OS << "\n";
289 }
290};
291
292class HexagonTargetELFStreamer : public HexagonTargetStreamer {
293public:
295 return static_cast<MCELFStreamer &>(Streamer);
296 }
297 HexagonTargetELFStreamer(MCStreamer &S, MCSubtargetInfo const &STI)
299 getStreamer().getWriter().setELFHeaderEFlags(Hexagon_MC::GetELFFlags(STI));
300 }
301
303 unsigned ByteAlignment,
304 unsigned AccessSize) override {
305 HexagonMCELFStreamer &HexagonELFStreamer =
306 static_cast<HexagonMCELFStreamer &>(getStreamer());
307 HexagonELFStreamer.HexagonMCEmitCommonSymbol(
308 Symbol, Size, Align(ByteAlignment), AccessSize);
309 }
310
312 unsigned ByteAlignment,
313 unsigned AccessSize) override {
314 HexagonMCELFStreamer &HexagonELFStreamer =
315 static_cast<HexagonMCELFStreamer &>(getStreamer());
316 HexagonELFStreamer.HexagonMCEmitLocalCommonSymbol(
317 Symbol, Size, Align(ByteAlignment), AccessSize);
318 }
319
320 void finish() override { finishAttributeSection(); }
321
322 void reset() override { AttributeSection = nullptr; }
323
324private:
325 MCSection *AttributeSection = nullptr;
326
327 void finishAttributeSection() override {
329 if (S.Contents.empty())
330 return;
331
332 S.emitAttributesSection("hexagon", ".hexagon.attributes",
333 ELF::SHT_HEXAGON_ATTRIBUTES, AttributeSection);
334 }
335
337 getStreamer().setAttributeItem(Attribute, Value,
338 /*OverwriteExisting=*/true);
339 }
340};
341
342} // end anonymous namespace
343
345 MCInstrInfo *X = new MCInstrInfo();
346 InitHexagonMCInstrInfo(X);
347 return X;
348}
349
352 InitHexagonMCRegisterInfo(X, Hexagon::R31, /*DwarfFlavour=*/0,
353 /*EHFlavour=*/0, /*PC=*/Hexagon::PC);
354 return X;
355}
356
358 const Triple &TT,
359 const MCTargetOptions &Options) {
360 MCAsmInfo *MAI = new HexagonMCAsmInfo(TT);
361
362 // VirtualFP = (R30 + #0).
364 nullptr, MRI.getDwarfRegNum(Hexagon::R30, true), 0);
365 MAI->addInitialFrameState(Inst);
366
367 return MAI;
368}
369
371 unsigned SyntaxVariant,
372 const MCAsmInfo &MAI,
373 const MCInstrInfo &MII,
374 const MCRegisterInfo &MRI)
375{
376 if (SyntaxVariant == 0)
377 return new HexagonInstPrinter(MAI, MII, MRI);
378 else
379 return nullptr;
380}
381
384 MCInstPrinter *IP) {
385 return new HexagonTargetAsmStreamer(S, OS, *IP);
386}
387
389 std::unique_ptr<MCAsmBackend> &&MAB,
390 std::unique_ptr<MCObjectWriter> &&OW,
391 std::unique_ptr<MCCodeEmitter> &&Emitter) {
392 return createHexagonELFStreamer(T, Context, std::move(MAB), std::move(OW),
393 std::move(Emitter));
394}
395
396static MCTargetStreamer *
398 return new HexagonTargetELFStreamer(S, STI);
399}
400
402 return new HexagonTargetStreamer(S);
403}
404
406 if (STI->hasFeature(F))
407 STI->ToggleFeature(F);
408}
409
411 return STI->hasFeature(F);
412}
413
414namespace {
415std::string selectHexagonFS(StringRef CPU, StringRef FS) {
417 if (!FS.empty())
418 Result.push_back(FS);
419
420 switch (EnableHVX) {
421 case Hexagon::ArchEnum::V5:
422 case Hexagon::ArchEnum::V55:
423 break;
424 case Hexagon::ArchEnum::V60:
425 Result.push_back("+hvxv60");
426 break;
427 case Hexagon::ArchEnum::V62:
428 Result.push_back("+hvxv62");
429 break;
430 case Hexagon::ArchEnum::V65:
431 Result.push_back("+hvxv65");
432 break;
433 case Hexagon::ArchEnum::V66:
434 Result.push_back("+hvxv66");
435 break;
436 case Hexagon::ArchEnum::V67:
437 Result.push_back("+hvxv67");
438 break;
439 case Hexagon::ArchEnum::V68:
440 Result.push_back("+hvxv68");
441 break;
442 case Hexagon::ArchEnum::V69:
443 Result.push_back("+hvxv69");
444 break;
445 case Hexagon::ArchEnum::V71:
446 Result.push_back("+hvxv71");
447 break;
448 case Hexagon::ArchEnum::V73:
449 Result.push_back("+hvxv73");
450 break;
451 case Hexagon::ArchEnum::V75:
452 Result.push_back("+hvxv75");
453 break;
454 case Hexagon::ArchEnum::Generic: {
455 Result.push_back(StringSwitch<StringRef>(CPU)
456 .Case("hexagonv60", "+hvxv60")
457 .Case("hexagonv62", "+hvxv62")
458 .Case("hexagonv65", "+hvxv65")
459 .Case("hexagonv66", "+hvxv66")
460 .Case("hexagonv67", "+hvxv67")
461 .Case("hexagonv67t", "+hvxv67")
462 .Case("hexagonv68", "+hvxv68")
463 .Case("hexagonv69", "+hvxv69")
464 .Case("hexagonv71", "+hvxv71")
465 .Case("hexagonv71t", "+hvxv71")
466 .Case("hexagonv73", "+hvxv73")
467 .Case("hexagonv75", "+hvxv75"));
468 break;
469 }
470 case Hexagon::ArchEnum::NoArch:
471 // Sentinel if -mhvx isn't specified
472 break;
473 }
474 if (EnableHvxIeeeFp)
475 Result.push_back("+hvx-ieee-fp");
477 Result.push_back("+cabac");
478
479 return join(Result.begin(), Result.end(), ",");
480}
481}
482
483static bool isCPUValid(StringRef CPU) {
484 return Hexagon::getCpu(CPU).has_value();
485}
486
487namespace {
488std::pair<std::string, std::string> selectCPUAndFS(StringRef CPU,
489 StringRef FS) {
490 std::pair<std::string, std::string> Result;
491 Result.first = std::string(Hexagon_MC::selectHexagonCPU(CPU));
492 Result.second = selectHexagonFS(Result.first, FS);
493 return Result;
494}
495std::mutex ArchSubtargetMutex;
496std::unordered_map<std::string, std::unique_ptr<MCSubtargetInfo const>>
497 ArchSubtarget;
498} // namespace
499
500MCSubtargetInfo const *
502 std::lock_guard<std::mutex> Lock(ArchSubtargetMutex);
503 auto Existing = ArchSubtarget.find(std::string(STI->getCPU()));
504 if (Existing == ArchSubtarget.end())
505 return nullptr;
506 return Existing->second.get();
507}
508
510 using namespace Hexagon;
511 // Make sure that +hvx-length turns hvx on, and that "hvx" alone
512 // turns on hvxvNN, corresponding to the existing ArchVNN.
513 FeatureBitset FB = S;
514 unsigned CpuArch = ArchV5;
515 for (unsigned F : {ArchV75, ArchV73, ArchV71, ArchV69, ArchV68, ArchV67,
516 ArchV66, ArchV65, ArchV62, ArchV60, ArchV55, ArchV5}) {
517 if (!FB.test(F))
518 continue;
519 CpuArch = F;
520 break;
521 }
522 bool UseHvx = false;
523 for (unsigned F : {ExtensionHVX, ExtensionHVX64B, ExtensionHVX128B}) {
524 if (!FB.test(F))
525 continue;
526 UseHvx = true;
527 break;
528 }
529 bool HasHvxVer = false;
530 for (unsigned F :
531 {ExtensionHVXV60, ExtensionHVXV62, ExtensionHVXV65, ExtensionHVXV66,
532 ExtensionHVXV67, ExtensionHVXV68, ExtensionHVXV69, ExtensionHVXV71,
533 ExtensionHVXV73, ExtensionHVXV75}) {
534 if (!FB.test(F))
535 continue;
536 HasHvxVer = true;
537 UseHvx = true;
538 break;
539 }
540
541 if (!UseHvx || HasHvxVer)
542 return FB;
543
544 // HasHvxVer is false, and UseHvx is true.
545 switch (CpuArch) {
546 case ArchV75:
547 FB.set(ExtensionHVXV75);
548 [[fallthrough]];
549 case ArchV73:
550 FB.set(ExtensionHVXV73);
551 [[fallthrough]];
552 case ArchV71:
553 FB.set(ExtensionHVXV71);
554 [[fallthrough]];
555 case ArchV69:
556 FB.set(ExtensionHVXV69);
557 [[fallthrough]];
558 case ArchV68:
559 FB.set(ExtensionHVXV68);
560 [[fallthrough]];
561 case ArchV67:
562 FB.set(ExtensionHVXV67);
563 [[fallthrough]];
564 case ArchV66:
565 FB.set(ExtensionHVXV66);
566 [[fallthrough]];
567 case ArchV65:
568 FB.set(ExtensionHVXV65);
569 [[fallthrough]];
570 case ArchV62:
571 FB.set(ExtensionHVXV62);
572 [[fallthrough]];
573 case ArchV60:
574 FB.set(ExtensionHVXV60);
575 break;
576 }
577 return FB;
578}
579
581 StringRef CPU,
582 StringRef FS) {
583 std::pair<std::string, std::string> Features = selectCPUAndFS(CPU, FS);
584 StringRef CPUName = Features.first;
585 StringRef ArchFS = Features.second;
586
587 MCSubtargetInfo *X = createHexagonMCSubtargetInfoImpl(
588 TT, CPUName, /*TuneCPU*/ CPUName, ArchFS);
589 if (X != nullptr && (CPUName == "hexagonv67t" || CPUName == "hexagon71t"))
590 addArchSubtarget(X, ArchFS);
591
592 if (CPU == "help")
593 exit(0);
594
595 if (!isCPUValid(CPUName.str())) {
596 errs() << "error: invalid CPU \"" << CPUName.str().c_str()
597 << "\" specified\n";
598 return nullptr;
599 }
600
601 // Add qfloat subtarget feature by default to v68 and above
602 // unless explicitely disabled
603 if (checkFeature(X, Hexagon::ExtensionHVXV68) &&
604 !ArchFS.contains("-hvx-qfloat")) {
605 llvm::FeatureBitset Features = X->getFeatureBits();
606 X->setFeatureBits(Features.set(Hexagon::ExtensionHVXQFloat));
607 }
608
610 llvm::FeatureBitset Features = X->getFeatureBits();
611 X->setFeatureBits(Features.reset(Hexagon::FeatureDuplex));
612 }
613
614 X->setFeatureBits(completeHVXFeatures(X->getFeatureBits()));
615
616 // The Z-buffer instructions are grandfathered in for current
617 // architectures but omitted for new ones. Future instruction
618 // sets may introduce new/conflicting z-buffer instructions.
619 const bool ZRegOnDefault =
620 (CPUName == "hexagonv67") || (CPUName == "hexagonv66");
621 if (ZRegOnDefault) {
622 llvm::FeatureBitset Features = X->getFeatureBits();
623 X->setFeatureBits(Features.set(Hexagon::ExtensionZReg));
624 }
625
626 return X;
627}
628
630 assert(STI != nullptr);
631 if (STI->getCPU().contains("t")) {
632 auto ArchSTI = createHexagonMCSubtargetInfo(
633 STI->getTargetTriple(),
634 STI->getCPU().substr(0, STI->getCPU().size() - 1), FS);
635 std::lock_guard<std::mutex> Lock(ArchSubtargetMutex);
636 ArchSubtarget[std::string(STI->getCPU())] =
637 std::unique_ptr<MCSubtargetInfo const>(ArchSTI);
638 }
639}
640
641std::optional<unsigned>
643 for (auto Arch : {Hexagon::ExtensionHVXV75, Hexagon::ExtensionHVXV73,
644 Hexagon::ExtensionHVXV71, Hexagon::ExtensionHVXV69,
645 Hexagon::ExtensionHVXV68, Hexagon::ExtensionHVXV67,
646 Hexagon::ExtensionHVXV66, Hexagon::ExtensionHVXV65,
647 Hexagon::ExtensionHVXV62, Hexagon::ExtensionHVXV60})
648 if (Features.test(Arch))
649 return Arch;
650 return {};
651}
652
653unsigned Hexagon_MC::getArchVersion(const FeatureBitset &Features) {
654 for (auto Arch :
655 {Hexagon::ArchV75, Hexagon::ArchV73, Hexagon::ArchV71, Hexagon::ArchV69,
656 Hexagon::ArchV68, Hexagon::ArchV67, Hexagon::ArchV66, Hexagon::ArchV65,
657 Hexagon::ArchV62, Hexagon::ArchV60, Hexagon::ArchV55, Hexagon::ArchV5})
658 if (Features.test(Arch))
659 return Arch;
660 llvm_unreachable("Expected arch v5-v75");
661 return 0;
662}
663
665 return StringSwitch<unsigned>(STI.getCPU())
680 .Case("hexagonv75", llvm::ELF::EF_HEXAGON_MACH_V75);
681}
682
684 return ArrayRef(VectRegRev);
685}
686
687namespace {
688class HexagonMCInstrAnalysis : public MCInstrAnalysis {
689public:
690 HexagonMCInstrAnalysis(MCInstrInfo const *Info) : MCInstrAnalysis(Info) {}
691
692 bool isUnconditionalBranch(MCInst const &Inst) const override {
693 //assert(!HexagonMCInstrInfo::isBundle(Inst));
695 }
696
697 bool isConditionalBranch(MCInst const &Inst) const override {
698 //assert(!HexagonMCInstrInfo::isBundle(Inst));
700 }
701
702 bool evaluateBranch(MCInst const &Inst, uint64_t Addr,
703 uint64_t Size, uint64_t &Target) const override {
704 if (!(isCall(Inst) || isUnconditionalBranch(Inst) ||
705 isConditionalBranch(Inst)))
706 return false;
707
708 //assert(!HexagonMCInstrInfo::isBundle(Inst));
709 if (!HexagonMCInstrInfo::isExtendable(*Info, Inst))
710 return false;
711 auto const &Extended(HexagonMCInstrInfo::getExtendableOperand(*Info, Inst));
712 assert(Extended.isExpr());
713 int64_t Value;
714 if (!Extended.getExpr()->evaluateAsAbsolute(Value))
715 return false;
716 Target = Value;
717 return true;
718 }
719};
720}
721
723 return new HexagonMCInstrAnalysis(Info);
724}
725
726// Force static initialization.
728 // Register the MC asm info.
730
731 // Register the MC instruction info.
734
735 // Register the MC register info.
738
739 // Register the MC subtarget info.
742
743 // Register the MC Code Emitter
746
747 // Register the asm backend
750
751 // Register the MC instruction analyzer.
754
755 // Register the obj streamer
757
758 // Register the obj target streamer
761
762 // Register the asm streamer
765
766 // Register the null streamer
769
770 // Register the MC Inst Printer
773}
unsigned const MachineRegisterInfo * MRI
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:686
#define LLVM_ATTRIBUTE_UNUSED
Definition: Compiler.h:282
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:128
dxil DXContainer Global Emitter
uint64_t Addr
std::string Name
uint64_t Size
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
cl::opt< Hexagon::ArchEnum > EnableHVX("mhvx", cl::desc("Enable Hexagon Vector eXtensions"), cl::values(clEnumValN(Hexagon::ArchEnum::V60, "v60", "Build for HVX v60"), clEnumValN(Hexagon::ArchEnum::V62, "v62", "Build for HVX v62"), clEnumValN(Hexagon::ArchEnum::V65, "v65", "Build for HVX v65"), clEnumValN(Hexagon::ArchEnum::V66, "v66", "Build for HVX v66"), clEnumValN(Hexagon::ArchEnum::V67, "v67", "Build for HVX v67"), clEnumValN(Hexagon::ArchEnum::V68, "v68", "Build for HVX v68"), clEnumValN(Hexagon::ArchEnum::V69, "v69", "Build for HVX v69"), clEnumValN(Hexagon::ArchEnum::V71, "v71", "Build for HVX v71"), clEnumValN(Hexagon::ArchEnum::V73, "v73", "Build for HVX v73"), clEnumValN(Hexagon::ArchEnum::V75, "v75", "Build for HVX v75"), clEnumValN(Hexagon::ArchEnum::Generic, "", "")), cl::init(Hexagon::ArchEnum::NoArch), cl::ValueOptional)
static cl::opt< bool > EnableHexagonCabac("mcabac", cl::desc("tbd"), cl::init(false))
static MCTargetStreamer * createHexagonNullTargetStreamer(MCStreamer &S)
static MCTargetStreamer * createHexagonObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static MCTargetStreamer * createMCAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *IP)
static MCInstrAnalysis * createHexagonMCInstrAnalysis(const MCInstrInfo *Info)
static MCInstPrinter * createHexagonMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static void LLVM_ATTRIBUTE_UNUSED clearFeature(MCSubtargetInfo *STI, uint64_t F)
static cl::opt< bool > DisableHVX("mno-hvx", cl::Hidden, cl::desc("Disable Hexagon Vector eXtensions"))
static MCStreamer * createMCStreamer(Triple const &T, MCContext &Context, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter)
static bool isCPUValid(StringRef CPU)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTargetMC()
static MCRegisterInfo * createHexagonMCRegisterInfo(const Triple &TT)
static StringRef DefaultArch
static cl::opt< bool > EnableHvxIeeeFp("mhvx-ieee-fp", cl::Hidden, cl::desc("Enable HVX IEEE floating point extensions"))
static MCAsmInfo * createHexagonMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
static StringRef HexagonGetArchVariant()
static bool LLVM_ATTRIBUTE_UNUSED checkFeature(MCSubtargetInfo *STI, uint64_t F)
#define HEXAGON_PACKET_SIZE
static LVOptions Options
Definition: LVOptions.cpp:25
#define F(x, y, z)
Definition: MD5.cpp:55
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file contains some functions that are useful when dealing with strings.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Container class for subtarget features.
constexpr FeatureBitset & reset(unsigned I)
constexpr bool test(unsigned I) const
FeatureBitset & set()
Prints bundles as a newline separated list of individual instructions Duplexes are separated by a ver...
void HexagonMCEmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, unsigned AccessSize)
void HexagonMCEmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, unsigned AccessSize)
virtual void emitCommonSymbolSorted(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment, unsigned AccessGranularity)
virtual void emitLocalCommonSymbolSorted(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlign, unsigned AccessGranularity)
virtual void emitAttribute(unsigned Attribute, unsigned Value)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.cpp:75
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:575
Context object for machine code objects.
Definition: MCContext.h:83
SmallVector< AttributeItem, 64 > Contents
void emitAttributesSection(StringRef Vendor, const Twine &Section, unsigned Type, MCSection *&AttributeSection)
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:46
virtual void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS)=0
Print the specified MCInst to the specified raw_ostream.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:185
virtual bool isCall(const MCInst &Inst) const
virtual bool isUnconditionalBranch(const MCInst &Inst) const
virtual bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size, uint64_t &Target) const
Given a branch instruction try to get the address the branch targets.
virtual bool isConditionalBranch(const MCInst &Inst) const
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
Streaming machine code generation interface.
Definition: MCStreamer.h:213
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
StringRef getCPU() const
FeatureBitset ToggleFeature(uint64_t FB)
Toggle a feature and return the re-computed feature bits.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Target specific streamer interface.
Definition: MCStreamer.h:94
virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, uint64_t Address, const MCInst &Inst, const MCSubtargetInfo &STI, raw_ostream &OS)
MCStreamer & getStreamer()
Definition: MCStreamer.h:102
MCStreamer & Streamer
Definition: MCStreamer.h:96
bool empty() const
Definition: SmallVector.h:81
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:700
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:229
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:571
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:147
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:150
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:424
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:44
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:69
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
LLVM Value Representation.
Definition: Value.h:74
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:661
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
StringRef attrTypeAsString(unsigned attr, TagNameMap tagNameMap, bool hasTagPrefix=true)
@ SHT_HEXAGON_ATTRIBUTES
Definition: ELF.h:1178
@ EF_HEXAGON_MACH_V5
Definition: ELF.h:619
@ EF_HEXAGON_MACH_V71T
Definition: ELF.h:630
@ EF_HEXAGON_MACH_V67T
Definition: ELF.h:626
@ EF_HEXAGON_MACH_V65
Definition: ELF.h:623
@ EF_HEXAGON_MACH_V67
Definition: ELF.h:625
@ EF_HEXAGON_MACH_V62
Definition: ELF.h:622
@ EF_HEXAGON_MACH_V73
Definition: ELF.h:631
@ EF_HEXAGON_MACH_V71
Definition: ELF.h:629
@ EF_HEXAGON_MACH_V68
Definition: ELF.h:627
@ EF_HEXAGON_MACH_V66
Definition: ELF.h:624
@ EF_HEXAGON_MACH_V55
Definition: ELF.h:620
@ EF_HEXAGON_MACH_V60
Definition: ELF.h:621
@ EF_HEXAGON_MACH_V75
Definition: ELF.h:632
@ EF_HEXAGON_MACH_V69
Definition: ELF.h:628
const TagNameMap & getHexagonAttributeTags()
bool isSlot0Only(unsigned units)
size_t bundleSize(MCInst const &MCI)
bool isMemReorderDisabled(MCInst const &MCI)
bool isBundle(MCInst const &MCI)
bool isExtendable(MCInstrInfo const &MCII, MCInst const &MCI)
MCOperand const & getExtendableOperand(MCInstrInfo const &MCII, MCInst const &MCI)
llvm::ArrayRef< MCPhysReg > GetVectRegRev()
unsigned getArchVersion(const FeatureBitset &Features)
unsigned GetELFFlags(const MCSubtargetInfo &STI)
std::optional< unsigned > getHVXVersion(const FeatureBitset &Features)
MCSubtargetInfo const * getArchSubtarget(MCSubtargetInfo const *STI)
StringRef selectHexagonCPU(StringRef CPU)
void addArchSubtarget(MCSubtargetInfo const *STI, StringRef FS)
FeatureBitset completeHVXFeatures(const FeatureBitset &FB)
MCSubtargetInfo * createHexagonMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Create a Hexagon MCSubtargetInfo instance.
std::optional< Hexagon::ArchEnum > getCpu(StringRef CPU)
@ FS
Definition: X86.h:211
@ ValueOptional
Definition: CommandLine.h:130
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:711
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
unsigned HexagonConvertUnits(unsigned ItinUnits, unsigned *Lanes)
cl::opt< bool > HexagonDisableCompound
MCCodeEmitter * createHexagonMCCodeEmitter(const MCInstrInfo &MCII, MCContext &MCT)
unsigned HexagonGetLastSlot()
Target & getTheHexagonTarget()
MCAsmBackend * createHexagonAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
MCInstrInfo * createHexagonMCInstrInfo()
MCStreamer * createHexagonELFStreamer(Triple const &TT, MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > CE)
cl::opt< bool > HexagonDisableDuplex
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for the given target.
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)