Path: blob/main/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZConstantPoolValue.cpp
35266 views
//===-- SystemZConstantPoolValue.cpp - SystemZ constant-pool value --------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "SystemZConstantPoolValue.h"9#include "llvm/ADT/FoldingSet.h"10#include "llvm/IR/DerivedTypes.h"11#include "llvm/IR/GlobalValue.h"12#include "llvm/Support/raw_ostream.h"1314using namespace llvm;1516SystemZConstantPoolValue::17SystemZConstantPoolValue(const GlobalValue *gv,18SystemZCP::SystemZCPModifier modifier)19: MachineConstantPoolValue(gv->getType()), GV(gv), Modifier(modifier) {}2021SystemZConstantPoolValue *22SystemZConstantPoolValue::Create(const GlobalValue *GV,23SystemZCP::SystemZCPModifier Modifier) {24return new SystemZConstantPoolValue(GV, Modifier);25}2627int SystemZConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,28Align Alignment) {29const std::vector<MachineConstantPoolEntry> &Constants = CP->getConstants();30for (unsigned I = 0, E = Constants.size(); I != E; ++I) {31if (Constants[I].isMachineConstantPoolEntry() &&32Constants[I].getAlign() >= Alignment) {33auto *ZCPV =34static_cast<SystemZConstantPoolValue *>(Constants[I].Val.MachineCPVal);35if (ZCPV->GV == GV && ZCPV->Modifier == Modifier)36return I;37}38}39return -1;40}4142void SystemZConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) {43ID.AddPointer(GV);44ID.AddInteger(Modifier);45}4647void SystemZConstantPoolValue::print(raw_ostream &O) const {48O << GV << "@" << int(Modifier);49}505152