PMVtmpltcstmat not declared

26 views
Skip to first unread message

David Smith

unread,
May 20, 2021, 7:15:32 PM5/20/21
to ats-lang-users

Hey, I'm trying to write some code for a GBA game using ATS, meaning I plan on not using the prelude.

In my code (at the end), I'm trying to just loop over every pixel on the screen and set it to white, however it fails to compile due to PMVtmpltcstmat not being defined, leading to a whole chain of errors.

How do I circumvent/avoid this problem, preferably without falling back to using the prelude?

Thanks in advance!


extern fun
m3_write_screen(pos: size_t, col: usint) : void = "mac#"

implement
main0() =
  let
    fun
    loop{x,y:nat | x <= y} .<y-x>.
      (pos: int(x), max: int(y)) : void =
        if pos < max
        then
          (
            // m3_write_screen($UN.cast2size(pos), $UN.cast2usint(0xffff));
            loop(pos + 1, max)
          )
  in
    (
      set_screen_mode($UN.cast2usint(0x403));
      loop(0, 240 * 160)
    )
  end

Dambaev Alexander

unread,
May 20, 2021, 8:51:57 PM5/20/21
to ats-lan...@googlegroups.com
Hi,
try to place 
```
#include "share/atspre_staload.hats"
```
at the top of of your module

David Smith

unread,
May 21, 2021, 7:01:59 AM5/21/21
to ats-lang-users

When I do that I get a couple of warnings and then an error at link time, due to me not using the prelude (-D_ATS_CCOMP_PRELUDE_NONE_).

Here's the output:

In file included from DATS/hello_dats.c:15:
DATS/hello_dats.c: In function 'mainats_0_void':
DATS/hello_dats.c:254:19: warning: implicit declaration of function 'atspre_g1int_mul_int' [-Wimplicit-function-declaration]
  254 | ATSINSmove(tmp11, atspre_g1int_mul_int(ATSPMVi0nt(240), ATSPMVi0nt(160))) ;
      |                   ^~~~~~~~~~~~~~~~~~~~
/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c: In function 'loop_1':
DATS/hello_dats.c:312:18: warning: implicit declaration of function 'atspre_g0int_mod_int' [-Wimplicit-function-declaration]
  312 | ATSINSmove(tmp8, atspre_g0int_mod_int(arg0, ATSPMVi0nt(0x8000))) ;
      |                  ^~~~~~~~~~~~~~~~~~~~
/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:322:18: warning: implicit declaration of function 'atspre_g1int_add_int' [-Wimplicit-function-declaration]
  322 | ATSINSmove(tmp9, atspre_g1int_add_int(arg0, ATSPMVi0nt(1))) ;
      |                  ^~~~~~~~~~~~~~~~~~~~
/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c: In function 'ATSLIB_056_prelude__lt_g1int_int__2__1':
DATS/hello_dats.c:418:21: warning: implicit declaration of function 'atspre_g1int2int_int_int' [-Wimplicit-function-declaration]
  418 | ATSINSmove(tmp4__1, atspre_g1int2int_int_int(arg1)) ;
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:423:24: warning: implicit declaration of function 'atspre_g1int_lt_int' [-Wimplicit-function-declaration]
  423 | ATSINSmove(tmpret3__1, atspre_g1int_lt_int(arg0, tmp4__1)) ;
      |                        ^~~~~~~~~~~~~~~~~~~
/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
arm-none-eabi-gcc -o out.elf asm/crt0.o DATS/hello_dats.o -Tgba.lds -nostartfiles
/nix/store/xzgbmyz4qdfycbk88mmdszk86w5z9qar-gcc-arm-embedded-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: DATS/hello_dats.o: in function `mainats_0_void':
hello_dats.c:(.text+0x18): undefined reference to `atspre_g1int_mul_int'
/nix/store/xzgbmyz4qdfycbk88mmdszk86w5z9qar-gcc-arm-embedded-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: hello_dats.c:(.text+0x34): undefined reference to `atspre_g0int_mod_int'
/nix/store/xzgbmyz4qdfycbk88mmdszk86w5z9qar-gcc-arm-embedded-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: hello_dats.c:(.text+0x50): undefined reference to `atspre_g1int_add_int'
/nix/store/xzgbmyz4qdfycbk88mmdszk86w5z9qar-gcc-arm-embedded-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: hello_dats.c:(.text+0x5c): undefined reference to `atspre_g1int2int_int_int'
/nix/store/xzgbmyz4qdfycbk88mmdszk86w5z9qar-gcc-arm-embedded-10-2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: hello_dats.c:(.text+0x68): undefined reference to `atspre_g1int_lt_int'
collect2: error: ld returned 1 exit status
make: *** [Makefile:31: hello.gba] Error 1

Dambaev Alexander

unread,
May 21, 2021, 8:57:29 AM5/21/21
to ats-lan...@googlegroups.com
Can you share the original error message as well?

ATS's prelude heavy relies on templates, so I guess you sign yourself to a pain by disabling prelude. For example, you can check how arithmetic operators are being defined by issuing 
```
find <path_to_ats_prelude> -name '*.sats' -exec grep -s -H "overload +" {} \; | less
```

just as an example:
integer.sats contains:
```
typedef
g1int_add_type
  (tk:tk) =
  {i,j:int}
(
  g1int(tk, i)
, g1int(tk, j)
) -<fun0> g1int(tk, i+j)
//
fun
{tk:tk}
g1int_add : g1int_add_type(tk)
//

overload + with g1int_add of 20
```

