Jump to content

Introspector/GccCpp/rtl.h

From Wikibooks, open books for an open world

here is my start


#ifndef RTX_H
#define RTX_H

// we dont have this fully defined yet, rtx_code
class TRefrtx_code : public TRef<int>
{
 public:
  TREECONSTRUCTOR(TRefrtx_code)
    
    operator int();
  TRefrtx_code & operator =  (TRefrtx_code &);
  //  TRefrtx_code & operator =  (rtx_code );
  //  TRefrtx_code & operator ==  (rtx_code );
  //  TRefrtx_code & operator ==  (int );
};


class rtvec_def;
//typedef struct rtvec_def *rtvec;
//union tree_node;

class rtx;
class rtvec;
class mem_attrs;
class reg_attrs;

class addr_diff_vec_flags
{
 public:
  /* Set at the start of shorten_branches - ONLY WHEN OPTIMIZING - : */
  BitRef2  min_align;
  /* Flags: */
  BitRef2  base_after_vec; /* BASE is after the ADDR_DIFF_VEC.  */
  BitRef2  min_after_vec;  /* minimum address target label is
				 after the ADDR_DIFF_VEC.  */
  BitRef2  max_after_vec;  /* maximum address target label is
				 after the ADDR_DIFF_VEC.  */
  BitRef2  min_after_base; /* minimum address target label is
				 after BASE.  */
  BitRef2  max_after_base; /* maximum address target label is
				 after BASE.  */
  /* Set by the actual branch shortening process - ONLY WHEN OPTIMIZING - : */
  BitRef2  offset_unsigned; /* offsets have to be treated as unsigned.  */
 
  BitRef scale;
};


class rtunion_base
{
 public:
  mystring rtstr;
  TRef<int> rtint;  
  TRef<unsigned int> rtuint;
  TRef<rtx> m_rtx;
  TPtr<rtvec> m_rtvec;
  TRefmachine_mode rttype;
  addr_diff_vec_flags rt_addr_diff_vec_flags;
  cselib_val_struct *rt_cselib;
  bitmap_head_def *rtbit;
  tree rttree;
  basic_block_def *bb;
  mem_attrs *rtmem;
  reg_attrs *rtreg;
};
//typedef union rtunion_def rtunion;

class rtx_u {
 public:
  rtunion_base fld[1];
  HOST_WIDE_INT hwint[1];
} ;


class rtx_insides
{
 public:

  TRefmachine_mode mode;
  TRefrtx_code code;



  /* 1 in a MEM if we should keep the alias set for this mem unchanged
     when we access a component.
     1 in a CALL_INSN if it is a sibling call.
     1 in a SET that is for a return.
     In a CODE_LABEL, part of the two-bit alternate entry field.  */
  BitRef2 jump ;
  /* In a CODE_LABEL, part of the two-bit alternate entry field.
     1 in a MEM if it cannot trap.  */
  BitRef2  call ;
  /* 1 in a REG, MEM, or CONCAT if the value is set at most once, anywhere.
     1 in a SUBREG if it references an unsigned object whose mode has been
     from a promoted to a wider mode.
     1 in a SYMBOL_REF if it addresses something in the per-function
     constants pool.
     1 in a CALL_INSN, NOTE, or EXPR_LIST for a const or pure call.
     1 in a JUMP_INSN, CALL_INSN, or INSN of an annulling branch.  */
  BitRef2   unchanging ;
  /* 1 in a MEM or ASM_OPERANDS expression if the memory reference is volatile.
     1 in an INSN, CALL_INSN, JUMP_INSN, CODE_LABEL, BARRIER, or NOTE
     if it has been deleted.
     1 in a REG expression if corresponds to a variable declared by the user,
     0 for an internally generated temporary.
     1 in a SUBREG with a negative value.
     1 in a LABEL_REF or in a REG_LABEL note for a non-local label.
     In a SYMBOL_REF, this flag is used for machine-specific purposes.  */
  BitRef2  volatil ;
  /* 1 in a MEM referring to a field of an aggregate.
     0 if the MEM was a variable or the result of a * operator in C;
     1 if it was the result of a . or -> operator (on a struct) in C.
     1 in a REG if the register is used only in exit code a loop.
     1 in a SUBREG expression if was generated from a variable with a
     promoted mode.
     1 in a CODE_LABEL if the label is used for nonlocal gotos
     and must not be deleted even if its count is zero.
     1 in a LABEL_REF if this is a reference to a label outside the
     current loop.
     1 in an INSN, JUMP_INSN or CALL_INSN if this insn must be scheduled
     together with the preceding insn.  Valid only within sched.
     1 in an INSN, JUMP_INSN, or CALL_INSN if insn is in a delay slot and
     from the target of a branch.  Valid from reorg until end of compilation;
     cleared before used.
     1 in an INSN, JUMP_INSN or CALL_INSN or related rtx if this insn is
     dead code.  Valid only during dead-code elimination phase; cleared
     before use.  */
  BitRef2   in_struct ;
  /* At the end of RTL generation, 1 if this rtx is used.  This is used for
     copying shared structure.  See `unshare_all_rtl'.
     In a REG, this is not needed for that purpose, and used instead
     in `leaf_renumber_regs_insn'.
     1 in a SYMBOL_REF, means that emit_library_call
     has used it as the function.  */
  BitRef2   used ;
  /* Nonzero if this rtx came from procedure integration.
     1 in a REG or PARALLEL means this rtx refers to the return value
     of the current function.
     1 in a SYMBOL_REF if the symbol is weak.  */
  BitRef2   integrated ;
  /* 1 in an INSN or a SET if this rtx is related to the call frame,
     either changing how we compute the frame address or saving and
     restoring registers in the prologue and epilogue.
     1 in a MEM if the MEM refers to a scalar, rather than a member of
     an aggregate.
     1 in a REG if the register is a pointer.
     1 in a SYMBOL_REF if it addresses something in the per-function
     constant string pool.  */
  BitRef2   frame_related ;


  rtx_u u;
};



class rtx
{

 public:
  rtx();
  rtx(const rtx & );
  rtx(rtx &);
  rtx(rtx *);
  rtx(int);
  operator bool();
  operator void*();
  rtx_insides * operator -> ();
};

class rtvec
{
 public:
  rtvec(int);
  operator bool();

  int num_elem;		/* number of elements */
  rtx elem[1];

};
#endif