2015-03-03 13:38:14 -08:00
|
|
|
// Copyright 2015 The Go Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package ssa
|
|
|
|
|
|
2015-08-24 02:16:19 -07:00
|
|
|
import (
|
2015-10-23 12:34:03 -04:00
|
|
|
"cmd/internal/obj"
|
2015-08-24 02:16:19 -07:00
|
|
|
"testing"
|
|
|
|
|
)
|
2015-06-12 11:01:13 -07:00
|
|
|
|
2015-03-03 13:38:14 -08:00
|
|
|
var CheckFunc = checkFunc
|
|
|
|
|
var PrintFunc = printFunc
|
2015-05-28 16:45:33 -07:00
|
|
|
var Opt = opt
|
2015-03-03 13:38:14 -08:00
|
|
|
var Deadcode = deadcode
|
2015-06-04 15:18:27 -07:00
|
|
|
|
2015-07-30 11:03:05 -07:00
|
|
|
func testConfig(t *testing.T) *Config {
|
2015-10-23 12:34:03 -04:00
|
|
|
testCtxt := &obj.Link{}
|
|
|
|
|
return NewConfig("amd64", DummyFrontend{t}, testCtxt)
|
2015-07-30 11:03:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DummyFrontend is a test-only frontend.
|
|
|
|
|
// It assumes 64 bit integers and pointers.
|
2015-06-12 11:01:13 -07:00
|
|
|
type DummyFrontend struct {
|
2015-06-25 14:04:55 -07:00
|
|
|
t testing.TB
|
2015-06-12 11:01:13 -07:00
|
|
|
}
|
2015-06-04 15:18:27 -07:00
|
|
|
|
2015-07-24 11:28:12 -07:00
|
|
|
func (DummyFrontend) StringData(s string) interface{} {
|
2015-06-04 15:18:27 -07:00
|
|
|
return nil
|
|
|
|
|
}
|
2015-10-22 14:22:38 -07:00
|
|
|
func (DummyFrontend) Auto(t Type) GCNode {
|
2015-08-24 02:16:19 -07:00
|
|
|
return nil
|
|
|
|
|
}
|
2015-06-12 11:01:13 -07:00
|
|
|
|
2016-01-13 11:14:57 -08:00
|
|
|
func (d DummyFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) }
|
|
|
|
|
|
|
|
|
|
func (d DummyFrontend) Fatalf(line int32, msg string, args ...interface{}) { d.t.Fatalf(msg, args...) }
|
|
|
|
|
func (d DummyFrontend) Unimplementedf(line int32, msg string, args ...interface{}) {
|
|
|
|
|
d.t.Fatalf(msg, args...)
|
|
|
|
|
}
|
2015-10-26 17:34:06 -04:00
|
|
|
func (d DummyFrontend) Warnl(line int, msg string, args ...interface{}) { d.t.Logf(msg, args...) }
|
|
|
|
|
func (d DummyFrontend) Debug_checknil() bool { return false }
|
2015-07-30 11:03:05 -07:00
|
|
|
|
|
|
|
|
func (d DummyFrontend) TypeBool() Type { return TypeBool }
|
|
|
|
|
func (d DummyFrontend) TypeInt8() Type { return TypeInt8 }
|
|
|
|
|
func (d DummyFrontend) TypeInt16() Type { return TypeInt16 }
|
|
|
|
|
func (d DummyFrontend) TypeInt32() Type { return TypeInt32 }
|
|
|
|
|
func (d DummyFrontend) TypeInt64() Type { return TypeInt64 }
|
|
|
|
|
func (d DummyFrontend) TypeUInt8() Type { return TypeUInt8 }
|
|
|
|
|
func (d DummyFrontend) TypeUInt16() Type { return TypeUInt16 }
|
|
|
|
|
func (d DummyFrontend) TypeUInt32() Type { return TypeUInt32 }
|
|
|
|
|
func (d DummyFrontend) TypeUInt64() Type { return TypeUInt64 }
|
2015-08-28 14:24:10 -04:00
|
|
|
func (d DummyFrontend) TypeFloat32() Type { return TypeFloat32 }
|
|
|
|
|
func (d DummyFrontend) TypeFloat64() Type { return TypeFloat64 }
|
2015-07-30 11:03:05 -07:00
|
|
|
func (d DummyFrontend) TypeInt() Type { return TypeInt64 }
|
|
|
|
|
func (d DummyFrontend) TypeUintptr() Type { return TypeUInt64 }
|
|
|
|
|
func (d DummyFrontend) TypeString() Type { panic("unimplemented") }
|
|
|
|
|
func (d DummyFrontend) TypeBytePtr() Type { return TypeBytePtr }
|
2015-09-18 22:58:10 -07:00
|
|
|
|
|
|
|
|
func (d DummyFrontend) CanSSA(t Type) bool {
|
|
|
|
|
// There are no un-SSAable types in dummy land.
|
|
|
|
|
return true
|
|
|
|
|
}
|