Added preliminary code for generating C headers with the DSL
This commit is contained in:
@@ -36,7 +36,8 @@
|
|||||||
ASTNode* root = NULL;
|
ASTNode* root = NULL;
|
||||||
|
|
||||||
static const char inout_name_prefix[] = "handle_";
|
static const char inout_name_prefix[] = "handle_";
|
||||||
static bool doing_stencil_assembly = true;
|
typedef enum { STENCIL_ASSEMBLY, STENCIL_PROCESS, STENCIL_HEADER } CompilationType;
|
||||||
|
static CompilationType compilation_type;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
@@ -212,11 +213,14 @@ translate_latest_symbol(void)
|
|||||||
// FUNCTION PARAMETER
|
// FUNCTION PARAMETER
|
||||||
else if (symbol->type == SYMBOLTYPE_FUNCTION_PARAMETER) {
|
else if (symbol->type == SYMBOLTYPE_FUNCTION_PARAMETER) {
|
||||||
if (symbol->type_qualifier == IN || symbol->type_qualifier == OUT) {
|
if (symbol->type_qualifier == IN || symbol->type_qualifier == OUT) {
|
||||||
if (doing_stencil_assembly)
|
if (compilation_type == STENCIL_ASSEMBLY)
|
||||||
printf("const __restrict__ %s* %s", translate(symbol->type_specifier),
|
printf("const __restrict__ %s* %s", translate(symbol->type_specifier),
|
||||||
symbol->identifier);
|
symbol->identifier);
|
||||||
else
|
else if (compilation_type == STENCIL_PROCESS)
|
||||||
printf("const %sData& %s", translate(symbol->type_specifier), symbol->identifier);
|
printf("const %sData& %s", translate(symbol->type_specifier), symbol->identifier);
|
||||||
|
else
|
||||||
|
printf("Invalid compilation type %d, IN and OUT qualifiers not supported\n",
|
||||||
|
compilation_type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print_symbol(handle);
|
print_symbol(handle);
|
||||||
@@ -550,9 +554,11 @@ main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
if (!strcmp(argv[1], "-sas"))
|
if (!strcmp(argv[1], "-sas"))
|
||||||
doing_stencil_assembly = true;
|
compilation_type = STENCIL_ASSEMBLY;
|
||||||
else if (!strcmp(argv[1], "-sps"))
|
else if (!strcmp(argv[1], "-sps"))
|
||||||
doing_stencil_assembly = false;
|
compilation_type = STENCIL_PROCESS;
|
||||||
|
else if (!strcmp(argv[1], "-hh"))
|
||||||
|
compilation_type = STENCIL_HEADER;
|
||||||
else
|
else
|
||||||
printf("Unknown flag %s. Generating stencil assembly.\n", argv[1]);
|
printf("Unknown flag %s. Generating stencil assembly.\n", argv[1]);
|
||||||
}
|
}
|
||||||
@@ -576,7 +582,7 @@ main(int argc, char** argv)
|
|||||||
|
|
||||||
// Traverse
|
// Traverse
|
||||||
traverse(root);
|
traverse(root);
|
||||||
if (doing_stencil_assembly)
|
if (compilation_type == STENCIL_ASSEMBLY)
|
||||||
generate_preprocessed_structures();
|
generate_preprocessed_structures();
|
||||||
|
|
||||||
// print_symbol_table();
|
// print_symbol_table();
|
||||||
|
Reference in New Issue
Block a user