~ubuntu-branches/ubuntu/maverick/clamav/maverick-backports

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Gran, Stephen Gran, Michael Tautschnig
  • Date: 2010-04-26 21:41:18 UTC
  • mfrom: (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100426214118-i6lo606wnh7ywfj6
Tags: 0.96+dfsg-4
[ Stephen Gran ]
* Fixed typo in clamav-milter's postinst

[ Michael Tautschnig ]
* Fixed typo in clamav-freshclam's postinst (closes: #579271)
* Debconf translation updates
  - Portuguese (closes: #579068)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===-- CodeGen/MachineJumpTableInfo.h - Abstract Jump Tables  --*- 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
// The MachineJumpTableInfo class keeps track of jump tables referenced by
 
11
// lowered switch instructions in the MachineFunction.
 
12
//
 
13
// Instructions reference the address of these jump tables through the use of 
 
14
// MO_JumpTableIndex values.  When emitting assembly or machine code, these 
 
15
// virtual address references are converted to refer to the address of the 
 
16
// function jump tables.
 
17
//
 
18
//===----------------------------------------------------------------------===//
 
19
 
 
20
#ifndef LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
 
21
#define LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
 
22
 
 
23
#include <vector>
 
24
#include <cassert>
 
25
 
 
26
namespace llvm {
 
27
 
 
28
class MachineBasicBlock;
 
29
class TargetData;
 
30
class raw_ostream;
 
31
 
 
32
/// MachineJumpTableEntry - One jump table in the jump table info.
 
33
///
 
34
struct MachineJumpTableEntry {
 
35
  /// MBBs - The vector of basic blocks from which to create the jump table.
 
36
  std::vector<MachineBasicBlock*> MBBs;
 
37
  
 
38
  explicit MachineJumpTableEntry(const std::vector<MachineBasicBlock*> &M)
 
39
  : MBBs(M) {}
 
40
};
 
41
  
 
42
class MachineJumpTableInfo {
 
43
public:
 
44
  /// JTEntryKind - This enum indicates how each entry of the jump table is
 
45
  /// represented and emitted.
 
46
  enum JTEntryKind {
 
47
    /// EK_BlockAddress - Each entry is a plain address of block, e.g.:
 
48
    ///     .word LBB123
 
49
    EK_BlockAddress,
 
50
    
 
51
    /// EK_GPRel32BlockAddress - Each entry is an address of block, encoded
 
52
    /// with a relocation as gp-relative, e.g.:
 
53
    ///     .gprel32 LBB123
 
54
    EK_GPRel32BlockAddress,
 
55
    
 
56
    /// EK_LabelDifference32 - Each entry is the address of the block minus
 
57
    /// the address of the jump table.  This is used for PIC jump tables where
 
58
    /// gprel32 is not supported.  e.g.:
 
59
    ///      .word LBB123 - LJTI1_2
 
60
    /// If the .set directive is supported, this is emitted as:
 
61
    ///      .set L4_5_set_123, LBB123 - LJTI1_2
 
62
    ///      .word L4_5_set_123
 
63
    EK_LabelDifference32,
 
64
    
 
65
    /// EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the
 
66
    /// TargetLowering::LowerCustomJumpTableEntry hook.
 
67
    EK_Custom32
 
68
  };
 
69
private:
 
70
  JTEntryKind EntryKind;
 
71
  std::vector<MachineJumpTableEntry> JumpTables;
 
72
public:
 
73
  MachineJumpTableInfo(JTEntryKind Kind): EntryKind(Kind) {}
 
74
    
 
75
  JTEntryKind getEntryKind() const { return EntryKind; }
 
76
 
 
77
  /// getEntrySize - Return the size of each entry in the jump table.
 
78
  unsigned getEntrySize(const TargetData &TD) const;
 
79
  /// getEntryAlignment - Return the alignment of each entry in the jump table.
 
80
  unsigned getEntryAlignment(const TargetData &TD) const;
 
81
  
 
82
  /// createJumpTableIndex - Create a new jump table.
 
83
  ///
 
84
  unsigned createJumpTableIndex(const std::vector<MachineBasicBlock*> &DestBBs);
 
85
  
 
86
  /// isEmpty - Return true if there are no jump tables.
 
87
  ///
 
88
  bool isEmpty() const { return JumpTables.empty(); }
 
89
 
 
90
  const std::vector<MachineJumpTableEntry> &getJumpTables() const {
 
91
    return JumpTables;
 
92
  }
 
93
 
 
94
  /// RemoveJumpTable - Mark the specific index as being dead.  This will
 
95
  /// prevent it from being emitted.
 
96
  void RemoveJumpTable(unsigned Idx) {
 
97
    JumpTables[Idx].MBBs.clear();
 
98
  }
 
99
  
 
100
  /// ReplaceMBBInJumpTables - If Old is the target of any jump tables, update
 
101
  /// the jump tables to branch to New instead.
 
102
  bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New);
 
103
 
 
104
  /// ReplaceMBBInJumpTable - If Old is a target of the jump tables, update
 
105
  /// the jump table to branch to New instead.
 
106
  bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old,
 
107
                             MachineBasicBlock *New);
 
108
 
 
109
  /// print - Used by the MachineFunction printer to print information about
 
110
  /// jump tables.  Implemented in MachineFunction.cpp
 
111
  ///
 
112
  void print(raw_ostream &OS) const;
 
113
 
 
114
  /// dump - Call to stderr.
 
115
  ///
 
116
  void dump() const;
 
117
};
 
118
 
 
119
} // End llvm namespace
 
120
 
 
121
#endif