PseudoSourceValue.cpp revision a54cf176613f9ae8301519a61b8935652c0fb8ae
1//===-- llvm/CodeGen/PseudoSourceValue.cpp ----------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file implements the PseudoSourceValue class. 11// 12//===----------------------------------------------------------------------===// 13 14#include "llvm/CodeGen/PseudoSourceValue.h" 15#include "llvm/DerivedTypes.h" 16#include "llvm/Support/Compiler.h" 17#include "llvm/Support/ManagedStatic.h" 18#include <map> 19 20namespace llvm { 21 static ManagedStatic<PseudoSourceValue[4]> PSVs; 22 23 const PseudoSourceValue *PseudoSourceValue::getStack() 24 { return &(*PSVs)[0]; } 25 const PseudoSourceValue *PseudoSourceValue::getGOT() 26 { return &(*PSVs)[1]; } 27 const PseudoSourceValue *PseudoSourceValue::getJumpTable() 28 { return &(*PSVs)[2]; } 29 const PseudoSourceValue *PseudoSourceValue::getConstantPool() 30 { return &(*PSVs)[3]; } 31 32 static const char *const PSVNames[] = { 33 "Stack", 34 "GOT", 35 "JumpTable" 36 "ConstantPool" 37 }; 38 39 PseudoSourceValue::PseudoSourceValue() : 40 Value(PointerType::getUnqual(Type::Int8Ty), PseudoSourceValueVal) {} 41 42 void PseudoSourceValue::print(std::ostream &OS) const { 43 OS << PSVNames[this - *PSVs]; 44 } 45 46 /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue 47 /// for holding FixedStack values, which must include a frame 48 /// index. 49 class VISIBILITY_HIDDEN FixedStackPseudoSourceValue 50 : public PseudoSourceValue { 51 const int FI; 52 public: 53 explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {} 54 virtual void print(std::ostream &OS) const { 55 OS << "FixedStack" << FI; 56 } 57 }; 58 59 static ManagedStatic<std::map<int, const PseudoSourceValue *> > FSValues; 60 61 const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) { 62 const PseudoSourceValue *&V = (*FSValues)[FI]; 63 if (!V) 64 V = new FixedStackPseudoSourceValue(FI); 65 return V; 66 } 67} 68