Skip to content

Commit

Permalink
feat(IR): add some classes and methods related to debug information
Browse files Browse the repository at this point in the history
  • Loading branch information
ApsarasX committed Dec 12, 2021
1 parent 791c5d1 commit 7531651
Show file tree
Hide file tree
Showing 73 changed files with 1,732 additions and 22 deletions.
2 changes: 2 additions & 0 deletions include/IR/AllocaInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ class AllocaInst : public Napi::ObjectWrap<AllocaInst> {
Napi::Value getArraySize(const Napi::CallbackInfo &info);

Napi::Value getType(const Napi::CallbackInfo &info);

void setDebugLoc(const Napi::CallbackInfo &info);
};
2 changes: 2 additions & 0 deletions include/IR/BranchInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ class BranchInst : public Napi::ObjectWrap<BranchInst> {
Napi::Value getNumSuccessors(const Napi::CallbackInfo &info);

Napi::Value getSuccessor(const Napi::CallbackInfo &info);

void setDebugLoc(const Napi::CallbackInfo &info);
};
2 changes: 2 additions & 0 deletions include/IR/CallInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ class CallInst : public Napi::ObjectWrap<CallInst> {

private:
llvm::CallInst *callInst = nullptr;

void setDebugLoc(const Napi::CallbackInfo &info);
};
24 changes: 24 additions & 0 deletions include/IR/DIBasicType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DIBasicType : public Napi::ObjectWrap<DIBasicType> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DIBasicType *type);

static bool IsClassOf(const Napi::Value &value);

static llvm::DIBasicType *Extract(const Napi::Value &value);

explicit DIBasicType(const Napi::CallbackInfo &info);

llvm::DIBasicType *getLLVMPrimitive();

private:
llvm::DIBasicType *type = nullptr;
};
44 changes: 44 additions & 0 deletions include/IR/DIBuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DIBuilder.h>

class DIBuilder : public Napi::ObjectWrap<DIBuilder> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DIBuilder *builder);

static bool IsClassOf(const Napi::Value &value);

static llvm::DIBuilder *Extract(const Napi::Value &value);

explicit DIBuilder(const Napi::CallbackInfo &info);

llvm::DIBuilder *getLLVMPrimitive();

private:
llvm::DIBuilder *builder = nullptr;

Napi::Value createFile(const Napi::CallbackInfo &info);

Napi::Value createCompileUnit(const Napi::CallbackInfo &info);

Napi::Value createFunction(const Napi::CallbackInfo &info);

Napi::Value createBasicType(const Napi::CallbackInfo &info);

Napi::Value getOrCreateTypeArray(const Napi::CallbackInfo &info);

Napi::Value createSubroutineType(const Napi::CallbackInfo &info);

// Napi::Value createGlobalVariableExpression(const Napi::CallbackInfo &info);
//
// Napi::Value insertDbgValueIntrinsic(const Napi::CallbackInfo &info);

void finalizeSubprogram(const Napi::CallbackInfo &info);

void finalize(const Napi::CallbackInfo &info);
};
26 changes: 26 additions & 0 deletions include/IR/DICompileUnit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DICompileUnit : public Napi::ObjectWrap<DICompileUnit> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DICompileUnit *unit);

static bool IsClassOf(const Napi::Value &value);

static llvm::DICompileUnit *Extract(const Napi::Value &value);

explicit DICompileUnit(const Napi::CallbackInfo &info);

llvm::DICompileUnit *getLLVMPrimitive();

private:
llvm::DICompileUnit *unit = nullptr;

Napi::Value getFile(const Napi::CallbackInfo &info);
};
24 changes: 24 additions & 0 deletions include/IR/DIFile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DIFile : public Napi::ObjectWrap<DIFile> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DIFile *file);

static bool IsClassOf(const Napi::Value &value);

static llvm::DIFile *Extract(const Napi::Value &value);

explicit DIFile(const Napi::CallbackInfo &info);

llvm::DIFile *getLLVMPrimitive();

private:
llvm::DIFile *file = nullptr;
};
24 changes: 24 additions & 0 deletions include/IR/DILocalScope.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DILocalScope : public Napi::ObjectWrap<DILocalScope> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DILocalScope *scope);

static bool IsClassOf(const Napi::Value &value);

static llvm::DILocalScope *Extract(const Napi::Value &value);

explicit DILocalScope(const Napi::CallbackInfo &info);

llvm::DILocalScope *getLLVMPrimitive();

