2025-12-20 21:03:31 +01:00
|
|
|
#include "amduat/pel/decode.h"
|
|
|
|
|
|
|
|
|
|
#include "amduat/enc/pel1_result.h"
|
|
|
|
|
#include "amduat/enc/pel_program_dag.h"
|
2025-12-22 08:16:58 +01:00
|
|
|
#include "amduat/enc/pel_program_dag_desc.h"
|
2025-12-20 21:03:31 +01:00
|
|
|
#include "amduat/enc/pel_trace_dag.h"
|
|
|
|
|
#include "amduat/pel/program_dag_desc.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
bool amduat_pel_program_decode_artifact(const amduat_artifact_t *artifact,
|
|
|
|
|
amduat_pel_program_t *out_program) {
|
|
|
|
|
if (artifact == NULL || out_program == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (artifact->has_type_tag &&
|
|
|
|
|
artifact->type_tag.tag_id != AMDUAT_PEL_TYPE_TAG_PROGRAM_DAG_1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
memset(out_program, 0, sizeof(*out_program));
|
|
|
|
|
return amduat_enc_pel_program_dag_decode_v1(artifact->bytes, out_program);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-22 08:16:58 +01:00
|
|
|
bool amduat_pel_program_dag_desc_decode_artifact(
|
|
|
|
|
const amduat_artifact_t *artifact,
|
|
|
|
|
amduat_pel_dag_scheme_descriptor_t *out_desc) {
|
|
|
|
|
if (artifact == NULL || out_desc == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (artifact->has_type_tag &&
|
|
|
|
|
artifact->type_tag.tag_id != AMDUAT_PEL_TYPE_TAG_SCHEME_DESC_1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
memset(out_desc, 0, sizeof(*out_desc));
|
|
|
|
|
return amduat_enc_pel_program_dag_desc_decode_v1(artifact->bytes, out_desc);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-20 21:03:31 +01:00
|
|
|
bool amduat_pel_trace_decode_artifact(const amduat_artifact_t *artifact,
|
|
|
|
|
amduat_pel_trace_dag_value_t *out_trace) {
|
|
|
|
|
if (artifact == NULL || out_trace == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (artifact->has_type_tag &&
|
|
|
|
|
artifact->type_tag.tag_id != AMDUAT_TYPE_TAG_PEL_TRACE_DAG_1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
memset(out_trace, 0, sizeof(*out_trace));
|
|
|
|
|
return amduat_enc_pel_trace_dag_decode_v1(artifact->bytes, out_trace);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool amduat_pel_result_decode_artifact(
|
|
|
|
|
const amduat_artifact_t *artifact,
|
|
|
|
|
amduat_pel_surface_execution_result_t *out_result) {
|
|
|
|
|
if (artifact == NULL || out_result == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (artifact->has_type_tag &&
|
|
|
|
|
artifact->type_tag.tag_id != AMDUAT_TYPE_TAG_PEL1_RESULT_1) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
memset(out_result, 0, sizeof(*out_result));
|
|
|
|
|
return amduat_enc_pel1_result_decode_v1(artifact->bytes, out_result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool amduat_pel_program_validate_artifact(const amduat_artifact_t *artifact,
|
|
|
|
|
bool *out_valid) {
|
|
|
|
|
amduat_pel_program_t program;
|
|
|
|
|
bool ok;
|
|
|
|
|
|
|
|
|
|
if (out_valid == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
*out_valid = false;
|
|
|
|
|
if (!amduat_pel_program_decode_artifact(artifact, &program)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ok = amduat_pel_program_dag_validate(&program);
|
|
|
|
|
amduat_enc_pel_program_dag_free(&program);
|
|
|
|
|
*out_valid = ok;
|
|
|
|
|
return true;
|
|
|
|
|
}
|