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/DerivedTypes.h"
12 #include "llvm/IR/GlobalValue.h"
13 #include "llvm/Support/raw_ostream.h"
17 SystemZConstantPoolValue::
18 SystemZConstantPoolValue(const GlobalValue
*gv
,
19 SystemZCP::SystemZCPModifier modifier
)
20 : MachineConstantPoolValue(gv
->getType()), GV(gv
), Modifier(modifier
) {}
22 SystemZConstantPoolValue
*
23 SystemZConstantPoolValue::Create(const GlobalValue
*GV
,
24 SystemZCP::SystemZCPModifier Modifier
) {
25 return new SystemZConstantPoolValue(GV
, Modifier
);
28 int SystemZConstantPoolValue::
29 getExistingMachineCPValue(MachineConstantPool
*CP
, unsigned Alignment
) {
30 unsigned AlignMask
= Alignment
- 1;
31 const std::vector
<MachineConstantPoolEntry
> &Constants
= CP
->getConstants();
32 for (unsigned I
= 0, E
= Constants
.size(); I
!= E
; ++I
) {
33 if (Constants
[I
].isMachineConstantPoolEntry() &&
34 (Constants
[I
].getAlignment() & AlignMask
) == 0) {
36 static_cast<SystemZConstantPoolValue
*>(Constants
[I
].Val
.MachineCPVal
);
37 if (ZCPV
->GV
== GV
&& ZCPV
->Modifier
== Modifier
)
44 void SystemZConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID
&ID
) {
46 ID
.AddInteger(Modifier
);
49 void SystemZConstantPoolValue::print(raw_ostream
&O
) const {
50 O
<< GV
<< "@" << int(Modifier
);