2008-10-31 06:54:29 +03:00
|
|
|
//===--- CGDebugInfo.h - DebugInfo for LLVM CodeGen -------------*- C++ -*-===//
|
2008-05-08 12:54:20 +04:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This is the source level debug info generator for llvm translation.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef CLANG_CODEGEN_CGDEBUGINFO_H
|
|
|
|
#define CLANG_CODEGEN_CGDEBUGINFO_H
|
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
#include "clang/AST/Type.h"
|
2008-05-08 12:54:20 +04:00
|
|
|
#include "clang/Basic/SourceLocation.h"
|
2008-08-11 20:50:21 +04:00
|
|
|
#include "llvm/Support/IRBuilder.h"
|
2008-05-08 12:54:20 +04:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class Function;
|
|
|
|
class DISerializer;
|
|
|
|
class CompileUnitDesc;
|
|
|
|
class BasicBlock;
|
|
|
|
class AnchorDesc;
|
|
|
|
class DebugInfoDesc;
|
|
|
|
class Value;
|
2008-05-25 09:15:42 +04:00
|
|
|
class TypeDesc;
|
2008-05-30 14:30:31 +04:00
|
|
|
class VariableDesc;
|
2008-05-25 09:15:42 +04:00
|
|
|
class SubprogramDesc;
|
2008-06-05 12:59:10 +04:00
|
|
|
class GlobalVariable;
|
|
|
|
class GlobalVariableDesc;
|
2008-06-07 08:46:53 +04:00
|
|
|
class EnumeratorDesc;
|
2008-06-09 14:47:41 +04:00
|
|
|
class SubrangeDesc;
|
2008-05-08 12:54:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace clang {
|
2008-05-25 09:15:42 +04:00
|
|
|
class FunctionDecl;
|
2008-05-30 14:30:31 +04:00
|
|
|
class VarDecl;
|
2008-05-08 12:54:20 +04:00
|
|
|
namespace CodeGen {
|
|
|
|
class CodeGenModule;
|
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
/// CGDebugInfo - This class gathers all debug information during compilation
|
|
|
|
/// and is responsible for emitting to llvm globals or pass directly to
|
|
|
|
/// the backend.
|
2008-05-08 12:54:20 +04:00
|
|
|
class CGDebugInfo {
|
|
|
|
private:
|
|
|
|
CodeGenModule *M;
|
|
|
|
llvm::DISerializer *SR;
|
|
|
|
SourceLocation CurLoc;
|
|
|
|
SourceLocation PrevLoc;
|
|
|
|
|
2008-08-11 20:50:21 +04:00
|
|
|
typedef llvm::IRBuilder<> BuilderType;
|
|
|
|
|
2008-05-08 12:54:20 +04:00
|
|
|
/// CompileUnitCache - Cache of previously constructed CompileUnits.
|
2008-10-24 04:46:51 +04:00
|
|
|
std::map<const FileEntry*, llvm::CompileUnitDesc *> CompileUnitCache;
|
2008-05-25 09:15:42 +04:00
|
|
|
|
|
|
|
/// TypeCache - Cache of previously constructed Types.
|
|
|
|
std::map<void *, llvm::TypeDesc *> TypeCache;
|
2008-05-08 12:54:20 +04:00
|
|
|
|
|
|
|
llvm::Function *StopPointFn;
|
2008-05-25 09:15:42 +04:00
|
|
|
llvm::Function *FuncStartFn;
|
|
|
|
llvm::Function *DeclareFn;
|
2008-05-08 12:54:20 +04:00
|
|
|
llvm::Function *RegionStartFn;
|
|
|
|
llvm::Function *RegionEndFn;
|
2008-05-25 09:15:42 +04:00
|
|
|
llvm::AnchorDesc *CompileUnitAnchor;
|
|
|
|
llvm::AnchorDesc *SubprogramAnchor;
|
2008-06-05 12:59:10 +04:00
|
|
|
llvm::AnchorDesc *GlobalVariableAnchor;
|
2008-05-30 14:30:31 +04:00
|
|
|
std::vector<llvm::DebugInfoDesc *> RegionStack;
|
|
|
|
std::vector<llvm::VariableDesc *> VariableDescList;
|
2008-06-05 12:59:10 +04:00
|
|
|
std::vector<llvm::GlobalVariableDesc *> GlobalVarDescList;
|
2008-06-07 08:46:53 +04:00
|
|
|
std::vector<llvm::EnumeratorDesc *> EnumDescList;
|
2008-06-09 14:47:41 +04:00
|
|
|
std::vector<llvm::SubrangeDesc *> SubrangeDescList;
|
2008-05-25 09:15:42 +04:00
|
|
|
llvm::SubprogramDesc *Subprogram;
|
2008-05-22 05:40:10 +04:00
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
/// Helper functions for getOrCreateType.
|
|
|
|
llvm::TypeDesc *getOrCreateCVRType(QualType type,
|
|
|
|
llvm::CompileUnitDesc *unit);
|
|
|
|
llvm::TypeDesc *getOrCreateBuiltinType(QualType type,
|
2008-10-31 06:54:29 +03:00
|
|
|
llvm::CompileUnitDesc *unit);
|
2008-05-25 09:15:42 +04:00
|
|
|
llvm::TypeDesc *getOrCreateTypedefType(QualType type,
|
2008-10-31 06:54:29 +03:00
|
|
|
llvm::CompileUnitDesc *unit);
|
2008-05-25 09:15:42 +04:00
|
|
|
llvm::TypeDesc *getOrCreatePointerType(QualType type,
|
2008-10-31 06:54:29 +03:00
|
|
|
llvm::CompileUnitDesc *unit);
|
2008-05-25 09:15:42 +04:00
|
|
|
llvm::TypeDesc *getOrCreateFunctionType(QualType type,
|
2008-10-31 06:54:29 +03:00
|
|
|
llvm::CompileUnitDesc *unit);
|
2008-10-31 07:04:54 +03:00
|
|
|
void getOrCreateRecordType(QualType type,
|
|
|
|
llvm::CompileUnitDesc *unit,
|
|
|
|
llvm::TypeDesc *&Slot);
|
2008-06-07 08:46:53 +04:00
|
|
|
llvm::TypeDesc *getOrCreateEnumType(QualType type,
|
2008-10-31 06:54:29 +03:00
|
|
|
llvm::CompileUnitDesc *unit);
|
2008-10-31 07:04:54 +03:00
|
|
|
void getOrCreateTaggedType(QualType type,
|
|
|
|
llvm::CompileUnitDesc *unit,
|
|
|
|
llvm::TypeDesc *&Slot);
|
2008-06-09 14:47:41 +04:00
|
|
|
llvm::TypeDesc *getOrCreateArrayType(QualType type,
|
2008-10-31 06:54:29 +03:00
|
|
|
llvm::CompileUnitDesc *unit);
|
2008-05-08 12:54:20 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
CGDebugInfo(CodeGenModule *m);
|
|
|
|
~CGDebugInfo();
|
|
|
|
|
2008-10-17 20:15:48 +04:00
|
|
|
/// setLocation - Update the current source location. If \arg loc is
|
|
|
|
/// invalid it is ignored.
|
2008-05-29 15:08:17 +04:00
|
|
|
void setLocation(SourceLocation loc);
|
2008-05-08 12:54:20 +04:00
|
|
|
|
|
|
|
/// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of
|
|
|
|
/// source line.
|
2008-08-11 20:50:21 +04:00
|
|
|
void EmitStopPoint(llvm::Function *Fn, BuilderType &Builder);
|
2008-05-25 09:15:42 +04:00
|
|
|
|
|
|
|
/// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
|
2008-10-18 22:22:23 +04:00
|
|
|
/// start of a new function.
|
|
|
|
void EmitFunctionStart(const char *Name, QualType ReturnType,
|
|
|
|
llvm::Function *Fn, BuilderType &Builder);
|
2008-05-08 12:54:20 +04:00
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
/// EmitRegionStart - Emit a call to llvm.dbg.region.start to indicate start
|
2008-05-08 12:54:20 +04:00
|
|
|
/// of a new block.
|
2008-08-11 20:50:21 +04:00
|
|
|
void EmitRegionStart(llvm::Function *Fn, BuilderType &Builder);
|
2008-05-08 12:54:20 +04:00
|
|
|
|
2008-05-25 09:15:42 +04:00
|
|
|
/// EmitRegionEnd - Emit call to llvm.dbg.region.end to indicate end of a
|
2008-05-08 12:54:20 +04:00
|
|
|
/// block.
|
2008-08-11 20:50:21 +04:00
|
|
|
void EmitRegionEnd(llvm::Function *Fn, BuilderType &Builder);
|
2008-05-30 14:30:31 +04:00
|
|
|
|
|
|
|
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
|
|
|
|
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
|
2008-08-11 20:50:21 +04:00
|
|
|
BuilderType &Builder);
|
2008-06-05 12:59:10 +04:00
|
|
|
|
|
|
|
/// EmitGlobalVariable - Emit information about a global variable.
|
|
|
|
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *decl);
|
2008-05-25 09:15:42 +04:00
|
|
|
|
|
|
|
/// getOrCreateCompileUnit - Get the compile unit from the cache or create a
|
|
|
|
/// new one if necessary.
|
|
|
|
llvm::CompileUnitDesc *getOrCreateCompileUnit(SourceLocation loc);
|
|
|
|
|
|
|
|
/// getOrCreateType - Get the type from the cache or create a new type if
|
|
|
|
/// necessary.
|
|
|
|
llvm::TypeDesc *getOrCreateType(QualType type, llvm::CompileUnitDesc *unit);
|
|
|
|
|
|
|
|
/// getCastValueFor - Return a llvm representation for a given debug
|
|
|
|
/// information descriptor cast to an empty struct pointer.
|
|
|
|
llvm::Value *getCastValueFor(llvm::DebugInfoDesc *DD);
|
|
|
|
|
|
|
|
/// getValueFor - Return a llvm representation for a given debug information
|
|
|
|
/// descriptor.
|
|
|
|
llvm::Value *getValueFor(llvm::DebugInfoDesc *DD);
|
2008-05-08 12:54:20 +04:00
|
|
|
};
|
|
|
|
} // namespace CodeGen
|
|
|
|
} // namespace clang
|
|
|
|
|
|
|
|
#endif
|