[RFC] Encoding of modes in module exports

Jose E. Marchesi jemarch@gnu.org
Mon Nov 3 23:16:12 GMT 2025


Also procs shall be distinguished from operands...

---

load elf;

type ga68_str = offset<Elf_Word,B>;
type ga68_text_reloc = Elf64_Addr;
type ga68_data_reloc = Elf64_Addr;

var GA68_MODE_VOID = 0,
    GA68_MODE_INT = 1,
    GA68_MODE_REAL = 2,
    GA68_MODE_BITS = 3,
    GA68_MODE_BYTES = 4,
    GA68_MODE_CHAR = 5,
    GA68_MODE_CMPL = 6,
    GA68_MODE_ROW = 7,
    GA68_MODE_STRUCT = 8,
    GA68_MODE_UNION = 9,
    GA68_MODE_NAME = 10,
    GA68_MODE_PROC = 11,
    GA68_MODE_OP = 12,
    GA68_MOID = 13;

type ga68_mode =
  struct
  {
    Elf_Word kind;
    union
    {
      struct
      {
        ga68_text_reloc name;
        ga68_data_reloc mode;
      } moid : kind == GA68_MODE_MOID;

      struct
      {
        Elf_Sword sizety;
      } integer : kind == GA68_MODE_INT;

      struct
      {
        Elf_Sword sizety;
      } real : kind == GA68_MODE_REAL;

      struct
      {
        Elf_Sword sizety;
      } bits : kind == GA68_MODE_BITS;

      struct
      {
        Elf_Sword sizety;
      } bits : kind == GA68_MODE_BYTES;

      struct
      {
        Elf_Word flex;
        ga68_data_reloc mode;
      } name : kind == GA68_MODE_NAME;

      struct
      {
        Elf_Word dim;
        struct { ga68_text_reloc lb; ga68_text_reloc ub; Elf64_Off stride; }[dim] triplets;
        ga68_data_reloc row_of;
      } row : kind == GA68_MODE_ROW;

      struct
      {
        Elf_Word nfields;
        struct { ga68_str name; ga68_data_reloc mode }[nfields] fields;
      } sct : kind == GA68_MODE_STRUCT;

      struct
      {
        Elf_Word nmodes;
        ga68_data_reloc[nmodes] modes;
      } uni : kind == GA68_MODE_UNION;

      struct
      {
        ga68_mode ret_mode;
        Elf_Word nargs;
        struct
        {
          ga68_str name; /* For diagnostics.  */
          ga68_mode mode;
        }[nargs] args;
      } routine : kind == GA68_MODE_PROC;

      struct
      {
        ga68_mode ret_mode;
        Elf_Word nops : nops <= 2;
        struct
        {
          ga68_str name; /* For diagnostics.  */
          ga68_mode mode;
        }[nops] ops;
      } routine : kind == GA68_MODE_PROC;

      struct {};
    } data;
  };

type ga68_prio =
  struct
  {
    ga68_str opname;
    Elf_Word prio;
  };

type ga68_decl =
  struct
  {
    ga68_str name;
    ga68_mode mode;
    /* Perhaps also an entry in the symbol table?  Or should we rely
       entirely in implicit mangling?  */
  };

/* The contents of the .ga68_exports section can be mapped as a
   ga68_export[sec.sh_size] */

var GA68_EXPORT_DECL = 0,
    GA68_EXPORT_MODE = 1,
    GA68_EXPORT_PRIO = 2;

type ga68_export =
  struct
  {
    Elf_Word kind : kind in [GA68_EXPORT_DECL, GA68_EXPORT_MODE, GA68_EXPORT_PRIO];
    Elf64_Off size;
    union
    {
      ga68_decl decl : kind == GA68_EXPORT_DECL;
      ga68_mode mode : kind == GA68_EXPORT_MODE;
      ga68_prio prio : kind == GA68_EXPORT_PRIO;
    } export : export'size == size;
  };


More information about the Algol68 mailing list