[m-dev.] proof-of-concept code for choosing a grade

Peter Wang novalazy at gmail.com
Sat Dec 5 22:26:05 AEDT 2015

On Sat, 05 Dec 2015 13:39:41 +1100 (AEDT), "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> I am mostly seeking feedback on the overall design approach.
> - The decision to do it in C.

It is not ideal for cross compiling.  We need to build the program with
one C compiler to run on the building system, then with another C
compiler to run on the system we are targeting.  We do already run into
this issue in boehm_gc/Makefile.direct where (as a hack) we just assume
'cc' is usable to compile helper programs that run as part of the build
process.  Something to be aware of.

I doubt anyone is using the compiler in non-C grades, but it does work
(or did) and would be nice to keep it open as a possibility.

Another approach may be to write the compute grade code in Mercury
for the compiler.  Then, from the same data, enumerate all valid grades
and generate a shell script that uses pattern matching or other simple
techniques to select a valid grade given the values of the variables.
See the attached script for example.  It is an awk script but something
similar could be done in shell.  I think the number of valid grades
should not be too great.

-------------- next part --------------
# echo $code_level,$target,$stack_segments,$debug | awk -f grade.awk

/^(hl|),(c|),(stfix|),(none|)$/ {
    print "hlc" ; exit
/^(hl|),(java|),(stfix|),(none|)$/ {
    print "java" ; exit
/^(hl|),(csharp|),(stfix|),(none|)$/ {
    print "csharp" ; exit
/^(hl|),(erlang|),(stfix|),(none|)$/ {
    print "erlang" ; exit
/^(ll|),(c|),(stseg|),(none|)$/ {
    print "asm_fast.stseg" ; exit
/^(ll|),(c|),(stseg|),(debug|)$/ {
    print "asm_fast.stseg.debug" ; exit
/^(ll|),(c|),(stseg|),(decldebug|)$/ {
    print "asm_fast.stseg.decldebug" ; exit
/^(ll|),(c|),(stfix|),(none|)$/ {
    print "asm_fast.stfix" ; exit
/^(ll|),(c|),(stfix|),(debug|)$/ {
    print "asm_fast.stfix.debug" ; exit
/^(ll|),(c|),(stfix|),(decldebug|)$/ {
    print "asm_fast.stfix.decldebug" ; exit

More information about the developers mailing list