编写数值线性代数编译器
我正在开发一个小项目,该项目的主要目的是为数值线性代数创建一个编译器。我计划的方法是,
- 用 Java 编程语言创建编译器
- ,它将生成本机汇编代码。
- 我将使用一个精确的数值线性代数包(用 C 编写),并将与编译器生成的汇编代码链接。
此外,我正在考虑在我要创建的新语言中支持多线程。
我对汇编语言非常陌生,有以下问题。
- 为了支持多线程,我是否需要使用单独的线程库,或者是否需要使用生成的汇编代码来实现?
- 由于我是在Windows平台上开发这个,是否值得用C#语言开发它并生成CLR、IL而不是生成本机汇编语言。
谢谢,
乌普尔
I’m working on a small project and main purpose of the project is to create a compiler for numerical liner algebra. The approach I’m planning is,
- Create the Compiler in Java Programming language
- That will generate native assembly codes
- I Will be using an excising numerical linear algebra package (written in C) and will link with the assembly code generated by the compiler.
Furthermore, I’m thinking to support multithreading in the new language I’m going to create.
I’m very new to the assembly language and having the following questions.
- In order to support multithreading, do I need to use a separate threading library or is it necessary to do it by using generated assembly code?
- Since I’m developing this in the windows platform, is it worthwhile to develop this in C# language and generate CLR, IL instead of generating native assembly language.
Thanks,
Upul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好首先生成“编译”输出作为 C 代码,然后使用 C 编译器生成汇编代码,
这比直接汇编器更容易开发,因为您可以检查中间代码是否有错误,并且不需要担心将包链接到生成的代码中,因为这将由编译器完成
it might be best to generate the "compiled" output first as C code and use a C compiler to generate the assembly code
this is much easier to develop than direct to assembler because you can examine the intermediate code for errors and you don't have to worry about linking the package into the generated code as that will be done by the compiler
1. 的答案已经预设了您选择的汇编器是一个好的汇编器。但我强烈反对这样做,原因如下:
如今,汇编程序无法再击败用 C、C++ 或 D 等语言编写的优化程序。但是,作为编译器编写者,您可以通过以这样的方式生成输出来为自己节省巨大的麻烦。语言而不是汇编语言。最重要的是:您并不固定在单一平台上。
当您对此做出决定时,您的第一个问题就会转变为:“(如何)我的目标语言支持多线程?”
The answer on 1. already presupposes that your choice of assembler is a good one. But I would strongly discourage it on the following ground:
Nowadays, assembler cannot beat anymore an optimized program written in a language like C, or C++ or maybe D. But, as a compiler writer you save yourself enomous trouble by generating output in such a language instead of assembler. Not the least of it: You're not fixed to a si8ngle platform.
When you make a decision on this, your first question is then transformed to: "(How) Does my target language support multithreading?"