so g1int_add is a template function and you are missing implementation of this function

David Smith

unread,
May 21, 2021, 9:48:52 AM5/21/21
to ats-lang-users
Yeah, I figured it was something like that.

I'll try to play around with HX's makefile, thanks for the link!

Here is the original error:

In file included from DATS/hello_dats.c:36:
/usr/lib/ats2-postiats-0.4.2/prelude/CATS/char.cats: In function 'atspre_isascii_int':
/usr/lib/ats2-postiats-0.4.2/prelude/CATS/char.cats:377:11: warning: implicit declaration of function 'isascii' [-Wimplicit-function-declaration]
  377 |   return (isascii(c) ? atsbool_true : atsbool_false) ;
      |           ^~~~~~~

In file included from DATS/hello_dats.c:15:
DATS/hello_dats.c: In function 'mainats_0_void':
DATS/hello_dats.c:206:18: error: 'PMVtmpltcstmat' undeclared (first use in this function)
  206 | ATSINSmove(tmp9, PMVtmpltcstmat[0](g1int_mul<S2Eextkind(atstype_int)>)(ATSPMVintrep(240), ATSPMVintrep(160))) ;
      |                  ^~~~~~~~~~~~~~

/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:206:18: note: each undeclared identifier is reported only once for each function it appears in
  206 | ATSINSmove(tmp9, PMVtmpltcstmat[0](g1int_mul<S2Eextkind(atstype_int)>)(ATSPMVintrep(240), ATSPMVintrep(160))) ;
      |                  ^~~~~~~~~~~~~~

/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:206:36: error: 'g1int_mul' undeclared (first use in this function)
  206 | SINSmove(tmp9, PMVtmpltcstmat[0](g1int_mul<S2Eextkind(atstype_int)>)(ATSPMVintrep(240), ATSPMVintrep(160))) ;
      |                                  ^~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:206:46: warning: implicit declaration of function 'S2Eextkind' [-Wimplicit-function-declaration]
  206 | mp9, PMVtmpltcstmat[0](g1int_mul<S2Eextkind(atstype_int)>)(ATSPMVintrep(240), ATSPMVintrep(160))) ;
      |                                  ^~~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:206:57: error: expected expression before 'atstype_int'
  206 | ltcstmat[0](g1int_mul<S2Eextkind(atstype_int)>)(ATSPMVintrep(240), ATSPMVintrep(160))) ;
      |                                  ^~~~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:206:70: error: expected expression before ')' token
  206 | 1int_mul<S2Eextkind(atstype_int)>)(ATSPMVintrep(240), ATSPMVintrep(160))) ;
      |                                  ^


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c: In function 'fill_screen_2':
DATS/hello_dats.c:290:18: error: 'PMVtmpltcstmat' undeclared (first use in this function)
  290 | ATSINSmove(tmp3, PMVtmpltcstmat[0](lt_g1int_int<S2Eextkind(atstype_int)>)(arg0, arg1)) ;
      |                  ^~~~~~~~~~~~~~

/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:290:36: error: 'lt_g1int_int' undeclared (first use in this function)
  290 | SINSmove(tmp3, PMVtmpltcstmat[0](lt_g1int_in <S2Eextkind(atstype_int)>)(arg0, arg1)) ;
      |                                  ^~~~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:290:60: error: expected expression before 'atstype_int'
  290 | stmat[0](lt_g1int_int<S2Eextkind(atstype_int)>)(arg0, arg1)) ;
      |                                  ^~~~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:290:73: error: expected expression before ')' token
  290 | 1int_int<S2Eextkind(atstype_int)>)(arg0, arg1)) ;
      |                                  ^


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:301:36: error: 'g0int_mod' undeclared (first use in this function)
  301 | SINSmove(tmp5, PMVtmpltcstmat[0](g0int_mod<S2Eextkind(atstype_int)>)(arg0, ATSPMVi0nt(0x8000))) ;
      |                                  ^~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:301:57: error: expected expression before 'atstype_int'
  301 | ltcstmat[0](g0int_mod<S2Eextkind(atstype_int)>)(arg0, ATSPMVi0nt(0x8000))) ;
      |                                  ^~~~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:301:70: error: expected expression before ')' token
  301 | 0int_mod<S2Eextkind(atstype_int)>)(arg0, ATSPMVi0nt(0x8000))) ;
      |                                  ^


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:311:36: error: 'g1int_add' undeclared (first use in this function)
  311 | SINSmove(tmp6, PMVtmpltcstmat[0](g1int_add<S2Eextkind(atstype_int)>)(arg0, ATSPMVi0nt(1))) ;
      |                                  ^~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:311:57: error: expected expression before 'atstype_int'
  311 | ltcstmat[0](g1int_add<S2Eextkind(atstype_int)>)(arg0, ATSPMVi0nt(1))) ;
      |                                  ^~~~~~~~~~~


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
DATS/hello_dats.c:311:70: error: expected expression before ')' token
  311 | 1int_add<S2Eextkind(atstype_int)>)(arg0, ATSPMVi0nt(1))) ;
      |                                  ^


/usr/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro 'ATSINSmove'
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
make: *** [<builtin>: DATS/hello_dats.o] Error 1
Reply all
Reply to author
Forward
0 new messages