2008-02-06 22:27:42 +00:00
|
|
|
//===-- llvm/CodeGen/PseudoSourceValue.cpp ----------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the PseudoSourceValue class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
|
|
|
#include "llvm/DerivedTypes.h"
|
2008-07-11 22:44:52 +00:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2008-02-06 22:27:42 +00:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
2008-07-11 22:44:52 +00:00
|
|
|
#include <map>
|
2008-02-06 22:27:42 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2008-07-11 22:44:52 +00:00
|
|
|
static ManagedStatic<PseudoSourceValue[4]> PSVs;
|
2008-02-06 22:27:42 +00:00
|
|
|
|
2008-02-11 18:57:43 +00:00
|
|
|
const PseudoSourceValue *PseudoSourceValue::getStack()
|
2008-07-11 22:44:52 +00:00
|
|
|
{ return &(*PSVs)[0]; }
|
2008-02-11 18:57:43 +00:00
|
|
|
const PseudoSourceValue *PseudoSourceValue::getGOT()
|
2008-07-11 22:44:52 +00:00
|
|
|
{ return &(*PSVs)[1]; }
|
|
|
|
const PseudoSourceValue *PseudoSourceValue::getJumpTable()
|
2008-02-11 18:57:43 +00:00
|
|
|
{ return &(*PSVs)[2]; }
|
|
|
|
const PseudoSourceValue *PseudoSourceValue::getConstantPool()
|
|
|
|
{ return &(*PSVs)[3]; }
|
2008-02-06 22:27:42 +00:00
|
|
|
|
2008-03-25 21:45:14 +00:00
|
|
|
static const char *const PSVNames[] = {
|
2008-02-06 22:27:42 +00:00
|
|
|
"Stack",
|
|
|
|
"GOT",
|
|
|
|
"JumpTable"
|
2008-07-11 22:44:52 +00:00
|
|
|
"ConstantPool"
|
2008-02-06 22:27:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PseudoSourceValue::PseudoSourceValue() :
|
|
|
|
Value(PointerType::getUnqual(Type::Int8Ty), PseudoSourceValueVal) {}
|
|
|
|
|
|
|
|
void PseudoSourceValue::print(std::ostream &OS) const {
|
|
|
|
OS << PSVNames[this - *PSVs];
|
|
|
|
}
|
2008-07-11 22:44:52 +00:00
|
|
|
|
|
|
|
/// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
|
|
|
|
/// for holding FixedStack values, which must include a frame
|
|
|
|
/// index.
|
|
|
|
class VISIBILITY_HIDDEN FixedStackPseudoSourceValue
|
|
|
|
: public PseudoSourceValue {
|
|
|
|
const int FI;
|
|
|
|
public:
|
|
|
|
explicit FixedStackPseudoSourceValue(int fi) : FI(fi) {}
|
|
|
|
virtual void print(std::ostream &OS) const {
|
|
|
|
OS << "FixedStack" << FI;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static ManagedStatic<std::map<int, const PseudoSourceValue *> > FSValues;
|
|
|
|
|
|
|
|
const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) {
|
|
|
|
const PseudoSourceValue *&V = (*FSValues)[FI];
|
|
|
|
if (!V)
|
|
|
|
V = new FixedStackPseudoSourceValue(FI);
|
|
|
|
return V;
|
|
|
|
}
|
2008-02-06 22:27:42 +00:00
|
|
|
}
|