1//===-- JumpInstrTableInfo.h: Info for Jump-Instruction Tables --*- C++ -*-===// 2// 3// This file is distributed under the University of Illinois Open Source 4// License. See LICENSE.TXT for details. 5// 6//===----------------------------------------------------------------------===// 7/// 8/// \file 9/// \brief Information about jump-instruction tables that have been created by 10/// JumpInstrTables pass. 11/// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H 15#define LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H 16 17#include "llvm/ADT/DenseMap.h" 18#include "llvm/Pass.h" 19 20#include <vector> 21 22namespace llvm { 23class Function; 24class FunctionType; 25 26/// This class stores information about jump-instruction tables created by the 27/// JumpInstrTables pass (in lib/CodeGen/JumpInstrTables.cpp). Each table is a 28/// map from a function type to a vector of pairs. The first element of each 29/// pair is the function that has the jumptable annotation. The second element 30/// is a function that was declared by JumpInstrTables and used to replace all 31/// address-taking sites for the original function. 32/// 33/// The information in this pass is used in AsmPrinter 34/// (lib/CodeGen/AsmPrinter/AsmPrinter.cpp) to generate the required assembly 35/// for the jump-instruction tables. 36class JumpInstrTableInfo : public ImmutablePass { 37public: 38 static char ID; 39 40 JumpInstrTableInfo(); 41 virtual ~JumpInstrTableInfo(); 42 const char *getPassName() const override { 43 return "Jump-Instruction Table Info"; 44 } 45 46 typedef std::pair<Function *, Function *> JumpPair; 47 typedef DenseMap<FunctionType *, std::vector<JumpPair> > JumpTables; 48 49 /// Inserts an entry in a table, adding the table if it doesn't exist. 50 void insertEntry(FunctionType *TableFunTy, Function *Target, Function *Jump); 51 52 /// Gets the tables. 53 const JumpTables &getTables() const { return Tables; } 54 55private: 56 JumpTables Tables; 57}; 58} 59 60#endif /* LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H */ 61