编译为GHC核心 [英] Compiling to GHC Core

查看:149
本文介绍了编译为GHC核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个可生成GHC Core的简单语言的前端。然后我想通过正常的GHC管道获取这个输出。根据此页,它是不能直接从ghc命令中获得。我想知道是否有任何的方式来做到这一点。



理想情况下,我希望对ghc-api进行一些函数调用,但是我也欢迎任何包含(不那么广泛)黑客入侵GHC的建议。任何指针都会有帮助!

解决方案

无论如何通过 ghc 命令或API。对不起:(

从理论上讲,使用GHC API可以从你的代表构建核心语法树,但这听起来非常痛苦,我建议针对其他后端。你不一定要停止使用GHC;使用unboxed类型的简单Haskell和 unsafeCoerce 可以让你非常接近Core,所以你可以定义你自己的简单的 Core-ish语言并编译它(确实,你甚至可以编译GHC Core 本身,但这对我的口味来说太过分了。)


I would like to create a frontend for a simple language that would produce GHC Core. I would like to then take this output and run it through the normal GHC pipeline. According to this page, it is not directly possible from the ghc command. I am wondering if there is any way to do it.

I am ideally expecting a few function calls to the ghc-api but I am also open to any suggestions that include (not-so-extensive) hacking in the source of GHC. Any pointers would help!

解决方案

There's still no way to read External Core files, whether via the ghc command or the API. Sorry :(

It's probably theoretically possible to build the Core syntax tree up from your representation using the GHC API, but that sounds very painful. I would recommend targeting some other backend. You don't necessarily have to stop using GHC; straightforward Haskell with unboxed types and unsafeCoerce lets you get pretty close to the resulting Core, so you could define your own simple "Core-ish" language and compile it to that. (Indeed, you could probably even compile GHC Core itself, but that's a bit too meta for my tastes.)

这篇关于编译为GHC核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