Mercurial > hg > CbC > CbC_llvm
comparison include/llvm/Support/TargetRegistry.h @ 147:c2174574ed3a
LLVM 10
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 16:55:33 +0900 |
parents | 3a76565eade5 |
children |
comparison
equal
deleted
inserted
replaced
134:3a76565eade5 | 147:c2174574ed3a |
---|---|
1 //===- Support/TargetRegistry.h - Target Registration -----------*- C++ -*-===// | 1 //===- Support/TargetRegistry.h - Target Registration -----------*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // This file is distributed under the University of Illinois Open Source | 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 // License. See LICENSE.TXT for details. | |
7 // | 6 // |
8 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
9 // | 8 // |
10 // This file exposes the TargetRegistry interface, which tools can use to access | 9 // This file exposes the TargetRegistry interface, which tools can use to access |
11 // the appropriate target specific classes (TargetMachine, AsmPrinter, etc.) | 10 // the appropriate target specific classes (TargetMachine, AsmPrinter, etc.) |
17 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
18 | 17 |
19 #ifndef LLVM_SUPPORT_TARGETREGISTRY_H | 18 #ifndef LLVM_SUPPORT_TARGETREGISTRY_H |
20 #define LLVM_SUPPORT_TARGETREGISTRY_H | 19 #define LLVM_SUPPORT_TARGETREGISTRY_H |
21 | 20 |
22 #include "llvm-c/Disassembler.h" | 21 #include "llvm-c/DisassemblerTypes.h" |
23 #include "llvm/ADT/Optional.h" | 22 #include "llvm/ADT/Optional.h" |
24 #include "llvm/ADT/StringRef.h" | 23 #include "llvm/ADT/StringRef.h" |
25 #include "llvm/ADT/Triple.h" | 24 #include "llvm/ADT/Triple.h" |
26 #include "llvm/ADT/iterator_range.h" | 25 #include "llvm/ADT/iterator_range.h" |
27 #include "llvm/Support/CodeGen.h" | 26 #include "llvm/Support/CodeGen.h" |
44 class MCContext; | 43 class MCContext; |
45 class MCDisassembler; | 44 class MCDisassembler; |
46 class MCInstPrinter; | 45 class MCInstPrinter; |
47 class MCInstrAnalysis; | 46 class MCInstrAnalysis; |
48 class MCInstrInfo; | 47 class MCInstrInfo; |
48 class MCObjectWriter; | |
49 class MCRegisterInfo; | 49 class MCRegisterInfo; |
50 class MCRelocationInfo; | 50 class MCRelocationInfo; |
51 class MCStreamer; | 51 class MCStreamer; |
52 class MCSubtargetInfo; | 52 class MCSubtargetInfo; |
53 class MCSymbolizer; | 53 class MCSymbolizer; |
58 class raw_pwrite_stream; | 58 class raw_pwrite_stream; |
59 class TargetMachine; | 59 class TargetMachine; |
60 class TargetOptions; | 60 class TargetOptions; |
61 | 61 |
62 MCStreamer *createNullStreamer(MCContext &Ctx); | 62 MCStreamer *createNullStreamer(MCContext &Ctx); |
63 MCStreamer *createAsmStreamer(MCContext &Ctx, | 63 // Takes ownership of \p TAB and \p CE. |
64 std::unique_ptr<formatted_raw_ostream> OS, | 64 |
65 bool isVerboseAsm, bool useDwarfDirectory, | 65 /// Create a machine code streamer which will print out assembly for the native |
66 MCInstPrinter *InstPrint, MCCodeEmitter *CE, | 66 /// target, suitable for compiling with a native assembler. |
67 MCAsmBackend *TAB, bool ShowInst); | 67 /// |
68 | 68 /// \param InstPrint - If given, the instruction printer to use. If not given |
69 /// Takes ownership of \p TAB and \p CE. | 69 /// the MCInst representation will be printed. This method takes ownership of |
70 /// InstPrint. | |
71 /// | |
72 /// \param CE - If given, a code emitter to use to show the instruction | |
73 /// encoding inline with the assembly. This method takes ownership of \p CE. | |
74 /// | |
75 /// \param TAB - If given, a target asm backend to use to show the fixup | |
76 /// information in conjunction with encoding information. This method takes | |
77 /// ownership of \p TAB. | |
78 /// | |
79 /// \param ShowInst - Whether to show the MCInst representation inline with | |
80 /// the assembly. | |
81 MCStreamer * | |
82 createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS, | |
83 bool isVerboseAsm, bool useDwarfDirectory, | |
84 MCInstPrinter *InstPrint, std::unique_ptr<MCCodeEmitter> &&CE, | |
85 std::unique_ptr<MCAsmBackend> &&TAB, bool ShowInst); | |
86 | |
70 MCStreamer *createELFStreamer(MCContext &Ctx, | 87 MCStreamer *createELFStreamer(MCContext &Ctx, |
71 std::unique_ptr<MCAsmBackend> &&TAB, | 88 std::unique_ptr<MCAsmBackend> &&TAB, |
72 raw_pwrite_stream &OS, | 89 std::unique_ptr<MCObjectWriter> &&OW, |
73 std::unique_ptr<MCCodeEmitter> &&CE, | 90 std::unique_ptr<MCCodeEmitter> &&CE, |
74 bool RelaxAll); | 91 bool RelaxAll); |
75 MCStreamer *createMachOStreamer(MCContext &Ctx, | 92 MCStreamer *createMachOStreamer(MCContext &Ctx, |
76 std::unique_ptr<MCAsmBackend> &&TAB, | 93 std::unique_ptr<MCAsmBackend> &&TAB, |
77 raw_pwrite_stream &OS, | 94 std::unique_ptr<MCObjectWriter> &&OW, |
78 std::unique_ptr<MCCodeEmitter> &&CE, | 95 std::unique_ptr<MCCodeEmitter> &&CE, |
79 bool RelaxAll, bool DWARFMustBeAtTheEnd, | 96 bool RelaxAll, bool DWARFMustBeAtTheEnd, |
80 bool LabelSections = false); | 97 bool LabelSections = false); |
81 MCStreamer *createWasmStreamer(MCContext &Ctx, | 98 MCStreamer *createWasmStreamer(MCContext &Ctx, |
82 std::unique_ptr<MCAsmBackend> &&TAB, | 99 std::unique_ptr<MCAsmBackend> &&TAB, |
83 raw_pwrite_stream &OS, | 100 std::unique_ptr<MCObjectWriter> &&OW, |
84 std::unique_ptr<MCCodeEmitter> &&CE, | 101 std::unique_ptr<MCCodeEmitter> &&CE, |
85 bool RelaxAll); | 102 bool RelaxAll); |
103 MCStreamer *createXCOFFStreamer(MCContext &Ctx, | |
104 std::unique_ptr<MCAsmBackend> &&TAB, | |
105 std::unique_ptr<MCObjectWriter> &&OW, | |
106 std::unique_ptr<MCCodeEmitter> &&CE, | |
107 bool RelaxAll); | |
86 | 108 |
87 MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx); | 109 MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx); |
88 | 110 |
89 MCSymbolizer *createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, | 111 MCSymbolizer *createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, |
90 LLVMSymbolLookupCallback SymbolLookUp, | 112 LLVMSymbolLookupCallback SymbolLookUp, |
141 const MCRegisterInfo &MRI, | 163 const MCRegisterInfo &MRI, |
142 MCContext &Ctx); | 164 MCContext &Ctx); |
143 using ELFStreamerCtorTy = | 165 using ELFStreamerCtorTy = |
144 MCStreamer *(*)(const Triple &T, MCContext &Ctx, | 166 MCStreamer *(*)(const Triple &T, MCContext &Ctx, |
145 std::unique_ptr<MCAsmBackend> &&TAB, | 167 std::unique_ptr<MCAsmBackend> &&TAB, |
146 raw_pwrite_stream &OS, | 168 std::unique_ptr<MCObjectWriter> &&OW, |
147 std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll); | 169 std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll); |
148 using MachOStreamerCtorTy = | 170 using MachOStreamerCtorTy = |
149 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB, | 171 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB, |
150 raw_pwrite_stream &OS, | 172 std::unique_ptr<MCObjectWriter> &&OW, |
151 std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll, | 173 std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll, |
152 bool DWARFMustBeAtTheEnd); | 174 bool DWARFMustBeAtTheEnd); |
153 using COFFStreamerCtorTy = | 175 using COFFStreamerCtorTy = |
154 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB, | 176 MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB, |
155 raw_pwrite_stream &OS, | 177 std::unique_ptr<MCObjectWriter> &&OW, |
156 std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll, | 178 std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll, |
157 bool IncrementalLinkerCompatible); | 179 bool IncrementalLinkerCompatible); |
158 using WasmStreamerCtorTy = | 180 using WasmStreamerCtorTy = |
159 MCStreamer *(*)(const Triple &T, MCContext &Ctx, | 181 MCStreamer *(*)(const Triple &T, MCContext &Ctx, |
160 std::unique_ptr<MCAsmBackend> &&TAB, | 182 std::unique_ptr<MCAsmBackend> &&TAB, |
161 raw_pwrite_stream &OS, | 183 std::unique_ptr<MCObjectWriter> &&OW, |
162 std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll); | 184 std::unique_ptr<MCCodeEmitter> &&Emitter, bool RelaxAll); |
163 using NullTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S); | 185 using NullTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S); |
164 using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)( | 186 using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)( |
165 MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, | 187 MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, |
166 bool IsVerboseAsm); | 188 bool IsVerboseAsm); |
439 /// Create a target specific MCStreamer. | 461 /// Create a target specific MCStreamer. |
440 /// | 462 /// |
441 /// \param T The target triple. | 463 /// \param T The target triple. |
442 /// \param Ctx The target context. | 464 /// \param Ctx The target context. |
443 /// \param TAB The target assembler backend object. Takes ownership. | 465 /// \param TAB The target assembler backend object. Takes ownership. |
444 /// \param OS The stream object. | 466 /// \param OW The stream object. |
445 /// \param Emitter The target independent assembler object.Takes ownership. | 467 /// \param Emitter The target independent assembler object.Takes ownership. |
446 /// \param RelaxAll Relax all fixups? | 468 /// \param RelaxAll Relax all fixups? |
447 MCStreamer *createMCObjectStreamer(const Triple &T, MCContext &Ctx, | 469 MCStreamer *createMCObjectStreamer(const Triple &T, MCContext &Ctx, |
448 std::unique_ptr<MCAsmBackend> &&TAB, | 470 std::unique_ptr<MCAsmBackend> &&TAB, |
449 raw_pwrite_stream &OS, | 471 std::unique_ptr<MCObjectWriter> &&OW, |
450 std::unique_ptr<MCCodeEmitter> &&Emitter, | 472 std::unique_ptr<MCCodeEmitter> &&Emitter, |
451 const MCSubtargetInfo &STI, bool RelaxAll, | 473 const MCSubtargetInfo &STI, bool RelaxAll, |
452 bool IncrementalLinkerCompatible, | 474 bool IncrementalLinkerCompatible, |
453 bool DWARFMustBeAtTheEnd) const { | 475 bool DWARFMustBeAtTheEnd) const { |
454 MCStreamer *S; | 476 MCStreamer *S; |
455 switch (T.getObjectFormat()) { | 477 switch (T.getObjectFormat()) { |
456 default: | 478 case Triple::UnknownObjectFormat: |
457 llvm_unreachable("Unknown object format"); | 479 llvm_unreachable("Unknown object format"); |
458 case Triple::COFF: | 480 case Triple::COFF: |
459 assert(T.isOSWindows() && "only Windows COFF is supported"); | 481 assert(T.isOSWindows() && "only Windows COFF is supported"); |
460 S = COFFStreamerCtorFn(Ctx, std::move(TAB), OS, std::move(Emitter), | 482 S = COFFStreamerCtorFn(Ctx, std::move(TAB), std::move(OW), |
461 RelaxAll, IncrementalLinkerCompatible); | 483 std::move(Emitter), RelaxAll, |
484 IncrementalLinkerCompatible); | |
462 break; | 485 break; |
463 case Triple::MachO: | 486 case Triple::MachO: |
464 if (MachOStreamerCtorFn) | 487 if (MachOStreamerCtorFn) |
465 S = MachOStreamerCtorFn(Ctx, std::move(TAB), OS, std::move(Emitter), | 488 S = MachOStreamerCtorFn(Ctx, std::move(TAB), std::move(OW), |
466 RelaxAll, DWARFMustBeAtTheEnd); | 489 std::move(Emitter), RelaxAll, |
490 DWARFMustBeAtTheEnd); | |
467 else | 491 else |
468 S = createMachOStreamer(Ctx, std::move(TAB), OS, std::move(Emitter), | 492 S = createMachOStreamer(Ctx, std::move(TAB), std::move(OW), |
469 RelaxAll, DWARFMustBeAtTheEnd); | 493 std::move(Emitter), RelaxAll, |
494 DWARFMustBeAtTheEnd); | |
470 break; | 495 break; |
471 case Triple::ELF: | 496 case Triple::ELF: |
472 if (ELFStreamerCtorFn) | 497 if (ELFStreamerCtorFn) |
473 S = ELFStreamerCtorFn(T, Ctx, std::move(TAB), OS, std::move(Emitter), | 498 S = ELFStreamerCtorFn(T, Ctx, std::move(TAB), std::move(OW), |
474 RelaxAll); | 499 std::move(Emitter), RelaxAll); |
475 else | 500 else |
476 S = createELFStreamer(Ctx, std::move(TAB), OS, std::move(Emitter), | 501 S = createELFStreamer(Ctx, std::move(TAB), std::move(OW), |
477 RelaxAll); | 502 std::move(Emitter), RelaxAll); |
478 break; | 503 break; |
479 case Triple::Wasm: | 504 case Triple::Wasm: |
480 if (WasmStreamerCtorFn) | 505 if (WasmStreamerCtorFn) |
481 S = WasmStreamerCtorFn(T, Ctx, std::move(TAB), OS, std::move(Emitter), | 506 S = WasmStreamerCtorFn(T, Ctx, std::move(TAB), std::move(OW), |
482 RelaxAll); | 507 std::move(Emitter), RelaxAll); |
483 else | 508 else |
484 S = createWasmStreamer(Ctx, std::move(TAB), OS, std::move(Emitter), | 509 S = createWasmStreamer(Ctx, std::move(TAB), std::move(OW), |
485 RelaxAll); | 510 std::move(Emitter), RelaxAll); |
511 break; | |
512 case Triple::XCOFF: | |
513 S = createXCOFFStreamer(Ctx, std::move(TAB), std::move(OW), | |
514 std::move(Emitter), RelaxAll); | |
486 break; | 515 break; |
487 } | 516 } |
488 if (ObjectTargetStreamerCtorFn) | 517 if (ObjectTargetStreamerCtorFn) |
489 ObjectTargetStreamerCtorFn(*S, STI); | 518 ObjectTargetStreamerCtorFn(*S, STI); |
490 return S; | 519 return S; |
491 } | 520 } |
492 | 521 |
493 MCStreamer *createAsmStreamer(MCContext &Ctx, | 522 MCStreamer *createAsmStreamer(MCContext &Ctx, |
494 std::unique_ptr<formatted_raw_ostream> OS, | 523 std::unique_ptr<formatted_raw_ostream> OS, |
495 bool IsVerboseAsm, bool UseDwarfDirectory, | 524 bool IsVerboseAsm, bool UseDwarfDirectory, |
496 MCInstPrinter *InstPrint, MCCodeEmitter *CE, | 525 MCInstPrinter *InstPrint, |
497 MCAsmBackend *TAB, bool ShowInst) const { | 526 std::unique_ptr<MCCodeEmitter> &&CE, |
527 std::unique_ptr<MCAsmBackend> &&TAB, | |
528 bool ShowInst) const { | |
498 formatted_raw_ostream &OSRef = *OS; | 529 formatted_raw_ostream &OSRef = *OS; |
499 MCStreamer *S = llvm::createAsmStreamer(Ctx, std::move(OS), IsVerboseAsm, | 530 MCStreamer *S = llvm::createAsmStreamer( |
500 UseDwarfDirectory, InstPrint, CE, | 531 Ctx, std::move(OS), IsVerboseAsm, UseDwarfDirectory, InstPrint, |
501 TAB, ShowInst); | 532 std::move(CE), std::move(TAB), ShowInst); |
502 createAsmTargetStreamer(*S, OSRef, InstPrint, IsVerboseAsm); | 533 createAsmTargetStreamer(*S, OSRef, InstPrint, IsVerboseAsm); |
503 return S; | 534 return S; |
504 } | 535 } |
505 | 536 |
506 MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S, | 537 MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S, |