LLVM API Documentation

MachineJumpTableInfo.h

Go to the documentation of this file.
00001 //===-- CodeGen/MachineJumpTableInfo.h - Abstract Jump Tables  --*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by Nate Begeman and is distributed under the
00006 // University of Illinois Open Source License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // The MachineJumpTableInfo class keeps track of jump tables referenced by
00011 // lowered switch instructions in the MachineFunction.
00012 //
00013 // Instructions reference the address of these jump tables through the use of 
00014 // MO_JumpTableIndex values.  When emitting assembly or machine code, these 
00015 // virtual address references are converted to refer to the address of the 
00016 // function jump tables.
00017 //
00018 //===----------------------------------------------------------------------===//
00019 
00020 #ifndef LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
00021 #define LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
00022 
00023 #include <vector>
00024 #include <iosfwd>
00025 
00026 namespace llvm {
00027 
00028 class MachineBasicBlock;
00029 
00030 /// MachineJumpTableEntry - One jump table in the jump table info.
00031 ///
00032 struct MachineJumpTableEntry {
00033   /// MBBs - The vector of basic blocks from which to create the jump table.
00034   std::vector<MachineBasicBlock*> MBBs;
00035   
00036   MachineJumpTableEntry(std::vector<MachineBasicBlock*> &M) : MBBs(M) {}
00037 };
00038   
00039 class MachineJumpTableInfo {
00040   const TargetData *TD;
00041   std::vector<MachineJumpTableEntry> JumpTables;
00042 public:
00043   MachineJumpTableInfo(const TargetData *td) : TD(td) {}
00044     
00045   /// getJumpTableIndex - Create a new jump table or return an existing one.
00046   ///
00047   unsigned getJumpTableIndex(std::vector<MachineBasicBlock*> &DestBBs);
00048   
00049   /// isEmpty - Return true if there are no jump tables.
00050   ///
00051   bool isEmpty() const { return JumpTables.empty(); }
00052 
00053   const std::vector<MachineJumpTableEntry> &getJumpTables() const {
00054     return JumpTables;
00055   }
00056   
00057   /// getEntrySize - returns the size of an individual field in a jump table 
00058   unsigned getEntrySize() const;
00059   
00060   /// getAlignment - returns the target's preferred alignment for jump tables
00061   unsigned getAlignment() const;
00062   
00063   /// print - Used by the MachineFunction printer to print information about
00064   /// jump tables.  Implemented in MachineFunction.cpp
00065   ///
00066   void print(std::ostream &OS) const;
00067 
00068   /// dump - Call print(std::cerr) to be called from the debugger.
00069   ///
00070   void dump() const;
00071 };
00072 
00073 } // End llvm namespace
00074 
00075 #endif