This task will add the following capabilities to the existing CASM bridge plugin
- Generate C code of th input
.cSfile with the CASM HWM implementation embedded.
- Generate output Assembly code of the input
.cSfile with the output assembly instructions corresponding to the function(s) within the
.cSinput source file.
The following are the proposed sub-tasks:
Add logic within
tools/bridge-plugins/as-bridge/casmbridge_gensrc.mlto: parse the input AST, locate the CASM function definitions, and replace the corresponding CASM instructions within the CASM function definitions with their corresponding CASM/HWM implementation.
The bridge plugin support function
Uberspark.Context.get_hwm_manifest_var_cpuprovides the CPU HWM manifest var which contains the field
hwm.cpu.casm_instructionsthat is an association list of
casm_mnemonicto the record of type
json_node_uberspark_hwm_cpu_casm_instruction_tthat is defined within
Once the AST is modified with the CASM/HWM implementation then write out the corresponding CASM functions into the output
.cfile that is specified by the
Add logic within
tools/bridge-plugins/as-bridge/casmbridge_gensrc.mlto: parse the input AST, locate the CASM function definitions, and write the corresponding output assembly language instruction into the output
.sfile that is specified by the
For the step above, you will need to add a assembler function definition prologue for every CASM function defined. The prologue is as below:
.section #casm_fn_section_name .balign #casm_fn_alignment .global #casm_fn_name #casm_fn_name:
#casm_fn_nameis the name of the CASM function. The output assembly instructions will follow this prologue for the corresponding CASM function.
#casm_fn_section_nameis obtained by parsing any
__attribute__(section())directive for the function definition. If that is absent the default value of
.textis used for
#casm_fn_alignmentis obtained by parsing any
__attribute__(aligned())directive for the function definition. If that is absent the default value of
4is used for
#casm_fn_alignment. The attribute directives are part of the Cil function node.