2008-02-06 23:27:42 +01: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-12 00:44:52 +02:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2008-02-06 23:27:42 +01:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
2008-07-12 00:44:52 +02:00
|
|
|
#include <map>
|
2008-02-06 23:27:42 +01:00
|
|
|
|
|
|
|
namespace llvm {
|
2008-07-12 00:44:52 +02:00
|
|
|
static ManagedStatic<PseudoSourceValue[4]> PSVs;
|
2008-02-06 23:27:42 +01:00
|
|
|
|
2008-02-11 19:57:43 +01:00
|
|
|
const PseudoSourceValue *PseudoSourceValue::getStack()
|
2008-07-12 00:44:52 +02:00
|
|
|
{ return &(*PSVs)[0]; }
|
2008-02-11 19:57:43 +01:00
|
|
|
const PseudoSourceValue *PseudoSourceValue::getGOT()
|
2008-07-12 00:44:52 +02:00
|
|
|
{ return &(*PSVs)[1]; }
|
|
|
|
const PseudoSourceValue *PseudoSourceValue::getJumpTable()
|
2008-02-11 19:57:43 +01:00
|
|
|
{ return &(*PSVs)[2]; }
|
|
|
|
const PseudoSourceValue *PseudoSourceValue::getConstantPool()
|
|
|
|
{ return &(*PSVs)[3]; }
|
2008-02-06 23:27:42 +01:00
|
|
|
|
2008-03-25 22:45:14 +01:00
|
|
|
static const char *const PSVNames[] = {
|
2008-02-06 23:27:42 +01:00
|
|
|
"Stack",
|
|
|
|
"GOT",
|
2008-07-14 19:45:47 +02:00
|
|
|
"JumpTable",
|
2008-07-12 00:44:52 +02:00
|
|
|
"ConstantPool"
|
2008-02-06 23:27:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
PseudoSourceValue::PseudoSourceValue() :
|
|
|
|
Value(PointerType::getUnqual(Type::Int8Ty), PseudoSourceValueVal) {}
|
|
|
|
|
|
|
|
void PseudoSourceValue::print(std::ostream &OS) const {
|
|
|
|
OS << PSVNames[this - *PSVs];
|
|
|
|
}
|
2008-07-12 00:44:52 +02: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 23:27:42 +01:00
|
|
|
}
|