From fa2da43db34633c9415ace13e82268b2f5cd45b2 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Fri, 17 Feb 2023 13:30:46 +0800 Subject: [PATCH] readme: update to add link to GoDoc "hello world" example 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 --- README.md | 14 +++++++------- ir/hello_test.go | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 62625976..b781c319 100644 --- a/README.md +++ b/README.md @@ -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). @@ -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 @@ -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 @@ -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 diff --git a/ir/hello_test.go b/ir/hello_test.go index 6d92aeec..0a507203 100644 --- a/ir/hello_test.go +++ b/ir/hello_test.go @@ -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 // } - }