一个C--的例子:1 Introduction
C-- is a compiler-target language. The idea is that a compiler for a high-level language translates programs
into into C--, leaving the C-- compiler to generate native code. C--’s major goals are these:
• C-- encapsulates compilation techniques that are well understood, but difficult to implement. Such
techniques include instruction selection, register allocation, instruction scheduling, and optimization
of imperative code with loops.
• C-- is a language, rather than a library (such as gcc’s RTL back end). As such, it has a concrete syntax
that can be read by people, and a semantics that is independent of any particular implementation.
• C-- is a portable assembly language. It is, by design, as low-level as possible while still concealing
details of the particular machine architecture.
• C-- is independent of both source programming language and target architecture. Its design accom-
modates a variety of source languages and leaves room for back-end optimization, all without upcalls
from the back end to the front end.
• C-- is efficient—or at least admits efficient implementation. So C-- provides almost as much flexibility
and performance (assuming a good C-- compiler) as a custom code generator.
A client of C-- is divided into two parts. The front-end compiler generates programs written in the C--
language, which the C-- compiler translates into efficient machine code. This code interoperates with the
front-end run-time system, which implements such services as garbage collection, exception dispatch, thread
scheduling, and so on. The front-end run-time system relies on mechanisms provided by the C-- run-time
system; they interact through the C-- run-time interface. This document describes the C-- language and
run-time interface. It is intended for authors who wish to write clients of the C-- system.
The C-- team has prepared some demonstration front ends that may help you learn to use C--.
• Paul Govereau’s tigerc compiler includes a compiler for Tiger (the language of Andrew Appel’s
compiler text) as well as a small run-time system with garbage collector. The tigerc compiler is
written in Objective Caml.
• Norman Ramsey’s lcc back end works with lcc to translate C into C--. It is written in C.
• Reuben Olinsky’s interpreter, which is packaged with the Quick C-- sources, includes sample run-time
clients for garbage collection and exception dispatch.
All this code is available through the C-- web site at http://www.cminusminus.org.
1.1 What C-- is not
C-- has some important non-goals:
• C-- is not an execution platform, such as the Java Virtual Machine or the .NET Common Language
Runtime. These virtual machines are extremely high-level compared to C--. Each provides a rich type
system, garbage collector, class loader, just-in-time compiler, byte-code verifier, exception-dispatch
mechanism, debugger, massive libraries, and much more besides. These may be good things, but
they clearly involve much more than encapsulating code-generation technology, and depending on your
language model, they may impose a significant penalty in both space and time.
6
• C-- is not “write-once, run-anywhere”. It conceals most architecture-specific details, such as the
number of registers, but it exposes some. In particular, C-- exposes the word size, byte order, and
alignment properties of the target architecture, for two reasons. First, to hide these details would
require introducing a great deal of complexity, inefficiency, or both—especially when the front-end
compiler needs to control the representation of its high-level data types. Second, these details are easy
to handle in a front-end compiler. Indeed, a compiler may benefit, because it can do address arithmetic
using integers instead of symbolic constants such as FloatSize and IntSize.
一门很有用的编程语言:C--
- stlxv
- 论坛版主
- 帖子: 8275
- 注册时间: 2006-05-03 0:39
- 来自: المريخ
一门很有用的编程语言:C--
官方网站:http://www.cminusminus.org
- 附件
-
- man2.pdf.zip
- The C-- Language Specification
Version 2.0
( CVS Revision 1.128 ) - (308.6 KiB) 已下载 165 次
PHP是最好的语言!不服来战!
- bones7456
- 帖子: 8495
- 注册时间: 2006-04-12 20:05
- 来自: 杭州
- 联系:
- shellex
- 帖子: 2180
- 注册时间: 2007-02-18 19:33
- 系统: OSX
- 来自: lyric.im
- 联系:
-
- 帖子: 25
- 注册时间: 2008-01-08 10:28
- 来自: 江苏南京
-
- 帖子: 43
- 注册时间: 2007-03-13 14:08
- ljj_jjl2008
- 论坛版主
- 帖子: 14255
- 注册时间: 2007-09-16 8:29
又是一堆英文,我还是看不懂,我再哭!!
闻到死太贵, 麦克价更高。 有了笨笨兔, 二者皆可抛。
+ 我的六轮折腾
+ 折腾6轮的结果(对40余种WM的测试和分析,多种DE和WM并存的方案)
+ 折腾的中间成果:可以独立运行的一个Wharf(图标化的启动菜单)
+ 强烈推荐----折腾的终极成果:一个自己开发的DE环境
+ 签名空闲链接位置招租
+ 我的六轮折腾
+ 折腾6轮的结果(对40余种WM的测试和分析,多种DE和WM并存的方案)
+ 折腾的中间成果:可以独立运行的一个Wharf(图标化的启动菜单)
+ 强烈推荐----折腾的终极成果:一个自己开发的DE环境
+ 签名空闲链接位置招租
- stlxv
- 论坛版主
- 帖子: 8275
- 注册时间: 2006-05-03 0:39
- 来自: المريخ
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- ghosTM55
- 帖子: 86
- 注册时间: 2007-02-14 18:05
- 来自: 上海
- 联系:
-
- 帖子: 234
- 注册时间: 2006-10-12 21:31