1 //===-- SystemZConstantPoolValue.cpp - SystemZ constant-pool value --------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "SystemZConstantPoolValue.h"
10 #include "llvm/ADT/FoldingSet.h"
11 #include "llvm/IR/GlobalValue.h"
12 #include "llvm/Support/raw_ostream.h"
16 SystemZConstantPoolValue::
17 SystemZConstantPoolValue(const GlobalValue
*gv
,
18 SystemZCP::SystemZCPModifier modifier
)
19 : MachineConstantPoolValue(gv
->getType()), GV(gv
), Modifier(modifier
) {}
21 SystemZConstantPoolValue
*
22 SystemZConstantPoolValue::Create(const GlobalValue
*GV
,
23 SystemZCP::SystemZCPModifier Modifier
) {
24 return new SystemZConstantPoolValue(GV
, Modifier
);
27 int SystemZConstantPoolValue::getExistingMachineCPValue(MachineConstantPool
*CP
,
29 const std::vector
<MachineConstantPoolEntry
> &Constants
= CP
->getConstants();
30 for (unsigned I
= 0, E
= Constants
.size(); I
!= E
; ++I
) {
31 if (Constants
[I
].isMachineConstantPoolEntry() &&
32 Constants
[I
].getAlign() >= Alignment
) {
34 static_cast<SystemZConstantPoolValue
*>(Constants
[I
].Val
.MachineCPVal
);
35 if (ZCPV
->GV
== GV
&& ZCPV
->Modifier
== Modifier
)
42 void SystemZConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID
&ID
) {
44 ID
.AddInteger(Modifier
);
47 void SystemZConstantPoolValue::print(raw_ostream
&O
) const {
48 O
<< GV
<< "@" << int(Modifier
);