mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-18 10:31:57 +00:00
82c5eb7bc8
Move the stringifying method for that enum into class AllocInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9616 91177308-0d34-0410-b5e6-96231b3b80d8
81 lines
2.8 KiB
C++
81 lines
2.8 KiB
C++
//===-- AllocInfo.h - Store info about regalloc decisions -------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This header file contains the data structure used to save the state
|
|
// of the global, graph-coloring register allocator.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef ALLOCINFO_H
|
|
#define ALLOCINFO_H
|
|
|
|
#include "llvm/Type.h"
|
|
#include "llvm/DerivedTypes.h"
|
|
#include "llvm/Constants.h"
|
|
|
|
/// AllocInfo - Structure representing one instruction's operand's-worth of
|
|
/// register allocation state. We create tables made out of these data
|
|
/// structures to generate mapping information for this register allocator.
|
|
///
|
|
struct AllocInfo {
|
|
unsigned Instruction;
|
|
unsigned Operand;
|
|
enum AllocStateTy { NotAllocated = 0, Allocated, Spilled };
|
|
AllocStateTy AllocState;
|
|
int Placement;
|
|
|
|
AllocInfo (unsigned Instruction_, unsigned Operand_,
|
|
AllocStateTy AllocState_, int Placement_) :
|
|
Instruction (Instruction_), Operand (Operand_),
|
|
AllocState (AllocState_), Placement (Placement_) { }
|
|
|
|
/// getConstantType - Return a StructType representing an AllocInfo object.
|
|
///
|
|
static StructType *getConstantType () {
|
|
std::vector<const Type *> TV;
|
|
TV.push_back (Type::UIntTy);
|
|
TV.push_back (Type::UIntTy);
|
|
TV.push_back (Type::UIntTy);
|
|
TV.push_back (Type::IntTy);
|
|
return StructType::get (TV);
|
|
}
|
|
|
|
/// toConstant - Convert this AllocInfo into an LLVM Constant of type
|
|
/// getConstantType(), and return the Constant.
|
|
///
|
|
Constant *toConstant () const {
|
|
StructType *ST = getConstantType ();
|
|
std::vector<Constant *> CV;
|
|
CV.push_back (ConstantUInt::get (Type::UIntTy, Instruction));
|
|
CV.push_back (ConstantUInt::get (Type::UIntTy, Operand));
|
|
CV.push_back (ConstantUInt::get (Type::UIntTy, AllocState));
|
|
CV.push_back (ConstantSInt::get (Type::IntTy, Placement));
|
|
return ConstantStruct::get (ST, CV);
|
|
}
|
|
|
|
/// AllocInfos compare equal if the allocation placements are equal
|
|
/// (i.e., they can be equal even if they refer to operands from two
|
|
/// different instructions.)
|
|
///
|
|
bool operator== (const AllocInfo &X) const {
|
|
return (X.AllocState == AllocState) && (X.Placement == Placement);
|
|
}
|
|
bool operator!= (const AllocInfo &X) const { return !(*this == X); }
|
|
|
|
/// Returns a human-readable string representation of the AllocState member.
|
|
///
|
|
const std::string allocStateToString () const {
|
|
static const char *AllocStateNames[] =
|
|
{ "NotAllocated", "Allocated", "Spilled" };
|
|
return std::string (AllocStateNames[AllocState]);
|
|
}
|
|
};
|
|
|
|
#endif // ALLOCINFO_H
|