This is the mail archive of the
mailing list for the GCC project.
GCC, OOP, and GC...
- From: <aspiesrule at mcleodusa dot net>
- To: <gcc at gcc dot gnu dot org>
- Date: Sun, 25 Jan 2004 17:55:19 -0000
- Subject: GCC, OOP, and GC...
GCC source is _very_ hard to read at times (too many macros, huge
conditionals (example from gcc/cp/rtti.c (comments have been stripped):
if (TREE_CODE (t) == VAR_DECL && IDENTIFIER_GLOBAL_VALUE (DECL_NAME (t)) ==
t && TREE_TYPE (DECL_NAME (t)) && TREE_CODE (TREE_TYPE (t)) == RECORD_TYPE
&& TYPE_FIELDS (TREE_TYPE (t)) && TREE_TYPE (TYPE_FIELDS (TREE_TYPE (t))) ==
and another example: (this one is from flow.c)
if (GET_CODE (insn) == CODE_LABEL && LABEL_NUSES (insn) == LABEL_PRESERVE_P
(insn) && GET_CODE (next) == JUMP_INSN && GET_CODE (PATTERN (next)) ==
ADDR_VEC || GET_CODE (PATTERN (next)) == ADDR_DIF_VEC))
and yet another example: (this one is from loop.c)
if (loop_info->has_call && regs->array[regno].single_usage != 0 && regs-
>array[regno].single_usage != const0_rtx && REGNO_FIRST_UID (regno) ==
INSN_UID (p) && (REGNO_LAST_UID (regno) == INSN_UID (regs->array
[regno].single_usage)) && regs->array[regno].set_in_loop == 1 && GET_CODE
(SET_SRC (set)) != ASM_OPERANDS && ! side_effects_p (SET_SRC (set)) && !
find_reg_note (p, REG_RETVAL, NULL_RTX) && (! SMALL_REGISTER_CLASSES || (!
(GET_CODE (SET_SRC (set)) == REG && (REGNO (SET_SRC (set))
), ifdef's in strange places (middle of if-test, anyone) (example is also
if (! in_libcall && (set = single_set (p)) && GET_CODE (SET_DEST (set)) ==
&& SET_DEST (set) != pic_offset_table_rtx
&& ! regs->array[REGNO (SET_DEST (set))].may_not_optimize)
, ...). For those who think I am just ranting, ask yourself, "Could this
code be maintained by someone 10 years down the road?" This is why, for GCC
4.x, a change to OOP would be a _very_ good idea. With OOP, we could move
most (if not all) of the RTL and tree tests into accessor methods, as well
as keeping internal details hidden from the GCC code base at-large, which
would allow us to change RTL structures without having to touch all of the
code that uses or manipulates RTL, for example. The same idea holds for
trees, too. Using OOP also means we can create "smart reference" classes
that can ease the burden placed on the garbage collector. This is why this
change would be a good idea.