2001-03-11 01:29:38 +01:00
|
|
|
#ifndef __compile_H
|
|
|
|
|
#define __compile_H
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
#if !defined(WINNT)
|
2001-03-20 07:16:23 +01:00
|
|
|
#ident "$Id: compile.h,v 1.6 2001/03/20 06:16:24 steve Exp $"
|
2001-03-11 01:29:38 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include <stdio.h>
|
2001-03-20 07:16:23 +01:00
|
|
|
# include "parse_misc.h"
|
2001-03-18 05:35:18 +01:00
|
|
|
# include "vpi_user.h"
|
2001-03-11 01:29:38 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The functions described here are the compile time support
|
|
|
|
|
* functions. Various bits of the compile process are taken care of
|
|
|
|
|
* here. What is called when is mostly controlled by the parser.
|
|
|
|
|
*
|
|
|
|
|
* Before compilation takes place, the compile_init function must be
|
|
|
|
|
* called once to set stuff up.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
extern void compile_init(void);
|
|
|
|
|
|
|
|
|
|
extern void compile_cleanup(void);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This function is called by the parser to compile a functor
|
|
|
|
|
* statement. The strings passed in are allocated by the lexor, but
|
|
|
|
|
* this function will free them. (Or save them permanently.) This
|
|
|
|
|
* includes the argv array and the strings it references.
|
|
|
|
|
*
|
|
|
|
|
* The argc and argv are a list of char* that are the port paramters
|
|
|
|
|
* of the functor. The compile should match those port parameters up
|
|
|
|
|
* to existing functors to manage the linking.
|
|
|
|
|
*/
|
2001-03-11 23:42:11 +01:00
|
|
|
extern void compile_functor(char*label, char*type, unsigned init,
|
2001-03-20 07:16:23 +01:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2001-03-11 01:29:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A code statement is a label, an opcode and up to 3 operands. There
|
|
|
|
|
* are a few lexical types that the parser recognizes of the operands,
|
|
|
|
|
* given by the ltype_e enumeration. The compile_code function takes
|
|
|
|
|
* the label, mnemonic and parsed operands and writes a properly
|
|
|
|
|
* formed instruction into the code space. The label is set into the
|
|
|
|
|
* symbol table with the address of the instruction.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define OPERAND_MAX 3
|
2001-03-20 07:16:23 +01:00
|
|
|
enum ltype_e { L_NUMB, L_SYMB };
|
2001-03-11 01:29:38 +01:00
|
|
|
|
|
|
|
|
struct comp_operands_s {
|
|
|
|
|
unsigned argc;
|
|
|
|
|
struct {
|
|
|
|
|
enum ltype_e ltype;
|
|
|
|
|
union {
|
|
|
|
|
unsigned long numb;
|
2001-03-20 07:16:23 +01:00
|
|
|
struct symb_s symb;
|
2001-03-11 01:29:38 +01:00
|
|
|
};
|
|
|
|
|
} argv[OPERAND_MAX];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct comp_operands_s*comp_operands_t;
|
|
|
|
|
|
|
|
|
|
extern void compile_code(char*label, char*mnem, comp_operands_t opa);
|
2001-03-18 05:35:18 +01:00
|
|
|
extern void compile_vpi_call(char*label, char*name,
|
|
|
|
|
unsigned argc, vpiHandle*argv);
|
2001-03-11 01:29:38 +01:00
|
|
|
|
2001-03-18 01:37:55 +01:00
|
|
|
/*
|
|
|
|
|
* The parser uses these functions to compile .scope statements.
|
|
|
|
|
* The implementations of these live in the vpi_scope.cc file.
|
|
|
|
|
*/
|
|
|
|
|
extern void compile_scope_decl(char*lab, char*nam, char*par);
|
|
|
|
|
extern void compile_scope_recall(char*sym);
|
|
|
|
|
|
2001-03-11 01:29:38 +01:00
|
|
|
/*
|
|
|
|
|
* The parser uses this function to declare a thread. The start_sym is
|
|
|
|
|
* the start instruction, and must already be defined.
|
|
|
|
|
*/
|
|
|
|
|
extern void compile_thread(char*start_sym);
|
|
|
|
|
|
|
|
|
|
/*
|
2001-03-20 07:16:23 +01:00
|
|
|
* This function is called to create a var vector with the given name.
|
2001-03-11 01:29:38 +01:00
|
|
|
*/
|
2001-03-20 07:16:23 +01:00
|
|
|
extern void compile_variable(char*label, char*name, int msb, int lsb);
|
2001-03-11 01:29:38 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This is a diagnostic aid. Dump all the compiler tables to the file
|
|
|
|
|
* descriptor in a readable form.
|
|
|
|
|
*/
|
|
|
|
|
extern void compile_dump(FILE*fd);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: compile.h,v $
|
2001-03-20 07:16:23 +01:00
|
|
|
* Revision 1.6 2001/03/20 06:16:24 steve
|
|
|
|
|
* Add support for variable vectors.
|
|
|
|
|
*
|
2001-03-18 05:35:18 +01:00
|
|
|
* Revision 1.5 2001/03/18 04:35:18 steve
|
|
|
|
|
* Add support for string constants to VPI.
|
|
|
|
|
*
|
2001-03-18 01:37:55 +01:00
|
|
|
* Revision 1.4 2001/03/18 00:37:55 steve
|
|
|
|
|
* Add support for vpi scopes.
|
|
|
|
|
*
|
2001-03-16 02:44:34 +01:00
|
|
|
* Revision 1.3 2001/03/16 01:44:34 steve
|
|
|
|
|
* Add structures for VPI support, and all the %vpi_call
|
|
|
|
|
* instruction. Get linking of VPI modules to work.
|
|
|
|
|
*
|
2001-03-11 23:42:11 +01:00
|
|
|
* Revision 1.2 2001/03/11 22:42:11 steve
|
|
|
|
|
* Functor values and propagation.
|
|
|
|
|
*
|
2001-03-11 01:29:38 +01:00
|
|
|
* Revision 1.1 2001/03/11 00:29:38 steve
|
|
|
|
|
* Add the vvp engine to cvs.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#endif
|