LLVM  16.0.0git
RISCVELFStreamer.h
Go to the documentation of this file.
1 //===-- RISCVELFStreamer.h - RISCV ELF Target Streamer ---------*- 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 #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H
10 #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVELFSTREAMER_H
11 
12 #include "RISCVTargetStreamer.h"
13 #include "llvm/MC/MCELFStreamer.h"
14 
15 namespace llvm {
16 
18 private:
19  enum class AttributeType { Hidden, Numeric, Text, NumericAndText };
20 
21  struct AttributeItem {
22  AttributeType Type;
23  unsigned Tag;
24  unsigned IntValue;
25  std::string StringValue;
26  };
27 
28  StringRef CurrentVendor;
30 
31  MCSection *AttributeSection = nullptr;
32  const MCSubtargetInfo &STI;
33 
34  AttributeItem *getAttributeItem(unsigned Attribute) {
35  for (size_t i = 0; i < Contents.size(); ++i)
36  if (Contents[i].Tag == Attribute)
37  return &Contents[i];
38  return nullptr;
39  }
40 
41  void setAttributeItem(unsigned Attribute, unsigned Value,
42  bool OverwriteExisting) {
43  // Look for existing attribute item.
44  if (AttributeItem *Item = getAttributeItem(Attribute)) {
45  if (!OverwriteExisting)
46  return;
47  Item->Type = AttributeType::Numeric;
48  Item->IntValue = Value;
49  return;
50  }
51 
52  // Create new attribute item.
53  Contents.push_back({AttributeType::Numeric, Attribute, Value, ""});
54  }
55 
56  void setAttributeItem(unsigned Attribute, StringRef Value,
57  bool OverwriteExisting) {
58  // Look for existing attribute item.
59  if (AttributeItem *Item = getAttributeItem(Attribute)) {
60  if (!OverwriteExisting)
61  return;
62  Item->Type = AttributeType::Text;
63  Item->StringValue = std::string(Value);
64  return;
65  }
66 
67  // Create new attribute item.
68  Contents.push_back({AttributeType::Text, Attribute, 0, std::string(Value)});
69  }
70 
71  void setAttributeItems(unsigned Attribute, unsigned IntValue,
72  StringRef StringValue, bool OverwriteExisting) {
73  // Look for existing attribute item.
74  if (AttributeItem *Item = getAttributeItem(Attribute)) {
75  if (!OverwriteExisting)
76  return;
77  Item->Type = AttributeType::NumericAndText;
78  Item->IntValue = IntValue;
79  Item->StringValue = std::string(StringValue);
80  return;
81  }
82 
83  // Create new attribute item.
84  Contents.push_back({AttributeType::NumericAndText, Attribute, IntValue,
85  std::string(StringValue)});
86  }
87 
88  void emitAttribute(unsigned Attribute, unsigned Value) override;
89  void emitTextAttribute(unsigned Attribute, StringRef String) override;
90  void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
91  StringRef StringValue) override;
92  void finishAttributeSection() override;
93  size_t calculateContentSize() const;
94 
95  void reset() override;
96 
97 public:
100 
101  void emitDirectiveOptionPush() override;
102  void emitDirectiveOptionPop() override;
103  void emitDirectiveOptionPIC() override;
104  void emitDirectiveOptionNoPIC() override;
105  void emitDirectiveOptionRVC() override;
106  void emitDirectiveOptionNoRVC() override;
107  void emitDirectiveOptionRelax() override;
108  void emitDirectiveOptionNoRelax() override;
109  void emitDirectiveVariantCC(MCSymbol &Symbol) override;
110 
111  void finish() override;
112 };
113 
115  std::unique_ptr<MCAsmBackend> MAB,
116  std::unique_ptr<MCObjectWriter> MOW,
117  std::unique_ptr<MCCodeEmitter> MCE,
118  bool RelaxAll);
119 }
120 #endif
llvm::RISCVTargetELFStreamer::emitDirectiveOptionPush
void emitDirectiveOptionPush() override
Definition: RISCVELFStreamer.cpp:46
i
i
Definition: README.txt:29
llvm::createRISCVELFStreamer
MCELFStreamer * createRISCVELFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > MOW, std::unique_ptr< MCCodeEmitter > MCE, bool RelaxAll)
Definition: RISCVELFStreamer.cpp:288
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:76
llvm::Attribute
Definition: Attributes.h:67
llvm::SmallVector< AttributeItem, 64 >
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::RISCVTargetELFStreamer::emitDirectiveOptionNoRelax
void emitDirectiveOptionNoRelax() override
Definition: RISCVELFStreamer.cpp:53
llvm::dwarf::Tag
Tag
Definition: Dwarf.h:105
llvm::RISCVTargetELFStreamer::finish
void finish() override
Definition: RISCVELFStreamer.cpp:150
MCELFStreamer.h
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:212
llvm::RISCVTargetELFStreamer::emitDirectiveOptionPIC
void emitDirectiveOptionPIC() override
Definition: RISCVELFStreamer.cpp:48
llvm::MCELFStreamer
Definition: MCELFStreamer.h:31
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::RISCVTargetELFStreamer::emitDirectiveOptionPop
void emitDirectiveOptionPop() override
Definition: RISCVELFStreamer.cpp:47
RISCVTargetStreamer.h
llvm::RISCVTargetELFStreamer::emitDirectiveOptionRelax
void emitDirectiveOptionRelax() override
Definition: RISCVELFStreamer.cpp:52
llvm::RISCVTargetELFStreamer::emitDirectiveVariantCC
void emitDirectiveVariantCC(MCSymbol &Symbol) override
Definition: RISCVELFStreamer.cpp:190
llvm::RISCVTargetELFStreamer::emitDirectiveOptionNoRVC
void emitDirectiveOptionNoRVC() override
Definition: RISCVELFStreamer.cpp:51
llvm::RISCVTargetELFStreamer::RISCVTargetELFStreamer
RISCVTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition: RISCVELFStreamer.cpp:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::RISCVTargetELFStreamer::emitDirectiveOptionNoPIC
void emitDirectiveOptionNoPIC() override
Definition: RISCVELFStreamer.cpp:49
llvm::RISCVTargetELFStreamer::getStreamer
MCELFStreamer & getStreamer()
Definition: RISCVELFStreamer.cpp:42
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::RISCVTargetELFStreamer
Definition: RISCVELFStreamer.h:17
llvm::RISCVTargetELFStreamer::emitDirectiveOptionRVC
void emitDirectiveOptionRVC() override
Definition: RISCVELFStreamer.cpp:50
llvm::RISCVTargetStreamer
Definition: RISCVTargetStreamer.h:20
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:76
llvm::Value
LLVM Value Representation.
Definition: Value.h:74