I am trying to generate MIPS machine code out of Tcl script, however, up until now I haven't found any tools that can do that even to other processors. As fas as I know, Tcl has Tcl Assembly Language (TAL) which produces stack-based CISC, but this output is not applicable for me. Any other options and solutions ?
Asked
Active
Viewed 183 times
1 Answers
1
Converting Tcl code to machine code (via LLVM) is a current project that a friend and me are working on; the project concerned is tclquadcode. I've no idea if MIPS is a supported target, or if cross-compilation is practical (we're looking more at JIT as our key use case).
However… You might be better off looking at ways of packaging Tcl code into an executable (e.g., constructing a starpack) so that you get the single-file benefits of compilation without depending on stuff that is frankly still very much only research-grade software. Sometimes it is necessary to take a step back from the problem you're looking at and instead work from a different perspective that takes you to where you're really aiming to go.

Donal Fellows
- 133,037
- 18
- 149
- 215
-
1As far as I know, people run Tcl Interpreter on their machine and that Tcl interpreter just executes the code. But to do that you need (modern) machine that has an OS and has C library (because Tcl needs it) CMIIW. In my case I am just allowed to have simple processor to run Tcl code (because the system code is written in Tcl). Is it possible for me to write my own compiler for this ? like generating binary machine code for it ? p.s : I haven't take any classes or courses related to compiler. – pakpik Feb 12 '16 at 16:13
-
Writing a compiler is extremely difficult. What you want to look into is cross compiling for your platform. Cross compiling will enable you to build an executable for a mips target using an x86 platform. Setting up the tools for cross compilation can be difficult. – Brad Lanam Feb 12 '16 at 17:04
-
Tcl really doesn't require vast amounts of resources to run. It's target platform is a bit bigger than the 1MB machines I remember using at university, but it's trivially small by comparison with modern desktop systems. – Donal Fellows Feb 13 '16 at 17:01
-
Which one is easier between using cross compilation and writing my own compiler ? I haven't found any compiler that works compiling Tcl into compilable C program and neither cross compilers that targets single cycle MIPS. – pakpik Feb 15 '16 at 13:19