1 //===-- AllocInfo.h - Store info about regalloc decisions -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This header file contains the data structure used to save the state
11 // of the global, graph-coloring register allocator.
13 //===----------------------------------------------------------------------===//
18 #include "llvm/Type.h"
19 #include "llvm/DerivedTypes.h"
20 #include "llvm/Constants.h"
22 /// AllocInfo - Structure representing one instruction's operand's-worth of
23 /// register allocation state. We create tables made out of these data
24 /// structures to generate mapping information for this register allocator.
31 AllocInfo (unsigned Instruction_, unsigned Operand_,
32 unsigned AllocState_, int Placement_) :
33 Instruction (Instruction_), Operand (Operand_),
34 AllocState (AllocState_), Placement (Placement_) { }
36 /// getConstantType - Return a StructType representing an AllocInfo object.
38 static StructType *getConstantType () {
39 std::vector<const Type *> TV;
40 TV.push_back (Type::UIntTy);
41 TV.push_back (Type::UIntTy);
42 TV.push_back (Type::UIntTy);
43 TV.push_back (Type::IntTy);
44 return StructType::get (TV);
47 /// toConstant - Convert this AllocInfo into an LLVM Constant of type
48 /// getConstantType(), and return the Constant.
50 Constant *toConstant () const {
51 StructType *ST = getConstantType ();
52 std::vector<Constant *> CV;
53 CV.push_back (ConstantUInt::get (Type::UIntTy, Instruction));
54 CV.push_back (ConstantUInt::get (Type::UIntTy, Operand));
55 CV.push_back (ConstantUInt::get (Type::UIntTy, AllocState));
56 CV.push_back (ConstantSInt::get (Type::IntTy, Placement));
57 return ConstantStruct::get (ST, CV);