Skip to content

Commit

Permalink
Remove CompilerOptions from codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
fsaintjacques committed Jan 8, 2020
1 parent 546f94c commit a70a591
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
8 changes: 6 additions & 2 deletions include/jitmap/query/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
#pragma once

#include <memory>
#include <string>
#include <tuple>

#include <jitmap/query/query.h>
#include <jitmap/size.h>
#include <jitmap/util/exception.h>

namespace llvm {
class LLVMContext;
Expand Down Expand Up @@ -48,12 +50,14 @@ struct CompilerOptions {
std::string cpu = "";
};

class Query;

// The QueryIRCodeGen class generates LLVM IR for query expression on dense
// bitmaps. The QueryIRCodeGen is backed by a single llvm::Module where each
// Query object is represented by a single llvm::Function.
class QueryIRCodeGen {
public:
QueryIRCodeGen(const std::string& module_name, CompilerOptions options = {});
QueryIRCodeGen(const std::string& module_name);
QueryIRCodeGen(QueryIRCodeGen&&);
~QueryIRCodeGen();

Expand Down
16 changes: 2 additions & 14 deletions include/jitmap/query/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,13 @@

#include <memory>
#include <string>
#include <vector>

#include <jitmap/jitmap.h>
#include <jitmap/query/expr.h>
#include <jitmap/query/parser.h>
#include <jitmap/query/type_fwd.h>

namespace jitmap {
namespace query {

// Attach a unique name to a bitmap. Used to bind name in the query with a
// physical bitmap.
template <typename T>
struct NamedData {
std::string name;
T bitmap;
};

using NamedBitmap = NamedData<Bitmap*>;
using NamedDenseBitset = NamedData<DenseBitset>;

class Query : public std::enable_shared_from_this<Query> {
public:
// Create a new query object based on an expression.
Expand Down
5 changes: 1 addition & 4 deletions src/jitmap/jitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@

#include <jitmap/jitmap.h>

namespace jitmap {


}
namespace jitmap {}
11 changes: 5 additions & 6 deletions src/jitmap/query/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <llvm/Support/raw_ostream.h>

#include "jitmap/query/compiler.h"
#include "jitmap/query/expr.h"
#include "jitmap/query/query.h"
#include "jitmap/query/type_traits.h"

Expand Down Expand Up @@ -85,11 +86,10 @@ struct ExprCodeGenVisitor {

class QueryIRCodeGen::Impl {
public:
Impl(const std::string& module_name, CompilerOptions options)
Impl(const std::string& module_name)
: ctx_(std::make_unique<llvm::LLVMContext>()),
module_(std::make_unique<llvm::Module>(module_name, *ctx_)),
builder_(*ctx_),
options_(std::move(options)) {}
builder_(*ctx_) {}

void Compile(const Query& query) { FunctionDeclForQuery(query); }

Expand Down Expand Up @@ -243,11 +243,10 @@ class QueryIRCodeGen::Impl {
std::unique_ptr<llvm::LLVMContext> ctx_;
std::unique_ptr<llvm::Module> module_;
llvm::IRBuilder<> builder_;
CompilerOptions options_;
};

QueryIRCodeGen::QueryIRCodeGen(const std::string& module_name, CompilerOptions options)
: impl_(std::make_unique<QueryIRCodeGen::Impl>(module_name, std::move(options))) {}
QueryIRCodeGen::QueryIRCodeGen(const std::string& module_name)
: impl_(std::make_unique<QueryIRCodeGen::Impl>(module_name)) {}
QueryIRCodeGen::QueryIRCodeGen(QueryIRCodeGen&& other) { std::swap(impl_, other.impl_); }
QueryIRCodeGen::~QueryIRCodeGen() {}

Expand Down
1 change: 1 addition & 0 deletions tests/jitmap_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <jitmap/jitmap.h>
#include <jitmap/query/compiler.h>
#include <jitmap/query/jit.h>
#include <jitmap/query/query.h>
#include <jitmap/size.h>

namespace jitmap {
Expand Down
2 changes: 1 addition & 1 deletion tools/jitmap_ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main(int argc, char** argv) {

try {
auto query = Query::Make("query", argv[1]);
auto compiler = QueryIRCodeGen("jitmap-ir-module", {});
auto compiler = QueryIRCodeGen("jitmap-ir-module");
compiler.Compile(*query);
auto [module, ctx] = std::move(compiler).Finish();
std::cout << DumpIR(*module) << "\n";
Expand Down

0 comments on commit a70a591

Please sign in to comment.