import isa and implicit operands

This commit is contained in:
Michael McLoughlin
2018-11-23 17:14:18 -06:00
parent 86373c79ee
commit 4e059c258b
2 changed files with 24 additions and 6 deletions

View File

@@ -7,8 +7,9 @@ type Instruction struct {
} }
type Form struct { type Form struct {
Operands []Operand ISA []string
CPUID []string Operands []Operand
ImplicitOperands []Operand
} }
type Operand struct { type Operand struct {
@@ -16,6 +17,11 @@ type Operand struct {
Action Action Action Action
} }
type ImplicitOperand struct {
Register string
Action Action
}
type Action uint8 type Action uint8
const ( const (

View File

@@ -81,10 +81,6 @@ func (l *Loader) init() error {
return err return err
} }
// for a, op := range l.alias {
// log.Printf("alias %#v -> %s", a, op)
// }
l.order = opcodescsv.BuildOrderMap(icsv) l.order = opcodescsv.BuildOrderMap(icsv)
return nil return nil
@@ -279,8 +275,24 @@ func (l Loader) form(opcode string, f opcodesxml.Form) inst.Form {
ops[0].Type = "imm2u" ops[0].Type = "imm2u"
} }
// Extract implicit operands.
var implicits []inst.ImplicitOperand
for _, implicit := range f.ImplicitOperands {
implicits = append(implicits, inst.ImplicitOperand{
Register: implicit.ID,
Action: inst.ActionFromReadWrite(implicit.Input, implicit.Output),
})
}
// Extract ISA flags.
var isas []string
for _, isa := range f.ISA {
isas = append(isas, isa.ID)
}
return inst.Form{ return inst.Form{
Operands: ops, Operands: ops,
ISA: isas,
} }
} }