Treegraph-based Instruction Scheduling for Stack-based Virtual Machines

  • Authors:
  • Jiin Park;Jinhyung Park;Wonjoon Song;Songwook Yoon;Bernd Burgstaller;Bernhard Scholz

  • Affiliations:
  • Department of Computer Science, Yonsei University, Seoul, Korea;Department of Computer Science, Yonsei University, Seoul, Korea;Department of Computer Science, Yonsei University, Seoul, Korea;Department of Computer Science, Yonsei University, Seoul, Korea;Department of Computer Science, Yonsei University, Seoul, Korea;School of Information Technologies, The University of Sydney, Sydney, Australia

  • Venue:
  • Electronic Notes in Theoretical Computer Science (ENTCS)
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

Abstract

Given the growing interest in the JVM and Microsoft@?s CLI as programming language implementation targets, code generation techniques for efficient stack-code are required. Compiler infrastructures such as LLVM are attractive for their highly optimizing middleend. However, LLVM@?s intermediate representation is register-based, and an LLVM code generator for a stack-based virtual machine needs to bridge the fundamental differences of the register and stack-based computation models. In this paper we investigate how the semantics of a register-based IR can be mapped to stack-code. We introduce a novel program representation called treegraphs. Treegraph nodes encapsulate computations that can be represented by DFS trees. Treegraph edges manifest computations with multiple uses, which is inherently incompatible with the consuming semantics of stack-based operators. Instead of saving a multiply-used value in a temporary, our method keeps all values on the stack, which avoids costly store and load instructions. Code-generation then reduces to scheduling of treegraph nodes in the most cost-effective way. We implemented a treegraph-based instruction scheduler for the LLVM compiler infrastructure. We provide experimental results from our implementation of an LLVM backend for TinyVM, which is an embedded systems virtual machine for C.