aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2019-09-21 20:02:54 +0200
committerAyke <[email protected]>2019-09-24 18:16:43 +0200
commitda7f7eef0087e456bb5b0ecf7e73b63903b8b93d (patch)
treeb7668c9f7e1aae5667970eb3f1d0aa574a727bce
parent17ef7a5c3277c19225395f10528e2f9516fa6939 (diff)
downloadtinygo-da7f7eef0087e456bb5b0ecf7e73b63903b8b93d.tar.gz
tinygo-da7f7eef0087e456bb5b0ecf7e73b63903b8b93d.zip
interp: avoid an extra TargetData argument
This can be easily calculated from the module datalayout string.
-rw-r--r--compiler/compiler.go5
-rw-r--r--interp/interp.go4
-rw-r--r--main.go2
3 files changed, 3 insertions, 8 deletions
diff --git a/compiler/compiler.go b/compiler/compiler.go
index 25017bc4a..cba701355 100644
--- a/compiler/compiler.go
+++ b/compiler/compiler.go
@@ -187,11 +187,6 @@ func (c *Compiler) Module() llvm.Module {
return c.mod
}
-// Return the LLVM target data object. Only valid after a successful compile.
-func (c *Compiler) TargetData() llvm.TargetData {
- return c.targetData
-}
-
// selectGC picks an appropriate GC strategy if none was provided.
func (c *Compiler) selectGC() string {
if c.GC != "" {
diff --git a/interp/interp.go b/interp/interp.go
index 14cd6e782..e1005657b 100644
--- a/interp/interp.go
+++ b/interp/interp.go
@@ -24,7 +24,7 @@ type Eval struct {
// Run evaluates the function with the given name and then eliminates all
// callers.
-func Run(mod llvm.Module, targetData llvm.TargetData, debug bool) error {
+func Run(mod llvm.Module, debug bool) error {
if debug {
println("\ncompile-time evaluation:")
}
@@ -32,7 +32,7 @@ func Run(mod llvm.Module, targetData llvm.TargetData, debug bool) error {
name := "runtime.initAll"
e := &Eval{
Mod: mod,
- TargetData: targetData,
+ TargetData: llvm.NewTargetData(mod.DataLayout()),
Debug: debug,
dirtyGlobals: map[llvm.Value]struct{}{},
}
diff --git a/main.go b/main.go
index 38a50e65a..0778de46d 100644
--- a/main.go
+++ b/main.go
@@ -145,7 +145,7 @@ func Compile(pkgName, outpath string, spec *TargetSpec, config *BuildConfig, act
return errors.New("verification error after IR construction")
}
- err = interp.Run(c.Module(), c.TargetData(), config.dumpSSA)
+ err = interp.Run(c.Module(), config.dumpSSA)
if err != nil {
return err
}