\chapter{Long immediate related data structures}
\label{app:limm-datastructures}

This appendix contains excerpts of some scheduler data classes, with
emphasis on the new long immediate format.


\paragraph{LImmMOp}
{\small
\begin{verbatim}
class LImmMOp : public ListItem {
    friend Mach;

public:
    LImmMOp(const LImmMOp&);
    LImmMOp(unsigned, int, int);
    unsigned Slots()          const { return slots; };
    void SetSlots(unsigned s)       { slots = s; };
    int Bits()                const { return nbits; };
    int Encoding()            const { return enc; };
private:
    const int nbits;
    unsigned slots;
    const int enc;
};
\end{verbatim}}%\small

\paragraph{LImmControl}
{\small\begin{verbatim}
class LImmControl : public ListItem {
    friend int yyparse();
    friend Mach;

public:
    unsigned  Slots()                   const { return slots; };
    void SetSlots(unsigned s)                 { slots = s; };
    const LImmMOpList& GetMOpList()     const { return microops; };
    void CheckContents();

private:
    LImmControl(LImmMOpList& list);
    LImmMOpList microops;
    unsigned slots;
};
\end{verbatim}}%\small

\paragraph{Mach}
{\small\begin{verbatim}
class Mach {
...
    const LImmControl* Mach::GetDefaultEncoding();
    const LImmControl& GetLImmControl(int index);
    int NumLImmOperations()	{ return icontrol.Count(); };
...
}
\end{verbatim}}%\small

\paragraph{IReg}
{\small\begin{verbatim}
class IReg: public ListItem, public Mark
{
...
public:
    LImmMOpIter PossibleEncoding(int size);
    LImmMOpIter GetMOp()        { return mops; };
    LImmMOpList mops;
...
}
\end{verbatim}}%\small

\paragraph{Insn}
{\small\begin{verbatim}
class Insn: public ListItem, public FlagSet, public Mark
{
...
public:
    const LImmControl* ImmControlOp() { return immctrl; };
    void SetImmControlOp(const LImmControl* newimm) { immctrl=newimm;};
private:
    const LImmControl* immctrl;
...
}
\end{verbatim}}%\small


\paragraph{RTabEntry}
{\small\begin{verbatim}
class RTabEntry: public Mark
{
public:
  int IsFree(IReg *ireg, int val)
  { 
    int idx = ireg->Index();
    return ireg_busy[idx] == 0 || ireg_val[idx] == val;
  }
  int IsBusy(IReg *ireg)
  {
    int idx = ireg->Index();
    return ireg_busy[idx];
  }
  int IsBusy(IReg *ireg, int val)
  {
    return !IsFree(ireg, val);
  }
  void Claim(IReg *ireg, int val)
  {
    int idx = ireg->Index();

    ireg_busy[idx]++;
    ireg_val[idx] = val;
  }
  void Release(IReg *ireg)
  {
    ireg_busy[ireg->Index()]--;
  }
  long IRegVal(IReg* ireg) const
  {
      return ireg_val[ireg->Index()];
  }
private:
  char ireg_busy[MAX_N_IMMEDIATE_REGISTERS];
  long ireg_val[MAX_N_IMMEDIATE_REGISTERS];
  
private:
  const LImmControl* immctrl;    
public:
  const LImmControl* ImmControlOp() { return immctrl; };
  void SetImmControlOp(const LImmControl* newimm) { immctrl=newimm; };

\end{verbatim}}%\small




%\chapter{Long immediate algorithms}
%\label{app:limm-alg}
% it seems these are all in the body texts already, no need for an
% appendix

