mewmew / uc

A compiler for the µC language.
58 stars 5 forks source link

all: fix build and update to latest version llir/llvm #79

Closed mewmew closed 5 years ago

mewmew commented 5 years ago

In preparation for the v0.3.0 release of llir/llvm, we should update uc to make use of the latest llir/llvm API.

The build of uc currently fails with the following compile time error:

# github.com/mewmew/uc/irgen
irgen/irgen.go:40:3: m.AppendFunction undefined (type *Module has no field or method AppendFunction)
irgen/irgen.go:65:31: sig.Ret undefined (type *"github.com/llir/llvm/ir/types".FuncType has no field or method Ret)
irgen/irgen.go:65:40: cannot use sig.Params (type []"github.com/llir/llvm/ir/types".Type) as type []*ir.Param in argument to ir.NewFunction
irgen/irgen.go:79:24: invalid operation: f.Function.Name == "main" (mismatched types func() string and string)
irgen/irgen.go:87:19: f.Function.Sig.Ret undefined (type *"github.com/llir/llvm/ir/types".FuncType has no field or method Ret)
irgen/irgen.go:94:26: f.Function.Sig.Ret undefined (type *"github.com/llir/llvm/ir/types".FuncType has no field or method Ret)
irgen/irgen.go:95:9: undefined: "github.com/llir/llvm/ir/types".IsVoid
irgen/lower.go:130:48: undefined: "github.com/llir/llvm/ir/types".Param
irgen/lower.go:158:7: undefined: "github.com/llir/llvm/ir/types".IsInt
irgen/lower.go:159:25: cannot use 0 (type int) as type *"github.com/llir/llvm/ir/types".IntType in argument to constant.NewInt
irgen/lower.go:159:25: too many errors
mewmew commented 5 years ago

From https://github.com/mewmew/uc/commit/69873ed74983ff01d24d1d53d2b60e2e3c7ae6a0:

Note, constant.NewGetElementPtr and ir.NewGetElementPtr currently requires an elemType parameter. The llir/llvm library will be update to remove this requirement, as elemType may be inferred from the src and indices parameters.

Edit: as of rev https://github.com/llir/llvm/commit/d4f47978f3b28bd3957686a36724690cb3b44439 llir/llvm has been updated to remove the elemType parameter, which is now inferred from src instead.