private:
llvm::DILocalScope *scope = nullptr;
};
26 changes: 26 additions & 0 deletions include/IR/DILocation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DILocation : public Napi::ObjectWrap<DILocation> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DILocation *location);

static bool IsClassOf(const Napi::Value &value);

static llvm::DILocation *Extract(const Napi::Value &value);

explicit DILocation(const Napi::CallbackInfo &info);

llvm::DILocation *getLLVMPrimitive();

private:
llvm::DILocation *location = nullptr;

static Napi::Value get(const Napi::CallbackInfo &info);
};
24 changes: 24 additions & 0 deletions include/IR/DINode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DINode : public Napi::ObjectWrap<DINode> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DINode *node);

static bool IsClassOf(const Napi::Value &value);

static llvm::DINode *Extract(const Napi::Value &value);

explicit DINode(const Napi::CallbackInfo &info);

llvm::DINode *getLLVMPrimitive();

private:
llvm::DINode *node = nullptr;
};
24 changes: 24 additions & 0 deletions include/IR/DIScope.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DIScope : public Napi::ObjectWrap<DIScope> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DIScope *scope);

static bool IsClassOf(const Napi::Value &value);

static llvm::DIScope *Extract(const Napi::Value &value);

explicit DIScope(const Napi::CallbackInfo &info);

llvm::DIScope *getLLVMPrimitive();

private:
llvm::DIScope *scope = nullptr;
};
24 changes: 24 additions & 0 deletions include/IR/DISubprogram.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DISubprogram : public Napi::ObjectWrap<DISubprogram> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DISubprogram *subProgram);

static bool IsClassOf(const Napi::Value &value);

static llvm::DISubprogram *Extract(const Napi::Value &value);

explicit DISubprogram(const Napi::CallbackInfo &info);

llvm::DISubprogram *getLLVMPrimitive();

private:
llvm::DISubprogram *subprogram = nullptr;
};
24 changes: 24 additions & 0 deletions include/IR/DISubroutineType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DISubroutineType : public Napi::ObjectWrap<DISubroutineType> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DISubroutineType *type);

static bool IsClassOf(const Napi::Value &value);

static llvm::DISubroutineType *Extract(const Napi::Value &value);

explicit DISubroutineType(const Napi::CallbackInfo &info);

llvm::DISubroutineType *getLLVMPrimitive();

private:
llvm::DISubroutineType *type = nullptr;
};
24 changes: 24 additions & 0 deletions include/IR/DIType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DIType : public Napi::ObjectWrap<DIType> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DIType *type);

static bool IsClassOf(const Napi::Value &value);

static llvm::DIType *Extract(const Napi::Value &value);

explicit DIType(const Napi::CallbackInfo &info);

llvm::DIType *getLLVMPrimitive();

private:
llvm::DIType *type = nullptr;
};
24 changes: 24 additions & 0 deletions include/IR/DITypeRefArray.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugInfoMetadata.h>

class DITypeRefArray : public Napi::ObjectWrap<DITypeRefArray> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DITypeRefArray *array);

static bool IsClassOf(const Napi::Value &value);

static llvm::DITypeRefArray *Extract(const Napi::Value &value);

explicit DITypeRefArray(const Napi::CallbackInfo &info);

llvm::DITypeRefArray *getLLVMPrimitive();

private:
llvm::DITypeRefArray *array = nullptr;
};
24 changes: 24 additions & 0 deletions include/IR/DebugLoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include <napi.h>
#include <llvm/IR/DebugLoc.h>

class DebugLoc : public Napi::ObjectWrap<DebugLoc> {
public:
static inline Napi::FunctionReference constructor; // NOLINT

static void Init(Napi::Env env, Napi::Object &exports);

static Napi::Value New(Napi::Env env, llvm::DebugLoc *location);

static bool IsClassOf(const Napi::Value &value);

static llvm::DebugLoc *Extract(const Napi::Value &value);

explicit DebugLoc(const Napi::CallbackInfo &info);

llvm::DebugLoc *getLLVMPrimitive();

private:
llvm::DebugLoc *location = nullptr;
};
4 changes: 4 additions & 0 deletions include/IR/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ class Function : public Napi::ObjectWrap<Function> {
void setPersonalityFn(const Napi::CallbackInfo &info);

void setDoesNotThrow(const Napi::CallbackInfo &info);

void setSubprogram(const Napi::CallbackInfo &info);

Napi::Value getSubprogram(const Napi::CallbackInfo &info);
};
Loading

0 comments on commit 7531651

Please sign in to comment.