ad230506fb37506e9381cac92f48267238148326
[oota-llvm.git] / lib / Target / SparcV9 / RegAlloc / AllocInfo.h
1 //===-- AllocInfo.h - Store info about regalloc decisions -------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This header file contains the data structure used to save the state
11 // of the global, graph-coloring register allocator.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef ALLOCINFO_H
16 #define ALLOCINFO_H
17
18 #include "llvm/Type.h"
19 #include "llvm/DerivedTypes.h"
20 #include "llvm/Constants.h"
21
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.
25 ///
26 struct AllocInfo {
27   unsigned Instruction;
28   unsigned Operand;
29   unsigned AllocState;
30   int Placement;
31   AllocInfo (unsigned Instruction_, unsigned Operand_,
32              unsigned AllocState_, int Placement_) :
33     Instruction (Instruction_), Operand (Operand_),
34        AllocState (AllocState_), Placement (Placement_) { }
35
36   /// getConstantType - Return a StructType representing an AllocInfo object.
37   ///
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);
45   }
46
47   /// toConstant - Convert this AllocInfo into an LLVM Constant of type
48   /// getConstantType(), and return the Constant.
49   ///
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);
58   }
59 };
60
61 #endif // ALLOCINFO_H