757 lines
9.5 KiB
HTML
757 lines
9.5 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
<meta name="description" content="">
|
|
<meta name="author" content="Eelco Visser">
|
|
<meta name="generator" content="Jekyll v3.8.5">
|
|
<title>Lecture 13: Implementing Register Allocation & Control Flow & Memory Management</title>
|
|
<!-- <base href="/2021"> -->
|
|
|
|
<!--link rel="canonical" href="https://getbootstrap.com/docs/4.3/examples/starter-template/"-->
|
|
|
|
<link rel="icon" href="../img/logo/pl_ico2_2B3_icon.ico" type="image/x-icon">
|
|
|
|
<!-- Bootstrap core CSS -->
|
|
<!--link href="https://getbootstrap.com/docs/4.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"-->
|
|
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
|
|
|
|
|
|
|
<style>
|
|
.bd-placeholder-img {
|
|
font-size: 1.125rem;
|
|
text-anchor: middle;
|
|
-webkit-user-select: none;
|
|
-moz-user-select: none;
|
|
-ms-user-select: none;
|
|
user-select: none;
|
|
}
|
|
|
|
@media (min-width: 768px) {
|
|
.bd-placeholder-img-lg {
|
|
font-size: 3.5rem;
|
|
}
|
|
}
|
|
</style>
|
|
<!-- Custom styles for this template -->
|
|
<link href="../css/main.css" rel="stylesheet">
|
|
<link href="../css/borders-responsive.css" rel="stylesheet">
|
|
|
|
<link rel="stylesheet" href="../css/pl.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
|
|
|
|
<a class="navbar-brand" href="../index.html">
|
|
TU Delft | CS4200
|
|
</a>
|
|
|
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
|
|
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
|
|
<ul class="navbar-nav mr-auto">
|
|
|
|
|
|
|
|
|
|
|
|
<li class="nav-item active">
|
|
<a class="nav-link" href="../lectures/index.html" tabindex="-1" aria-disabled="true">Lectures</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="nav-item active">
|
|
<a class="nav-link" href="../homework/index.html" tabindex="-1" aria-disabled="true">Homework</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="nav-item active">
|
|
<a class="nav-link" href="../project/index.html" tabindex="-1" aria-disabled="true">Project</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="nav-item active">
|
|
<a class="nav-link" href="../news/index.html" tabindex="-1" aria-disabled="true">News</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="nav-item active">
|
|
<a class="nav-link" href="../blog/index.html" tabindex="-1" aria-disabled="true">Blog</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
</nav>
|
|
|
|
|
|
<div class="container">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-sm-12 col-md-12 col-lg-12 col-xl-12">
|
|
|
|
<a href="../lectures/2021/13-control-flow/CS4200-2021-13-control-flow.pdf">
|
|
<img class="border border-dark" width="100%" src="../lectures/2021/13-control-flow/CS4200-2021-13-control-flow/CS4200-2021-13-control-flow.011.png"/>
|
|
</a>
|
|
|
|
|
|
<div class="mt-3 mb-3 pt-3 pb-3 text-dark border-top border-bottom border-grey">
|
|
<div class="text-dark font-weight-bold">
|
|
<h1>
|
|
|
|
Lecture 13: Implementing Register Allocation & Control Flow & Memory Management
|
|
|
|
</h1>
|
|
</div>
|
|
<div>
|
|
|
|
Eelco Visser
|
|
|
|
|
|
</div>
|
|
<div>
|
|
|
|
|
|
Lecture
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| <a class="text-primary" href="../lectures/2021/13-control-flow/CS4200-2021-13-control-flow.pdf">PDF</a>
|
|
|
|
|
|
</div>
|
|
<div>
|
|
December 02, 2021
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-sm-12 col-md-12 col-lg-9 border-lg-right border-grey">
|
|
<h3 id="implementing-register-allocation">Implementing Register Allocation</h3>
|
|
|
|
<p>Last week we looked at the approach for using graph coloring for register allocation, conceptually.
|
|
This week we study Stratego code for implementing register allocation (for straigh line code).
|
|
Register allocation consists of liveness analysis, building an interference graph from the results of that analysis, coloring the nodes of that graph, and finally applying the coloring result to the program.</p>
|
|
|
|
<h3 id="control-flow">Control Flow</h3>
|
|
|
|
<p>We extend our compiler to handle boolean values and control flow constructs in the subject language.
|
|
By desugaring the language we can reduce the constructs that the downstream compiler has to consider.</p>
|
|
|
|
<h3 id="memory-management">Memory Management</h3>
|
|
|
|
<p>We make a start with the safety considerations of memory management and consider automated memory management techniques.
|
|
We study a range of garbage collection algorithms and study their properties.
|
|
To be continued next week.</p>
|
|
|
|
<p>Slides:</p>
|
|
<ul>
|
|
<li><a href="../lectures/2021/13-control-flow/CS4200-2021-13-memory-management.pdf">PDF</a></li>
|
|
</ul>
|
|
|
|
<p><img src="../lectures/2021/13-control-flow/CS4200-2021-13-memory-management/CS4200-2021-13-memory-management.022.png" class="border border-dark" /></p>
|
|
|
|
<h3 id="references">References</h3>
|
|
|
|
<p>See the memory management slide for references.</p>
|
|
|
|
<!-- In this lecture we study further code generation techniques.
|
|
|
|
### Calling Conventions
|
|
|
|
We first study functions in ChocoPy and the operational semantics rules that define their meaning.
|
|
Then we look at activation records, what motivates their existence, and how they are used to implement function calls.
|
|
We reconstruct the RISC-V calling convention described in the ChocoPy language implementation guide, looking in detail at the implementation of an example caller and callee.
|
|
|
|
### Dynamic Rewrite Rules
|
|
|
|
In the second part of the lecture, we study dynamic rewrite rules in Stratego, which can be used to define context-sensitive transformations. We look at examples for keeping track of stack offsets, and mapping variables to their offsets. See the paper by Bravenboer et al. (2006) for more information about dynamic rules.
|
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
<ul class="list-group list-group-flush pb-3">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</div>
|
|
<div class="col-sm-12 col-md-12 col-lg-3 col-xl-3 " >
|
|
<div class="sticky-top top70 d-none d-lg-block d-xl-block">
|
|
<div class="pb4 mb3 border-bottom border-grey ">
|
|
<nav>
|
|
<ul class="pagination justify-content-left">
|
|
|
|
<li class="page-item">
|
|
<a class="page-link" href="12.html">
|
|
«
|
|
</a>
|
|
</li>
|
|
|
|
<li class="page-item">
|
|
<a class="page-link" href="../lectures/index.html">
|
|
^
|
|
</a>
|
|
</li>
|
|
|
|
<li class="page-item">
|
|
<a class="page-link" href="14.html">»</a>
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
<ul id="my_toc" class="toc list-group list-group-flush d-none d-lg-block d-xl-block p-0 ml-0 mt-3">
|
|
<li class="list-group-item pl-0 ml-0 border-0 pl-0 pt-0 pb-1 pr-0 m-0 mr-3"><a href="13.html#implementing-register-allocation">Implementing Register Allocation</a></li>
|
|
<li class="list-group-item pl-0 ml-0 border-0 pl-0 pt-0 pb-1 pr-0 m-0 mr-3"><a href="13.html#control-flow">Control Flow</a></li>
|
|
<li class="list-group-item pl-0 ml-0 border-0 pl-0 pt-0 pb-1 pr-0 m-0 mr-3"><a href="13.html#memory-management">Memory Management</a></li>
|
|
<li class="list-group-item pl-0 ml-0 border-0 pl-0 pt-0 pb-1 pr-0 m-0 mr-3"><a href="13.html#references">References</a></li>
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="border-top border-bottom border-grey mt-3 pt-3">
|
|
<nav>
|
|
<ul class="pagination justify-content-center">
|
|
|
|
<li class="page-item">
|
|
<a class="page-link" href="12.html">
|
|
Previous
|
|
</a>
|
|
</li>
|
|
|
|
|
|
<li class="page-item">
|
|
<a class="page-link" href="14.html">Next</a>
|
|
</li>
|
|
|
|
<li class="page-item">
|
|
<a class="page-link" href="../lectures/index.html">
|
|
Index
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Optional JavaScript -->
|
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
|
|
|
</body>
|
|
</html>
|