2018-11-20 13:51:17 -06:00
|
|
|
package opcodesxml
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/xml"
|
|
|
|
|
"io"
|
|
|
|
|
"os"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Read(r io.Reader) (*InstructionSet, error) {
|
|
|
|
|
d := xml.NewDecoder(r)
|
|
|
|
|
is := &InstructionSet{}
|
|
|
|
|
if err := d.Decode(is); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return is, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ReadFile(filename string) (*InstructionSet, error) {
|
|
|
|
|
f, err := os.Open(filename)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
|
|
return Read(f)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type InstructionSet struct {
|
|
|
|
|
Name string `xml:"name,attr"`
|
|
|
|
|
Instructions []Instruction `xml:"Instruction"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Instruction struct {
|
|
|
|
|
Name string `xml:"name,attr"`
|
|
|
|
|
Summary string `xml:"summary,attr"`
|
|
|
|
|
Forms []Form `xml:"InstructionForm"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Form struct {
|
|
|
|
|
GASName string `xml:"gas-name,attr"`
|
|
|
|
|
GoName string `xml:"go-name,attr"`
|
|
|
|
|
MMXMode string `xml:"mmx-mode,attr"`
|
|
|
|
|
XMMMode string `xml:"xmm-mode,attr"`
|
|
|
|
|
CancellingInputs bool `xml:"cancelling-inputs,attr"`
|
|
|
|
|
Operands []Operand `xml:"Operand"`
|
|
|
|
|
ImplicitOperands []ImplicitOperand `xml:"ImplicitOperand"`
|
|
|
|
|
ISA []ISA `xml:"ISA"`
|
2018-11-21 21:38:19 -06:00
|
|
|
Encoding Encoding `xml:"Encoding"`
|
2018-11-20 13:51:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Operand struct {
|
|
|
|
|
Type string `xml:"type,attr"`
|
|
|
|
|
Input bool `xml:"input,attr"`
|
|
|
|
|
Output bool `xml:"output,attr"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ImplicitOperand struct {
|
|
|
|
|
ID string `xml:"id,attr"`
|
|
|
|
|
Input bool `xml:"input,attr"`
|
|
|
|
|
Output bool `xml:"output,attr"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ISA struct {
|
|
|
|
|
ID string `xml:"id,attr"`
|
|
|
|
|
}
|
2018-11-21 21:38:19 -06:00
|
|
|
|
|
|
|
|
type Encoding struct {
|
|
|
|
|
REX *REX `xml:"REX"`
|
|
|
|
|
VEX *VEX `xml:"VEX"`
|
|
|
|
|
EVEX *EVEX `xml:"EVEX"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type REX struct {
|
|
|
|
|
Mandatory bool `xml:"mandatory,attr"`
|
2018-11-21 22:28:55 -06:00
|
|
|
W uint `xml:"W,attr"`
|
2018-11-21 21:38:19 -06:00
|
|
|
R string `xml:"R,attr"`
|
|
|
|
|
X string `xml:"X,attr"`
|
|
|
|
|
B string `xml:"B,attr"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VEX struct {
|
|
|
|
|
Type string `xml:"type,attr"`
|
2018-11-21 22:28:55 -06:00
|
|
|
W *uint `xml:"W,attr"`
|
|
|
|
|
L uint `xml:"L,attr"`
|
2018-11-21 21:38:19 -06:00
|
|
|
M5 string `xml:"m-mmmm,attr"`
|
|
|
|
|
PP string `xml:"pp,attr"`
|
|
|
|
|
R string `xml:"R,attr"`
|
|
|
|
|
X string `xml:"X,attr"`
|
|
|
|
|
B string `xml:"B,attr"`
|
|
|
|
|
V4 string `xml:"vvvv,attr"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type EVEX struct {
|
|
|
|
|
M2 string `xml:"mm,attr"`
|
|
|
|
|
PP string `xml:"pp,attr"`
|
2018-11-21 22:28:55 -06:00
|
|
|
W *uint `xml:"W,attr"`
|
2018-11-21 21:38:19 -06:00
|
|
|
LL string `xml:"LL,attr"`
|
|
|
|
|
V4 string `xml:"vvvv,attr"`
|
|
|
|
|
V string `xml:"V,attr"`
|
|
|
|
|
RR string `xml:"RR,attr"`
|
|
|
|
|
B string `xml:"B,attr"`
|
|
|
|
|
X string `xml:"X,attr"`
|
|
|
|
|
Bsml string `xml:"b,attr"`
|
|
|
|
|
A3 string `xml:"aaa,attr"`
|
|
|
|
|
Z string `xml:"Z,attr"`
|
|
|
|
|
Disp8xN string `xml:"disp8xN,attr"`
|
|
|
|
|
}
|