This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[fixed-point] Patch to support fixed-point constants


Hello,

  Here is the patch to support fixed-point constants.  Constant folding
has not been updated for fixed-point values.  Thanks!

Regards,
Chao-ying

Ex: (qc.c)
short _Fract f0 = 0.9999999hr;
_Fract f1 = 0.99999999999r;
long _Fract f2 = 0.99999999999999999999999lr;
long long _Fract f3 = 0.999999999999999999999999999999999999999llr;

unsigned short _Fract uf0 = 0.9999999uhr;
unsigned _Fract uf1 = 0.99999999999ur;
unsigned long _Fract uf2 = 0.99999999999999999999999ulr;
unsigned long long _Fract uf3 = 0.999999999999999999999999999999999999999ullr;

short _Accum a0 = 0.9999999hk;
_Accum a1 = 0.99999999999k;
long _Accum a2 = 0.99999999999999999999999lk;
long long _Accum a3 = 0.999999999999999999999999999999999999999llk;

unsigned short _Accum ua0 = 0.9999999uhk;
unsigned _Accum ua1 = 0.99999999999uk;
unsigned long _Accum ua2 = 0.99999999999999999999999ulk;
unsigned long long _Accum ua3 = 0.999999999999999999999999999999999999999ullk;
--------------------------------------
	.file	1 "qc.c"
	.section .mdebug.eabi64
	.section .gcc_compiled_long64
	.previous
	.globl	f0
	.section	.sdata,"aw",@progbits
	.align	1
	.type	f0, @object
	.size	f0, 2
f0:
	.half	32767
	.globl	f1
	.align	2
	.type	f1, @object
	.size	f1, 4
f1:
	.word	2147483647
	.globl	f2
	.align	3
	.type	f2, @object
	.size	f2, 8
f2:
	.dword	9223372036854775807
	.globl	f3
	.data
	.align	3
	.type	f3, @object
	.size	f3, 16
f3:
	.dword	9223372036854775807
	.dword	0xffffffffffffffff
	.globl	uf0
	.section	.sdata
	.align	1
	.type	uf0, @object
	.size	uf0, 2
uf0:
	.half	65535
	.globl	uf1
	.align	2
	.type	uf1, @object
	.size	uf1, 4
uf1:
	.word	4294967295
	.globl	uf2
	.align	3
	.type	uf2, @object
	.size	uf2, 8
uf2:
	.dword	0xffffffffffffffff
	.globl	uf3
	.data
	.align	3
	.type	uf3, @object
	.size	uf3, 16
uf3:
	.dword	0xffffffffffffffff
	.dword	0xffffffffffffffff
	.globl	a0
	.section	.sdata
	.align	2
	.type	a0, @object
	.size	a0, 4
a0:
	.word	32767
	.globl	a1
	.align	3
	.type	a1, @object
	.size	a1, 8
a1:
	.dword	2147483647
	.globl	a2
	.data
	.align	3
	.type	a2, @object
	.size	a2, 16
a2:
	.dword	0
	.dword	9223372036854775807
	.globl	a3
	.align	3
	.type	a3, @object
	.size	a3, 16
a3:
	.dword	0
	.dword	9223372036854775807
	.globl	ua0
	.section	.sdata
	.align	2
	.type	ua0, @object
	.size	ua0, 4
ua0:
	.word	65535
	.globl	ua1
	.align	3
	.type	ua1, @object
	.size	ua1, 8
ua1:
	.dword	4294967295
	.globl	ua2
	.data
	.align	3
	.type	ua2, @object
	.size	ua2, 16
ua2:
	.dword	0
	.dword	0xffffffffffffffff
	.globl	ua3
	.align	3
	.type	ua3, @object
	.size	ua3, 16
ua3:
	.dword	0
	.dword	0xffffffffffffffff
	.ident	"GCC: (GNU) 4.3.0 20061031 (experimental)"
--------------------------------------

gcc/libcpp/ChangeLog
2006-11-14  Chao-ying Fu  <fu@mips.com>

	* include/cpplib.h (CPP_N_SMALL, CPP_N_MEDIUM, CPP_N_LARGE): Change
	comments to support fixed-point values.
	(CPP_N_FRACT, CPP_N_ACCUM): Define.

	* expr.c (interpret_float_suffix): Support hr, r, lr, llr, uhr, ur,
	ulr, ullr, hk, k, lk, llk, uhk, uk, ulk, ullk.

gcc/gcc/ChangeLog
2006-11-14  Chao-ying Fu  <fu@mips.com>

	* c-lex.c (interpret_fixed): Declare.
	(interpret_float): Process _Fract and _Accum.
	(interpret_fixed): New function.

	* tree.h (TREE_FIXED_CST_PTR, TREE_FIXED_CST): Define.
	(struct tree_fixed_cst): New.
	(tree_node): Add fixed_cst.

	* tree.def (FIXED_CST): New constant.

	* tree.c (fixed_value.h): New include.
	(tree_code_size): Support FIXED_CST.
	(build_fixed): New function.
	(tree_node_structure): Support FIXED_CST.
	(simple_cst_equal): Likewise.
	(walk_tree): Likewise.

	* final.c (output_addr_const): Process CONST_FIXED.

	* tree-gimple.c (is_gimple_formal_tmp_rhs): Process FIXED_CST.
	(is_gimple_min_invariant): Likewise.

	* rtl.h (fixed_value.h): New include.
	(rtx_def): Add a new field of fixed_value to u.
	(XCNMPFV): Define for accessing fixed_value.
	(CONST_FIXED_VALUE, CONST_FIXED_VALUE_HIGH, CONST_FIXED_VALUE_LOW):
	Define.
	
	* rtl.def (CONST_FIXED): New constant.

	* expr.c (expand_expr_real_1): Process FIXED_CST.

	* treestruct.def: Add TS_FIXED_CST.

	* gimplify.c (gimplify_expr): Process FIXED_CST.

	* emit-rtl.c (const_fixed_htab): New hash table.
	(const_fixed_htab_hash, const_fixed_htab_eq, lookup_const_fixed):
	Declare.
	(const_fixed_htab_hash, const_fixed_htab_eq, lookup_const_fixed,
	const_fixed_from_fixed_value): New functions.
	(init_emit_once): Create const_fixed_htab.

	* simplify-rtx.c (simplify_immed_subreg): Support CONST_FIXED.
	Process MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM.
	(simplify_subreg): Support CONST_FIXED.

	* varasm.c (assemble_integer): Extend to support fixed-point constants
	by using different machine classes.
	(const_rtx_hash_1): Support CONST_FIXED.
	(output_constant_pool_2): Process MODE_FRACT, MODE_UFRACT, MODE_ACCUM,
	MODE_UACCUM, MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM,
	MODE_VECTOR_UACCUM.
	(initializer_constant_valid_p): Support FIXED_CST.
	(output_constant): Support FIXED_POINT_TYPE.

	* Makefile.in (OBJS-common): Add fixed_value.o.
	(fixed_value.o): New rule to build it.
	(GTFILES): Add fixed_value.h.

	* fixed_value.h, fixed_value.c: New files.

Attachment: gcc.diff
Description: gcc.diff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]