-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See also: #24
- Loading branch information
Showing
6 changed files
with
418 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "arm_mcdhelper.hpp" | ||
#include "ab_mcdhelper.hpp" | ||
#include "at_mcdhelper.hpp" | ||
#include "atb_mcdhelper.hpp" | ||
#include "riscv_mcdhelper.hpp" | ||
#include "pc_mcdhelper.hpp" | ||
#include "cc_mcdhelper.hpp" | ||
#include "dt16x2_mcdhelper.hpp" | ||
#include "dt32x1_mcdhelper.hpp" | ||
|
||
void setup_decoders() | ||
{ | ||
arm::mcdhelper::setup_decoder(); | ||
ab::mcdhelper::setup_decoder(); | ||
at::mcdhelper::setup_decoder(); | ||
atb::mcdhelper::setup_decoder(); | ||
riscv::mcdhelper::setup_decoder(); | ||
pc::mcdhelper::setup_decoder(); | ||
cc::mcdhelper::setup_decoder(); | ||
dt16x2::mcdhelper::setup_decoder(); | ||
dt32x1::mcdhelper::setup_decoder(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "{{ ns }}mcdhelper.hpp" | ||
|
||
#include "mcdhelper.hpp" | ||
|
||
extern "C" { | ||
#include "{{ ns }}mcdecoder.h" | ||
} | ||
|
||
namespace {{ mcdecoder.namespace }} { | ||
namespace mcdhelper { | ||
|
||
#pragma region Internal functions | ||
|
||
{% for inst in instruction_decoders -%} | ||
static void convert_result_{{ inst.name }}(const {{ ns }}DecodeResult& concrete_result, ::mcdhelper::DecodeResult* result) { | ||
result->instruction_name = "{{ inst.name }}"; | ||
{% for field in inst.field_decoders -%} | ||
result->fields["{{ field.name }}"] = concrete_result.instruction.{{ inst.name }}.{{ field.name }}; | ||
{% endfor %} | ||
} | ||
{% endfor %} | ||
|
||
static bool decode_instruction(const ::mcdhelper::DecodeRequest& request, ::mcdhelper::DecodeResult* result) { | ||
{{ ns }}DecodeRequest concrete_request; | ||
{{ ns }}DecodeResult concrete_result; | ||
int result_code; | ||
|
||
concrete_request.codes = request.codes; | ||
|
||
result_code = {{ ns }}decode_instruction(&concrete_request, &concrete_result); | ||
|
||
switch (concrete_result.instruction_id) { | ||
{% for inst in instruction_decoders -%} | ||
case {{ ns }}InstructionId_k_{{ inst.name }}: | ||
convert_result_{{ inst.name }}(concrete_result, result); | ||
break; | ||
{% endfor %} | ||
} | ||
|
||
return result_code; | ||
} | ||
|
||
#pragma endregion Internal functions | ||
|
||
#pragma region External functions | ||
|
||
void setup_decoder(void) { | ||
::mcdhelper::Decoder decoder = { | ||
"{{ mcdecoder.namespace }}", | ||
decode_instruction, | ||
}; | ||
|
||
::mcdhelper::regist_decoder(decoder); | ||
} | ||
|
||
#pragma endregion External functions | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace {{ mcdecoder.namespace }} { | ||
namespace mcdhelper { | ||
|
||
#pragma region Functions | ||
|
||
extern void setup_decoder(void); | ||
|
||
#pragma endregion Functions | ||
|
||
} | ||
} |
Oops, something went wrong.