loadertest: add memory operands
This commit is contained in:
@@ -16,10 +16,13 @@ func (l LoaderTest) Generate(w io.Writer, is []*inst.Instruction) error {
|
||||
|
||||
p.printf("TEXT loadertest(SB), 0, $0\n")
|
||||
|
||||
counts := map[string]int{}
|
||||
|
||||
for _, i := range is {
|
||||
p.printf("\t// %s %s\n", i.Opcode, i.Summary)
|
||||
if skip, msg := l.skip(i.Opcode); skip {
|
||||
p.printf("\t// SKIP: %s\n", msg)
|
||||
counts["skip"]++
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -28,15 +31,21 @@ func (l LoaderTest) Generate(w io.Writer, is []*inst.Instruction) error {
|
||||
p.printf("\t// %#v\n", f.Operands)
|
||||
if as == nil {
|
||||
p.printf("\t// TODO\n")
|
||||
counts["todo"]++
|
||||
continue
|
||||
}
|
||||
p.printf("\t%s\t%s\n", i.Opcode, strings.Join(as, ", "))
|
||||
counts["total"]++
|
||||
}
|
||||
p.printf("\n")
|
||||
}
|
||||
|
||||
p.printf("\tRET\n")
|
||||
|
||||
for m, c := range counts {
|
||||
p.printf("// %s: %d\n", m, c)
|
||||
}
|
||||
|
||||
return p.Err()
|
||||
}
|
||||
|
||||
@@ -68,29 +77,30 @@ func args(ops []inst.Operand) []string {
|
||||
// arg generates an argument for an operand of the given type.
|
||||
func arg(t string) string {
|
||||
m := map[string]string{
|
||||
// <xs:enumeration value="1" />
|
||||
// <xs:enumeration value="3" />
|
||||
"1": "$1", // <xs:enumeration value="1" />
|
||||
"3": "$3", // <xs:enumeration value="3" />
|
||||
"imm2u": "$3",
|
||||
// <xs:enumeration value="imm4" />
|
||||
"imm8": fmt.Sprintf("$%d", math.MaxInt8), // <xs:enumeration value="imm8" />
|
||||
"imm16": fmt.Sprintf("$%d", math.MaxInt16), // <xs:enumeration value="imm16" />
|
||||
"imm32": fmt.Sprintf("$%d", math.MaxInt32), // <xs:enumeration value="imm32" />
|
||||
"imm64": fmt.Sprintf("$%d", math.MaxInt64), // <xs:enumeration value="imm64" />
|
||||
// <xs:enumeration value="al" />
|
||||
// <xs:enumeration value="cl" />
|
||||
"al": "AL", // <xs:enumeration value="al" />
|
||||
"cl": "CL", // <xs:enumeration value="cl" />
|
||||
|
||||
// <xs:enumeration value="r8" />
|
||||
// <xs:enumeration value="r8l" />
|
||||
// <xs:enumeration value="ax" />
|
||||
// <xs:enumeration value="r16" />
|
||||
// <xs:enumeration value="r16l" />
|
||||
// <xs:enumeration value="eax" />
|
||||
"eax": "AX", // <xs:enumeration value="eax" />
|
||||
// <xs:enumeration value="r32" />
|
||||
// <xs:enumeration value="r32l" />
|
||||
// <xs:enumeration value="rax" />
|
||||
"rax": "AX", // <xs:enumeration value="rax" />
|
||||
"r64": "R15", // <xs:enumeration value="r64" />
|
||||
// <xs:enumeration value="mm" />
|
||||
// <xs:enumeration value="xmm0" />
|
||||
"xmm": "X7", // <xs:enumeration value="xmm" />
|
||||
"xmm0": "X0", // <xs:enumeration value="xmm0" />
|
||||
"xmm": "X7", // <xs:enumeration value="xmm" />
|
||||
// <xs:enumeration value="xmm{k}" />
|
||||
// <xs:enumeration value="xmm{k}{z}" />
|
||||
// <xs:enumeration value="ymm" />
|
||||
@@ -104,16 +114,16 @@ func arg(t string) string {
|
||||
// <xs:enumeration value="moffs32" />
|
||||
// <xs:enumeration value="moffs64" />
|
||||
// <xs:enumeration value="m" />
|
||||
// <xs:enumeration value="m8" />
|
||||
// <xs:enumeration value="m16" />
|
||||
"m8": "8(AX)(CX*2)", // <xs:enumeration value="m8" />
|
||||
"m16": "16(AX)(CX*2)", // <xs:enumeration value="m16" />
|
||||
// <xs:enumeration value="m16{k}{z}" />
|
||||
// <xs:enumeration value="m32" />
|
||||
"m32": "32(AX)(CX*2)", // <xs:enumeration value="m32" />
|
||||
// <xs:enumeration value="m32{k}" />
|
||||
// <xs:enumeration value="m32{k}{z}" />
|
||||
// <xs:enumeration value="m64" />
|
||||
"m64": "64(AX)(CX*2)", // <xs:enumeration value="m64" />
|
||||
// <xs:enumeration value="m64{k}" />
|
||||
// <xs:enumeration value="m64{k}{z}" />
|
||||
// <xs:enumeration value="m128" />
|
||||
"m128": "128(AX)(CX*2)", // <xs:enumeration value="m128" />
|
||||
// <xs:enumeration value="m128{k}{z}" />
|
||||
// <xs:enumeration value="m256" />
|
||||
// <xs:enumeration value="m256{k}{z}" />
|
||||
|
||||
Reference in New Issue
Block a user