~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/TableGen/CodeGenRegisters.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//===- CodeGenRegisters.h - Register and RegisterClass Info -----*- C++ -*-===//
2
 
//
3
 
//                     The LLVM Compiler Infrastructure
4
 
//
5
 
// This file is distributed under the University of Illinois Open Source
6
 
// License. See LICENSE.TXT for details.
7
 
//
8
 
//===----------------------------------------------------------------------===//
9
 
//
10
 
// This file defines structures to encapsulate information gleaned from the
11
 
// target register and register class definitions.
12
 
//
13
 
//===----------------------------------------------------------------------===//
14
 
 
15
 
#ifndef CODEGEN_REGISTERS_H
16
 
#define CODEGEN_REGISTERS_H
17
 
 
18
 
#include "llvm/CodeGen/ValueTypes.h"
19
 
#include "llvm/ADT/DenseMap.h"
20
 
#include <string>
21
 
#include <vector>
22
 
#include <set>
23
 
#include <cstdlib>
24
 
 
25
 
namespace llvm {
26
 
  class Record;
27
 
 
28
 
  /// CodeGenRegister - Represents a register definition.
29
 
  struct CodeGenRegister {
30
 
    Record *TheDef;
31
 
    const std::string &getName() const;
32
 
    unsigned DeclaredSpillSize, DeclaredSpillAlignment;
33
 
    CodeGenRegister(Record *R);
34
 
  };
35
 
 
36
 
 
37
 
  struct CodeGenRegisterClass {
38
 
    Record *TheDef;
39
 
    std::string Namespace;
40
 
    std::vector<Record*> Elements;
41
 
    std::vector<MVT::SimpleValueType> VTs;
42
 
    unsigned SpillSize;
43
 
    unsigned SpillAlignment;
44
 
    int CopyCost;
45
 
    // Map SubRegIndex -> RegisterClass
46
 
    DenseMap<Record*,Record*> SubRegClasses;
47
 
    std::string MethodProtos, MethodBodies;
48
 
 
49
 
    const std::string &getName() const;
50
 
    const std::vector<MVT::SimpleValueType> &getValueTypes() const {return VTs;}
51
 
    unsigned getNumValueTypes() const { return VTs.size(); }
52
 
    
53
 
    MVT::SimpleValueType getValueTypeNum(unsigned VTNum) const {
54
 
      if (VTNum < VTs.size())
55
 
        return VTs[VTNum];
56
 
      assert(0 && "VTNum greater than number of ValueTypes in RegClass!");
57
 
      abort();
58
 
    }
59
 
    
60
 
    // Returns true if RC is a strict subclass.
61
 
    // RC is a sub-class of this class if it is a valid replacement for any
62
 
    // instruction operand where a register of this classis required. It must 
63
 
    // satisfy these conditions:
64
 
    //
65
 
    // 1. All RC registers are also in this.
66
 
    // 2. The RC spill size must not be smaller than our spill size.
67
 
    // 3. RC spill alignment must be compatible with ours.
68
 
    //
69
 
    bool hasSubClass(const CodeGenRegisterClass *RC) const {
70
 
 
71
 
      if (RC->Elements.size() > Elements.size() ||
72
 
          (SpillAlignment && RC->SpillAlignment % SpillAlignment) ||
73
 
          SpillSize > RC->SpillSize)
74
 
        return false;
75
 
 
76
 
      std::set<Record*> RegSet;
77
 
      for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
78
 
        Record *Reg = Elements[i];
79
 
        RegSet.insert(Reg);
80
 
      }
81
 
 
82
 
      for (unsigned i = 0, e = RC->Elements.size(); i != e; ++i) {
83
 
        Record *Reg = RC->Elements[i];
84
 
        if (!RegSet.count(Reg))
85
 
          return false;
86
 
      }
87
 
 
88
 
      return true;
89
 
    }
90
 
 
91
 
    CodeGenRegisterClass(Record *R);
92
 
  };
93
 
}
94
 
 
95
 
#endif