LLVM 24.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"
18#include "llvm/MC/MCAsmInfo.h"
21#include "llvm/MC/MCInstrInfo.h"
23#include "llvm/MC/MCSchedule.h"
28#include <memory>
29
30using namespace llvm;
31
32#define GET_INSTRINFO_MC_DESC
33#define GET_INSTRINFO_MC_HELPERS
34#include "DirectXGenInstrInfo.inc"
35
36#define GET_SUBTARGETINFO_MC_DESC
37#include "DirectXGenSubtargetInfo.inc"
38
39#define GET_REGINFO_MC_DESC
40#include "DirectXGenRegisterInfo.inc"
41
42namespace {
43
44// DXILInstPrinter is a null stub because DXIL instructions aren't printed.
45class DXILInstPrinter : public MCInstPrinter {
46public:
47 DXILInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
48 const MCRegisterInfo &MRI)
49 : MCInstPrinter(MAI, MII, MRI) {}
50
51 void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
52 const MCSubtargetInfo &STI, raw_ostream &O) override {}
53
54 std::pair<const char *, uint64_t>
55 getMnemonic(const MCInst &MI) const override {
56 return std::make_pair<const char *, uint64_t>("", 0ull);
57 }
58
59private:
60};
61
62class DXILMCCodeEmitter : public MCCodeEmitter {
63public:
64 DXILMCCodeEmitter() {}
65
66 void encodeInstruction(const MCInst &Inst, SmallVectorImpl<char> &CB,
68 const MCSubtargetInfo &STI) const override {}
69};
70
71class DXILAsmBackend : public MCAsmBackend {
72
73public:
74 DXILAsmBackend(const MCSubtargetInfo &STI)
76 ~DXILAsmBackend() override = default;
77
78 void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,
79 uint8_t *Data, uint64_t Value, bool IsResolved) override {}
80
81 std::unique_ptr<MCObjectTargetWriter>
82 createObjectTargetWriter() const override {
84 }
85
86 bool writeNopData(raw_ostream &OS, uint64_t Count,
87 const MCSubtargetInfo *STI) const override {
88 return true;
89 }
90};
91
92class DirectXMCAsmInfo : public MCAsmInfo {
93public:
94 explicit DirectXMCAsmInfo(const Triple &TT, const MCTargetOptions &Options)
95 : MCAsmInfo(Options) {}
96};
97
98} // namespace
99
101 unsigned SyntaxVariant,
102 const MCAsmInfo &MAI,
103 const MCInstrInfo &MII,
104 const MCRegisterInfo &MRI) {
105 if (SyntaxVariant == 0)
106 return new DXILInstPrinter(MAI, MII, MRI);
107 return nullptr;
108}
109
111 MCContext &Ctx) {
112 return new DXILMCCodeEmitter();
113}
114
116 const MCSubtargetInfo &STI,
117 const MCRegisterInfo &MRI,
118 const MCTargetOptions &Options) {
119 return new DXILAsmBackend(STI);
120}
121
122static MCSubtargetInfo *
124 return createDirectXMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
125}
126
130
132
uint64_t uint64_t
#define X(NUM, ENUM, NAME)
Definition ELF.h:665
#define LLVM_ABI
Definition Compiler.h:211
#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)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeDirectXTargetMC()
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)
This file contains DirectX target interface.
IRTranslator LLVM IR MI
static LVOptions Options
Definition LVOptions.cpp:25
#define T
MachineRegisterInfo & MRI
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:67
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:65
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...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
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()
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
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.