This is the mail archive of the gcc@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]

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):

--snip--
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))) == 
ti_desc_type_node)
--end snip--

and another example: (this one is from flow.c)

--snip--
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))
--end snip--

and yet another example: (this one is from loop.c)

--snip--
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))
--end snip--

), ifdef's in strange places (middle of if-test, anyone) (example is also 
from loop.c)

--snip--
if (! in_libcall && (set = single_set (p)) && GET_CODE (SET_DEST (set)) == 
REG
#ifdef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
 && SET_DEST (set) != pic_offset_table_rtx
#endif
 && ! regs->array[REGNO (SET_DEST (set))].may_not_optimize)
--end snip--

, ...).  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.

Lucas


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