Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / Target / DirectX / DirectXAsmPrinter.cpp
blob15def3637c5a746e552c2227d6b136b04ac3a043
1 //===-- DirectXAsmPrinter.cpp - DirectX assembly writer --------*- 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 // This file contains AsmPrinters for the DirectX backend.
11 //===----------------------------------------------------------------------===//
13 #include "TargetInfo/DirectXTargetInfo.h"
14 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/IR/GlobalVariable.h"
16 #include "llvm/IR/Module.h"
17 #include "llvm/MC/MCStreamer.h"
18 #include "llvm/MC/SectionKind.h"
19 #include "llvm/MC/TargetRegistry.h"
20 #include "llvm/Target/TargetLoweringObjectFile.h"
22 using namespace llvm;
24 #define DEBUG_TYPE "asm-printer"
26 namespace {
28 // The DXILAsmPrinter is mostly a stub because DXIL is just LLVM bitcode which
29 // gets embedded into a DXContainer file.
30 class DXILAsmPrinter : public AsmPrinter {
31 public:
32 explicit DXILAsmPrinter(TargetMachine &TM,
33 std::unique_ptr<MCStreamer> Streamer)
34 : AsmPrinter(TM, std::move(Streamer)) {}
36 StringRef getPassName() const override { return "DXIL Assembly Printer"; }
37 void emitGlobalVariable(const GlobalVariable *GV) override;
38 bool runOnMachineFunction(MachineFunction &MF) override { return false; }
40 } // namespace
42 void DXILAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
43 // If there is no initializer, or no explicit section do nothing
44 if (!GV->hasInitializer() || GV->hasImplicitSection() || !GV->hasSection())
45 return;
46 // Skip the LLVM metadata
47 if (GV->getSection() == "llvm.metadata")
48 return;
49 SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
50 MCSection *TheSection = getObjFileLowering().SectionForGlobal(GV, GVKind, TM);
51 OutStreamer->switchSection(TheSection);
52 emitGlobalConstant(GV->getDataLayout(), GV->getInitializer());
55 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeDirectXAsmPrinter() {
56 RegisterAsmPrinter<DXILAsmPrinter> X(getTheDirectXTarget());