LLVM API Documentation

JumpInstrTableInfo.h
Go to the documentation of this file.
00001 //===-- JumpInstrTableInfo.h: Info for Jump-Instruction Tables --*- C++ -*-===//
00002 //
00003 // This file is distributed under the University of Illinois Open Source
00004 // License. See LICENSE.TXT for details.
00005 //
00006 //===----------------------------------------------------------------------===//
00007 ///
00008 /// \file
00009 /// \brief Information about jump-instruction tables that have been created by
00010 /// JumpInstrTables pass.
00011 ///
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H
00015 #define LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H
00016 
00017 #include "llvm/ADT/DenseMap.h"
00018 #include "llvm/Pass.h"
00019 
00020 #include <vector>
00021 
00022 namespace llvm {
00023 class Function;
00024 class FunctionType;
00025 
00026 /// This class stores information about jump-instruction tables created by the
00027 /// JumpInstrTables pass (in lib/CodeGen/JumpInstrTables.cpp). Each table is a
00028 /// map from a function type to a vector of pairs. The first element of each
00029 /// pair is the function that has the jumptable annotation. The second element
00030 /// is a function that was declared by JumpInstrTables and used to replace all
00031 /// address-taking sites for the original function.
00032 ///
00033 /// The information in this pass is used in AsmPrinter
00034 /// (lib/CodeGen/AsmPrinter/AsmPrinter.cpp) to generate the required assembly
00035 /// for the jump-instruction tables.
00036 class JumpInstrTableInfo : public ImmutablePass {
00037 public:
00038   static char ID;
00039 
00040   JumpInstrTableInfo();
00041   virtual ~JumpInstrTableInfo();
00042   const char *getPassName() const override {
00043     return "Jump-Instruction Table Info";
00044   }
00045 
00046   typedef std::pair<Function *, Function *> JumpPair;
00047   typedef DenseMap<FunctionType *, std::vector<JumpPair> > JumpTables;
00048 
00049   /// Inserts an entry in a table, adding the table if it doesn't exist.
00050   void insertEntry(FunctionType *TableFunTy, Function *Target, Function *Jump);
00051 
00052   /// Gets the tables.
00053   const JumpTables &getTables() const { return Tables; }
00054 
00055 private:
00056   JumpTables Tables;
00057 };
00058 }
00059 
00060 #endif /* LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H */