-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ir | ||
|
||
// A BasicBlock is a sequence of non-branching instructions, terminated by a | ||
// control flow instruction (such as br or ret) [1]. | ||
// | ||
// [1]: http://llvm.org/docs/LangRef.html#terminators | ||
type BasicBlock struct { | ||
// Parent function of the basic block. | ||
Parent *Function | ||
// Instructions. | ||
Insts []Instruction | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Package ir declares the types used to represent the LLVM IR language [1]. | ||
// | ||
// LLVM code is organized into modules containing top-level definitions, such as | ||
// functions and global variables. A function definition contains a set of basic | ||
// blocks, which forms the nodes in a Control Flow Graph of the function. Each | ||
// basic block consists of a sequence of non-branching instructions, terminated | ||
// by a control flow instruction (such as br or ret). | ||
// | ||
// [1]: http://llvm.org/docs/LangRef.html | ||
package ir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ir | ||
|
||
// A Function definition contains a set of basic blocks, interconnected by | ||
// control flow instructions (such as br), which forms the nodes in a Control | ||
// Flow Graph of the function [1,2]. | ||
// | ||
// [1]: http://llvm.org/docs/LangRef.html#functions | ||
// [2]: http://llvm.org/docs/LangRef.html#terminators | ||
type Function struct { | ||
// Basic blocks of the function. | ||
Blocks []*BasicBlock | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package ir | ||
|
||
type Global struct { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package ir | ||
|
||
type Instruction interface { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package ir | ||
|
||
type Metadata struct { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ir | ||
|
||
// A Module contains top-level function definitions, external function | ||
// declarations, global variables, type definitions, and metadata [1]. | ||
// | ||
// [1]: http://llvm.org/docs/LangRef.html#module-structure | ||
type Module struct { | ||
|
||
// TODO(u): Add external function declarations, or let *Function handle | ||
// function definitions without bodies. If *Function handles both, update the | ||
// doc comment to: | ||
// Function definitions and external function declarations (Blocks is nil). | ||
|
||
// Function definitions. | ||
Funcs []*Function | ||
|
||
// TODO(u): Replace with any of the following? | ||
// Globals []Value | ||
// Globals []*Variable | ||
|
||
// Global variables. | ||
Globals []*Global | ||
// Type definitions. | ||
Types []*Type | ||
// Metadata. | ||
Metadata []*Metadata | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package ir | ||
|
||
type Type struct { | ||
} |