PageRenderTime 404ms CodeModel.GetById 222ms app.highlight 7ms RepoModel.GetById 174ms app.codeStats 0ms

/opengles/src/codegen/emit.h

http://ftk.googlecode.com/
C++ Header | 135 lines | 59 code | 29 blank | 47 comment | 1 complexity | 5514941af8e5898df4d7d77d5d14cac7 MD5 | raw file
  1#ifndef CODEGEN_EMIT_H
  2#define CODEGEN_EMIT_H 1
  3
  4/****************************************************************************/
  5/*																			*/
  6/* Copyright (c) 2004, Hans-Martin Will. All rights reserved.				*/
  7/*																			*/
  8/* Redistribution and use in source and binary forms, with or without		*/
  9/* modification, are permitted provided that the following conditions are   */
 10/* met:																		*/
 11/*																			*/
 12/* *  Redistributions of source code must retain the above copyright		*/
 13/*    notice, this list of conditions and the following disclaimer.			*/
 14/*																			*/
 15/* *  Redistributions in binary form must reproduce the above copyright		*/
 16/*    notice, this list of conditions and the following disclaimer in the   */
 17/*    documentation and/or other materials provided with the distribution.  */
 18/*																			*/
 19/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS		*/
 20/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT		*/
 21/* LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A   */
 22/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER */
 23/* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
 24/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,		*/
 25/* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR		*/
 26/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   */
 27/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING		*/
 28/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS		*/
 29/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.				*/
 30/*																			*/
 31/****************************************************************************/
 32
 33
 34#include "codegen.h"
 35#include "instruction.h"
 36#include "heap.h"
 37#include "segment.h"
 38
 39
 40#ifdef __cplusplus
 41extern "C" {
 42#endif
 43
 44
 45/****************************************************************************/
 46/* Symbolic labels															*/
 47/****************************************************************************/
 48
 49#if defined(__GCC32__) && defined(__cplusplus)
 50struct cg_label_t;
 51struct cg_codegen_t;
 52#else
 53typedef struct cg_label_t cg_label_t;
 54typedef struct cg_codegen_t cg_codegen_t;
 55#endif
 56
 57typedef enum 
 58{
 59	cg_reference_offset12,					/* LDR relative from code		*/
 60	cg_reference_branch24,					/* branch relative from code	*/
 61	cg_reference_absolute32,				/* absolute 32-bit address		*/
 62} 
 63cg_reference_type_t;
 64
 65
 66/****************************************************************************/
 67/* Runtime function pointers												*/
 68/* Accidentially, these methods signatures co-incide with the mathematical  */
 69/* functions defined in the Intel GPP...									*/
 70/****************************************************************************/
 71
 72
 73typedef struct cg_runtime_info_t
 74{
 75	div_t (*div)				(I32 numer, I32 denom);	/* Std. C runtime	*/
 76
 77	I32 (*div_HP_16_32s)		(I32 num, I32 denom);
 78	I32 (*inv_HP_16_32s)		(I32 src);
 79	I32 (*sqrt_HP_16_32s)		(I32 src);
 80	I32 (*inv_sqrt_HP_16_32s)	(I32 src);
 81
 82	I32 (*div_LP_16_32s)		(I32 num, I32 denom);
 83	I32 (*inv_LP_16_32s)		(I32 src);
 84	I32 (*sqrt_LP_16_32s)		(I32 src);
 85	I32 (*inv_sqrt_LP_16_32s)	(I32 src);
 86
 87	/*
 88	void (*sin_LP_16_32s)		(I32 theta, I32* sin_theta);
 89	void (*cos_LP_16_32s)		(I32 theta, I32* cos_theta);
 90	void (*sin_cos_LP_16_32s)	(I32 theta, I32* sin_theta, I32* cos_theta);
 91	void (*sin_HP_16_32s)		(I32 theta, I32* sin_theta);
 92	void (*cos_HP_16_32s)		(I32 theta, I32* cos_theta);
 93	void (*sin_cos_HP_16_32s)	(I32 theta, I32* sin_theta, I32* cos_theta);
 94	*/
 95}
 96cg_runtime_info_t;
 97
 98
 99typedef struct cg_processor_info_t 
100{
101	int		useV5;				/* can use instructions from V5 arch.		*/
102}
103cg_processor_info_t;
104
105/****************************************************************************/
106/* Code generator															*/
107/****************************************************************************/
108
109cg_codegen_t * cg_codegen_create(cg_heap_t * heap, cg_runtime_info_t * runtime,
110								 cg_processor_info_t * processor);
111
112void cg_codegen_destroy(cg_codegen_t * gen);
113
114void cg_codegen_emit_module(cg_codegen_t * gen, cg_module_t * module);
115void cg_codegen_emit_proc(cg_codegen_t * gen, cg_proc_t * proc);
116void cg_codegen_emit_block(cg_codegen_t * gen, cg_block_t * block, int reinit);
117void cg_codegen_emit_inst(cg_codegen_t * gen, cg_inst_t * inst);
118
119size_t cg_codegen_emit_literal(cg_codegen_t * gen, U32 literal, int distinct);
120
121void cg_codegen_fix_refs(cg_codegen_t * gen);
122
123cg_label_t * cg_codegen_create_label(cg_codegen_t * gen);
124
125void cg_codegen_define(cg_codegen_t * gen, cg_label_t * label);
126void cg_codegen_reference(cg_codegen_t * gen, cg_label_t * label, 
127						  cg_reference_type_t ref_type);
128
129cg_segment_t * cg_codegen_segment(cg_codegen_t * gen);
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif //ndef CODEGEN_EMIT_H