blob: 2097a1d2f06ceffc6d0fb5955945d8941cf380d1 [file] [log] [blame]
Sanjiv Gupta40e56a12008-05-08 08:54:20 +00001//===--- CGDebugInfo.h - DebugInfo for LLVM CodeGen -----------------------===//
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// This is the source level debug info generator for llvm translation.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CLANG_CODEGEN_CGDEBUGINFO_H
15#define CLANG_CODEGEN_CGDEBUGINFO_H
16
17#include "clang/Basic/SourceLocation.h"
18#include <map>
19#include <vector>
20
21
22namespace llvm {
23 class Function;
24 class IRBuilder;
25 class DISerializer;
26 class CompileUnitDesc;
27 class BasicBlock;
28 class AnchorDesc;
29 class DebugInfoDesc;
30 class Value;
31}
32
33namespace clang {
34namespace CodeGen {
35 class CodeGenModule;
36
37/// DebugInfo - This class gathers all debug information during compilation and
38/// is responsible for emitting to llvm globals or pass directly to the backend.
39class CGDebugInfo {
40private:
41 CodeGenModule *M;
42 llvm::DISerializer *SR;
43 SourceLocation CurLoc;
44 SourceLocation PrevLoc;
45
46 /// CompileUnitCache - Cache of previously constructed CompileUnits.
47 std::map<unsigned, llvm::CompileUnitDesc *> CompileUnitCache;
48
49 llvm::Function *StopPointFn;
50 llvm::AnchorDesc *CompileUnitAnchor;
51 llvm::Function *RegionStartFn;
52 llvm::Function *RegionEndFn;
53 std::vector<llvm::DebugInfoDesc *> RegionStack;
54
55public:
56 CGDebugInfo(CodeGenModule *m);
57 ~CGDebugInfo();
58
59 void setLocation(SourceLocation loc) { CurLoc = loc; };
60
61 /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of
62 /// source line.
63 void EmitStopPoint(llvm::Function *Fn, llvm::IRBuilder &Builder);
64
65 /// EmitRegionStart - Emit a call to llvm.dbg.region.start to indicate start
66 /// of a new block.
67 void EmitRegionStart(llvm::Function *Fn, llvm::IRBuilder &Builder);
68
69 /// EmitRegionEnd - Emit call to llvm.dbg.region.end to indicate end of a
70 /// block.
71 void EmitRegionEnd(llvm::Function *Fn, llvm::IRBuilder &Builder);
72
73 /// getOrCreateCompileUnit - Get the compile unit from the cache or create a
74 /// new one if necessary.
75 llvm::CompileUnitDesc *getOrCreateCompileUnit(SourceLocation loc);
76
77 /// getCastValueFor - Return a llvm representation for a given debug
78 /// information descriptor cast to an empty struct pointer.
79 llvm::Value *getCastValueFor(llvm::DebugInfoDesc *DD);
80};
81} // namespace CodeGen
82} // namespace clang
83
84#endif