Skip to content

Commit

Permalink
readme: update to add link to GoDoc "hello world" example
Browse files Browse the repository at this point in the history
Also, remove link to [1]. Info is mostly contained within example code
(i.e. convert from *[15]i8 to *i8).

[1]: https://github.com/anoopsarkar/compilers-class-hw/blob/master/llvm-practice/helloworld.ll
  • Loading branch information
mewmew committed Feb 17, 2023
1 parent 10625b0 commit fa2da43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Map between `llir/llvm` tagged releases and LLVM release versions.

## Usage

### Input example - Parse LLVM IR assembly
### Input example, parsing LLVM IR assembly

[Example usage in GoDoc](https://pkg.go.dev/github.com/llir/llvm/asm#example-package).

Expand Down Expand Up @@ -73,8 +73,10 @@ func main() {

#### Hello, World

[Example usage in GoDoc](https://pkg.go.dev/github.com/llir/llvm/ir#example-package-Hello).

```go
// This example produces LLVM IR generating "Hello, World" output:
// This example produces LLVM IR generating "Hello, World" output.

package main

Expand All @@ -95,15 +97,13 @@ func main() {
puts := m.NewFunc("puts", types.I32, ir.NewParam("", types.NewPointer(types.I8)))
main := m.NewFunc("main", types.I32)
entry := main.NewBlock("")
// Cast *[15]i8 to *i8; c.f.: [1]
// Cast *[15]i8 to *i8.
zero := constant.NewInt(types.I64, 0)
gep := constant.NewGetElementPtr(hello.Typ, str, zero, zero)
entry.NewCall(puts, gep)
entry.NewRet(constant.NewInt(types.I32, 0))
fmt.Println(m)
}
// [1] See also:
// https://github.com/anoopsarkar/compilers-class-hw/blob/master/llvm-practice/helloworld.ll
```

#### Pseudo Random-Number Generator
Expand Down Expand Up @@ -176,9 +176,9 @@ func main() {
}
```

### Analysis example - Process LLVM IR
### Analysis example, processing LLVM IR

[Example usage in GoDoc](https://pkg.go.dev/github.com/llir/llvm/ir#example-package--Callgraph).
[Example usage in GoDoc](https://pkg.go.dev/github.com/llir/llvm/ir#example-package-Callgraph).

```go
// This example program analyses an LLVM IR module to produce a callgraph in
Expand Down
1 change: 0 additions & 1 deletion ir/hello_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ func Example_hello() {
// %1 = call i32 @puts(i8* getelementptr ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
// ret i32 0
// }

}

0 comments on commit fa2da43

Please sign in to comment.