1 //===-- llvm/CodeGen/PseudoSourceValue.cpp ----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the PseudoSourceValue class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/PseudoSourceValue.h"
15 #include "llvm/DerivedTypes.h"
16 #include "llvm/Support/Compiler.h"
17 #include "llvm/Support/ManagedStatic.h"
21 static ManagedStatic<PseudoSourceValue[4]> PSVs;
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]; }
32 static const char *const PSVNames[] = {
39 PseudoSourceValue::PseudoSourceValue() :
40 Value(PointerType::getUnqual(Type::Int8Ty), PseudoSourceValueVal) {}
42 void PseudoSourceValue::print(std::ostream &OS) const {
43 OS << PSVNames[this - *PSVs];
46 /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
47 /// for holding FixedStack values, which must include a frame
49 class VISIBILITY_HIDDEN FixedStackPseudoSourceValue
50 : public PseudoSourceValue {
53 explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {}
54 virtual void print(std::ostream &OS) const {
55 OS << "FixedStack" << FI;
59 static ManagedStatic<std::map<int, const PseudoSourceValue *> > FSValues;
61 const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) {
62 const PseudoSourceValue *&V = (*FSValues)[FI];
64 V = new FixedStackPseudoSourceValue(FI);