OpenMP的类似语言编译器 [英] OpenMP-like language compiler

查看:302
本文介绍了OpenMP的类似语言编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过翻译与编译指示code A C到C code。与动态库调用来创建的OpenMP样的函数(#pragma语句)扩展的C语言。它不是简单地扩大编译指示,同样它做阵列线性化,新的变量声明,等等。所以我在寻找一个源到源工具需要的。

I need to create OpenMP-like (#pragma statements) extension to C language by translating a C with pragmas code to a C code with calls of a dynamic library. It's not simply expanding of pragmas, also it's needed to do arrays linearization, new variables declarations, etc. So I am searching a source-to-source tool.

我找到了一些线索:通心络,JetBrains公司MPS,元环境,西洋陆军棋/ XT,玫瑰,DMS。任何人可以解释一下什么是它们之间各自的优点和缺点的差异,好吗?我将不胜感激任何建议。

I've found some clues: TXL, JetBrains MPS, The Meta-Environment, Stratego/XT, Rose, DMS. Could anybody explain what are differences between them, their advantages and disadvantages, please? I will be greatful for any advices.

推荐答案

我后面的 DMS 。您可能会发现我的答案偏见。

I'm the guy behind DMS. You may find my answer biased.

所有这些工具共享源到源转换的基本知识。他们分析了一些源语言(您可以通过各种形式的语法定义的工具),打造树木,让你写code导航/检查/修改的树木,然后prettyprint树了至其目的是某种编译code的文本字符串。

All of these tools share the basics of source-to-source transformation. They parse some source language (which you can define to the tool via a grammar in various forms), build trees, allow you to write code to navigate/inspect/modify the trees, and then prettyprint the tree out to a text string which is intended to be some kind of compilable code.


  • JetBrains公司MPS:我有这个知之甚少。我的认为的你必须写程序code爬过树。这是处理树木经典的编译器技术。我不相信它可以解析ç开箱即用,更不用说OpenMP的原语,你会发现,相当多的工作来获取正确的。

  • JetBrains MPS: I have very little knowledge of this. I think you have to write procedural code to climb over the trees. This is the classic compiler technique for handling trees. I don't believe it can parse C out of the box, let alone OpenMP primitives, and you will find that quite a lot of work to get right.

该MetaEnvironment:我对此一无所知工具。高概率赌注:不分析C语言

The MetaEnvironment: I know nothing about this tool. High probability bet: doesn't parse C.

通心络:这有一个模式匹配和code语言实例,使用过的树木函数实现的。功能可以进行模式匹配拿起和递归到子树,并调用函数装配树结果为较大的树木,最终产生一个最终的树。的模式是使用源的语法的图案,这使得它们非常容易写写入。什么通心络不会以明显的方式做的是开展了code的分析,供以后code代行动使用。有一个办法做到这一点:你建立包含一个功能通过分析辅助的树木,并通过另一个功能通产生的结果遵循它;这是apparantly一种常见的通心络技术。通心络可能有一个可用的Ç解析器,但它可能只适用于preprocessed C $ C $℃;你可以很可能这个弯来处理OpenMP的语法,而不巨大的麻烦量。什么它不会是一个方便的符号表,使您查找标识符,如果你想在任何有趣的方式变换C ++,你需要的意义。

TXL: This has a pattern matching and code instantiation language, implemented using functions over trees. The functions can pattern match to pick up and recurse into subtrees, and assemble tree results from called functions into larger trees, ultimately producing a final tree. The patterns are written using source-syntax patterns, which makes them fairly easy to write. What TXL does not do in an obvious way is carry out analyses of the code, for later code generation actions to use. There is a way to do it: you build auxiliary trees containing the analysis in one functional pass, and follow it by another functional pass producing results; this is apparantly a common TXL technique. TXL probably has an available C parser, but it likely only works on preprocessed C code; you can likely bend this to handle OpenMP syntax without a huge amount of trouble. What it won't have is a convenient symbol table enabling you to look up the meaning of identifiers, which you will need if you want to transform C in any interesting way.

西洋陆军棋/ XT:此工具的工作原理是结合源源重写,以战略,也就是排序操作可以让工具上下行走的树作为重写申请成功或失败。这一战略计划允许收集在树中的一个点信息,要远运到其他点。通心络一样,我是pretty相信你可以找到preprocessed C code进行解析。通心络一样,我不认为你会得到一个符号表或code的任何其他的深刻分析。

Stratego/XT: This tool works by combining source to source rewrites, with "strategies", that is, sequencing operations that allow the tool to walk up and down the tree as the rewrites apply successfully or fail. This strategy scheme allow information collected at one point in the tree, to be carried to other points far away. Like TXL, I'm pretty sure you can find a parser for preprocessed C code. Like TXL, I don't think you get a symbol table or any other deep analyses of the code.

罗斯:这个工具使用EDG的前端preprocess /解析C和C ++ code和建立一个AST;我认为EDG前端构建符号表,太。你似乎想使解析器添加的OpenMP样原语的定制版本;我不认为你可以做到这一点与玫瑰,因为我不相信EDG前端以源代码形式提供给你砍。底盘是用C ++;你可以写程序的游客翻越code和建立新的树节点。它具有处理源模式的一个神秘而可行的方案:它把它们转换成有效的,微小的主C ++程序,将它们传递到C ++语法分析器,并还给剥离掉主程序后壳结果树。罗斯所使用的LLNL对科学codeS工作,并可能接近你所需要的;我会感到惊讶,如果解析器没有处理的OpenMP因为这是在该社区利益的关键技术。罗斯还提供了一些控制和数据流分析,但我不知道他们是多么复杂;它确实使玫瑰从背包中脱颖而出。

Rose: This tool uses EDG's front end to preprocess/parse C and C++ code and build an AST; I think the EDG front end builds symbol tables, too. You seem to want to make a custom version of the parser to add your "OpenMP-like" primitives; I don't think you can do that with Rose as I don't believe the EDG front end is available in source form for you to hack. The undercarriage is in C++; you can write procedural visitors to climb over the code and build new tree nodes. It has an arcane but workable scheme for handling source patterns: it converts them into valid, tiny "main" C++ programs, passes them to the C++ parser, and gives back the resulting tree after stripping away the main program shell. Rose is used by LLNL to work on scientific codes, and might come close to what you need; I'd be surprised if its parser did NOT handle OpenMP since that's a key technology of interest in that community. Rose also provides some control and data flow analysis but I don't know how sophisticated they are; it does make Rose stand out from the rest of the pack.

DMS:这个工具的目的是操纵任意编程汉语语言。它提供了解析,prettyprinting,符号表结构,控制流和数据流分析,以及指向分析本地和全球性的。
DMS有完整的 C前结束并的 C ++前端使用preprocessor,解析和符号表建设完成。 C前端已经完全流分析执行(以上所有); C ++的前端现在还没有与流量分析,但我们正在努力。
所有DMS前端是提供源代码,以便他们可以定制,例如,添加自定义的OpenMP扩展。 DMS已经被用于为空调系统的全局分析19,000编译单元,以及code代和C的API提取系统的那么大。它已被用于重新构建庞大的C ++源$ C ​​$ C基地。它是一个工业强度的工具。罗斯可能是C ++在这一点上变换有所好转; DMS远比玫瑰恕我直言,更好地为语言的广度,它已被应用于支持分析和改造,以及各种任务的机制范围。

DMS: This tool is designed to manipulate arbitrary programming langauges. It provides parsing, prettyprinting, symbol table construction, control flow and data flow analysis, as well as points-to analysis both local and global. DMS has full C front end and C++ front end complete with preprocessor, parsing and symbol table construction. The C front end has complete flow analysis implemented (all of the above); the C++ front end isn't there yet with flow analysis but we're working on it. All DMS Front Ends are available in source form so that they can be customized, e.g., to add your custom OpenMP extensions. DMS has been used to for global analysis of C systems with 19,000 compilation units, as well as code generation and extraction of C APIs from systems that big. It has been used to rearchitect huge C++ source code bases. It is an industrial strength tool. Rose might be somewhat better for C++ transformations at this point; DMS is far better than Rose IMHO for the breadth of languages, scope of supporting mechanisms for analysis and transformation, and variety of tasks to which it has been applied.

您可以看到各种解析/转换工具详细对比>,包括大多数以上。

You can see a more detailed comparison of a variety of parsing/transformation tools, including most of the above.

这篇关于OpenMP的类似语言编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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