LLVM 22.0.0git
XtensaConstantPoolValue.cpp
Go to the documentation of this file.
1//===- XtensaConstantPoolValue.cpp - Xtensa constantpool value ------------===//
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 implements the Xtensa specific constantpool value class.
10//
11//===----------------------------------------------------------------------===//
12
14#include "llvm/ADT/FoldingSet.h"
16#include "llvm/IR/Constant.h"
17#include "llvm/IR/Constants.h"
18#include "llvm/IR/GlobalValue.h"
19#include "llvm/IR/Type.h"
21#include <cstdlib>
22using namespace llvm;
23
25 Type *Ty, unsigned ID, XtensaCP::XtensaCPKind Kind,
27 : MachineConstantPoolValue(Ty), LabelId(ID), Kind(Kind),
28 Modifier(modifier) {}
29
31 LLVMContext &C, unsigned ID, XtensaCP::XtensaCPKind Kind,
33 : MachineConstantPoolValue((Type *)Type::getInt32Ty(C)), LabelId(ID),
34 Kind(Kind), Modifier(Modifier) {}
35
37
39 switch (Modifier) {
41 return "";
42 case XtensaCP::TPOFF:
43 return "@TPOFF";
44 }
45 report_fatal_error("Unknown modifier!");
46}
47
49 Align Alignment) {
50 report_fatal_error("Shouldn't be calling this directly!");
51}
52
56
58 if (ACPV->Kind == Kind) {
59 if (ACPV->LabelId == LabelId)
60 return true;
61 }
62 return false;
63}
64
65#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
66void XtensaConstantPoolValue::dump() const { errs() << " " << *this; }
67#endif
68
70
71//===----------------------------------------------------------------------===//
72// XtensaConstantPoolConstant
73//===----------------------------------------------------------------------===//
74
75XtensaConstantPoolConstant::XtensaConstantPoolConstant(
76 const Constant *C, unsigned ID, XtensaCP::XtensaCPKind Kind)
77 : XtensaConstantPoolValue(C->getType(), ID, Kind), CVal(C) {}
78
82 return new XtensaConstantPoolConstant(C, ID, Kind);
83}
84
88
94
96 const XtensaConstantPoolConstant *ACPC =
98 return ACPC && ACPC->CVal == CVal &&
100}
101
106
108 O << CVal->getName();
110}
111
112XtensaConstantPoolSymbol::XtensaConstantPoolSymbol(
113 LLVMContext &C, const char *Str, unsigned ID, bool PrivLinkage,
115 : XtensaConstantPoolValue(C, ID, XtensaCP::CPExtSymbol, Modifier), S(Str),
116 PrivateLinkage(PrivLinkage) {}
117
120 bool PrivLinkage,
122
123{
124 return new XtensaConstantPoolSymbol(C, Str, ID, PrivLinkage, Modifier);
125}
126
131
133 const XtensaConstantPoolSymbol *ACPS =
135 return ACPS && ACPS->S == S && XtensaConstantPoolValue::hasSameValue(ACPV);
136}
137
142
147
148XtensaConstantPoolMBB::XtensaConstantPoolMBB(LLVMContext &C,
149 const MachineBasicBlock *M,
150 unsigned Id)
151 : XtensaConstantPoolValue(C, 0, XtensaCP::CPMachineBasicBlock), MBB(M) {}
152
154 const MachineBasicBlock *M,
155 unsigned Idx) {
156 return new XtensaConstantPoolMBB(C, M, Idx);
157}
158
163
165 const XtensaConstantPoolMBB *ACPMBB = dyn_cast<XtensaConstantPoolMBB>(ACPV);
166 return ACPMBB && ACPMBB->MBB == MBB &&
168}
169
174
176 O << "BB#" << MBB->getNumber();
178}
179
180XtensaConstantPoolJumpTable::XtensaConstantPoolJumpTable(LLVMContext &C,
181 unsigned Index)
182 : XtensaConstantPoolValue(C, 0, XtensaCP::CPJumpTable), Idx(Index) {}
183
185 unsigned Idx) {
186 return new XtensaConstantPoolJumpTable(C, Idx);
187}
188
194
196 const XtensaConstantPoolJumpTable *ACPJT =
198 return ACPJT && ACPJT->Idx == Idx &&
200}
201
203
205 O << "JT" << Idx;
207}
MachineBasicBlock & MBB
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines a hash set that can be used to remove duplication of nodes in a graph.
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
The address of a basic block.
Definition Constants.h:899
This is an important base class in LLVM.
Definition Constant.h:43
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition FoldingSet.h:330
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
XtensaConstantPoolConstant - Xtensa-specific constant pool values for Constants (for example BlockAdd...
int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment) override
bool hasSameValue(XtensaConstantPoolValue *ACPV) override
hasSameValue - Return true if this Xtensa constpool value can share the same constantpool entry as an...
const BlockAddress * getBlockAddress() const
static XtensaConstantPoolConstant * Create(const Constant *C, unsigned ID, XtensaCP::XtensaCPKind Kind)
void print(raw_ostream &O) const override
print - Implement operator<<
void addSelectionDAGCSEId(FoldingSetNodeID &ID) override
static XtensaConstantPoolJumpTable * Create(LLVMContext &C, unsigned Idx)
void addSelectionDAGCSEId(FoldingSetNodeID &ID) override
void print(raw_ostream &O) const override
print - Implement operator<<
int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment) override
bool hasSameValue(XtensaConstantPoolValue *ACPV) override
hasSameValue - Return true if this Xtensa constpool value can share the same constantpool entry as an...
static XtensaConstantPoolMBB * Create(LLVMContext &C, const MachineBasicBlock *M, unsigned ID)
void print(raw_ostream &O) const override
print - Implement operator<<
bool hasSameValue(XtensaConstantPoolValue *ACPV) override
hasSameValue - Return true if this Xtensa constpool value can share the same constantpool entry as an...
void addSelectionDAGCSEId(FoldingSetNodeID &ID) override
int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment) override
XtensaConstantPoolSymbol - Xtensa-specific constantpool values for external symbols.
void addSelectionDAGCSEId(FoldingSetNodeID &ID) override
void print(raw_ostream &O) const override
print - Implement operator<<
static XtensaConstantPoolSymbol * Create(LLVMContext &C, const char *S, unsigned ID, bool PrivLinkage, XtensaCP::XtensaCPModifier Modifier=XtensaCP::no_modifier)
int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment) override
bool hasSameValue(XtensaConstantPoolValue *ACPV) override
hasSameValue - Return true if this Xtensa constpool value can share the same constantpool entry as an...
XtensaConstantPoolValue - Xtensa specific constantpool value.
virtual bool hasSameValue(XtensaConstantPoolValue *ACPV)
hasSameValue - Return true if this Xtensa constpool value can share the same constantpool entry as an...
int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment) override
int getExistingMachineCPValueImpl(MachineConstantPool *CP, Align Alignment)
void print(raw_ostream &O) const override
print - Implement operator<<
XtensaConstantPoolValue(Type *Ty, unsigned ID, XtensaCP::XtensaCPKind Kind, XtensaCP::XtensaCPModifier Modifier=XtensaCP::no_modifier)
void addSelectionDAGCSEId(FoldingSetNodeID &ID) override
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:649
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:759
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:167
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39