Documentation ¶
Overview ¶
Package gen provides code generators based on the instruction database.
Index ¶
- func Action(a inst.Action) string
- func DeclareTestArguments(g *prnt.Generator)
- func Features(i inst.Instruction, f inst.Form) string
- func TestArgumentName(t string) string
- func TestSignature(f inst.Form) api.Signature
- type Builder
- type Enum
- func (e *Enum) AddValue(value string)
- func (e *Enum) ConstName(value string) string
- func (e *Enum) ConstNames() []string
- func (e *Enum) Doc() []string
- func (e *Enum) Max() int
- func (e *Enum) MaxName() string
- func (e *Enum) Name() string
- func (e *Enum) None() string
- func (e *Enum) Receiver() string
- func (e *Enum) SetDoc(doc ...string)
- func (e *Enum) UnderlyingType() string
- func (e *Enum) Values() []string
- type Func
- type Interface
- func GoFmt(i Interface) Interface
- func NewAsmTest(cfg printer.Config) Interface
- func NewBuild(cfg printer.Config) Interface
- func NewBuildTest(cfg printer.Config) Interface
- func NewCtors(cfg printer.Config) Interface
- func NewCtorsBench(cfg printer.Config) Interface
- func NewCtorsStress(cfg printer.Config) Interface
- func NewCtorsTest(cfg printer.Config) Interface
- func NewGoData(cfg printer.Config) Interface
- func NewGoDataTest(cfg printer.Config) Interface
- func NewMOV(cfg printer.Config) Interface
- func NewOptab(cfg printer.Config) Interface
- type Table
- func (t *Table) ISAs() *Enum
- func (t *Table) ISAsConst(isas []string) string
- func (t *Table) ImplicitRegister() *Enum
- func (t *Table) ImplicitRegisterConst(r string) string
- func (t *Table) Opcode() *Enum
- func (t *Table) OpcodeConst(opcode string) string
- func (t *Table) OperandType() *Enum
- func (t *Table) OperandTypeConst(typ string) string
- func (t *Table) Suffix() *Enum
- func (t *Table) SuffixConst(s inst.Suffix) string
- func (t *Table) SuffixesClass() *Enum
- func (t *Table) SuffixesClassConst(key string) string
- func (t *Table) SuffixesConst(suffixes inst.Suffixes) string
- func (t *Table) SuffixesList(suffixes inst.Suffixes) string
- func (t *Table) SuffixesTypeName() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeclareTestArguments ¶
DeclareTestArguments prints a block of variables declaring a valid operand of each operand type.
func Features ¶
func Features(i inst.Instruction, f inst.Form) string
Features returns code for the features constant describing the features of the given instruction form.
func TestArgumentName ¶
TestArgumentName returns the name of the variable of operand type t declared by DeclareTestArguments().
Types ¶
type Enum ¶
type Enum struct {
// contains filtered or unexported fields
}
Enum is a generated enumeration type. This assists with mapping between the conceptual values of the enum, and it's materialization as Go code.
func (*Enum) ConstName ¶
ConstName returns the constant name that refers to the given enumerator value.
func (*Enum) ConstNames ¶
ConstNames returns the constant names for all enumerator values.
func (*Enum) MaxName ¶
MaxName returns the name of the constant that represents the maximum enumerator. This value is placed at the very end of the enum, so all values will be between the None and Max enumerators.
func (*Enum) UnderlyingType ¶
UnderlyingType returns the underlying unsigned integer type used for the enumeration. This will be the smallest type that can represent all the values.
type Interface ¶
type Interface interface {
Generate([]inst.Instruction) ([]byte, error)
}
Interface of an instruction code generator.
func NewAsmTest ¶
NewAsmTest prints one massive assembly function containing a line for every instruction form in the database. The intention is to pass this to the Go assembler and confirm there are no errors, thus helping to ensure our database is compatible.
func NewBuild ¶
NewBuild builds a printer that will generate instruction functions in the build package. Each instruction will have one method on the build.Context type, and a corresponding wrapper operating on the global Context. These functions are thin wrappers around constructors generated by NewCtors.
func NewBuildTest ¶
NewBuildTest autogenerates tests for instruction methods on the build context.
func NewCtors ¶
NewCtors will build instruction constructors. Each constructor delegates to the optab-based instruction builder, providing it with a candidate list of forms to match against.
func NewCtorsBench ¶
NewCtorsBench autogenerates a benchmark for the instruction constructors.
func NewCtorsStress ¶
NewCtorsStress autogenerates stress tests for instruction constructors.
func NewCtorsTest ¶
NewCtorsTest autogenerates tests for the constructors build by NewCtors.
func NewGoData ¶
NewGoData writes a Go variable containing the instructions database. This is intended to provide a more friendly version of the instruction database, rather than having to use the raw data sources all the time.
func NewGoDataTest ¶
NewGoDataTest writes a test case to confirm that NewGoData faithfully represented the list. The reason for this is that NewGoData uses custom code to "pretty print" the database so it is somewhat human-readable. In the process we could easily mistakenly print the database incorrectly. This test prints the same slice of instructions with the ugly but correct "%#v" format specifier, and confirms that the two arrays agree.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents all the types required to represent the instruction operation table (optab).
func NewTable ¶
func NewTable(is []inst.Instruction) *Table
NewTable builds optab types to represent the given instructions.
func (*Table) ImplicitRegister ¶
ImplicitRegister returns the enumeration representing all possible operand types.
func (*Table) ImplicitRegisterConst ¶
ImplicitRegisterConst returns the constant name for the given register.
func (*Table) OpcodeConst ¶
OpcodeConst returns the constant name for the given opcode.
func (*Table) OperandType ¶
OperandType returns the enumeration representing all possible operand types.
func (*Table) OperandTypeConst ¶
OperandTypeConst returns the constant name for the given operand type.
func (*Table) SuffixConst ¶
SuffixConst returns the constant name for the given instruction suffix.
func (*Table) SuffixesClass ¶
SuffixesClass returns the enumeration representing all suffixes classes.
func (*Table) SuffixesClassConst ¶
SuffixesClassConst returns the constant name for a given suffixes class. The key is as returned from inst.SuffixesClasses() function.
func (*Table) SuffixesConst ¶
SuffixesConst returns the constant for a list of suffixes. Suffixes is a generated array type, so the list is a value not slice type.
func (*Table) SuffixesList ¶
SuffixesList returns the constant literal for a list of suffixes, type name not included. Use SuffxesConst if the type is required.
func (*Table) SuffixesTypeName ¶
SuffixesTypeName returns the name of the array type for a list of suffixes.