LLVM API Documentation
00001 //===-- SystemZConstantPoolValue.cpp - SystemZ constant-pool value --------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #include "SystemZConstantPoolValue.h" 00011 #include "llvm/ADT/FoldingSet.h" 00012 #include "llvm/IR/DerivedTypes.h" 00013 #include "llvm/IR/GlobalValue.h" 00014 #include "llvm/Support/raw_ostream.h" 00015 00016 using namespace llvm; 00017 00018 SystemZConstantPoolValue:: 00019 SystemZConstantPoolValue(const GlobalValue *gv, 00020 SystemZCP::SystemZCPModifier modifier) 00021 : MachineConstantPoolValue(gv->getType()), GV(gv), Modifier(modifier) {} 00022 00023 SystemZConstantPoolValue * 00024 SystemZConstantPoolValue::Create(const GlobalValue *GV, 00025 SystemZCP::SystemZCPModifier Modifier) { 00026 return new SystemZConstantPoolValue(GV, Modifier); 00027 } 00028 00029 unsigned SystemZConstantPoolValue::getRelocationInfo() const { 00030 switch (Modifier) { 00031 case SystemZCP::NTPOFF: 00032 // May require a relocation, but the relocations are always resolved 00033 // by the static linker. 00034 return 1; 00035 } 00036 llvm_unreachable("Unknown modifier"); 00037 } 00038 00039 int SystemZConstantPoolValue:: 00040 getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment) { 00041 unsigned AlignMask = Alignment - 1; 00042 const std::vector<MachineConstantPoolEntry> &Constants = CP->getConstants(); 00043 for (unsigned I = 0, E = Constants.size(); I != E; ++I) { 00044 if (Constants[I].isMachineConstantPoolEntry() && 00045 (Constants[I].getAlignment() & AlignMask) == 0) { 00046 auto *ZCPV = 00047 static_cast<SystemZConstantPoolValue *>(Constants[I].Val.MachineCPVal); 00048 if (ZCPV->GV == GV && ZCPV->Modifier == Modifier) 00049 return I; 00050 } 00051 } 00052 return -1; 00053 } 00054 00055 void SystemZConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) { 00056 ID.AddPointer(GV); 00057 ID.AddInteger(Modifier); 00058 } 00059 00060 void SystemZConstantPoolValue::print(raw_ostream &O) const { 00061 O << GV << "@" << int(Modifier); 00062 }