1 //===-- InstrProfData.inc - instr profiling runtime structures-----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines templates for core runtime data structures used by
11 // instrumentation based profiling and coverage mapping. The instrumentation
12 // runtime library, the compiler IR lowering, and profile reader/writer need
13 // to use the same template to make sure the same data structure is defined
16 // Examples of how the template is used:
17 // 1. To declare a structure:
20 // #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer) \
22 // #include "ProfileData/InstrProfData.inc"
25 // 2. To define local variables for struct member's LLVM types"
27 // #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer) \
28 // LLVMTypeVar = LLVMType;
29 // #include "ProfileData/InstrProfData.inc"
31 // 3. To construct LLVM type arrays for the struct type:
33 // Type *DataTypes[] = {
34 // #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer) \
36 // #include "ProfileData/InstrProfData.inc"
39 // 4. To construct constant array for the initializers:
40 // #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer) \
42 // Constant *ConstantVals[] = {
43 // #include "ProfileData/InstrProfData.inc"
45 //===----------------------------------------------------------------------===//
47 #ifndef INSTR_PROF_DATA
48 #define INSTR_PROF_DATA(Type, LLVMTypeVar, LLVMType, Name, Initializer)
51 // INSTR_PROF_DATA_START
52 INSTR_PROF_DATA(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx), NameSize, \
53 ConstantInt::get(Int32Ty, NameSize))
54 INSTR_PROF_DATA(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx), NumCounters, \
55 ConstantInt::get(Int32Ty, NumCounters))
56 INSTR_PROF_DATA(const uint64_t, Int64Ty, llvm::Type::getInt64Ty(Ctx), FuncHash, \
57 ConstantInt::get(Int64Ty, FuncHash))
58 INSTR_PROF_DATA(const IntPtrT, Int8PtrTy,llvm::Type::getInt8PtrTy(Ctx), NamePtr, \
59 ConstantExpr::getBitCast(Name, Int8PtrTy))
60 INSTR_PROF_DATA(const IntPtrT, Int64PtrTy, llvm::Type::getInt64PtrTy(Ctx), CounterPtr, \
61 ConstantExpr::getBitCast(CounterPtr, Int8PtrTy))
62 // INSTR_PROF_DATA_END
64 #ifdef INSTR_PROF_DATA
65 #undef INSTR_PROF_DATA
69 #ifndef COVMAP_FUNC_RECORD
70 #define COVMAP_FUNC_RECORD(Type, LLVMTypeVar, LLVMType, Name, Initializer)
73 // COVMAP_FUNC_RECORD_START
74 COVMAP_FUNC_RECORD(const IntPtrT, Int8PtrTy, llvm::Type::getInt8PtrTy(Ctx), \
75 NamePtr, llvm::ConstantExpr::getBitCast(NamePtr, Int8PtrTy))
76 COVMAP_FUNC_RECORD(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx), \
77 NameSize, llvm::ConstantInt::get(Int32Ty, NameSize))
78 COVMAP_FUNC_RECORD(const uint32_t, Int32Ty, llvm::Type::getInt32Ty(Ctx), \
79 DataSize, llvm::ConstantInt::get(Int32Ty, DataSize))
80 COVMAP_FUNC_RECORD(const uint64_t, Int64Ty, llvm::Type::getInt64Ty(Ctx), \
81 FuncHash, llvm::ConstantInt::get(Int64Ty, FuncSize))
82 // COVMAP_FUNC_RECORD_END
84 #ifdef COVMAP_FUNC_RECORD
85 #undef COVMAP_FUNC_RECORD