brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 8c31579 Raw
49 lines · cpp
1//===-- SystemZConstantPoolValue.cpp - SystemZ constant-pool 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-exception6//7//===----------------------------------------------------------------------===//8 9#include "SystemZConstantPoolValue.h"10#include "llvm/ADT/FoldingSet.h"11#include "llvm/IR/GlobalValue.h"12#include "llvm/Support/raw_ostream.h"13 14using namespace llvm;15 16SystemZConstantPoolValue::SystemZConstantPoolValue(17    const GlobalValue *GV, SystemZCP::SystemZCPModifier Modifier)18    : MachineConstantPoolValue(GV->getType()), GV(GV), Modifier(Modifier) {}19 20SystemZConstantPoolValue *21SystemZConstantPoolValue::Create(const GlobalValue *GV,22                                 SystemZCP::SystemZCPModifier Modifier) {23  return new SystemZConstantPoolValue(GV, Modifier);24}25 26int SystemZConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,27                                                        Align Alignment) {28  const std::vector<MachineConstantPoolEntry> &Constants = CP->getConstants();29  for (unsigned I = 0, E = Constants.size(); I != E; ++I) {30    if (Constants[I].isMachineConstantPoolEntry() &&31        Constants[I].getAlign() >= Alignment) {32      auto *ZCPV =33        static_cast<SystemZConstantPoolValue *>(Constants[I].Val.MachineCPVal);34      if (ZCPV->GV == GV && ZCPV->Modifier == Modifier)35        return I;36    }37  }38  return -1;39}40 41void SystemZConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) {42  ID.AddPointer(GV);43  ID.AddInteger(Modifier);44}45 46void SystemZConstantPoolValue::print(raw_ostream &O) const {47  O << GV << "@" << int(Modifier);48}49