LLVM 22.0.0git
DirectXMCTargetDesc.cpp
Go to the documentation of this file.
1//===- DirectXMCTargetDesc.cpp - DirectX Target Implementation --*- C++ -*-===//
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/// \file
10/// This file contains DirectX target initializer.
11///
12//===----------------------------------------------------------------------===//
13
14#include "DirectXMCTargetDesc.h"
17#include "llvm/MC/LaneBitmask.h"
19#include "llvm/MC/MCAsmInfo.h"
23#include "llvm/MC/MCInstrInfo.h"
25#include "llvm/MC/MCSchedule.h"
30#include <memory>
31
32using namespace llvm;
33
34#define GET_INSTRINFO_MC_DESC
35#define GET_INSTRINFO_MC_HELPERS
36#include "DirectXGenInstrInfo.inc"
37
38#define GET_SUBTARGETINFO_MC_DESC
39#include "DirectXGenSubtargetInfo.inc"
40
41#define GET_REGINFO_MC_DESC
42#include "DirectXGenRegisterInfo.inc"
43
44namespace {
45
46// DXILInstPrinter is a null stub because DXIL instructions aren't printed.
47class DXILInstPrinter : public MCInstPrinter {
48public:
49 DXILInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
50 const MCRegisterInfo &MRI)
51 : MCInstPrinter(MAI, MII, MRI) {}
52
53 void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
54 const MCSubtargetInfo &STI, raw_ostream &O) override {}
55
56 std::pair<const char *, uint64_t>
57 getMnemonic(const MCInst &MI) const override {
58 return std::make_pair<const char *, uint64_t>("", 0ull);
59 }
60
61private:
62};
63
64class DXILMCCodeEmitter : public MCCodeEmitter {
65public:
66 DXILMCCodeEmitter() {}
67
68 void encodeInstruction(const MCInst &Inst, SmallVectorImpl<char> &CB,
70 const MCSubtargetInfo &STI) const override {}
71};
72
73class DXILAsmBackend : public MCAsmBackend {
74
75public:
76 DXILAsmBackend(const MCSubtargetInfo &STI)
78 ~DXILAsmBackend() override = default;
79
80 void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,
81 uint8_t *Data, uint64_t Value, bool IsResolved) override {}
82
83 std::unique_ptr<MCObjectTargetWriter>
84 createObjectTargetWriter() const override {
86 }
87
88 bool writeNopData(raw_ostream &OS, uint64_t Count,
89 const MCSubtargetInfo *STI) const override {
90 return true;
91 }
92};
93
94class DirectXMCAsmInfo : public MCAsmInfo {
95public:
96 explicit DirectXMCAsmInfo(const Triple &TT, const MCTargetOptions &Options)
97 : MCAsmInfo() {}
98};
99
100} // namespace
101
103 unsigned SyntaxVariant,
104 const MCAsmInfo &MAI,
105 const MCInstrInfo &MII,
106 const MCRegisterInfo &MRI) {
107 if (SyntaxVariant == 0)
108 return new DXILInstPrinter(MAI, MII, MRI);
109 return nullptr;
110}
111
113 MCContext &Ctx) {
114 return new DXILMCCodeEmitter();
115}
116
118 const MCSubtargetInfo &STI,
119 const MCRegisterInfo &MRI,
120 const MCTargetOptions &Options) {
121 return new DXILAsmBackend(STI);
122}
123
124static MCSubtargetInfo *
126 return createDirectXMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
127}
128
132
134
unsigned const MachineRegisterInfo * MRI
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
MCAsmBackend * createDXILMCAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
static MCRegisterInfo * createDirectXMCRegisterInfo(const Triple &Triple)
static MCSubtargetInfo * createDirectXMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
static MCInstrInfo * createDirectXMCInstrInfo()
static MCInstPrinter * createDXILMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
MCCodeEmitter * createDXILMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeDirectXTargetMC()
This file contains DirectX target interface.
IRTranslator LLVM IR MI
static LVOptions Options
Definition LVOptions.cpp:25
A common definition of LaneBitmask for use in TableGen and CodeGen.
#define T
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
StringRef getMnemonic(unsigned Opc)
Generic interface to target specific assembler backends.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:64
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Definition MCContext.h:83
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:61
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Generic base class for all target subtargets.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheDirectXTarget()
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
std::unique_ptr< MCObjectTargetWriter > createDXContainerTargetObjectWriter()
RegisterMCAsmInfo - 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 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.