| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2018-2021 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
|
| 9 |
#include "Interface.hpp" |
| 10 |
|
| 11 |
#include "Decoder.hpp" |
| 12 |
#include "Encoder.hpp" |
| 13 |
|
| 14 |
using namespace iga; |
| 15 |
|
| 16 |
bool iga::ged::IsEncodeSupported(const Model &, const EncoderOpts &) { |
| 17 |
return true; |
| 18 |
} |
| 19 |
void iga::ged::Encode(const Model &m, const EncoderOpts &eopts, |
| 20 |
ErrorHandler &eh, Kernel &k, void *&bits, |
| 21 |
size_t &bitsLen) { |
| 22 |
Encoder enc(m, eh, eopts); |
| 23 |
uint32_t bitsLen32 = 0; |
| 24 |
try { |
| 25 |
enc.encodeKernel(k, k.getMemManager(), bits, bitsLen32); |
| 26 |
} catch (FatalError &) { |
| 27 |
// error already reported |
| 28 |
} |
| 29 |
bitsLen = bitsLen32; |
| 30 |
} |
| 31 |
|
| 32 |
bool iga::ged::IsDecodeSupported(const Model &, const DecoderOpts &) { |
| 33 |
return true; |
| 34 |
} |
| 35 |
Kernel *iga::ged::Decode(const Model &m, const DecoderOpts &dopts, |
| 36 |
ErrorHandler &eh, const void *bits, size_t bitsLen) { |
| 37 |
Kernel *k = nullptr; |
| 38 |
try { |
| 39 |
iga::Decoder decoder(m, eh); |
| 40 |
k = dopts.useNumericLabels ? decoder.decodeKernelNumeric(bits, bitsLen) |
| 41 |
: decoder.decodeKernelBlocks(bits, bitsLen); |
| 42 |
} catch (FatalError &) { |
| 43 |
// error already reported |
| 44 |
} |
| 45 |
return k; |
| 46 |
} |