/*

  Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.

   Path64 is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   Path64 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 Path64; see the file COPYING.  If not, write to the Free
   Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
   02110-1301, USA.

   Special thanks goes to SGI for their continued support to open source

*/


// isa_operands_gen.h
/////////////////////////////////////
//
//  Interface for specifying operands and results for various
//  instructions in the ISA.
//
//  void ISA_Operands_Begin( const char* archname )
//      Initialize to generate operands information for the architecture 
//      with the given <archname>.  The information will be written to the 
//      files targ_isa_operands.[ch].  
//
//  type OPERAND_VALUE_TYPE
//      An abstract type that describes different types of operands,
//	including results. An operand type can be a register or an
//	immediate or an enumeration.
//
//  type OPERAND_USE_TYPE
//	An abstract type that describes the useage of an operand.
//
//  OPERAND_VALUE_TYPE ISA_Reg_Opnd_Type_Create( 
//			const char* name, 
//			ISA_REGISTER_CLASS register_class, 
//			ISA_REGISTER_SUBCLASS sub_class,
//			int size, 
//			RTYPE type, 
//			REG_ALIAS_TYPE reg_alias,
//			FP_TYPE is_fp_int )
//      Used to create a new OPERAND_VALUE_TYPE.  
//	<name> is the operand_type name.
//
//  OPERAND_VALUE_TYPE ISA_Lit_Opnd_Type_Create( 
//			const char* name, 
//			int size,
//			RTYPE type, 
//			ISA_LIT_CLASS lc )
//      Used to create a new OPERAND_VALUE_TYPE.  
//	<name> is the operand_type name.
//
//  OPERAND_VALUE_TYPE ISA_Enum_Opnd_Type_Create( 
//			const char* name, 
//			int size,
//			RTYPE type, 
//			ISA_ENUM_CLASS ec )
//      Used to create a new OPERAND_VALUE_TYPE.  
//	<name> is the operand_type name.
//
//  OPERAND_USE_TYPE Create_Operand_Use(const char *name)
//	Create a new OPERAND_USE_TYPE. <name> identifies the usage
//	and is used to form enumerated constants of the form OU_<name>.
//
//  void Instruction_Group( const char *name, 
//			    TOP top, ....., TOP_UNDEFINED )
//      Start a list of instructions that have the same operand/result
//	descriptions. The list of TOPs is terminated by TOP_UNDEFINED.
//
//  void Operand (int operand_index, 
//		  OPERAND_VALUE_TYPE operand_type,
//		  [ OPERAND_USE_TYPE operand_use ])
//	The <operand_index>'th operand of the current instruction group
//      is of <operand_type> and usage <operand_use>. If <operand_use>
//	is omitted it defaults to "undefined".
//
//  void Relocatable (int operand_index)
//	The <operand_index>'th operand of the current instruction group
//      is relocatable. Not supported for results, and there can
//	be only one relocatable operand per topcode.
//
//  void Result (int result_index, OPERAND_VALUE_TYPE result_type)
//	The <result_index>'th result of the current instruction group 
// 	is of <result_type>. 
//
//  void ISA_Operands_End(void)
//      Complete processing of operands/results.
//
//
/////////////////////////////////////

//  $Revision$
//  $Date$
//  $Author$
//  $Source$

#ifndef isa_operands_gen_INCLUDED
#define isa_operands_gen_INCLUDED

#ifdef _KEEP_RCS_ID
static const char isa_operands_gen_rcs_id[] = "$Source$ $Revision$";
#endif /* _KEEP_RCS_ID */

#ifdef __cplusplus
extern "C" {
#endif

#include "targ_isa_registers.h"
#include "targ_isa_lits.h"
#include "targ_isa_enums.h"
/* Types:
 */

typedef struct operand_value_type *OPERAND_VALUE_TYPE;

// RTYPE (or the range-description type) is used to annotate a proper
// range value to the concerned OPERAND_VALUE_TYPE.  

typedef enum {PCREL, SIGNED, UNSIGNED, UNKNOWN} RTYPE; 

// FP_TYPE description is used to determine the fp-value in a floating register
// i.e. FP32_INT => 32-bit int value in a fp- register (fixed-point)
// or   FP64_INT => 64-bit int value in a fp- register (fixed-point)
// or   INVALID (which includes the rest of the category)

typedef enum {FP32_INT, FP64_INT, INVALID} FP_TYPE; 

typedef struct operand_use_type *OPERAND_USE_TYPE;

/* External functions 
 */

extern void ISA_Operands_Begin ( const char* archname );
extern OPERAND_VALUE_TYPE ISA_Reg_Opnd_Type_Create ( 
		const char* name, 
	  	ISA_REGISTER_CLASS register_class, 
		ISA_REGISTER_SUBCLASS sub_class,
		int size, 
		RTYPE rtype, 
		FP_TYPE is_fp_int );
extern OPERAND_VALUE_TYPE ISA_Lit_Opnd_Type_Create ( 
		const char* name, 
		int size,
		RTYPE rtype, 
		ISA_LIT_CLASS lc );
extern OPERAND_VALUE_TYPE ISA_Enum_Opnd_Type_Create ( 
		const char* name, 
		int size,
		RTYPE rtype, 
		ISA_ENUM_CLASS ec );
extern OPERAND_USE_TYPE Create_Operand_Use(const char *name);
extern void Instruction_Group ( const char *name, ... );
extern void Operand (int operand_index, 
		     OPERAND_VALUE_TYPE operand_type,
		     OPERAND_USE_TYPE operand_use = 0);
extern void Relocatable (int operand_index);
extern void Result (int result_index, OPERAND_VALUE_TYPE result_type);
extern void ISA_Operands_End(void);

#ifdef __cplusplus
}
#endif
#endif /* isa_operands_gen_INCLUDED */
