1 //===-- CodeGen/MachineJumpTableInfo.h - Abstract Jump Tables --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // The MachineJumpTableInfo class keeps track of jump tables referenced by
11 // lowered switch instructions in the MachineFunction.
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.
18 //===----------------------------------------------------------------------===//
20 #ifndef LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
21 #define LLVM_CODEGEN_MACHINEJUMPTABLEINFO_H
28 class MachineBasicBlock;
30 /// MachineJumpTableEntry - One jump table in the jump table info.
32 struct MachineJumpTableEntry {
33 /// MBBs - The vector of basic blocks from which to create the jump table.
34 std::vector<MachineBasicBlock*> MBBs;
36 MachineJumpTableEntry(std::vector<MachineBasicBlock*> &M) : MBBs(M) {}
39 class MachineJumpTableInfo {
41 std::vector<MachineJumpTableEntry> JumpTables;
43 MachineJumpTableInfo(const TargetData *td) : TD(td) {}
45 /// getJumpTableIndex - Create a new jump table or return an existing one.
47 unsigned getJumpTableIndex(std::vector<MachineBasicBlock*> &DestBBs);
49 /// isEmpty - Return true if there are no jump tables.
51 bool isEmpty() const { return JumpTables.empty(); }
53 const std::vector<MachineJumpTableEntry> &getJumpTables() const {
57 /// getEntrySize - returns the size of an individual field in a jump table
58 unsigned getEntrySize() const;
60 /// getAlignment - returns the target's preferred alignment for jump tables
61 unsigned getAlignment() const;
63 /// print - Used by the MachineFunction printer to print information about
64 /// jump tables. Implemented in MachineFunction.cpp
66 void print(std::ostream &OS) const;
68 /// dump - Call print(std::cerr) to be called from the debugger.
73 } // End llvm namespace