Skip to content

Commit

Permalink
Rebase on new version of Jasmin.
Browse files Browse the repository at this point in the history
  • Loading branch information
asoffer committed Dec 17, 2023
1 parent b33de60 commit 5c821f7
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 228 deletions.
12 changes: 6 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "asoffer_nth",
urls = ["https://github.com/asoffer/nth/archive/ca567073993e891dd53a40a4871f9ef8f666bf75.zip"],
strip_prefix = "nth-ca567073993e891dd53a40a4871f9ef8f666bf75",
sha256 = "edc4bf4e6f5fcccdea2eab8be537ec1ac40ee18095cb48878a25be3d50ce413d",
urls = ["https://github.com/asoffer/nth/archive/b818c47608dfad8085394c4aa81523b8549a1e03.zip"],
strip_prefix = "nth-b818c47608dfad8085394c4aa81523b8549a1e03",
sha256 = "f0b4c1a239eb49392b46b5c9d8871ff42d59abee5ab369248874ba3c0a4cd424",
)

http_archive(
name = "asoffer_jasmin",
urls = ["https://github.com/asoffer/jasmin/archive/a2b29865b04d44c0920b2107b15c7ebb397d089a.zip"],
strip_prefix = "jasmin-a2b29865b04d44c0920b2107b15c7ebb397d089a",
sha256 = "6a237d210c3511d61ff0d77d56641b4c96d84c7ba5dab2780abf7c29f1a28250",
urls = ["https://github.com/asoffer/jasmin/archive/093567c8764721fa5efd939967c86e224b77bf76.zip"],
strip_prefix = "jasmin-093567c8764721fa5efd939967c86e224b77bf76",
sha256 = "30d0c6cdc8dfb44b1dbcfe0b32c5dedc9973afe457626f585c7b097dc3c786c4",
)
2 changes: 1 addition & 1 deletion common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cc_library(
name = "module_id",
hdrs = ["module_id.h"],
deps = [
"@asoffer_jasmin//jasmin:value",
"@asoffer_jasmin//jasmin/core:value",
],
)

Expand Down
2 changes: 1 addition & 1 deletion common/module_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <span>
#include <utility>

#include "jasmin/value.h"
#include "jasmin/core/value.h"

namespace ic {

Expand Down
20 changes: 11 additions & 9 deletions ir/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ cc_library(
":module",
":module_cc_proto",
"//type:deserialize",
"@asoffer_jasmin//jasmin/core:metadata",
"@asoffer_nth//nth/base:attributes",
"@asoffer_nth//nth/debug",
"@asoffer_nth//nth/debug/log",
Expand Down Expand Up @@ -64,10 +65,11 @@ cc_library(
"//parse:tree",
"//type",
"@asoffer_jasmin//jasmin/instructions:arithmetic",
"@asoffer_jasmin//jasmin:execute",
"@asoffer_jasmin//jasmin/core:execute",
"@asoffer_nth//nth/debug",
"@asoffer_nth//nth/debug/log",
"@asoffer_nth//nth/container:interval_map",
"@asoffer_nth//nth/container:stack",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:btree",
],
Expand All @@ -92,15 +94,14 @@ cc_library(
"//common:module_id",
"//common:resources",
"//type",
"@asoffer_jasmin//jasmin:function",
"@asoffer_jasmin//jasmin:instruction",
"@asoffer_jasmin//jasmin/core:function",
"@asoffer_jasmin//jasmin/core:instruction",
"@asoffer_jasmin//jasmin/core:value",
"@asoffer_jasmin//jasmin/instructions:arithmetic",
"@asoffer_jasmin//jasmin/instructions:bool",
"@asoffer_jasmin//jasmin/instructions:core",
"@asoffer_jasmin//jasmin/instructions:common",
"@asoffer_jasmin//jasmin/instructions:compare",
"@asoffer_jasmin//jasmin/instructions:stack",
"@asoffer_jasmin//jasmin:value",
"@asoffer_jasmin//jasmin:value_stack",
"@asoffer_nth//nth/container:flyweight_map",
"@com_google_absl//absl/container:flat_hash_map",
],
Expand Down Expand Up @@ -132,8 +133,8 @@ cc_library(
"//parse:tree",
"//type",
"//type:cast",
"@asoffer_jasmin//jasmin:execute",
"@asoffer_jasmin//jasmin:value_stack",
"@asoffer_jasmin//jasmin/core:execute",
"@asoffer_jasmin//jasmin/core:value",
"@asoffer_nth//nth/debug",
"@asoffer_nth//nth/debug/log",
"@com_google_absl//absl/container:flat_hash_map",
Expand Down Expand Up @@ -164,7 +165,7 @@ cc_library(
":scope",
"//common:identifier",
"//type",
"@asoffer_jasmin//jasmin:value",
"@asoffer_jasmin//jasmin/core:value",
"@asoffer_nth//nth/debug",
"@asoffer_nth//nth/debug/log",
"@com_google_absl//absl/container:inlined_vector",
Expand Down Expand Up @@ -232,6 +233,7 @@ cc_library(
":module_cc_proto",
"//common:resources",
"//type:serialize",
"@asoffer_jasmin//jasmin/core:metadata",
"@asoffer_nth//nth/debug",
"@asoffer_nth//nth/debug/log",
],
Expand Down
4 changes: 2 additions & 2 deletions ir/builtin_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ nth::NoDestructor<IrFunction> Slice([] {
nth::NoDestructor<IrFunction> ForeignType([] {
IrFunction f(3, 1);
f.append<jasmin::Swap>();
f.append<jasmin::Drop>(1);
f.append<jasmin::Drop>();
f.append<jasmin::Swap>();
f.append<jasmin::Drop>(1);
f.append<jasmin::Drop>();
f.append<jasmin::Return>();
return f;
}());
Expand Down
10 changes: 4 additions & 6 deletions ir/deserialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "common/resources.h"
#include "ir/builtin_module.h"
#include "ir/foreign_function.h"
#include "jasmin/core/metadata.h"
#include "nth/debug/debug.h"
#include "nth/debug/log/log.h"
#include "type/deserialize.h"
Expand All @@ -26,11 +27,7 @@ bool Deserializer::DeserializeFunction(ModuleProto const& module_proto,
IrFunction& f) {
for (auto const& instruction : proto.instructions()) {
uint64_t op_code = static_cast<uint64_t>(instruction.op_code());

jasmin::Value op_code_value = jasmin::Value::Uninitialized();
op_code_value.set_raw_value(reinterpret_cast<uint64_t>(
InstructionSet::InstructionFunction(op_code)));
f.raw_append(op_code_value);
f.raw_append(jasmin::Metadata<InstructionSet>.metadata(op_code).function);
switch (op_code) {
case InstructionProto::PUSH_STRING_LITERAL: {
auto const& string_literals = module_proto.string_literals();
Expand Down Expand Up @@ -74,7 +71,8 @@ bool Deserializer::DeserializeFunction(ModuleProto const& module_proto,
}
} break;
default: {
auto op_code_metadata = InstructionSet::OpCodeMetadata(op_code_value);
auto op_code_metadata =
jasmin::Metadata<InstructionSet>.metadata(op_code);
if (op_code_metadata.immediate_value_count !=
instruction.content().size()) {
return false;
Expand Down
Loading

0 comments on commit 5c821f7

Please sign in to comment.