JumpTable support! What this represents is working asm and jit support for
[oota-llvm.git] / include / llvm / CodeGen / MachineJumpTableInfo.h
1 //===-- CodeGen/MachineJumpTableInfo.h - Abstract Jump Tables  --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Nate Begeman and is distributed under the
6 // University of Illinois Open Source 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 "llvm/Target/TargetData.h"
24 #include <vector>
25 #include <iosfwd>
26
27 namespace llvm {
28
29 class MachineBasicBlock;
30
31 /// MachineJumpTableEntry - One jump table in the jump table info.
32 ///
33 struct MachineJumpTableEntry {
34   /// MBBs - The vector of basic blocks from which to create the jump table.
35   std::vector<MachineBasicBlock*> MBBs;
36   
37   MachineJumpTableEntry(std::vector<MachineBasicBlock*> &M) : MBBs(M) {}
38 };
39   
40 class MachineJumpTableInfo {
41   const TargetData &TD;
42   std::vector<MachineJumpTableEntry> JumpTables;
43 public:
44   MachineJumpTableInfo(const TargetData &td) : TD(td) {}
45     
46   /// getJumpTableIndex - Create a new jump table or return an existing one.
47   ///
48   unsigned getJumpTableIndex(std::vector<MachineBasicBlock*> &DestBBs);
49   
50   /// isEmpty - Return true if there are no jump tables.
51   ///
52   bool isEmpty() const { return JumpTables.empty(); }
53
54   const std::vector<MachineJumpTableEntry> &getJumpTables() const {
55     return JumpTables;
56   }
57   
58   unsigned getEntrySize() const { return TD.getPointerSize(); }
59   unsigned getAlignment() const { return TD.getPointerAlignment(); }
60   
61   /// print - Used by the MachineFunction printer to print information about
62   /// jump tables.  Implemented in MachineFunction.cpp
63   ///
64   void print(std::ostream &OS) const;
65
66   /// dump - Call print(std::cerr) to be called from the debugger.
67   ///
68   void dump() const;
69 };
70
71 } // End llvm namespace
72
73 #endif