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 ¶ added in v0.4.0
DeclareTestArguments prints a block of variables declaring a valid operand of each operand type.
func Features ¶ added in v0.4.0
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 ¶ added in v0.4.0
TestArgumentName returns the name of the variable of operand type t declared by DeclareTestArguments().
Types ¶
type Enum ¶ added in v0.4.0
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 ¶ added in v0.4.0
ConstName returns the constant name that refers to the given enumerator value.
func (*Enum) ConstNames ¶ added in v0.4.0
ConstNames returns the constant names for all enumerator values.
func (*Enum) MaxName ¶ added in v0.4.0
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) None ¶ added in v0.4.0
None returns the name of the "unset" constant of this enumeration.
func (*Enum) UnderlyingType ¶ added in v0.4.0
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 ¶ added in v0.4.0
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 ¶ added in v0.4.0
NewCtorsBench autogenerates a benchmark for the instruction constructors.
func NewCtorsStress ¶ added in v0.4.0
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.
func NewMOV ¶
NewMOV generates a function that will auto-select the correct MOV instruction based on operand types and sizes.
type Table ¶ added in v0.4.0
type Table struct {
// contains filtered or unexported fields
}
Table represents all the types required to represent the instruction operation table (optab).
func NewTable ¶ added in v0.4.0
func NewTable(is []inst.Instruction) *Table
NewTable builds optab types to represent the given instructions.
func (*Table) ISAs ¶ added in v0.4.0
ISAs returns the enumeration for all possible ISA combinations.
func (*Table) ISAsConst ¶ added in v0.4.0
ISAsConst returns the constant name for the given ISA combination.
func (*Table) ImplicitRegister ¶ added in v0.4.0
ImplicitRegister returns the enumeration representing all possible operand types.
func (*Table) ImplicitRegisterConst ¶ added in v0.4.0
ImplicitRegisterConst returns the constant name for the given register.
func (*Table) OpcodeConst ¶ added in v0.4.0
OpcodeConst returns the constant name for the given opcode.
func (*Table) OperandType ¶ added in v0.4.0
OperandType returns the enumeration representing all possible operand types.
func (*Table) OperandTypeConst ¶ added in v0.4.0
OperandTypeConst returns the constant name for the given operand type.
func (*Table) Suffix ¶ added in v0.4.0
Suffix returns the enumeration representing instruction suffixes.
func (*Table) SuffixConst ¶ added in v0.4.0
SuffixConst returns the constant name for the given instruction suffix.
func (*Table) SuffixesClass ¶ added in v0.4.0
SuffixesClass returns the enumeration representing all suffixes classes.
func (*Table) SuffixesClassConst ¶ added in v0.4.0
SuffixesClassConst returns the constant name for a given suffixes class. The key is as returned from inst.SuffixesClasses() function.
func (*Table) SuffixesConst ¶ added in v0.4.0
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 ¶ added in v0.5.0
SuffixesList returns the constant literal for a list of suffixes, type name not included. Use SuffxesConst if the type is required.
func (*Table) SuffixesTypeName ¶ added in v0.4.0
SuffixesTypeName returns the name of the array type for a list of suffixes.