[arch] arm64/instgen: add assembler code generator for SVE

0 views
Skip to first unread message

Junyang Shao (Gerrit)

unread,
1:02 PM (7 hours ago) 1:02 PM
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, David Chase, Alexander Musman, Cherry Mui, golang-co...@googlegroups.com

Junyang Shao submitted the change with unreviewed changes

Unreviewed changes

13 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: arm64/instgen/generator.go
Insertions: 37, Deletions: 9.

@@ -24,6 +24,7 @@
type tmplData struct {
EncodingFuncs []funcData
Insts []instData
+ InstsByName []instsByName
// All possible arg patterns are aggregated here.
// They are unique with regard to [Class] and [Elms].
// [Asm] is not considered for uniqueness.
@@ -34,6 +35,11 @@
Constants []constantData
}

+type instsByName struct {
+ Name string
+ Insts []instData // All these insts share the same GoOp code.
+}
+
type constantData struct {
ConstName string
BinName string
@@ -82,19 +88,22 @@
const genTmpl = `// Code generated by 'instgen -o=$GOROOT # from go install golang.org/x/arch/arm64/instgen@latest'. DO NOT EDIT.

// The following constants are generated from the XML specification.
-// args are filled with constants named oc_<ACLASS_OP0>_<ENCODER_ELM0>_<ENCODER_ELM1>_..._<ACLASS_OP1>_...
-// the encoder functions are represented by their ID, i.e. encodeGen<ENCODER_ELM0> is the encoding
-// function you should look at for the 0-th op, 0-th element.

package arm64

-var insts = []instEncoder{
-{{- range .Insts}}
- // {{.Asm}} {{.Ops.OpAsms}}
+// insts are grouped by [goOp].
+var insts = [][]instEncoder{
+{{- range .InstsByName}}
+ // {{.Name}}
{
- goOp: {{.GoOp}},
- fixedBits: {{.FixedBits}},
- args: {{.Ops.BetterName}},
+{{- range .Insts}}
+ // {{.Asm}} {{.Ops.OpAsms}}
+ {
+ goOp: {{.GoOp}},
+ fixedBits: {{.FixedBits}},
+ args: {{.Ops.BetterName}},
+ },
+{{- end}}
},
{{- end}}
}
@@ -614,6 +623,25 @@
return data.UniqueArgs[i].Name < data.UniqueArgs[j].Name
})

+ // Group instructions by name
+ // Also sort them by their Go mnemonic.
+ sort.Slice(data.Insts, func(i, j int) bool {
+ return data.Insts[i].GoOp < data.Insts[j].GoOp
+ })
+ ibn := []instsByName{}
+ prevGoOp := ""
+ for _, inst := range data.Insts {
+ if inst.GoOp != prevGoOp {
+ ibn = append(ibn, instsByName{
+ Name: inst.GoOp[1:],
+ Insts: []instData{},
+ })
+ prevGoOp = inst.GoOp
+ }
+ ibn[len(ibn)-1].Insts = append(ibn[len(ibn)-1].Insts, inst)
+ }
+ data.InstsByName = ibn
+
// Generate inst_gen.go
formatAndFlush(outputDir, "src/cmd/internal/obj/arm64/inst_gen.go", data, genTmpl)

```

Change information

Commit message:
arm64/instgen: add assembler code generator for SVE

This CL implements the code generation logic.
It generates 4 files to the assembler:
- inst_gen.go: this file contains the instruction table for these new SVE
instructions.
- goops_gen.go: this file contains the go op constants for these new SVE
instructions.
- anames_gen.go: this file contains the anames (debugger symbols) for
these new SVE instructions.
- encoding_gen.go: this file contains the encoding functions for parts
(elements) of these new SVE instructions. They are emitted with their
natural language specification and we need to fill up their logic, which
will be in the next CL.

This CL generated files into CL 747180

This CL adds logic to allow only certain AClasses to be generated.

This CL also merged PREGZ and PREGM, and defer its check to encoding
phase. This is required to distinguish <P>/<ZM> cases.

This CL also filters out the generation of aliased encodings, as they
are not fully specified.

This CL also added encoding specifications for another weird encoding
defined in the decoding section, please see the added code in
`extractBinary` for details. An example instruction is "Unsigned divide
(predicated)".

It is useful for partial code gen for assembler without all AClasses
support.

This CL added a generation target that generates e2e test data, it uses
the GNU toolchain as an oracle. This CL assumes the toolchain version
2.45. There currently exists a bleeding edge new toolchain 2.46, some
special cases in `constructInstance` might be removed if we upgrade the
GNU toolchain.

This CL also rearranged the types. XML types are parsed data types are
in different files now.
Change-Id: Ia7e30e1d1da17ad6aff5d963cf90fe76bc1a76fd
Reviewed-by: David Chase <drc...@google.com>
Files:
  • A arm64/instgen/encodings.go
  • A arm64/instgen/generator.go
  • M arm64/instgen/main.go
  • D arm64/instgen/xmlspec/inst.go
  • A arm64/instgen/xmlspec/parsed.go
  • M arm64/instgen/xmlspec/parser.go
  • M arm64/instgen/xmlspec/parser_test.go
  • M arm64/instgen/xmlspec/printer.go
  • A arm64/instgen/xmlspec/util.go
  • A arm64/instgen/xmlspec/xml.go
Change size: XL
Delta: 10 files changed, 2311 insertions(+), 591 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by David Chase
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: arch
Gerrit-Branch: master
Gerrit-Change-Id: Ia7e30e1d1da17ad6aff5d963cf90fe76bc1a76fd
Gerrit-Change-Number: 755180
Gerrit-PatchSet: 16
Gerrit-Owner: Junyang Shao <shaoj...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Junyang Shao <shaoj...@google.com>
Gerrit-CC: Alexander Musman <alexande...@gmail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages