透過您的圖書館登入
IP:3.137.138.94
  • 學位論文

針對編譯器以XML為基礎之中間表示式之研究

XML-based Intermediate Representation for Compilers

指導教授 : 陳鵬升
若您是本文的作者,可授權文章由華藝線上圖書館中協助推廣。

摘要


中間表示法(IR)是一種在編譯器架構中用來轉換成目的過程中所用來表示程式的方法。所以,在一般的編譯過程中,我們會先將原始碼轉換成對應的IR,並將這個IR轉換成相對應的目的程式。 IR有助於簡易開發複雜的編譯器架構,甚至可以用來模組化整個編譯器的動作。 因此,基本上我們可以利用編譯器的API來取得IR的資訊。 XML(可延伸標記式語言)是一種用於網路上交換、攜帶以及儲存資訊的重要資料格式之一。因為XML本身擁有幾種特性可以方便開發者來使用,分別是: 自由定義格式、良好結構、可讀性高以及容易處理。也因為如此最近幾年越來越多的程式使用XML來儲存或描述資料與資訊。另外,XSLT 是一種以XML為基礎的語言,並且可以使用XSLT來轉換XML到不同的其他文件格式(包含XML),例如: PDF、HTML以及WML。 本篇論文希望可以設計與實作一個適用於編譯器的XML IR,我們也希望這個XML IR可以被輕易地使用,也可以輕鬆地擴展,也可以容易閱讀。因此,在實驗中,我們實作一個LLVM PASS轉換LLVM IR成我們自己設計的XML IR,並且我們也可以使用XSLT 來轉換XML IR 回原本的LLVM IR。除此之外,我們也實作了四種用來分析的PASS,並且針對XML使用XSLT來做分析與LLVM用自己的API來做分析為量測的基礎,並觀察兩者之間表現的差異。

並列摘要


An intermediate representation (IR) is an abstract language which can represent the source program for internal use in a compiler infrastructure. Generally, during the compilation, a source program is translated to the corresponding IR and then the IR is translated to the target program. The use of IR simplifies the complexity of compiler development and makes developing compilers more modularity. For a compiler, de-velopers need to use APIs provided by the compiler to access its IR. XML (eXtensible Markup Language) is a data format that is used to carry, send, and exchange information among devices. Due to the XML technique is free-formed, well-formed, readable, and easy-to-process, in recent years, more and more applica-tions use the XML format to describe and store the data. XSLT (eXtensible Stylesheet Language Transformations) is an XML-based language used for transferring an XML document into another XML document or another type of document (e.g., PDF, HTML, and WML). In this thesis, we design and implement an XML-based IR for compilers. The proposed XML-based IR has generality, extensibility, and readability. For the evalua-tion, we implement a LLVM pass to translate LLVM IR to the proposed XML IR, and an XSLT file to translate XML IR back to LLVM IR. We also develop four XSLT files which are applied to XML IRs to do program analyses and instrumentation. The experimental results show that the proposed XML IR is practicable and usable. In addition, it is possible to use XSLT to develop compiler passes.

並列關鍵字

Intermediate Representation XML

參考文獻


[1]Website. Introduction of Intermediate Representation.
[2]Fred Chow Intermediate Representation. Communications of the ACM 56, 12 (Dec. 2013), 57-62.
[10]Chris Lattner, LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation, CGO 2004.
[11]Website. The Saxon XSLT.
[14]Website. XML Tutorial.

延伸閱讀