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


\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}

\begin{algorithm}
\caption{BuildLongImmediates (*Move)}
\begin{algorithmic}[1]
%
\STATE /* compute number of slots needed for this move */
\STATE $imm\_size = ImmediateLength(move)$
\FORALL{mbus}
	\IF{mbus is an immediate bus}
		\STATE $nr\_slots++$
		\STATE $immsize -= m->slotsize$
	\ENDIF
	\IF{$immsize < 0$}
		\STATE break
	\ENDIF
\ENDFOR

\STATE /* make result move */
\STATE define new $r\_move$ and new $r\_insn$
\STATE /* for the new r\_move */
\STATE $src = MIN\_IMM\_REG$
\STATE $dst = original dst$
\STATE $immval = original src$
\STATE {\boldmath immval = original src}
\STATE immval = original src
\STATE Set {\sc$IMMEDIATE\_RESULT$} flag
\STATE $guard = original guard$
\STATE $next\_imm\_move = NULL$
\STATE /* for the new r\_insn */
\STATE $blck = original blck$
\STATE $move += new\_r\_move$
\STATE insert new $r\_insn$ before current insn in current blck

\end{algorithmic}
\end{algorithm}
