Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
RISCVConstantPoolValue.cpp
Go to the documentation of this file.
1//===------- RISCVConstantPoolValue.cpp - RISC-V 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 RISC-V specific constantpool value class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "RISCVConstantPoolValue.h"
14#include "llvm/ADT/FoldingSet.h"
15#include "llvm/IR/DerivedTypes.h"
16#include "llvm/IR/GlobalValue.h"
17#include "llvm/IR/Type.h"
18#include "llvm/Support/raw_ostream.h"
19
20using namespacellvm;
21
22RISCVConstantPoolValue::RISCVConstantPoolValue(Type *Ty,constGlobalValue *GV)
23 :MachineConstantPoolValue(Ty), GV(GV),Kind(RISCVCPKind::GlobalValue) {}
24
25RISCVConstantPoolValue::RISCVConstantPoolValue(LLVMContext &C,StringRef S)
26 :MachineConstantPoolValue(Type::getInt64Ty(C)), S(S),
27Kind(RISCVCPKind::ExtSymbol) {}
28
29RISCVConstantPoolValue *RISCVConstantPoolValue::Create(constGlobalValue *GV) {
30returnnewRISCVConstantPoolValue(GV->getType(), GV);
31}
32
33RISCVConstantPoolValue *RISCVConstantPoolValue::Create(LLVMContext &C,
34StringRef S) {
35returnnewRISCVConstantPoolValue(C, S);
36}
37
38intRISCVConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
39Align Alignment) {
40const std::vector<MachineConstantPoolEntry> &Constants = CP->getConstants();
41for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
42if (Constants[i].isMachineConstantPoolEntry() &&
43 Constants[i].getAlign() >= Alignment) {
44auto *CPV =
45static_cast<RISCVConstantPoolValue *>(Constants[i].Val.MachineCPVal);
46if (equals(CPV))
47return i;
48 }
49 }
50
51return -1;
52}
53
54voidRISCVConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
55if (isGlobalValue())
56ID.AddPointer(GV);
57else {
58assert(isExtSymbol() &&"unrecognized constant pool type");
59ID.AddString(S);
60 }
61}
62
63voidRISCVConstantPoolValue::print(raw_ostream &O) const{
64if (isGlobalValue())
65 O << GV->getName();
66else {
67assert(isExtSymbol() &&"unrecognized constant pool type");
68 O << S;
69 }
70}
71
72boolRISCVConstantPoolValue::equals(constRISCVConstantPoolValue *A) const{
73if (isGlobalValue() &&A->isGlobalValue())
74return GV ==A->GV;
75if (isExtSymbol() &&A->isExtSymbol())
76return S ==A->S;
77
78returnfalse;
79}
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
DerivedTypes.h
FoldingSet.h
This file defines a hash set that can be used to remove duplication of nodes in a graph.
GlobalValue.h
Type.h
RISCVConstantPoolValue.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::FoldingSetNodeID
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition:FoldingSet.h:327
llvm::GlobalValue
Definition:GlobalValue.h:48
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition:GlobalValue.h:295
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::MachineConstantPoolValue
Abstract base class for all machine specific constantpool value subclasses.
Definition:MachineConstantPool.h:35
llvm::MachineConstantPool
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
Definition:MachineConstantPool.h:117
llvm::RISCVConstantPoolValue
A RISCV-specific constant pool value.
Definition:RISCVConstantPoolValue.h:28
llvm::RISCVConstantPoolValue::Create
static RISCVConstantPoolValue * Create(const GlobalValue *GV)
Definition:RISCVConstantPoolValue.cpp:29
llvm::RISCVConstantPoolValue::equals
bool equals(const RISCVConstantPoolValue *A) const
Definition:RISCVConstantPoolValue.cpp:72
llvm::RISCVConstantPoolValue::isExtSymbol
bool isExtSymbol() const
Definition:RISCVConstantPoolValue.h:46
llvm::RISCVConstantPoolValue::print
void print(raw_ostream &O) const override
print - Implement operator<<
Definition:RISCVConstantPoolValue.cpp:63
llvm::RISCVConstantPoolValue::isGlobalValue
bool isGlobalValue() const
Definition:RISCVConstantPoolValue.h:45
llvm::RISCVConstantPoolValue::addSelectionDAGCSEId
void addSelectionDAGCSEId(FoldingSetNodeID &ID) override
Definition:RISCVConstantPoolValue.cpp:54
llvm::RISCVConstantPoolValue::getExistingMachineCPValue
int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment) override
Definition:RISCVConstantPoolValue.cpp:38
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition:Value.cpp:309
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
unsigned
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm::lltok::Kind
Kind
Definition:LLToken.h:18
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::getAlign
MaybeAlign getAlign(const Function &F, unsigned Index)
Definition:NVPTXUtilities.cpp:323
raw_ostream.h
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition:Alignment.h:39

Generated on Thu Jul 17 2025 15:26:29 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp