OLD | NEW |
(Empty) | |
| 1 //===-- ExceptionInfoWriter.h - Generate C++ exception info------*- C++ -*-===// |
| 2 // |
| 3 // The LLVM Compiler Infrastructure |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 |
| 10 #ifndef TRANSFORMS_NACL_EXCEPTIONINFOWRITER_H |
| 11 #define TRANSFORMS_NACL_EXCEPTIONINFOWRITER_H |
| 12 |
| 13 #include "llvm/ADT/DenseMap.h" |
| 14 #include "llvm/IR/Instructions.h" |
| 15 #include "llvm/IR/Module.h" |
| 16 |
| 17 namespace llvm { |
| 18 |
| 19 // The ExceptionInfoWriter class converts the clauses of a |
| 20 // "landingpad" instruction into data tables stored in global |
| 21 // variables, which are interpreted by PNaCl's C++ runtime library. |
| 22 // See ExceptionInfoWriter.cpp for a full description. |
| 23 class ExceptionInfoWriter { |
| 24 LLVMContext *Context; |
| 25 StructType *ActionTableEntryTy; |
| 26 |
| 27 // Data for populating __pnacl_eh_type_table[], which is an array of |
| 28 // std::type_info* pointers. Each of these pointers represents a |
| 29 // C++ exception type. |
| 30 SmallVector<Constant *, 10> TypeTableData; |
| 31 // Mapping from std::type_info* pointer to type ID (index in |
| 32 // TypeTableData). |
| 33 typedef DenseMap<Constant *, unsigned> TypeTableIDMapType; |
| 34 TypeTableIDMapType TypeTableIDMap; |
| 35 |
| 36 // Data for populating __pnacl_eh_action_table[], which is an array |
| 37 // of pairs. |
| 38 SmallVector<Constant *, 10> ActionTableData; |
| 39 // Pair of (clause_id, clause_list_id). |
| 40 typedef std::pair<unsigned, unsigned> ActionTableEntry; |
| 41 // Mapping from (clause_id, clause_list_id) to clause_id (index in |
| 42 // ActionTableData). |
| 43 typedef DenseMap<ActionTableEntry, unsigned> ActionTableIDMapType; |
| 44 ActionTableIDMapType ActionTableIDMap; |
| 45 |
| 46 // Data for populating __pnacl_eh_filter_table[], which is an array |
| 47 // of integers. |
| 48 SmallVector<Constant *, 10> FilterTableData; |
| 49 |
| 50 // Get the interned ID for an action. |
| 51 unsigned getIDForClauseListNode(unsigned ClauseID, unsigned NextClauseListID); |
| 52 |
| 53 // Get the clause ID for a "filter" clause. |
| 54 unsigned getIDForFilterClause(Value *Filter); |
| 55 |
| 56 public: |
| 57 explicit ExceptionInfoWriter(LLVMContext *Context); |
| 58 |
| 59 // Get the interned type ID (a small integer) for a C++ exception type. |
| 60 unsigned getIDForExceptionType(Value *Ty); |
| 61 |
| 62 // Get the clause list ID for a landingpad's clause list. |
| 63 unsigned getIDForLandingPadClauseList(LandingPadInst *LP); |
| 64 |
| 65 // Add the exception info tables to the module. |
| 66 void defineGlobalVariables(Module *M); |
| 67 }; |
| 68 |
| 69 } |
| 70 |
| 71 #endif |
OLD | NEW |